Index.js
21.5 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
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
'use strict';
var $ = require('jquery'),
common = require('../../../common/common');
var ZeroClipboard = require("../../../common/util/ZeroClipboard.min");
ZeroClipboard.config({swfPath: "http://cdn.yoho.cn/yohobuy-portal/assets/images/ZeroClipboard.swf"});
var ENUM = {
status: {
toAuditNum: '待审核',
failAuditNum: '驳回',
passAuditNum: '通过',
all: '全部'
}, //全部
tips: {
"toAuditNum": 0,
"failAuditNum": 0,
"passAuditNum": 0,
"all": ""
},
statusStr: {
100: '待审核',
200: '通过',
300: '驳回',
}
}
// 审核状态枚举
var AuditEnum = {
status: {
toAuditNum: 100,
passAuditNum: 200,
failAuditNum: 300
}
}
// 年龄层枚举
var AgeLevelEnum = {
level: {
1: "成人",
2: "大童",
3: "小童",
'2|3': "大小童",
'3|2': "大小童"
}
}
// 性别
var GenderEnum = {
gender: {
1: "男",
2: "女",
3: "通用"
}
}
// 性别
//1可补货,2不可补货 3部分可补货
var ReplenishEnum = {
enum: {
1: "可补货",
2: "不可补货",
3: "部分可补货"
}
}
// 商品类型
var GoodsTypeEnum = {
type: {
1: "普通商品",
2: "赠品",
3: "虚拟商品",
"": "未知类型"
}
}
var YNEnum = {
enum: {
"Y": "是",
"N": "否",
"B": "品牌设置"
}
}
/*下拉选择*/
new common.dropDown({
el: "#shopId",
ajax: "queryShopPass",
hash: true
});
new common.dropDown({
el: "#brandId",
ajax: "brand",
hash: true,
params:function(){
return {userLimitFlag:true};
}
});
new common.dropDown({
el: "#isOutLets",
ajax: ""
});
new common.dropDown({
el: "#isAdvance",
ajax: ""
});
new common.dropDown({
el: "#gender",
ajax: ""
});
new common.dropDown({
el: "#isJit",
ajax: ""
});
var tabTree = new common.tabTree("#sort");
tabTree.init();
var t = new common.tab2({
el: "#basicTab",
active:2,
click: function() {
var columnname=t.options.columns[t.options.active].name;
g.options.columns[6].hidden = true;
g.options.columns[9].hidden = true; //隐藏【创建时间】
g.options.columns[10].hidden = true; //隐藏【创建人】
g.options.columns[11].hidden = true; //隐藏【驳回时间】
g.options.columns[12].hidden = true; //隐藏【原因】
g.options.columns[13].hidden = true; //隐藏【通过时间】
g.options.columns[14].hidden = true; //隐藏【通过人】
g.options.columns[15].hidden = true; //隐藏【状态】
g.options.columns[16].hidden = true; //隐藏【操作信息】
if (columnname == "all") {
g.options.columns[6].hidden = false;
g.options.columns[15].hidden = false; //显示【状态】
g.options.columns[16].hidden = false; //显示【操作信息】
$("#daochu").hide();
} else {
switch (columnname) {
case 'toAuditNum':
{ // 待审核
g.options.columns[9].hidden = false; //显示【创建时间】
g.options.columns[10].hidden = false; //显示【创建人】
}
$("#daochu").hide();
break;
case 'failAuditNum':
{ // 待审核
g.options.columns[11].hidden = false; //显示【驳回时间】
g.options.columns[12].hidden = false; //显示【原因】
}
$("#daochu").hide();
break;
case 'passAuditNum':
{ // 待审核
g.options.columns[6].hidden = false;
g.options.columns[13].hidden = false; //显示【通过时间】
g.options.columns[14].hidden = false; //显示【通过人】
}
$("#daochu").show();
break;
default:
{
}
$("#daochu").hide();
break;
}
}
g.init('/product/getBaseProductList');
},
columns: [{
name: "toAuditNum",
display: "待审核({toAuditNum})"
}, {
name: "failAuditNum",
display: "驳回({failAuditNum})"
}, {
name: "passAuditNum",
display: "通过({passAuditNum})"
}, {
name: "all",
display: "全部{all}"
}]
}).init(ENUM.tips);
var g = new common.grid({
el: '#basicTable',
usepagesize:true,
parms: function() {
var select = tabTree.getAddress();
return {
productSkn: common.util.__input("productSkn"),
productSku: common.util.__input("productSku"),
productName: common.util.__input("productName"),
shopId: common.util.__input("shopId"),
brandId: common.util.__input("brandId"),
gender: common.util.__input("gender"),
name: common.util.__input("filter-name"),
isJit: common.util.__input("isJit"),
isOutLets: common.util.__input("isOutLets"),
isAdvance: common.util.__input("isAdvance"),
isAuditing: AuditEnum.status[t.getData().name],
maxSortId: select[0] ? select[0].id : "",
middleSortId: select[1] ? select[1].id : "",
smallSortId: select[2] ? select[2].id : "",
sortId: select[3] ? select[3].id : "",
founderName: common.util.__input("founderName"),
factoryCode: common.util.__input("factoryCode"),
skuFactoryCode: common.util.__input("skuFactoryCode"),
appType: common.util.__input("appType")
};
},
columns: [{
display: '',
type: 'checkbox'
}, {
display: "SKN",
render: function(item) {
var html = "<a class=\"btn btn-xs btn-success info-copy\" data-clipboard-text=\""+item.productSkn+"\" >"+item.productSkn+"</a>" ;
return html;
}
}, {
display: "商品信息",
render: function(item) {
var html = [];
var catgory = item.maxSortName;
if (item.smallSortName) {
catgory = item.smallSortName
} else if (item.middleSortName) {
catgory = item.middleSortName;
};
// mod by xueyin: 优化,商品名称去掉链接,支持业务复制
//html.push('<p>名称:<a target="_blank" data-index="' + item.__index + '" href="/base/goods/info/' + item.productSkn + '/' + item.isAuditing + '" class="btn btn-info btn-xs edit-class-btn">' + item.productName + '</a>');
html.push("<p>名称:" + item.productName + "</p>");
html.push("<p>品牌:" + item.brandName + "</p>");
html.push("<p>品类:" + catgory + "</p>");
return html.join('');
}
},
{
display: "售价",
render: function(item) {
var html = [];
html.push("<p>吊牌价:" + item.retailPrice + "</p>");
html.push("<p>销售价:" + item.salesPrice + "</p>");
//待审核和驳回列表中只显示吊牌价和销售价,通过的列表中显示
if (item.isAuditing === 200) {
html.push("<p>是否VIP:" + YNEnum.enum[item.isVip] + "</p>");
if(item.productPrice&&item.productPrice.returnCoinMoney){
html.push("<p>返yoho币金额:" + item.productPrice.returnCoinMoney + "</p>");
}else{
html.push("<p>返yoho币金额:0</p>");
}
}
return html.join('');
}
},
{
display: "年龄层/性别",
render: function(item) {
var html = [];
var ageLevel=common.config.__ageLevel(item.ageLevel);
var gender = GenderEnum.gender[item.gender];
html.push("<p>" + ageLevel + " / " + gender + "</p>");
return html.join('');
}
},
{
display: "是否预售",
render: function(item) {
var html = [];
//判断是否是预售商品
if (item.isAdvance === "Y") {
var formatted = "";
if (item.expectArrivalTime) {
var t = new Date(item.expectArrivalTime * 1000);
formatted = common.util.__dateFormat(t, "yyyy-MM-dd hh:mm:ss");
}
if (item.isDepositAdvance === 'Y') {
html.push("<p>定金预售</p>");
} else {
html.push("<p>普通预售</p>");
}
if (item.isDepositAdvance === 'Y') {
html.push("<p>定金:"+item.deposit+"</p>");
}
html.push("<p>预计到货时间:" + formatted + "</p>");
} else {
var formatted = "";
if (item.expectShelfTime) {
var t = new Date(item.expectShelfTime * 1000);
formatted = common.util.__dateFormat(t, "yyyy-MM-dd hh:mm:ss");
}
html.push("<p>否</p>");
}
return html.join('');
}
},
{
display: "是否BLK",
render: function(item) {
if (item.appType === 0) {
return "<p>有货</p>";
} else if (item.appType === 1) {
return "<p>BLK</p>";
}
}
},
{
display: "是否JIT",
render: function(item) {
if (item.isJit == "Y") {
return "<p>是</p>";
} else if (item.isJit == "N") {
return "<p>否</p>";
}
}
},
{
display: "奥莱",
render: function(item) {
if (item.isOutLets == "Y") {
return "<p>奥莱</p>";
} else if (item.isOutLets == "N") {
return "<p>否</p>";
} else if (item.isOutLets == "B") {
return "<p>品牌设置</p>";
}
}
},
{
display: "商品类别",
render: function(item) {
var type = GoodsTypeEnum.type[item.attribute] ? GoodsTypeEnum.type[item.attribute] : "未知类型";
return "<p>" + type + "</p>"
}
},
{
display: "其他",
render: function(item) {
var html = [];
var limited = (item.isLimited == "Y") ? "限量款" : "非限量款";
var limitedPurchase = (item.isLimitbuy == "Y") ? "限购" : "非限购";
var replenishment = item.isSupplied ? ReplenishEnum.enum[item.isSupplied] : "";
var gender = GenderEnum.gender[item.gender];
html.push("<p>" + limited + "</p>");
// html.push("<p>" + limitedPurchase + "</p>");
html.push("<p>" + replenishment + "</p>");
return html.join('');
}
},
// 9
{
display: "创建时间",
hidden: true,
render: function(item) {
var t = new Date(item.createTime * 1000);
var formatted = common.util.__dateFormat(t, "yyyy-MM-dd hh:mm:ss");
return "<p>" + formatted + "</p>";
}
},
// 10
{
display: "创建人",
name: "founderName",
hidden: true,
},
// 11
{
display: "驳回时间",
hidden: true,
render: function(item) {
var t = new Date(item.auditFailTime * 1000);
var formatted = common.util.__dateFormat(t, "yyyy-MM-dd hh:mm:ss");
return "<p>" + formatted + "</p>";
}
},
// 12
{
display: "原因",
hidden: true,
render: function(item) {
return "<p>" + common.util.__filterNull(item, 'rejectReason') + "</p>";
}
},
// 13
{
display: "通过时间",
hidden: true,
render: function(item) {
var t = new Date(item.auditPassTime * 1000);
var formatted = common.util.__dateFormat(t, "yyyy-MM-dd hh:mm:ss");
return "<p>" + formatted + "</p>";
}
},
// 14
{
display: "通过人",
hidden: true,
render: function(item) {
return "<p>" + common.util.__filterNull(item, 'auditPassName') + "</p>";
}
},
// 15
{
display: "状态",
render: function(item) {
var status = ENUM.statusStr[item.isAuditing];
return "<p>" + status + "</p>";
}
},
// 16
{
display: "操作信息",
render: function(item) {
var html = [];
return "<p>" + common.util.__filterNull(item, 'operateInfo') + "</p>";
}
},
{
display: "操作",
render: function(item) {
var html = [];
// add by xueyin: 仍然保留详情页链接
html.push('<a target="_blank" data-index="' + item.__index + '" href="/base/goods/info/' + item.productSkn + '/' + item.isAuditing + '" class="btn btn-info btn-xs edit-class-btn">查看</a>');
if (item.isAuditing != 100) {
html.push('<a target="_blank" data-index="' + item.__index + '" class="btn btn-info btn-xs edit-class-btn" href="/base/goods/update/' + item.productSkn + '/' + item.isAuditing + '">修改</a>');
}
if (item.isAuditing == 100) {
html.push('<a data-index="' + item.__index + '" href="JavaScript:;" class="btn operation btn-success btn-xs edit-class-btn apply-success">通过</a>');
html.push('<a data-index="' + item.__index + '" href="JavaScript:;" class="btn operation btn-danger btn-xs edit-class-btn apply-back">驳回</a>');
} else {
}
return html.join('');
}
},
],
complete: function () {
new ZeroClipboard($(".info-copy"));
}
});
g.init('/product/getBaseProductList');
$(document).on('click', '.info-copy', function () {
common.util.__tip("SKN已复制,可贴粘", "success")
});
// 筛选
$(document).on('click', "#filter-btn", function() {
g.reload(1);
loadTab();
});
// 通过
var BllPass = {
toast: function(content, fn) {
var $this = $(this);
common.dialog.confirm("温馨提示", content, function() {
common.util.__disButton.call($this);
common.util.__ajax({
url: '/base/goods/pass',
data: fn()
}, function() {
g.reload();
loadTab();
});
});
}
}
// 驳回
var BllReject = {
toast: function(content, fn) {
var $this = $(this);
common.dialog.confirm("温馨提示", content, function() {
common.util.__disButton.call($this);
common.util.__ajax({
url: '/base/goods/reject',
data: fn()
}, function() {
g.reload();
loadTab();
});
});
}
}
// tab初始化
var loadTab = function() {
setTimeout(function() {
common.util.__ajax({
url: "/base/goods/ajax/auditCount",
data: g.options.parms()
}, function(res) {
var __dt = $.extend({}, ENUM.tips, res.data);
t.setData(__dt);
t.render(__dt);
}, true);
}, 400);
}
loadTab();
//单个通过
$(document).on("click", ".apply-success", function() {
var item = g.rows[$(this).data("index")];
var data = function() {
return {
productSknList: JSON.stringify([item.productSkn]),
};
}
BllPass.toast.call(this, "你确定审核通过吗?", data);
});
//单个驳回
$(document).on("click", ".apply-back", function() {
var item = g.rows[$(this).data("index")];
var data = function() {
var reason = $('#bohui').val();
if (reason === '' || $.trim(reason) === '') {
return "请填写驳回原因";
}
return {
productSknList: JSON.stringify([item.productSkn]),
rejectReason: reason
};
}
BllReject.toast.call(this, $("#template").html(), data);
});
//批量驳回
$(document).on("click", "#reject-btn", function() {
var count = 0,
selectedArr = g.selected,
len = selectedArr.length,
data = g.options.parms();
var reason = $('#bohui').val();
if (reason === '' || $.trim(reason) === '') {
common.util.__tip('请填写驳回原因', 'warning');
return;
}
var filter=$(".wqt_all").prop("checked");
$.each(data, function(key, value) {
if (value && value != '' && key != 'size' && key != 'tab') {
count++;
}else{
delete data[key];
}
});
if ((count > 0&&filter) || len > 0) {
var productSknList=[];
if (len > 0) {
$.each(selectedArr, function(i, value) {
productSknList.push(value['productSkn']);
});
}
var result=function(){
if(filter){
return {
targetStatus: 3,
rejectReason: reason,
pramStr:JSON.stringify(data)
};
}else{
return {
targetStatus: 3,
rejectReason: reason,
productSknList:JSON.stringify(productSknList)
};
}
}
BllReject.toast.call(this, $("#template").html(), result);
}else{
common.util.__tip('请选择导出商品的条件', 'warning');
return;
}
});
//批量通过
$(document).on("click", "#pass-btn", function() {
var count = 0,
selectedArr = g.selected,
len = selectedArr.length,
data = g.options.parms();
var filter=$(".wqt_all").prop("checked");
// alert(filter);
$.each(data, function(key, value) {
if (value && value != '' && key != 'size' && key != 'tab') {
count++;
}else{
delete data[key];
}
});
if ((count > 0&&filter) || len > 0) {
var productSknList=[];
if (len > 0) {
$.each(selectedArr, function(i, value) {
productSknList.push(value['productSkn']);
});
}
var result=function(){
if(filter){
return {
pramStr:JSON.stringify(data)
};
}else{
return{productSknList:JSON.stringify(productSknList)};
}
}
BllPass.toast.call(this, "确定要通过该申请吗?", result);
}else{
common.util.__tip('请选择导出商品的条件', 'warning');
return;
}
});
/*删除*/
$(document).on("click", ".delete-class-btn", function() {
var item = g.rows[$(this).data("index")];
console.log(item);
common.util.__ajax({
url: '/base/goods/ajax/delete',
data: {
productSkn: item.productSkn,
isAuditing: item.isAuditing
}
});
});
/*******************************************************************/
/*验证 hack*/
$("#productSkn").on("keyup", function() {
$(this).val($(this).val().replace(/\D/g, ''));
});
$("#basedaochu").click(function(){
var count = 0,
selectedArr = g.selected,
len = selectedArr.length,
data = g.options.parms();
data.isAuditing=200;
var filter=$(".wqt_all").prop("checked");
$.each(data, function(key, value) {
if (value && value != '' && key != 'size' && key != 'tab') {
count++;
}
});
if ((count > 0&&filter) || len > 0) {
var productSknList=[];
if (len > 0) {
$.each(selectedArr, function(i, value) {
productSknList.push(value['productSkn']);
});
}
var getResult=function(){
if(filter){
var result={};
for(var name in data){
if(data.hasOwnProperty(name)&&data[name]){
result[name]=data[name];
}
}
return result
}else{
return{productSknList:productSknList,isAuditing:200};
}
}
window.open("/ajax/down?queryConf=" + JSON.stringify(getResult()) + "&type=baseProduce");
}else{
common.util.__tip('请选择导出商品的条件', 'warning');
return;
}
});