operations.limit.Index.js
8.57 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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
webpackJsonp([111],[
/* 0 */
/***/ function(module, exports, __webpack_require__) {
/*
*@time: 2016/2/4
*@author: chenglong
*/
var $ = __webpack_require__(1),
common = __webpack_require__(2);
var baseNum = 1;
var ENUM = {
status: {
0: '待审核',
1: '审核通过',
2: '驳回',
3: '过期',
4: '作废'
}, //全部
tips: {
"salenum": 0,
"notsalenum": 0,
"hotnum": 0,
"nothotnum": 0,
"all": 0
}
}
var t = new common.tab({
el: "#basicTab",
click: function() {
tableGird.reload();
},
columns: [{
name: "salenum",
key: "saleFlag",
value: "1",
display: "已发售({salenum})"
}, {
name: "notsalenum",
key: "saleFlag",
value: "0",
display: "未发售({notsalenum})"
}, {
name: "hotnum",
key: "hotFlag",
value: "1",
display: "热门({hotnum})"
}, {
name: "nothotnum",
key: "hotFlag",
value: "0",
display: "非热门({nothotnum})"
}, {
name: "all",
display: "全部({all})"
}]
}).init(ENUM.tips);
var tableGird = new common.grid({
el: "#limit-table-box",
parms: function() {
var obj = {
productName: common.util.__input("product-name"),
productSkn: common.util.__input("skn"),
hotFlag: $('input[name="hotFlag"]:checked').val(),
saleFlag: $('input[name="saleFlag"]:checked').val(),
showFlag: $('input[name="showFlag"]:checked').val()
}
if (t.key) {
obj[t.key] = t.value;
}
return obj;
},
columns: [{
display: "",
type: 'checkbox'
}, {
display: "名称",
name: "productName"
}, {
display: "限购商品code",
name: "limitProductCode"
}, {
display: "排序",
render: function(item) {
return ('<input class="form-control order-input width50" data-id="' + item.id + '" data-type="orderBy" type="text" value="' + item.orderBy + '"/>');
}
}, {
display: "封面图",
render: function(item) {
return ('<img class="cover-img" src="' + item.attachUrl + '" />');
}
}, {
display: "SKN",
name: "productSkn",
render: function(item) {
return item.productSkn || '待定';
}
}, {
display: "发售日期",
name: "saleTimeStr",
render: function(item) {
if (item.dayFlag == 1) {
return item.saleTimeStr;
} else {
return item.saleTimeStr.slice(0, 7);
}
}
}, {
display: "是否发售",
name: "saleFlag",
render: function(item) {
if (item.saleFlag == 1) {
return '是';
} else {
return '否';
}
}
}, {
display: "是否热门",
name: "hotFlag",
render: function(items) {
if (items.hotFlag) {
return '是';
} else {
return '否';
}
}
}, {
display: "是否开启",
name: "showFlag",
render: function(items) {
if (items.showFlag) {
return '是';
} else {
return '否';
}
}
},{
display: "首次开启时间",
render: function(items) {
return common.util.__secondsFormat(items.firstShowTime);
}
}, {
display: "操作",
render: function(items) {
var HtmArr = [];
if (items.showFlag) {
HtmArr.push('<a href="javascript:;" data-id="' + items.id + '" class="btn btn-danger btn-xs close-btn">关闭</a>');
} else {
HtmArr.push('<a href="javascript:;" data-id="' + items.id + '" class="btn btn-success btn-xs open-btn">开启</a>');
}
if (items.hotFlag) {
HtmArr.push('<a href="javascript:;" data-id="' + items.id + '" class="btn btn-info btn-xs hot-cancel">取消热门</a>');
} else {
HtmArr.push('<a href="javascript:;" data-id="' + items.id + '" class="btn btn-warning btn-xs hot-btn">设为热门</a>');
}
HtmArr.push('<a href="/limit/edit/' + items.id + '" data-id="' + items.id + '" class="btn btn-primary btn-xs">编辑</a>');
HtmArr.push('<a href="javascript:;" data-id="' + items.id + '" class="btn btn-danger btn-xs delete-btn">删除</a>');
return HtmArr.join('');
}
}]
});
tableGird.init('/limitProduct/getLimitProductList');
var loadtab = function() {
t.active = undefined;
setTimeout(function() {
common.util.__ajax({
url: '/limitProduct/getCountByStatus',
data: tableGird.options.parms()
}, function(res) {
for (var key in res.data) {
ENUM.tips[key] = res.data[key];
}
t.init(ENUM.tips);
}, true);
}, 400);
}
loadtab();
//筛选
$("#filter-btn").click(function() {
loadtab();
tableGird.reload(1);
});
//导出
$('#export-btn').on('click', function() {
var selectedArr = tableGird.selected,
len = selectedArr.length,
queryConf = '';
if (len <= 0) {
common.util.__tip('请选择要导出的商品', 'warning');
return;
}
$.each(selectedArr, function(i, value) {
queryConf += value['limitProductCode'];
if (i < len - 1) {
queryConf += '|';
}
});
window.open("/ajax/down?queryConf=" + queryConf + "&type=limitProductReminder");
// common.util.__ajax({
// url: '/ajax/down',
// type:'GET',
// data: {
// queryConf: '2016022517335568',
// type: 'limitProductReminder'
// }
// }, function(res) {
// console.log(res);
// })
});
//开启商品
$('#limit-table-box').on('click', '.open-btn', function() {
var param = {
id: $(this).data('id'),
showFlag: '1'
}
common.util.__ajax({
url: '/limitProduct/auditLimitProduct',
data: param
}, function(res) {
tableGird.reload();
});
});
//关闭商品
$('#limit-table-box').on('click', '.close-btn', function() {
var param = {
id: $(this).data('id'),
showFlag: '0'
}
common.util.__ajax({
url: '/limitProduct/auditLimitProduct',
data: param
}, function(res) {
tableGird.reload();
});
});
//设为热门
$('#limit-table-box').on('click', '.hot-btn', function() {
var param = {
id: $(this).data('id'),
hotFlag: 1
}
common.util.__ajax({
url: '/limitProduct/auditLimitProduct',
data: param
}, function(res) {
tableGird.reload();
});
});
//取消热门
$('#limit-table-box').on('click', '.hot-cancel', function() {
var param = {
id: $(this).data('id'),
hotFlag: 0
}
common.util.__ajax({
url: '/limitProduct/auditLimitProduct',
data: param
}, function(res) {
tableGird.reload();
});
});
//删除商品
$('#limit-table-box').on('click', '.delete-btn', function() {
var param = {
id: $(this).data('id')
}
/*common.util.__ajax({
url:'/limit/delete',
data:param
},function(res){
tableGird.reload();
});*/
common.dialog.confirm("温馨提示", "你确定要删除吗?", function() {
common.util.__ajax({
url: '/limitProduct/deleteLimitProduct',
data: param
}, function() {
tableGird.reload();
});
});
});
//热门排序,未发售排序修改
$('#limit-table-box').on('change', '.order-input', function() {
var goodsId = $(this).data('id'),
type = $(this).data('type'),
param = {
id: goodsId
};
if (!/^(?:[1-9][0-9]*|0)$/.test($(this).val())) {
common.util.__tip('排序只能为非负数', 'warning');
return;
} else {
param[type] = $(this).val();
}
common.util.__ajax({
url: '/limitProduct/auditLimitProduct',
data: param
}, function(res) {
console.log(res);
});
});
/***/ }
]);