productEdit.html
44.9 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
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8"/>
<title>Yoho!Buy运营平台</title>
<script src="/ufoPlatform/js/include.js"></script>
<script src="/ufoPlatform/js/ajaxfileupload.js"></script>
<script type="text/javascript" src="/ufoPlatform/js/ueditor/ueditor.config.js"></script>
<!-- 编辑器源码文件 -->
<script type="text/javascript" src="/ufoPlatform/js/ueditor/third-party/zeroclipboard/ZeroClipboard.min.js"></script>
<script type="text/javascript" src="/ufoPlatform/js/ueditor/ueditor.all.js"></script>
<script type="text/javascript" charset="utf-8" src="/ufoPlatform/js/ueditor/lang/zh-cn/zh-cn.js"></script>
<style>
.product-detail-page ul, .product-detail-page li {
list-style: none;
padding: 0;
margin: 0;
}
.product-detail-page .container > li {
border-bottom: 1px solid #eee;
padding-bottom: 20px;
}
.product-detail-page .container {
padding: 0 30px;
}
.product-detail-page .base-info li,
.product-detail-page .keyword {
display: flex;
align-items: center;
margin-bottom: 10px;
}
.product-detail-page .label {
width: 120px;
font-size: 14px;
text-align: right;
}
.product-detail-page .red {
color: red;
}
.product-detail-page .group-color, .product-detail-page .group-size {
display: flex;
align-items: center;
margin-bottom: 20px;
}
.product-detail-page .group-color li {
margin-right: 5px;
float: left;
line-height: 30px;
margin-left: 5px;
padding: 0 5px;
position: relative;
}
.product-detail-page .group-color .actived:before {
content: '';
width: 100%;
height: 100%;
display: block;
position: absolute;
top: 0;
background: #000;
opacity: 0.5;
border-radius: 5px;
}
.product-detail-page .group-size .size {
float:left;
margin-left: 10px;
}
.product-detail-page .goods-image {
display: flex;
}
.product-detail-page .goods-image2 {
display: flex;
}
.product-detail-page .goods-image .img {
width: 104px;
height: 104px;
margin-right: 10px;
background-size: cover;
background-repeat: no-repeat;
background-position: center;
position: relative;
}
.product-detail-page .goods-image2 .img {
width: 104px;
height: 104px;
margin-right: 10px;
background-size: cover;
background-repeat: no-repeat;
background-position: center;
position: relative;
}
.product-detail-page .goods-image .img:hover:before {
content: "删除";
width: 100%;
display: block;
position: absolute;
top: 0;
background: #000;
opacity: 0.5;
color: #fff;
text-align: center;
line-height: 104px;
}
.product-detail-page .goods-image2 .img:hover:before {
content: "删除";
width: 100%;
display: block;
position: absolute;
top: 0;
background: #000;
opacity: 0.5;
color: #fff;
text-align: center;
line-height: 104px;
}
</style>
</head>
<body class="easyui-layout product-detail-page" fit="true">
<div region="north">
<script>
document.write(addHead('商品管理 /基础商品 /商品创建', ''));
</script>
</div>
<div region="center" style="overflow-y: scroll; top: 65px; padding-top: 10px;">
<form id="productDetail">
<ul class="container">
<li>
<h2>基本信息</h2>
<ul class="base-info">
<li>
<div class="label">品牌 <span class="red">*</span>:</div>
<div class="base-info-item">
<input id="editBrandId" type="text" name="brandId">
</div>
</li>
<li>
<div class="label">分类 <span class="red">*</span>:</div>
<div class="base-info-item">
<input id="editMaxSortId" type="text" name="maxSortId"/>
<input id="editMidSortId" type="text" name="midSortId"/>
</div>
</li>
<li>
<div class="label">系列 :</div>
<div class="base-info-item">
<input id="editSeriesId" name="seriesId" type="text">
</div>
</li>
<li>
<div class="label">商品展示名称 <span class="red">*</span>:</div>
<div class="base-info-item">
<input id="editProductName" type="text" name="productName"/>
<span style="color: #939393">用于商品在各终端给用户的呈现名称</span>
</div>
</li>
<li>
<div class="label">中文名称 :</div>
<div class="base-info-item">
<input id="editProductNameCn" type="text" name="productNameCn"/>
</div>
</li>
<li>
<div class="label">搜索关键词 :</div>
<div class="base-info-item">
<input type="text" id="editProductSearchName" name="productSearchName" disabled="disabled">
<input type="text" id="keyword" name="keyWords">
</div>
</li>
<li>
<div class="label"></div>
<div class="base-info-item">
<span style="color: #939393">用于搜索功能检索使用,建议完成搜索关键词填写以提高商品在有货搜索结果页的排名</span>
</div>
</li>
<li>
<div class="label">货号 <span class="red">*</span>:</div>
<div class="base-info-item">
<input id="editProductCode" type="text" name="productCode"/>
</div>
</li>
<li>
<div class="label">发售日期 <span class="red">*</span>:</div>
<div class="base-info-item">
<input id="editSaleTime" type="text" name="saleTime"/>
</div>
</li>
<li>
<div class="label">发售价格 :</div>
<div class="base-info-item">
<input id="editOfferPrice" type="text" name="offerPrice"/>
<label><input type="checkbox" name="isSynCalender" value="1" checked/>同步至发送日历</label>
</div>
</li>
<li>
<div class="label">性别 <span class="red">*</span>:</div>
<div class="base-info-item">
<label for="boy"><input id="boy" type="radio" value="1" name="gender" checked>男</label>
<label for="girl"><input id="girl" type="radio" value="2" name="gender">女</label>
<label for="all"><input id="all" type="radio" value="3" name="gender">通用</label>
</div>
</li>
<li>
<div class="label">商品价格限制 <span class="red">*</span>:</div>
<div class="base-info-item">
<input id="editMinPrice" type="text" name="minPrice" maxlength="10"/>
<span style="margin-right: 20px;">~</span>
<input id="editMaxPrice" type="text" name="maxPrice" maxlength="10"/>
</div>
</li>
<li>
<div class="label">展示平台 <span class="red">*</span>:</div>
<div class="base-info-item">
<input type="checkbox" name="showChannel" id="showChannel0" value="0">有货
<input type="checkbox" name="showChannel" id="showChannel1" value="1">闲鱼
</div>
</li>
<li>
<div class="label" style="align-self: flex-start;">卖家限制<span class="red">*</span>:</div>
<div class="base-info-item">
<label><input type="radio" name="limitSale" value="0" />全部卖家可售</label>
<label><input type="radio" name="limitSale" value="1" />指定卖家可售 </label>
<a id="addLimitSaleBtn" class="easyui-linkbutton btn-success" style="float: right; height: 20px">添加行</a>
<table id="uidListTable" style="float: right;" border="1" cellspacing="0">
<tr>
<td>用户UID</td>
<td>平台服务费(%)</td>
<td>包装费</td>
<td>鉴定费</td>
<td>操作</td>
</tr>
<!-- <tr>
<td>
<input class="easyui-textbox" style="width: 90px;height: 20px">
</td>
<td>
<input class="easyui-textbox" style="width: 70px;height: 20px">
</td>
<td>
<a class="easyui-linkbutton btn-delete" style="float: right;color: red;height: 20px" onclick='{if(confirm("确定要删除吗?")) {deleteCurrentRow(this); }else {}}'>删除行</a>
</td>
</tr> -->
</table>
</div>
</li>
<li>
<div class="label">海关编码 :</div>
<div class="base-info-item">
<input id="editHsCode" type="text" name="hsCode"/>
</div>
</li>
<li>
<div class="label">申报计量编码 :</div>
<div class="base-info-item">
<input id="editMeasuremenCode" type="text" name="measuremenCode"/>
</div>
</li>
<li>
<div class="label">包装一条码 :</div>
<div class="base-info-item">
<input id="editBarCode" type="text" name="barCode"/>
</div>
</li>
</ul>
</li>
<li>
<h2>颜色尺码</h2>
<div class="group-color">
<div class="label">*颜色</div>
<ul style="float: left; margin-left: 10px;">
</ul>
</div>
<div class="group-size">
<div class="label">*尺寸</div>
<div class="size"></div>
</div>
<table id="colorSizeTable" style="width:100%;height:auto"></table>
</li>
<li>
<h2>商品图片</h2>
<div class="goods-image">
<div id="imageUpload"></div>
</div>
</li>
<!--<li>
<h2>商品关键词</h2>
<div class="keyword">
<div class="label" style="width: 120px;">商品关键词:</div>
<div class="keyword-right">
<input type="text" id="keyword" name="keyWords">
</div>
</div>
<div class="red" style="margin-left:120px;">*每个关键词用英文逗号隔开</div>
</li>-->
<li style="display: none;">
<h2>商品图文介绍</h2>
<div>
<script id="editor" type="text/plain" style="width:1024px;height:500px;"></script>
</div>
</li>
<li>
<h2>鉴定视频</h2>
<div class="goods-image2">
<div id="vedioImageUpload"></div>
</div>
</li>
<li>
<div class="label">视频链接 :</div>
<div class="base-info-item">
<input id="editVedioUrl" type="text" name="vedioUrl"/>
</div>
</li>
<li style="text-align: center; margin-top: 20px;">
<a id="submitBtn" class="easyui-linkbutton btn-success">提交</a>
<a id="cancelBtn" class="easyui-linkbutton btn-default">取消</a>
</li>
</ul>
</form>
</div>
<script>
/* 新增,修改公用页面
editImage代表图片是否修改过,新增固定传1。修改的时候根据是否修改,修改传1,无修改传0
1.新增,所有参数之前为空值,
提交地址:product/addOrUpdate
提交参数:{"brandId":78,"colorId":1,"colorName":"红色","editImage":1,"gender":3,"goodsName":"自定义红色","imageUrlList":["https://img10.static.yhbimg.com/goodsimg/2018/08/25/16/01e99496407347514356e5fe327d1f661d.jpg","https://img12.static.yhbimg.com/goodsimg/2018/08/25/16/0292fcebd071444401e6de340bcf2d8c19.jpg"],"keyWords":"球鞋,adidas","maxPrice":"899","maxSortId":10,"midSortId":18,"minPrice":"599","productCode":"009-009-009","productName":"测试商品009","saleTime":"2018-11-11","seriesId":8,"sizeIdList":[28,29]}
2.修改:首先根据传进来的id,获取商品信息把页面控件填写好。hidden记录id、goodsId、等参数
提交参数:{"brandId":78,"colorId":2,"colorName":"蓝色","editImage":1,"gender":3,"goodsId":6,"goodsName":"自定义蓝色","id":10000004,"imageUrlList":["https://img10.static.yhbimg.com/goodsimg/2018/08/25/16/01e99496407347514356e5fe327d1f661d.jpg","https://img12.static.yhbimg.com/goodsimg/2018/08/25/16/0292fcebd071444401e6de340bcf2d8c19.jpg"],"keyWords":"球鞋,adidas2","maxPrice":"898","maxSortId":10,"midSortId":18,"minPrice":"598","productCode":"009-009-009-e","productName":"测试商品009-e","saleTime":"2018-11-12","seriesId":8}
不可修改:品牌、分类、颜色、尺码、SKU(颜色展示名称除外:goodsName)
*/
var tempIndex = 0;
function deleteCurrentRow(obj){
var tr = obj.parentNode.parentNode;
var tbody = tr.parentNode;
tbody.removeChild(tr);
//只剩行首时删除表格
/* if(tbody.rows.length==1) {
tbody.parentNode.removeChild(tbody);
} */
//limitSaleInfoMap.delete($(obj).attr("rowid"));
}
var productDetail = {
initDom: function() {
this.dom = {
editBrandId: $('#editBrandId'),
editProductName: $('#editProductName'),
editProductNameCn: $('#editProductNameCn'),
editHsCode: $('#editHsCode'),
editVedioUrl: $('#editVedioUrl'),
editMeasuremenCode: $('#editMeasuremenCode'),
editBarCode: $('#editBarCode'),
editSaleTime: $('#editSaleTime'),
editMinPrice: $('#editMinPrice'),
editMaxPrice: $('#editMaxPrice'),
editProductCode: $('#editProductCode'),
editMaxSortId: $('#editMaxSortId'),
editMidSortId: $('#editMidSortId'),
editSeriesId: $('#editSeriesId'),
imageUpload: $('#imageUpload'),
vedioImageUpload: $('#vedioImageUpload'),
keyword: $('#keyword'),
colorSizeTable: $('#colorSizeTable'),
editOfferPrice: $('#editOfferPrice'),
editProductSearchName: $('#editProductSearchName'),
};
},
initFormData: function(detail) {
var that = this;
this.dom.editBrandId.combobox('select', detail.brandId)
this.dom.editProductName.textbox('setValue', detail.productName);
this.dom.editProductNameCn.textbox('setValue', detail.productNameCn);
this.dom.editHsCode.textbox('setValue', detail.hsCode);
this.dom.editVedioUrl.textbox('setValue', detail.vedioUrl);
this.dom.editMeasuremenCode.textbox('setValue', detail.measuremenCode);
this.dom.editBarCode.textbox('setValue', detail.barCode);
this.dom.editSaleTime.myDatebox('setValue', detail.saleTime);
this.dom.editMinPrice.textbox('setValue', detail.minPrice);
this.dom.editMaxPrice.textbox('setValue', detail.maxPrice);
this.dom.editProductCode.textbox('setValue', detail.productCode);
this.dom.editMaxSortId.combobox('select', detail.maxSortId);
this.dom.editMidSortId.combobox('select', detail.midSortId);
ue.setContent(detail.productIntro);
if (detail.seriesId && detail.seriesId != 0) {
this.dom.editSeriesId.combobox('select', detail.seriesId);
}
if(detail.limitSaleInfo.length>0) {
$("#addLimitSaleBtn").css('display','block');//隐藏
$("#uidListTable").css('display','block');//隐藏
for (var i = 0; i <detail.limitSaleInfo.length; i++){
var arrayUserInfo = detail.limitSaleInfo[i].split(" ");
var uid = arrayUserInfo[0];
var percent = arrayUserInfo[1];
var packageFee= "";
var appraiseFee= "";
if(arrayUserInfo.length>2) {
packageFee = arrayUserInfo[2];
}
if(arrayUserInfo.length>3) {
appraiseFee = arrayUserInfo[3];
}
addRowSetValue(uid,percent,packageFee,appraiseFee);
}
$("input[name=limitSale]:eq(1)").attr("checked",'checked');
}
if(detail.isSynCalender == 1){
$('input[name=isSynCalender]').attr('checked','checked');
}else if(detail.isSynCalender == 0){
$('input[name=isSynCalender]').attr('checked',false);
}
this.dom.editOfferPrice.textbox('setValue', detail.offerPrice);
this.dom.keyword.textbox('setValue', detail.keyWords);
$('input[name=gender]').eq(detail.gender - 1).attr('checked','true');
$('.group-color li[data-id=' + detail.colorId + ']').addClass('actived');
if (detail.imageUrlList && detail.imageUrlList.length > 0) {
detail.imageUrlList.map(function(item) {
that.dom.imageUpload.before('<div class="img" data-url="' + item + '" style="background-image:url(' + item + ');">');
});
}
if (detail.vedioImageUrl) {
that.dom.vedioImageUpload.before('<div class="img" data-url="' + detail.vedioImageUrl + '" style="background-image:url(' + detail.vedioImageUrl + ');">');
}
if (detail.showChannel && detail.showChannel.length > 0) {
for (var channel in detail.showChannel.split(",")) {
$('#showChannel' + detail.showChannel.split(",")[channel]).attr('checked','checked');
}
}
},
initForm: function() {
var that = this;
this.dom.editProductName.textbox({
required: true,
missingMessage: "商品名称不能为空",
prompt: "请输入",
width: 460
});
this.dom.editProductNameCn.textbox({
required: false,
prompt: "请输入(最大50个字)",
width: 460
});
this.dom.editHsCode.textbox({
required: false,
width: 200,
prompt: "请输入",
});
this.dom.editVedioUrl.textbox({
required: false,
width: 200
});
this.dom.editMeasuremenCode.textbox({
required: false,
width: 200,
prompt: "请输入",
});
this.dom.editBarCode.textbox({
required: false,
width: 200,
prompt: "请输入",
});
this.dom.keyword.textbox({
width: 700
});
this.dom.editBrandId.myCombobox({
editable: false,
prompt: "请选择",
width: 200,
valueField: "id",
textField: "text",
onSelect: function(data) {
that.dom.editSeriesId.combobox('enable');
that.dom.editSeriesId.myCombobox('reload', contextPath + '/brandSeries/querySeriesByBrandId?brandId=' + data.id);
that.dom.editSeriesId.combobox('select');
that.showProductSearchName(data.text, 1)
}
});
this.dom.editSeriesId.myCombobox({
method: "get",
editable: false,
prompt: "请选择",
width: 200,
valueField: "id",
textField: "text",
loadFilter: function (data) {
if (data && data.code == 200 && data.data.length > 0) {
//that.dom.editSeriesId.combobox('select', data.data[0].id);
}
return defaultLoadFilter(data);
},
onSelect: function(data){
that.showProductSearchName(data.text, 4);
}
});
this.dom.editMaxSortId.myCombobox({
editable: false,
valueField: 'id',
textField: 'text',
width: 200,
prompt:"请选择一级分类",
onSelect: function (rec) {
that.dom.editMidSortId.combobox('clear');
that.dom.editMidSortId.combobox('reload', contextPath + "/productSort/getLevel2SortBySortId?sortId=" + rec.id);
if (!that.productId) {
that.dom.editMidSortId.combobox('enable');
}
that.showProductSearchName(rec.text, 2);
}
});
this.dom.editSaleTime.myDatebox({
width: 200,
prompt : "请输入"
});
this.dom.editMidSortId.myCombobox({
method: 'get',
width: 200,
editable: false,
valueField: 'id',
textField: 'text',
prompt:"请选择二级分类",
loadFilter: function(data) {
if (data && data.code == 200 && data.data.length > 0) {
//that.dom.editMidSortId.combobox('select', data.data[0].id);
}
return defaultLoadFilter(data);
},
onSelect: function(opt) {
that.getSizeInfo(opt.id);
that.showProductSearchName(opt.text, 3);
}
});
this.dom.keyword.textbox({
prompt: "自定义关键词(多个关键词使用英文逗号分隔)",
width: 300,
onChange: function(opt){
that.showProductSearchName(opt, 5)
}
});
this.dom.editProductSearchName.textbox({
required: false,
prompt: "品牌 一级分类 二级分类 系列 自定义字段",
editable: false,
width: 460
});
this.dom.editProductCode.textbox({
prompt : "请输入",
required: true,
width:200,
missingMessage: "货号不能为空"
});
this.dom.editMinPrice.textbox({
prompt : "最低价",
required: true,
width: 200,
missingMessage: "最低价不能为空"
});
this.dom.editMaxPrice.textbox({
prompt : "最高价",
required: true,
width: 200,
missingMessage: "最高价不能为空"
});
this.dom.editOfferPrice.numberbox({
width: 200,
prompt : "请输入(价格须为整数)"
});
this.dom.colorSizeTable.myDatagrid({
fit: false,
fitColumns: true,
autoRowHeight: true,
nowrap: false,
columns: [[{
title: "色系名称",
field: "colorName",
width: 20,
align: "center"
}, {
title: "颜色展示名称",
field: "goodsName",
width: 50,
height: 50,
align: "center",
formatter: function(value) {
return '<input type="text" class="goods-name" value="' + value + '">';
}
}, {
title: "尺码",
field: "size",
width: 40,
align: "center"
}, {
title: "SKU",
field: "sku",
width: 40,
align: "center"
},{
title: "平台建议售价",
field: "suggestPrice",
width: 60,
align: "center"
},{
title: "状态",
field: "status",
width: 30,
align: "center"
},{
title: "操作",
field: "operate",
width: 30,
align: "center",
formatter: function(value, rowData) {
console.log(rowData);
if (rowData.status == "上架") {
return "<a role=\'downSkuStatus\' dataId=\'" + rowData.sku + "\' style=\'margin-left:10px;background-color: #5bc0de\'>下架</a>";
} else {
return "<a role=\'upSkuStatus\' dataId=\'" + rowData.sku + "\' style=\'margin-left:10px;background-color: #5bc0de\'>上架</a>";
}
}
},{
title: "净重(g)",
field: "netWeight",
width: 30,
align: "center"
}]],
cache: false,
pagination: false,
idField: "id",
singleSelect: false,
checkOnSelect: false,
onLoadSuccess: function() {
$('.goods-name').textbox({
width: 100
});
// 下架商品
$(this).myDatagrid("getPanel").find("a[role='downSkuStatus']").linkbutton({
iconCls: "icon-more",
onClick: function () {
updateSkuStatus($(this).attr("dataId"), 0);
}
});
// 上架
$(this).myDatagrid("getPanel").find("a[role='upSkuStatus']").linkbutton({
iconCls: "icon-more",
onClick: function () {
updateSkuStatus($(this).attr("dataId"), 1);
}
});
}
});
if (!this.productId) {
this.dom.editSeriesId.combobox('disable');
} else {
this.dom.editBrandId.combobox('disable');
this.dom.editMaxSortId.combobox('disable');
}
this.dom.editMidSortId.combobox('disable');
},
init: function() {
var that = this;
this.productId = this.getUrlParam('id');
this.detailData = {};
this.submitFlag = false;
this.colorSizeTableData = {
total: 0,
rows: []
};
this.initDom();
this.initForm();
this.dom.imageUpload.imageUpload({
width: 104,
height: 104,
realInputName: "goodsImage",
url: contextPath + '/fileupload/upload',
queryParams: {
bucket: "goodsimg"
},
onBeforeSubmit: function () {
$.messager.progress({
title: "正在执行",
msg: "正在执行,请稍后...",
interval: 500,
text: ""
});
},
filterFileName: function (data) {
if (!data || data.code != 200) {
$.messager.progress("close");
$.messager.alert("错误", data.message);
return "";
}
return data.data.url;
},
onLoadSuccess: function (data) {
$.messager.progress("close");
$(document).find('.file-close').click();
that.dom.imageUpload.before('<div class="img" data-url="' + data.data + '" style="background-image:url(' + data.data + ');">');
return false;
}
});
this.dom.vedioImageUpload.imageUpload({
width: 104,
height: 104,
realInputName: "goodsImage",
url: contextPath + '/fileupload/upload',
queryParams: {
bucket: "goodsimg"
},
onBeforeSubmit: function () {
$.messager.progress({
title: "正在执行",
msg: "正在执行,请稍后...",
interval: 500,
text: ""
});
},
filterFileName: function (data) {
if (!data || data.code != 200) {
$.messager.progress("close");
$.messager.alert("错误", data.message);
return "";
}
return data.data.url;
},
onLoadSuccess: function (data) {
$.messager.progress("close");
$(document).find('.file-close').click();
that.dom.vedioImageUpload.before('<div class="img" data-url="' + data.data + '" style="background-image:url(' + data.data + ');">');
return false;
}
});
$.when(this.getBrandList(), this.getMaxSortList(), this.getColorInfo()).then(function(brand, maxSort, colors) {
var brandId = '';
brand = brand[0];
maxSort = maxSort[0];
colors = colors[0] || [];
if (brand && brand.code == 200) {
that.dom.editBrandId.combobox({
data: brand.data || []
});
}
if (maxSort && maxSort.code == 200) {
that.dom.editMaxSortId.combobox({
data: maxSort.data || []
});
}
if (colors && colors.code == 200) {
colors.data.map(function(item) {
var color = item.colorValue ? 'background: url('+item.colorValue+')' : 'background:#' + item.colorCode;
$('.group-color ul').append('<li data-id="' + item.id + '"><i style="float: left;width: 30px; height: 30px;border-radius: 50%; margin-right: 3px;' + color + ';background-size: contain;"></i>' + item.colorName + '</li>');
});
}
if (that.productId) {
that.getDetailInfo();
} else {
that.getSizeInfo();
}
});
$(document).on('click', '.group-color li', function() {
if (that.productId) {
$.messager.alert('操作提示', "颜色不可修改!");
return;
}
if (!$(this).hasClass('actived')) {
var colorName = $(this).text();
if (that.colorSizeTableData.rows.length > 0) {
that.colorSizeTableData.rows.map(function(item) {
item.colorName = colorName;
item.goodsName = colorName;
});
} else {
that.colorSizeTableData.rows.push({
colorName: colorName,
goodsName: colorName,
size: '',
sku: '-',
suggestPrice: '-',
netWeight:''
});
}
that.mergeCells();
$(this).siblings().removeClass('actived');
$(this).addClass('actived');
}
});
$(document).on('click', '.group-size input', function() {
var colorName = goodsName = '';
if (that.productId && $(this).attr('exist') == 'true') {
$.messager.alert('操作提示', '尺码不可删除!');
return false;
}
if ($('.group-color .actived').length == 0) {
$.messager.alert('操作提示', '请先选择颜色!');
return false;
}
if (that.colorSizeTableData.rows.length > 0) {
colorName = that.colorSizeTableData.rows[0].colorName;
goodsName = that.colorSizeTableData.rows[0].goodsName;
} else {
colorName = goodsName = $('.group-color .actived').text();
}
var oldColorSizeTableData = {};
for (var rowItem in that.colorSizeTableData.rows) {
oldColorSizeTableData[that.colorSizeTableData.rows[rowItem].size] = that.colorSizeTableData.rows[rowItem];
}
that.colorSizeTableData.rows = [];
$('.size-item:checked').each(function(index, item) {
that.colorSizeTableData.rows.push({
colorName: colorName,
goodsName: goodsName,
size: $(item).parent().text(),
sku: ($(item).parent().text() in oldColorSizeTableData) ? oldColorSizeTableData[$(item).parent().text()].sku : '-',
suggestPrice: ($(item).parent().text() in oldColorSizeTableData) ? oldColorSizeTableData[$(item).parent().text()].suggestPrice : '-',
status:($(item).parent().text() in oldColorSizeTableData) ? oldColorSizeTableData[$(item).parent().text()].status : '-',
netWeight:($(item).parent().text() in oldColorSizeTableData) ? oldColorSizeTableData[$(item).parent().text()].netWeight : '-'
});
});
if ($('.size-item:checked').length == 0 && colorName) {
that.colorSizeTableData.rows.push({
colorName: colorName,
goodsName: goodsName,
size: '',
sku: '-',
suggestPrice:'-',
status:'-',
netWeight:'-'
});
}
that.mergeCells();
});
$(document).on('click', '.goods-image .img', function() {
$(this).remove();
});
$(document).on('click', '.goods-image2 .img', function() {
$(this).remove();
});
$('#cancelBtn').linkbutton({
onClick: function() {
window.location.href = contextPath + "/html/product/productList.html?time_version=" + new Date().getTime();
}
});
$('#submitBtn').linkbutton({
onClick: function () {
var limitSaleInfoMap = new Map();
for(var i=0;i<=tempIndex;i++) {
if($("#uid"+i).length > 0) {
var limi = {};
limi.uid = $("#uid"+i).val();
limi.per = $("#per"+i).val();
limi.packageFee = $("#packageFee"+i).val();
limi.appraiseFee = $("#appraiseFee"+i).val();
limitSaleInfoMap.set(i+'', limi);
}
}
var limitInfo = new Array();
for (var x of limitSaleInfoMap) { // 遍历Map
if(myTrim(x[1].uid)==""){
$.messager.alert('操作提示', '请填写有效的可售卖家信息!');
return false;
}
limitInfo.push(myTrim(x[1].uid) + " " + myTrim(x[1].per)+ " " + myTrim(x[1].packageFee)+ " " + myTrim(x[1].appraiseFee));
}
var limitSelect = $("input[name='limitSale']:checked").val();
if(limitSelect=="0") {
limitInfo = new Array();
} else{
if(limitInfo.length==0) {
$.messager.alert('操作提示', '请填写可售卖家信息!');
return false;
}
}
var imageUrlList = [];
var sizeIdList = [];
var editImage = 0;
if (that.submitFlag) {
return;
}
that.submitFlag = true;
$('.goods-image .img').each(function(index, item) {
imageUrlList.push($(item).data('url'));
});
debugger
var vedioImageUrlStr = "";
$('.goods-image2 .img').each(function(index, item) {
if(vedioImageUrlStr=="") {
vedioImageUrlStr = $(item).data('url');
}
});
if (that.productId) {
if (that.detailData.imageUrlList && imageUrlList.length == that.detailData.imageUrlList.length) {
$.each(imageUrlList, function(index, item) {
if (item != that.detailData.imageUrlList[index]) {
editImage = 1;
}
});
} else {
editImage = 1;
}
$('.group-size input:checked').each(function(index, item) {
if ($(item).attr('exist') != 'true') {
sizeIdList.push(+$(item).val());
}
});
} else {
editImage = 1;
$('.group-size input:checked').each(function(index, item) {
sizeIdList.push(+$(item).val());
});
}
var showChannel = "";
$("input[name='showChannel']:checked").each(function (index, item) {
if ($("input[name='showChannel']:checked").length - 1 == index) {
showChannel += $(this).val();
} else {
showChannel += $(this).val() + ",";
}
});
if (showChannel.length <= 0) {
$.messager.alert('操作提示', '请选择展示平台!');
that.submitFlag = false;
return false;
}
var ajaxData = {
brandId: +that.dom.editBrandId.textbox('getValue'),
colorId: +$('.group-color .actived').data('id'),
colorName: $('.group-color .actived').text(),
editImage: editImage,
gender: +$('input[name="gender"]:checked').val(),
goodsName: $('.goods-name').length>0 && $('.goods-name').textbox('getValue') || '',
imageUrlList: imageUrlList,
vedioImageUrl: vedioImageUrlStr,
keyWords: that.dom.keyword.textbox('getValue'),
maxPrice: that.dom.editMaxPrice.textbox('getValue'),
maxSortId: +that.dom.editMaxSortId.combobox('getValue'),
midSortId: +that.dom.editMidSortId.combobox('getValue'),
minPrice: that.dom.editMinPrice.textbox('getValue'),
productCode: that.dom.editProductCode.textbox('getValue'),
productName: that.dom.editProductName.textbox('getValue'),
productNameCn: that.dom.editProductNameCn.textbox('getValue'),
hsCode: that.dom.editHsCode.textbox('getValue'),
measuremenCode: that.dom.editMeasuremenCode.textbox('getValue'),
barCode: that.dom.editBarCode.textbox('getValue'),
saleTime: that.dom.editSaleTime.myDatebox('getValue'),
seriesId: +that.dom.editSeriesId.combobox('getValue'),
limitSaleInfo : limitInfo,
isSynCalender: $('input[name="isSynCalender"]:checked').val(),
offerPrice: that.dom.editOfferPrice.textbox('getValue'),
vedioUrl: that.dom.editVedioUrl.textbox('getValue'),
productIntro : ue.getContent(),
showChannel : showChannel
};
if (!ajaxData.brandId) {
$.messager.alert('操作提示', '请选择品牌!');
that.submitFlag = false;
return false;
}
if (!ajaxData.saleTime) {
$.messager.alert('操作提示', '请选择发售时间!');
that.submitFlag = false;
return false;
}
if (!ajaxData.maxSortId) {
$.messager.alert('操作提示', '请选择一级分类!');
that.submitFlag = false;
return false;
}
if (ajaxData.maxPrice && ajaxData.maxPrice > 100000000) {
$.messager.alert('操作提示', '最高价非法,最多一亿');
that.submitFlag = false;
return false;
}
if (!ajaxData.midSortId) {
$.messager.alert('错误提示', '请选择二级分类!');
that.submitFlag = false;
return false;
}
/* if (imageUrlList.length == 0) {
$.messager.alert('操作提示', '至少添加一张图片!');
that.submitFlag = false;
return false;
} */
if (!$('#productDetail').form("validate")) {
that.submitFlag = false;
return false;
}
if (!that.productId) {
ajaxData.sizeIdList = sizeIdList;
if (!ajaxData.colorName) {
$.messager.alert('错误提示', '请选择颜色!');
that.submitFlag = false;
return false;
}
if (sizeIdList.length ==0) {
$.messager.alert('错误提示', '请选择尺码!');
that.submitFlag = false;
return false;
}
} else {
ajaxData.sizeIdList = sizeIdList;
ajaxData.id = that.detailData.id;
ajaxData.goodsId = that.detailData.goodsId;
}
$.messager.progress({
title: "正在执行",
msg: "正在执行,请稍后...",
interval: 500,
text: ""
});
$.ajax({
url: contextPath + '/product/addOrUpdate',
contentType: "application/json",
dataType: "json",
type: "POST",
data: JSON.stringify(ajaxData),
success: function(ret) {
$.messager.progress("close");
that.submitFlag = false;
if (ret && ret.code == 200) {
$.messager.alert('操作提示', '提交成功!');
window.location.href = contextPath + "/html/product/productList.html?time_version=" + new Date().getTime();
} else {
$.messager.alert('操作提示', ret.message || '提交失败');
}
},
error: function(err) {
that.submitFlag = false;
$.messager.progress("close");
$.messager.alert('操作提示', err.message || '提交失败');
}
});
}
});
},
mergeCells: function() {
this.colorSizeTableData.total = this.colorSizeTableData.rows.length;
this.dom.colorSizeTable.datagrid('loadData', this.colorSizeTableData);
this.dom.colorSizeTable.datagrid('mergeCells', {index: 0, field: 'colorName', rowspan: this.colorSizeTableData.total});
this.dom.colorSizeTable.datagrid('mergeCells', {index: 0, field: 'goodsName', rowspan: this.colorSizeTableData.total});
this.dom.colorSizeTable.datagrid('resize');
},
getUrlParam: function(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if (r != null) {
return unescape(r[2]);
}
return null;
},
getDetailInfo: function() {
var that = this;
// 编辑的情况需要根据id查询商品信息
$.get(contextPath + '/product/find?id=' + this.productId).then(function(ret) {
if (ret && ret.code == 200) {
ret = ret.data || {};
that.initFormData(ret);
that.detailData = ret;
}
});
},
getBrandList: function() {
// 获取所有品牌
return $.get(contextPath + '/brand/getBrandName');
},
getMaxSortList: function() {
// 获取一级分类
return $.get(contextPath + "/productSort/getLevel1SortIdAndName");
},
getSizeInfo: function(sortId) {
var that = this;
sortId = sortId || 0;
// 获取所有尺寸
$.get(contextPath + '/size/queryAllSecondSize4Goods?sortId=' + sortId, function(ret) {
if (ret && ret.code == 200) {
$('.group-size .size').html('');
$.each(ret.data || [], function(index, item) {
if (item.id) {
$('.group-size .size').append('<label for="size" style="margin-right: 5px;" data-id="' + item.id + '"><input type="checkbox" value="' + item.id + '" class="size-item">'+item.text+'</label>');
}
});
if (that.detailData.sizeIdList) {
/* that.detailData.sizeIdList.map(function(item) {
$('.group-size label[data-id=' + item + '] input').attr('checked','true');
that.colorSizeTableData.rows.push({
colorName: $('.group-color li[data-id='+that.detailData.colorId+']').text(),
goodsName: that.detailData.goodsName,
size: $('.group-size label[data-id=' + item + ']').text(),
sku: '-'
});
}); */
for ( var i = 0; i <that.detailData.sizeIdList.length; i++){
item = that.detailData.sizeIdList[i];
$('.group-size label[data-id=' + item + '] input').attr('checked','true').attr('exist','true');
that.colorSizeTableData.rows.push({
colorName: $('.group-color li[data-id='+that.detailData.colorId+']').text(),
goodsName: that.detailData.goodsName,
size: $('.group-size label[data-id=' + item + ']').text(),
sku: that.detailData.storageIdList[i],
suggestPrice: that.detailData.suggestPriceList[i],
status:that.detailData.statusList[i] == 1 ? '上架' : '<font color="red" >下架</font>',
netWeight:that.detailData.netWeightList[i],
});
}
}
that.mergeCells();
}
});
},
getColorInfo: function() {
// 获取所有颜色
return $.get(contextPath + '/productColor/getAllColor');
},
showProductSearchName: function(text, type) {
var brandId = type === 1 ? text : this.dom.editBrandId.textbox('getText') === "" ? "" : this.dom.editBrandId.textbox('getText');
var maxSortId = type === 2 ? text : this.dom.editMaxSortId.textbox('getText') === "" ? "" : this.dom.editMaxSortId.textbox('getText') ;
var midSortId = type === 3 ? text : this.dom.editMidSortId.textbox('getText') === "" ? "" : this.dom.editMidSortId.textbox('getText') ;
var seriesId = type === 4 ? text : this.dom.editSeriesId.textbox('getText') === "" ? "" : this.dom.editSeriesId.textbox('getText') ;
var keyword = type === 5 ? text : this.dom.keyword.textbox('getText') === "" ? "" : this.dom.keyword.textbox('getText') ;
var productSearchName = brandId ;
if(productSearchName != "" && maxSortId != ""){
productSearchName = productSearchName + ","
}
if(maxSortId != ""){
productSearchName = productSearchName + maxSortId
}
if(productSearchName != "" && midSortId != ""){
productSearchName = productSearchName + ","
}
if(midSortId != ""){
productSearchName = productSearchName + midSortId
}
if(productSearchName != "" && seriesId != ""){
productSearchName = productSearchName + ","
}
if(seriesId != ""){
productSearchName = productSearchName + seriesId
}
if(productSearchName != "" && keyword != ""){
productSearchName = productSearchName + ","
}
if(keyword != ""){
productSearchName = productSearchName + keyword
}
this.dom.editProductSearchName.textbox('setValue', productSearchName);
}
};
$(function () {
productDetail.init();
$("#addLimitSaleBtn").linkbutton({
onClick: function () {
addRow(tempIndex,0);
}
});
$("#addLimitSaleBtn").linkbutton({
onClick: function () {
addRow(1,1);
//$.parser.parse($("#addLimitSaleBtn").parent());
}
});
$('input[name="limitSale"]').click(function(){
if($(this).val() == "0") {
$("#addLimitSaleBtn").css('display','none');//隐藏
$("#uidListTable").css('display','none');//隐藏
} else {
$("#addLimitSaleBtn").css('display','block');//隐藏
$("#uidListTable").css('display','block');//隐藏
if($("#uidListTable").find("tr").length==1) {
$("#uidListTable tr:not(:first)").empty("");
addRow(tempIndex,0);
}
}
});
$("#addLimitSaleBtn").css('display','none');//隐藏
$("#uidListTable").css('display','none');//隐藏
$("input[name=limitSale]:eq(0)").attr("checked",'checked');
});
function addRowSetValue(uid,percent,packageFee,appraiseFee) {
tempIndex++;
if(percent==null || percent=="null") percent = "";
var rowStr ="<tr>";
rowStr += "<td><input id=\"uid" +tempIndex+ "\" style=\"width: 90px;height: 15px\"></td>";
rowStr += "<td><input id=\"per" +tempIndex+ "\" style=\"width: 70px;height: 15px\"></td>";
rowStr += "<td><input id=\"packageFee" +tempIndex+ "\" style=\"width: 70px;height: 15px\"></td>";
rowStr += "<td><input id=\"appraiseFee" +tempIndex+ "\" style=\"width: 70px;height: 15px\"></td>";
rowStr += "<td><a rowid=\"" +tempIndex+ "\" class=\"easyui-linkbutton btn-delete\" style=\"float: right;color: red;height: 20px\" onclick='{ var that = this;$.messager.confirm(\"操作提示\", \"确定要删除吗?\", function (data) { if(data) deleteCurrentRow(that);})}'>删除行</a></td>";
rowStr += "</tr>";
$("#uidListTable").append(rowStr);
$.parser.parse($("#addLimitSaleBtn").parent());
$("#uid"+tempIndex).val(uid);
$("#per"+tempIndex).val(percent);
$("#packageFee"+tempIndex).val(packageFee);
$("#appraiseFee"+tempIndex).val(appraiseFee);
}
function addRow(percent) {
tempIndex++;
var rowStr ="<tr>";
rowStr += "<td><input id=\"uid" +tempIndex+ "\" style=\"width: 90px;height: 15px\"></td>";
rowStr += "<td><input id=\"per" +tempIndex+ "\" style=\"width: 70px;height: 15px\"></td>";
rowStr += "<td><input id=\"packageFee" +tempIndex+ "\" style=\"width: 70px;height: 15px\"></td>";
rowStr += "<td><input id=\"appraiseFee" +tempIndex+ "\" style=\"width: 70px;height: 15px\"></td>";
rowStr += "<td><a rowid=\"" +tempIndex+ "\" class=\"easyui-linkbutton btn-delete\" style=\"float: right;color: red;height: 20px\" onclick='{ var that = this;$.messager.confirm(\"操作提示\", \"确定要删除吗?\", function (data) { if(data) deleteCurrentRow(that);})}'>删除行</a></td>";
rowStr += "</tr>";
$("#uidListTable").append(rowStr);
$.parser.parse($("#addLimitSaleBtn").parent());
}
function myTrim(x) {
return x.replace(/^\s+|\s+$/gm,'');
}
function updateSkuStatus(sku, status) {
$.get(contextPath + '/storage/updateSkuStatus?storageId=' + sku + '&status=' + status, function(ret) {
if (ret && ret.code == 200) {
window.location.reload();
}
});
}
var ue = UE.getEditor('editor');
UE.Editor.prototype._bkGetActionUrl = UE.Editor.prototype.getActionUrl;
UE.Editor.prototype.getActionUrl = function(action) {
if (action == 'uploadimage' || action == 'uploadfile') {
return contextPath + '/fileupload/upload4UE';
} else {
return this._bkGetActionUrl.call(this, action);
}
};
//$(".edui-mask").off("click mousedown");
ue.ready(function() {
$(".edui-mask").removeAttr("onclick").removeAttr("onmousedown");
ue.execCommand('serverparam', function(editor) {
return {
'bucket': 'goodsimg' //设置富文本编辑器请求时,携带的额外参数
};
});
});
</script>
</body>
</html>