goods.js
9.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
var Controller = {
index: function () {
// 初始化表格参数配置
Table.api.init({
extend: {
index_url: 'goods/index' + location.search,
add_url: 'goods/add',
edit_url: 'goods/edit',
del_url: 'goods/del',
multi_url: 'goods/multi',
table: 'goods',
}
});
var table = $("#table");
// 初始化表格
table.bootstrapTable({
url: $.fn.bootstrapTable.defaults.extend.index_url,
pk: 'id',
sortName: 'weigh',
columns: [
[
{checkbox: true},
{field: 'id', title: __('Id')},
{field: 'category_one_id', title: __('Category_one_id'),visible:false},
{field: 'category_two_id', title: __('Category_two_id'),visible:false},
{field: 'category_three_id', title: __('Category_three_id'),visible:false},
{field: 'category_group_ids', title: __('Category_group_ids'),visible:false},
{field: 'country_id', title: __('Country_id'),visible:false},
{field: 'brand_id', title: __('Brand_id'),visible:false},
{field: 'level_id', title: __('Level_id'),visible:false},
{field: 'part_id', title: __('Part_id'),visible:false},
{field: 'category2_id', title: __('Category2_id'),visible:false},
{field: 'depot_id', title: __('Depot_id'),visible:false},
{field: 'ch_name', title: __('Ch_name')},
{field: 'en_name', title: __('En_name')},
{field: 'image', title: __('Image'), events: Table.api.events.image, formatter: Table.api.formatter.image, operate:false},
{field: 'images', title: __('Images'),visible:false, events: Table.api.events.image, formatter: Table.api.formatter.images, operate:false},
{field: 'goods_no', title: __('Goods_no')},
{field: 'ch_specification', title: __('Ch_specification'),visible:false, operate:false},
{field: 'en_specification', title: __('En_specification'),visible:false, operate:false},
{field: 'ch_save_where', title: __('Ch_save_where'),visible:false, operate:false},
{field: 'en_save_where', title: __('En_save_where'),visible:false, operate:false},
{field: 'ch_period', title: __('Ch_period'),visible:false, operate:false},
{field: 'en_period', title: __('En_period'),visible:false, operate:false},
{field: 'stock_num', title: __('Stock_num'), operate:false},
{field: 'sales_initial', title: __('Sales_initial'), operate:false},
{field: 'sales_actual', title: __('Sales_actual'), operate:false},
{field: 'is_group', title: __('Is_group'), searchList: {"1":__('Is_group 1'),"2":__('Is_group 2')}, formatter: Table.api.formatter.normal,visible:false},
{field: 'group_num', title: __('Group_num'),visible:false, operate:false},
{field: 'goods_price', title: __('Goods_price'), operate:'BETWEEN'},
{field: 'vip_price', title: __('Vip_price'), operate:'BETWEEN',visible:false},
{field: 'is_vip_price', title: __('Is_vip_price'), searchList: {"1":__('Is_vip_price 1'),"2":__('Is_vip_price 2')}, formatter: Table.api.formatter.normal,visible:false},
// {field: 'is_recommend', title: __('Is_recommend'), searchList: {"1":__('Is_recommend 1'),"2":__('Is_recommend 2')}, formatter: Table.api.formatter.normal},
{field: 'status', title: __('Status'), searchList: {"1":__('Status 1'),"2":__('Status 2')}, formatter: Table.api.formatter.toggle,yes:1,no:2},
{field: 'weigh', title: __('Weigh'), operate:false},
{field: 'createtime', title: __('Createtime'), operate:false, addclass:'datetimerange', formatter: Table.api.formatter.datetime},
{field: 'updatetime', title: __('Updatetime'), operate:false, addclass:'datetimerange', formatter: Table.api.formatter.datetime},
{field: 'country.ch_name', title: __('Country.ch_name'), formatter: Table.api.formatter.label},
// {field: 'category.name', title: __('Category.name'), formatter: Table.api.formatter.label},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate,
buttons: [
{
name: 'depot', title: '仓库信息', icon: 'fa fa-bars',
classname: 'btn btn-xs btn-warning btn-dialog',
url: 'depot/index/goods_id/{id}/type/1',
extend: "data-area='[\"65%\",\"80%\"]'"
},
{
name: 'evaluate', title: '评价信息', icon: 'fa fa-bars',
classname: 'btn btn-xs btn-info btn-dialog',
url: 'evaluate/index/goods_id/{id}/type/1',
extend: "data-area='[\"65%\",\"80%\"]'",
}
]
}
]
]
});
// 为表格绑定事件
Table.api.bindevent(table);
$("#c-category_two_id").data("params", function (obj) {
var id = $("#c-category_one_id").val()?$("#c-category_one_id").val():-1;
return {wherein: {pid: id}};
});
$("#c-category_one_id").on('change',function(){
$("#c-category_two_id").val('');
$("#c-category_two_id_text").val('');
$("#c-category_three_id").val('');
$("#c-category_three_id_text").val('');
$(".category_two .selected_tag").remove();
$(".category_three .selected_tag").remove();
});
$("#c-category_three_id").data("params", function (obj) {
var id = $("#c-category_two_id").val()?$("#c-category_two_id").val():-1;
return {wherein: {pid: id}};
});
$("#c-category_two_id").on('change',function(){
$("#c-category_three_id").val('');
$("#c-category_three_id_text").val('');
$(".category_three .selected_tag").remove();
});
},
add: function () {
Controller.api.bindevent();
$('#c-is_group').change(function () {
var val = $('#c-is_group').val();
if(val == 1){
$('.group').show();
}else {
$('.group').hide();
}
});
$('#c-is_vip_price').change(function () {
var val = $('#c-is_vip_price').val();
if(val == 1){
$('.vip_price').show();
}else {
$('.vip_price').hide();
}
});
// $("#c-category_two_id").data("params", function (obj) {
// var id = $("#c-category_one_id").val()?$("#c-category_one_id").val():-1;
// return {wherein: {pid: id}};
// });
// $("#c-category_one_id").on('change',function(){
// $("#c-category_two_id").val('');
// $("#c-category_two_id_text").val('');
// $("#c-category_three_id").val('');
// $("#c-category_three_id_text").val('');
// $(".category_two .selected_tag").remove();
// $(".category_three .selected_tag").remove();
// });
// $("#c-category_three_id").data("params", function (obj) {
// var id = $("#c-category_two_id").val()?$("#c-category_two_id").val():-1;
// return {wherein: {pid: id}};
// });
// $("#c-category_two_id").on('change',function(){
// $("#c-category_three_id").val('');
// $("#c-category_three_id_text").val('');
// $(".category_three .selected_tag").remove();
// });
},
edit: function () {
Controller.api.bindevent();
var val = $('#c-is_group').val();
if(val == 1){
$('.group').show();
}
var val1 = $('#c-is_vip_price').val();
if(val1 == 1){
$('.vip_price').show();
}
$('#c-is_group').change(function () {
var val = $('#c-is_group').val();
if(val == 1){
$('.group').show();
}else {
$('.group').hide();
}
});
$('#c-is_vip_price').change(function () {
var val = $('#c-is_vip_price').val();
if(val == 1){
$('.vip_price').show();
}else {
$('.vip_price').hide();
}
});
},
api: {
bindevent: function () {
Form.api.bindevent($("form[role=form]"));
}
}
};
return Controller;
});