netsale.js
11.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
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
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
'use strict';
var $ = require('jquery'),
common = require('../common/common');
var ENUM = {
gender: {
1: '男',
2: '女',
3: '通用'
},
ageLevel: {
1: '成人',
2: '大童',
3: '小童'
},
status: {
'8': '待上架',
'2': '待审核',
'3': '驳回',
'4': '通过',
'1': '已上架',
'0': '已下架',
'5': '再上架待审核',
'6': '再上架驳回',
'7': '再上架通过'
},
attribute: {
1: '普通',
2: '赠品'
},
tab: {
'1': 0,
'2': 0,
'3': 0,
'4': 0,
'all': 0
},
isVIP: {
'N': '否',
'Y': '是'
}
};
var tabTree = new common.tabTree("#sortTree");
tabTree.init();
new common.dropDown({
el: '#shopId',
ajax: 'shopsRest'
});
new common.dropDown({
el: '#brandId',
ajax: 'brand'
});
var editPostion = '';
var t = new common.tab({
el: "#basicTab",
click: function() {
g.options.columns[11].hidden = true;
g.options.columns[8].hidden = true;
g.options.page = 1;
var columnname = $(this).find('a').attr('columnname');
if (columnname == 3) {
g.options.columns[11].hidden = false;
} else if (columnname == 2) {
g.options.columns[8].hidden = false;
};
if (columnname == 1 || columnname == 2) {
editPostion = '#position9';
}
g.init($("#gridurl").val());
},
columns: [{
name: "0",
value: '8,3,2',
display: "上架前({1})"
}, {
name: "1",
value: '4,1,0,5,6',
display: "上架后({2})"
}, {
name: "2",
value: '1',
display: "搜索/标签({3})"
}, {
name: "3",
value: '1',
display: "上架后信息缺失({4})"
}, {
name: "all",
value: 'all',
display: "全部商品({all})"
}]
}).init(ENUM.tab);
//tab
var loadtab = function() {
t.active = undefined;
setTimeout(function() {
common.util.__ajax({
url: '/goods/product/queryTabProductNum',
data: g.options.parms()
}, function(res) {
var __dt = $.extend({}, ENUM.tab, res.data);
t.init(__dt);
}, true);
}, 400);
}
loadtab();
var g = new common.grid({
el: "#basicTable",
parms: function() {
return {
productSkn: common.util.__input("productSkn"),
productSkc: common.util.__input("productSkc"),
productSku: common.util.__input("productSku"),
productName: common.util.__input("productName"),
shopId: common.util.__input("shopId"),
brandId: common.util.__input("brandId"),
isJit: common.util.__input("isJit"),
stock: common.util.__input("stock"),
isScreen: common.util.__input("isScreen"),
isMeasure: common.util.__input("isMeasure"),
gender: common.util.__input("gender"),
maxSortId: tabTree.selected[0] ? tabTree.selected[0].id : "",
middleSortId: tabTree.selected[1] ? tabTree.selected[1].id : "",
smallSortId: tabTree.selected[2] ? tabTree.selected[2].id : "",
isOutLets: common.util.__input("isOutLets"),
productStatus: common.util.__input("productStatus"),
size: common.util.__input("size"),
productStatusStr: t.value,
tab: $('#basicTab').find('.active').index()
};
},
columns: [{
display: '',
type: 'checkbox'
}, {
display: 'skn',
name: 'productSkn',
render: function(item) {
return '<a href="/goods/netsale/info/' + item.productSkn + editPostion + '">' + item.productSkn + '</a>'
}
}, {
display: '图片',
name: 'picImgUrl',
render: function(item) {
if (item.picImgUrl) {
return '<img src="' + item.picImgUrl + '" width="100" height="60">';
} else {
return '';
}
}
}, {
display: '商品信息',
render: function(item) {
var productName = item.productName ? item.productName : '',
brandName = item.brandName ? item.brandName : '',
maxSortName = item.maxSortName ? item.maxSortName : '',
middleSortName = item.middleSortName ? item.middleSortName : '',
html = '';
html += '<p><strong>名称:</strong>' + productName + '</p>';
html += '<p><strong>品牌:</strong>' + brandName + '</p>';
html += '<p><strong>类目:</strong>' + maxSortName;
if (middleSortName) {
html += '/' + middleSortName;
}
return html + '</p>';
}
}, {
display: '售价',
render: function(item) {
var vip = ENUM.isVIP[item.isVIP] ? ENUM.isVIP[item.isVIP] : '',
retailPrice = item.retailPrice ? item.retailPrice : '',
salesPrice = item.salesPrice ? item.salesPrice : '';
return '<p><strong>吊牌价:</strong>' + retailPrice + '</p>' +
'<p><strong>销售价:</strong>' + salesPrice + '</p>' +
'<p><strong>是否VIP:</strong>' + vip + '</p>';
/*'<p style="color: #ccc;"><strong>yoho币:</strong>' + item.returnCoin + '</p>';*/
}
}, {
display: '库存',
name: 'stock'
}, {
display: '年龄层/性别',
render: function(item) {
var html = '';
if (ENUM.ageLevel[item.ageLevel]) {
html += ENUM.ageLevel[item.ageLevel];
if (item.gender) {
html += '/';
}
}
if (ENUM.gender[item.gender]) {
html += ENUM.gender[item.gender]
}
return html;
}
}, {
display: '商品类别',
name: 'attribute', //商品属性(1普通、2赠品等) 商品类别
render: function(item) {
if (item.attribute) {
return ENUM.attribute[item.attribute];
} else {
return '';
}
}
}, {
display: '搜索/标签',
hidden: true,
render: function(item) {
var searchAndLabel = item.searchAndLabel ? item.searchAndLabel : '',
style = item.style ? item.style : '',
pattern = item.pattern ? item.pattern : '',
makeCrafts = item.makeCrafts ? item.makeCrafts : '';
return '关键词:' + searchAndLabel + '<br>' +
'风格:' + style + '<br>' +
'纹理:' + pattern + '<br>' +
'工艺:' + makeCrafts + '<br>';
}
}, {
display: '操作信息',
render: function(item) {
var html = '';
if (item.founderName) {
html += '<p>' + item.founderName + '</p>';
}
if (item.editTime) {
html += '<p>' + item.editTime + '</p>';
}
return html;
}
}, {
display: '上架状态',
name: 'status', // 8待上架,2待审核,3驳回,4通过,1已上架,0已下架,5再上架待审核,6再上架驳回,7再上架通过。
render: function(item) {
var html = '';
if (ENUM.status[item.status]) {
html += ENUM.status[item.status];
}
if (item.shelveTime) {
html += '<br>上架时间:' + item.shelveTime;
}
if (item.status == 3 || item.status == 6) {
html += '<p style="color:red;">(' + item.rejectReason + ')</p>'
}
return html;
}
}, {
display: '缺失信息',
hidden: true,
render: function(item) {
return '<p style="color: red;">' + item.missInfo + '</p>'
}
}, {
display: '操作',
render: function(item) {
var HtmArr = [];
if (item.status == 4 || item.status == 1 || item.status == 5 || item.status == 6) {
HtmArr.push('<a href="/goods/netsale/edit/' + item.productSkn + editPostion + '" class="btn btn-info btn-xs edit-btn">编辑</a>');
HtmArr.push('<a href="javascript:;" class="btn btn-danger btn-xs shelve-btn" data-skn="' + item.productSkn + '">下架</a>');
} else if (item.status == 3 || item.status == 8 || item.status == 2 || item.status == 0) {
HtmArr.push('<a href="/goods/netsale/edit/' + item.productSkn + editPostion + '" class="btn btn-info btn-xs edit-btn">编辑</a>');
HtmArr.push('<a href="javascript:;" class="btn btn-success btn-xs shelve-btn" data-skn="' + item.productSkn + '">上架</a>');
}
HtmArr.push('<a href="/goods/netsale/info/' + item.productSkn + editPostion + '" class="btn btn-info btn-xs info-btn">查看</a>');
return HtmArr.join('');
}
}]
});
g.init($("#gridurl").val());
//筛选
$("#filter-btn").click(function() {
loadtab();
g.reload(1);
});
/*
* 上架下架弹框
* params: title(弹框标题), html(弹框内容html)
*/
function shelveModal(title, html) {
var selectedArr = g.selected,
len = selectedArr.length,
productSknList = [],
shelveLayer = null;
if (len <= 0) {
common.util.__tip('请选择要' + title + '的商品', 'warning');
return;
}
$.each(selectedArr, function(i, value) {
productSknList.push(value['productSkn']);
});
shelveLayer = common.dialog.open({
title: '上架',
content: html
});
var e = new common.edit('.shelve-form');
e.init();
$('.shelve-form').on('click', '.btn', function() {
var type = $(this).data('type');
$(this).closest('.form-group').find('input').attr('required', true)
.end().siblings('.form-group').find('input').attr('required', false);
e.submit('/goods/product/updateProductSknTimingInfo', function(option) {
option.data.productSknList = JSON.stringify(productSknList);
option.data.type = type;
option.success = function(res) {
if (res.data.code == 200) {
e.$tip(res.data.message, function() {
shelveLayer.close();
loadtab();
g.reload();
}, 'growl-success');
} else {
e.$tip(res.data.message);
}
}
});
});
}
//批量skn上架
$('#onshelve').on('click', function() {
shelveModal('上架', $('#onshelve-template').html());
});
//批量skn下架
$('#offshelve').on('click', function() {
shelveModal('下架', $('#offshelve-template').html());
});
//导出
$('#export-btn').on('click', function() {
var count = 0,
selectedArr = g.selected,
len = selectedArr.length,
data = g.options.parms();
$.each(data, function(key, value) {
if (value && value != '' && key != 'size' && key != 'tab') {
count++;
}
});
if (count == 0 && len <= 0) {
common.util.__tip('请选择导出商品的条件', 'warning');
return;
}
if (len > 0) {
data.productSknList = [];
$.each(selectedArr, function(i, value) {
data.productSknList.push(value['productSkn']);
});
}
window.open("/ajax/down?queryConf=" + JSON.stringify(data) + "&type=netSale");
});
//sku skc上架表格
var shelveTable = new common.grid({
el: "#shelve-table",
secondIndex: 2,
columns: [{
display: 'SKC(商品信息)',
render: function(item) {
return 'SKC:' + item.productSkc + '<br>' +
'颜色:' + item.goodsName;
}
}, {
display: 'SKC上架操作(状态)',
render: function(item) {
if (item.status == 0) {
return '<a class="btn btn-success" data-type="1" data-skc="' + item.productSkc + '" href="javascript:;">点击上架</a>';
} else {
return '<a class="btn btn-danger" data-type="0" data-skc="' + item.productSkc + '" href="javascript:;">点击下架</a>';
}
}
}, {
display: 'SKU',
name: 'productSku'
}, {
display: '尺码',
name: 'sizeName'
}, {
display: '库存',
name: 'stock'
}, {
display: 'SKU上架操作',
render: function(item) {
if (item.status == 0) {
return '下架';
} else {
return '上架';
}
}
}, {
display: 'SKU上架操作',
render: function(item) {
if (item.status == 0) {
return '<a class="btn btn-success" data-type="1" data-sku="' + item.productSku + '" href="javascript:;">上架</a>';
} else {
return '<a class="btn btn-danger" data-type="0" data-sku="' + item.productSku + '" href="javascript:;">下架</a>';
}
}
}]
});
//单个sku,skc上下架
$('#basicTable').on('click', '.shelve-btn', function() {
var that = this,
skn = $(this).data('skn'),
shelveModalHtml = '',
shelveLayer = null;
$(that).addClass('disabled');
common.util.__ajax({
url: '/goods/netsale/getdata',
data: {
param: skn
}
}, function(res) {
shelveModalHtml = common.util.__template($('#template').html(), res.data.baseProductInfo.baseProduct);
shelveLayer = common.dialog.open({
title: '上/下架',
width: 900,
content: shelveModalHtml
});
$(that).removeClass('disabled');
shelveTable.init(res.data.goodsList, 'goodsSizeList');
$('#shelve-table').on('click', '.btn', function() {
var param = {},
reqUrl = '';
if ($(this).data('skc')) {
param.productSkc = $(this).data('skc');
reqUrl = '/goods/product/updateGoodsStatus';
} else if ($(this).data('sku')) {
param.productSku = $(this).data('sku');
reqUrl = '/goods/product/updateProductSkuStatus';
}
param.targetStatus = $(this).data('type');
common.util.__ajax({
url: reqUrl,
data: param
}, function(res) {
if (res.code == 200) {
shelveLayer.close();
}
})
})
}, true);
});