goods.audit.Index.js
18.6 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
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
webpackJsonp([31],[
/* 0 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
var $ = __webpack_require__(1),
common = __webpack_require__(2);
var ENUM = {
//0已下架,1待上架,2待审核,3驳回,4通过,1已上架,5再上架待审核,6再上架驳回,7再上架通过。
status: {
'0': '已下架',
'1': '已上架',
'2': '待审核',
'3': '上架驳回',
'4': '通过',
'5': '再上架待审核',
'6': '再上架驳回',
'7': '再上架通过',
'8': '待上架',
'9': '下架驳回',
'10':'下架待审核'
},
//tips:{"0":0,"1":0,"2":0,"3":0,"4":0,"all":0}
enum: {
1: '待审核',
2: '驳回',
3: '通过',
all: "全部商品"
},
tips: {
"1": 0,
"2": 0,
"3": 0,
"all": 0
}
}
// 审核状态枚举
var AuditEnum = {
status: {
100: "待审核",
200: "审核通过",
300: "驳回",
"": "过期",
"1": "作废",
}
}
// 年龄层枚举
var AgeLevelEnum = {
level: {
1: "成人",
2: "大童",
3: "小童",
'2|3': "大小童",
'3|2': "大小童"
}
}
// 性别
var GenderEnum = {
gender: {
1: "男",
2: "女",
3: "通用"
}
}
// 申请类型
var applyTypeEnum = {
applyType: {
0: "申请下架",
1: "申请上架"
}
}
// 商品类型
var GoodsTypeEnum = {
type: {
1: "普通商品",
2: "赠品",
3: "虚拟商品",
4: "组合商品",
"": "未知类型"
}
}
/*下拉选择*/
new common.dropDown({
el: "#shopId",
ajax: "queryShop"
});
new common.dropDown({
el: "#brandId",
ajax: "brand",
params:function(){
return {userLimitFlag:true};
}
});
new common.dropDown({
el: "#founder",
ajax: "querySupplier"
});
new common.dropDown({
el: "#isJit",
ajax: ""
});
new common.dropDown({
el: "#gender",
ajax: ""
});
new common.dropDown({
el: "#isJit",
ajax: ""
});
new common.dropDown({
el: "#size",
ajax: ""
});
var tabTree = new common.tabTree("#sort");
tabTree.init();
var t = new common.tab({
el: "#basicTab",
click: function() {
var columnname = $(this).find('a').attr('columnname');
console.log("columnname = " + columnname);
// 选择【全部商品】
if (columnname == "all") {
g.options.columns[11].hidden = false; //显示【审核状态】
g.options.columns[13].hidden = true; //
} else {
g.options.columns[11].hidden = true;
if (columnname == 2) {
g.options.columns[13].hidden = false; // 显示【驳回原因】
} else
switch (columnname) {
case 1:
case 3:
{ // 待审核, 通过
g.options.columns[11].hidden = true;
g.options.columns[13].hidden = true;
}
break;
case 2:
{ // 驳回
g.options.columns[11].hidden = true;
g.options.columns[13].hidden = false;
}
break;
default:
{
g.options.columns[11].hidden = true;
g.options.columns[13].hidden = true;
}
}
}
g.init('/product/queryNetSaleInforList');
},
columns: [{
name: "1",
display: "待审核({1})",
value: '2,5,10'
}, {
name: "2",
display: "驳回({2})",
value: '3,6,9'
}, {
name: "3",
display: "通过({3})",
value: '1,4,7,0'
}, {
name: "all",
display: "全部商品({all})",
value: '0,1,2,3,4,5,6,7,9,10'
}]
}).init(ENUM.tips);
var g = new common.grid({
el: '#basicTable',
usepagesize:true,
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"),
isOneSend:common.util.__input("isOneSend"),
gender: common.util.__input("gender"),
applyType:common.util.__input("applyType"),
maxSortId: tabTree.selected.length > 0 ? tabTree.selected[0].id : "", // 一级类目
middleSortId: tabTree.selected.length > 1 ? tabTree.selected[1].id : "", // 二级类目
smallSortId: tabTree.selected.length > 2 ? tabTree.selected[2].id : "", // 三级类目
productStatusStr: t.value ? t.value : '0,1,2,3,4,5,6,7,9,10'
};
},
columns: [{
display: '',
type: 'checkbox'
},
{
display: "申请类型",
render: function(item) {
if((typeof(item.applyType) == "undefined")){
return "<p></p>"
}else{
return "<p>" + applyTypeEnum.applyType[item.applyType] + "</p>"
}
}
},
{
display: 'SKN',
name: 'productSkn'
}, {
display: '图片',
name: 'picImgUrl',
render: function(item) {
return '<img src="' + filterNull(item, 'picImgUrl') + '" style="width:78px; height:78px">';
}
},
{
display: '商品信息',
render: function(item) {
return '<p><strong>名称:</strong>' + filterNull(item, 'productName') + '</p>' +
'<p><strong>品牌:</strong>' + filterNull(item, 'brandName') + '</p>' +
'<p><strong>类目:</strong>' + filterNull(item, 'maxSortName') + '/' + filterNull(item, 'middleSortName') + '</p>';
}
},
{
display: "售价",
render: function(item) {
return '<p><strong>吊牌价:</strong>' + filterNull(item, 'retailPrice') + '</p>' +
'<p><strong>销售价:</strong>' + filterNull(item, 'salesPrice') + '</p>' +
'<p><strong>是否VIP:</strong></p>' +
'<p style="color: #ccc;"><strong>yoho币:</strong>' + filterNull(item, 'returnCoin') + '</p>';
}
},
{
display: '库存',
name: 'stock'
},
{
display: "年龄层/性别",
render: function(item) {
var html = '';
if (item.ageLevel) {
html += common.config.__ageLevel(item.ageLevel);
}
if (html&&item.gender) {
html += '/';
}
if (GenderEnum.gender[item.gender]) {
html += GenderEnum.gender[item.gender]
}
return html;
}
},
{
display: "预售/奥莱",
render: function(item) {
var html = [];
//判断是否是预售商品
if (item.isAdvance === "Y") {
html.push("<p>预售</p>");
} else {
html.push("<p>否</p>");
}
if (item.isOutLets == "Y") {
html.push("<p>/奥莱</p>");
} else {
html.push("<p>/否</p>");
}
return html.join('');
}
},
{
display: "上下架时间",
render: function(item) {
if(item.applyType==0){
return "<p>下架时间:" + filterNull(item, 'offshelveTime') + "</p>";
}else{
return "<p>上架时间:" + filterNull(item, 'shelveTime') + "</p>";
}
}
}, {
display: "商品类别",
render: function(item) {
var type = GoodsTypeEnum.type[item.attribute] ? GoodsTypeEnum.type[item.attribute] : "未知类型";
return "<p>" + type + "</p>"
}
},
// 审核状态(全部商品是显示) 10
{
display: "审核状态",
render: function(item) {
var html = [];
html.push("<p>" + ENUM.status[item.status] + "</p>");
if (item.status == 3 || item.status == 6) {
html.push("<p style='color:red;'>" + filterNull(item, 'rejectReason') + "</p>");
}
return html.join('');
}
},
{
display: "操作信息",
render: function(item) {
var html = [];
html.push("<p>" + filterNull(item, 'founderName') + "</p>");
html.push("<p>" + filterNull(item, 'editTime') + "</p>");
return html.join('');
}
}, {
// 12
display: '驳回原因',
hidden: true,
name: 'status', // 8待上架,2待审核,3驳回,4通过,1已上架,0已下架,5再上架待审核,6再上架驳回,7再上架通过
render: function(item) {
var html = '';
html += ENUM.status[item.status];
if (item.status == 3 || item.status == 6 || item.status == 9) {
html += '<p style="color:red;">' + filterNull(item, 'rejectReason') + '</p>'
}
return html;
}
}, {
display: "操作",
render: function(item) {
var html = [];
//html.push('<a data-index="'+ item.__index+ '" href="JavaScript:;" class="btn btn-info btn-xs edit-class-btn" id="btn-item-info">查看</a>');
html.push('<a target="_black" href="/goods/audit/info/' + item.productSkn + '" class="btn btn-info btn-xs info-btn">查看</a>');
//if (item.status == 3 || item.status == 6) { // 驳回
// html.push('<a data-index="'+ item.__index+ '" href="JavaScript:;" class="btn operation btn-success btn-xs edit-class-btn" id="btn-item-pass">通过</a>');
//}
if (item.status == 2 || item.status == 5 ||item.status == 10) { // 待审核
html.push('<a data-index="' + item.__index + '" href="JavaScript:;" class="btn operation btn-success btn-xs edit-class-btn" id="btn-item-pass">通过</a>');
html.push('<a data-index="' + item.__index + '" href="JavaScript:;" class="btn operation btn-danger btn-xs edit-class-btn" id="btn-item-reject">驳回</a>');
}
return html.join('');
}
},
]
});
g.init('/product/queryNetSaleInforList');
// tab初始化
var loadTab = function() {
t.active = undefined;
setTimeout(function() {
common.util.__ajax({
url: "/product/queryTabCheck",
data: g.options.parms()
}, function(res) {
res.data["all"] = res.data["1"] + res.data["2"] + res.data["3"];
var __dt = $.extend({}, ENUM.tips, res.data);
t.init(__dt);
}, true);
}, 800);
}
loadTab();
// 筛选
$(document).on('click', "#filter-btn", function() {
loadTab();
g.reload();
});
var Bll = {
toast: function(content, fn) {
// 如果是申请下架,且通过的申请,需要校验、并提示线下店库存
var data = fn();
if (data.params && data.params != '') {
var checkStorageParam = {};
checkStorageParam.type = 'skn';
checkStorageParam.paramsStr = data.params;
common.util.__ajax({
url: '/product/checkOfflineStorage',
data: checkStorageParam
}, function(res) {
if (res.data != '') { //当下架操作时 校验线下店存在库存
var existStorageSkn = res.data;
common.dialog.confirm('警告', "此商品 " + existStorageSkn + " 正在线下店销售,下架可能会影响线下店商品正常购买!!!是否确定下架", function() {
Bll.updateProductSknStatus(data);
});
} else {
common.dialog.confirm("温馨提示", content, function() {
Bll.updateProductSknStatus(data);
});
}
}, true);
}
},
toast1: function(content, fn) {
common.dialog.confirm("温馨提示", content, function() {
var data = fn();
Bll.updateProductSknStatus(data);
});
},
updateProductSknStatus : function(data) {
common.util.__ajax({
url: '/product/updateProductSknStatus',
data: data
}, function() {
g.reload();
loadTab();
});
}
}
$(document).on("change", ".wqt_checkbox,.wqt_all", function () {
var _count = 0;
$.each(g.selected, function (index, item) {
/*添加兼容逻辑*/
if (item.status == 2 || item.status == 5 || item.status == 10 ) {
_count++;
}
});
if(_count==g.selected.length){
$('#pass-btn').removeClass('disabled');
$('#reject-btn').removeClass('disabled');
}else{
$('#reject-btn').addClass('disabled');
$('#pass-btn').addClass('disabled');
}
// var _count1 = 0,
// _count2 = 0,
// $.each(g.selected, function (index, item) {
// /*添加兼容逻辑*/
// if (item.status == 8 || item.status == 3 || item.status == 2 || item.status == 0) {
// _count1++; //上
// } else {
// _count2++; //下
// }
// });
// if (_count1 == g.selected.length) {
// $('#reject-btn').removeClass('disabled');
// } else {
// $('#reject-btn').addClass('disabled');
// }
// if (_count2 == g.selected.length) {
// $('#pass-btn').removeClass('disabled');
// } else {
// $('#pass-btn').addClass('disabled');
// }
});
//批量驳回
$(document).on("click", "#reject-btn", function() {
var selectedArr = g.selected,
len = selectedArr.length,
sknList = [];
if (len <= 0) {
common.util.__tip('请选择要驳回的商品', 'warning');
return;
}
var data = function() {
var reason = $('#reason').val();
if (reason === '' || $.trim(reason) === '') {
return "请填写驳回原因";
}
$.each(selectedArr, function(i, value) {
sknList.push(value['productSkn']);
});
console.log(sknList);
return {
productSknList: JSON.stringify(sknList),
targetStatus: 3, // 驳回
rejectReason: reason
};
}
Bll.toast1($("#template").html(), data);
});
//批量通过
$(document).on("click", "#pass-btn", function() {
var selectedArr = g.selected,
len = selectedArr.length,
sknList = [],
downApplySkn = [];
if (len <= 0) {
common.util.__tip('请选择审核通过的商品', 'warning');
return;
}
var data = function() {
$.each(selectedArr, function(i, value) {
sknList.push(value['productSkn']);
if (value['applyType'] == 0) {
downApplySkn.push(value['productSkn']);
}
});
console.log(sknList);
return {
productSknList: JSON.stringify(sknList),
targetStatus: 4, // 通过
rejectReason: "",
params : JSON.stringify(downApplySkn)
};
}
Bll.toast1("确定要通过该申请吗?", data);
});
// 单个驳回
$(document).on("click", "#btn-item-reject", function() {
//auditOperation([],3,)
var item = g.rows[$(this).data("index")];
var data = function() {
var reason = $('#reason').val();
if (reason === '' || $.trim(reason) === '') {
return "请填写驳回原因";
}
return {
productSknList: JSON.stringify([item.productSkn]),
targetStatus: 3, // 驳回
rejectReason: reason
};
}
Bll.toast1($("#template").html(), data);
});
// 单个通过
$(document).on("click", "#btn-item-pass", function() {
//auditOperation([],3,)
var item = g.rows[$(this).data("index")];
var data = function() {
return {
productSknList: JSON.stringify([item.productSkn]),
targetStatus: 4, //通过
rejectReason: "",
params : item.applyType == 0 ? JSON.stringify([item.productSkn]) : ''
};
}
Bll.toast1("确定要通过该申请吗?", data);
});
// 时间转化
Date.prototype.format = function(format) {
var date = {
"M+": this.getMonth() + 1,
"d+": this.getDate(),
"h+": this.getHours(),
"m+": this.getMinutes(),
"s+": this.getSeconds(),
"q+": Math.floor((this.getMonth() + 3) / 3),
"S+": this.getMilliseconds()
};
if (/(y+)/i.test(format)) {
format = format.replace(RegExp.$1, (this.getFullYear() + '').substr(4 - RegExp.$1.length));
}
for (var k in date) {
if (new RegExp("(" + k + ")").test(format)) {
format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? date[k] : ("00" + date[k]).substr(("" + date[k]).length));
}
}
return format;
}
// 判断item里面 instr属性是不是为空
function filterNull(item, instr) {
if (item[instr]) {
return item[instr];
} else {
return "";
}
}
/***/ }
]);