packageForm.vue
59.7 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
<!-- 表单 -->
<template>
<div class="package-form">
<el-form :ref="`${formRef}d2FormRuleForm`"
:model="formData"
:rules="rules">
<slot name="title" />
<div v-for="(i, idx) in formList"
:key="idx"
class="package-form-block">
<div class="title">
<span v-show="i.title">{{ i.title }}</span>
<el-button v-if="i.addBtn"
type="primary"
@click="addGroundingGoods">
{{ i.addBtn }}
</el-button>
</div>
<div style="padding: 20px;">
<!-- 产品信息块 -->
<div v-if="idx == 2">
<div v-for="(ele, eleIndex) in formData.groundingGoodsList"
:key="eleIndex"
class="groundingGoods-item">
<div v-for="(item, index) in i.formBlock[eleIndex]" :key="index">
<!-- 上架部位 -->
<div v-if="item.type === 'radio-select' && ele.goodsType == 1 && !item.index">
<el-form-item :id="`groundingGoodsList[${eleIndex}][${item.name}]`"
class="dis-in-block"
:label="item.label ? `${item.label}:` : ''"
:label-width="item.label ? '180px' : '0px'"
:prop="`groundingGoodsList[${eleIndex}][${item.name}]`"
:rules="rules[item.name]"
:style="{ 'margin-bottom': !item.type ? '0px' : '22px' }">
<el-select v-model="ele[item.name]"
filterable
:placeholder="`请选择${item.label}`"
:style="{ width: item.width || formItemWidth }"
@change="selectAddAttr($event, item)">
<el-option v-for="subItem in positionTypeList"
:key="subItem.position"
:label="subItem.confName"
:value="subItem.position" />
</el-select>
<!-- <el-radio-group v-model="ele[item.name]">
<el-radio v-for="(subItem, subIndex) in positionTypeList"
:key="subIndex"
:label="subItem.position">
{{
subItem.confName }}
</el-radio>
</el-radio-group> -->
</el-form-item>
</div>
<div v-if="item.type === 'radio' && item.index && (ele.goodsType == 1 || (formData.baseSceneCode && this.filterBaseSceneCodeBySceneType(3).includes(formData.baseSceneCode)))">
<el-form-item :id="`groundingGoodsList[${eleIndex}][${item.name}]`"
class="dis-in-block"
:label="item.label ? `${item.label}:` : ''"
:label-width="item.label ? '180px' : '0px'"
:prop="`groundingGoodsList[${eleIndex}][${item.name}]`"
:rules="rules[item.name]"
:style="{ 'margin-bottom': !item.type ? '0px' : '22px' }">
<el-radio-group v-model="ele[item.name]" @change="($event, index) => upgradeSupplyModeChange($event, eleIndex)">
<el-radio v-for="(subItem, subIndex) in item.radioGroupList"
:key="subIndex"
:label="subItem.confId">
{{
subItem.confName }}
</el-radio>
</el-radio-group>
</el-form-item>
</div>
<!-- 产品附带信息 -->
<div v-if="ele.upgradeGoodsId && item.type === 'incidBox'">
<div class="incid_box">
<div v-for="(subItem, subIndex) in item.detailInfo"
:key="subIndex"
class="item">
<div class="label">
{{ subItem.unit ? (membraneTypeList.includes(ele[item.key]) ? `${subItem.label
}(元)/${subItem.value == 'purchasePrice' ? '卷' : '车'}` : (`${subItem.label}(元)/件`)) : subItem.label }}:
</div>
<div class="value">
<EllipsisPopover :content="subItem.unit || subItem.type == 'price' ? priceFilter(ele.upgradeGoods[subItem.value]) : ele.upgradeGoods[subItem.value] || ''"></EllipsisPopover>
</div>
</div>
<!-- 权益/延保非第三方展示 -->
<div v-if="(equitySceneType.includes(ele[item.key]) || extendedPosiType.includes(ele[item.key])) && !baseConfig.supplierCode.includes(`${ele.supplierCode}`)" class="item">
<div class="label">
嘀加成本元/件:
</div>
<div class="value">
<EllipsisPopover :content="priceFilter(ele.upgradeGoods.djCost)"></EllipsisPopover>
</div>
</div>
<!-- 产品分类 权益服务 非第三方 -->
<div v-if="equitySceneType.includes(ele[item.key]) && !baseConfig.supplierCode.includes(`${ele.supplierCode}`)" class="item">
<div class="label">
服务项目:
</div>
<div class="value">
<EllipsisPopover :content="ele.upgradeGoods.serviceItemNames || ''"></EllipsisPopover>
</div>
</div>
<!-- 产品分类 权益服务 -->
<div v-if="equitySceneType.includes(ele[item.key])" class="item">
<div class="label">
实体卡:
</div>
<div class="value">
<EllipsisPopover :content="ele.upgradeGoods.entityCardFlag == 'Y' ? '是' : '否'"></EllipsisPopover>
</div>
</div>
<!-- 质保年限 膜类展示 -->
<div v-if="membraneTypeList.includes(ele[item.key])" class="item">
<div class="label">
质保年限/年:
</div>
<div class="value">
<EllipsisPopover :content="`${ele.upgradeGoods.warrantyPeriod}年` || ''"></EllipsisPopover>
</div>
</div>
</div>
</div>
<!-- 下拉框/输入框 -->
<div v-if="item.type === 'input' || item.type === 'select' || item.type === 'searchSelect'">
<el-form-item :id="`groundingGoodsList[${eleIndex}][${item.name}]`"
class="dis-in-block"
:label="item.label ? `${item.unit ? (membraneTypeList.includes(ele.goodsType) ? `${item.label}(元)/车` : (`${item.label}(元)/件`)) : item.label}:` : ''"
:label-width="item.label ? '180px' : '0px'"
:prop="`groundingGoodsList[${eleIndex}][${item.name}]`"
:rules="item.name == 'minSellPrice' ? rules[item.name + eleIndex] : rules[item.name]"
:style="{ 'margin-bottom': !item.type ? '0px' : '22px' }">
<template v-if="item.type === 'input'">
<el-input v-model.trim="ele[item.name]"
clearable
:disabled="item.isDisabled"
:maxlength="item.maxlength"
:placeholder="item.label"
:style="{ width: item.width || formItemWidth }"
@blur="blur(item)"
@input="input($event, item, eleIndex)">
</el-input>
</template>
<template v-if="item.name == 'minSellPrice'">
<el-checkbox v-model="ele.validMinSellPriceFlag" class="check-min-price"></el-checkbox>
<span class="tips-text">勾选时提单校验最低价</span>
</template>
<el-select v-else-if="item.type === 'select'"
:ref="`selectRefs_${item.name}`"
v-model="ele[item.name]"
:clearable="item.isClear"
filterable
:placeholder="`请选择${item.label}`"
:style="{ width: item.width || formItemWidth }"
@change="selectAddAttr($event, item)">
<el-option v-for="subItem in item.optionList"
:key="subItem[item.optionId]"
:label="subItem[item.optionLabel]"
:value="subItem[item.optionId]" />
</el-select>
<!-- 上架产品 -->
<el-button v-else-if="item.type === 'searchSelect'"
icon="el-icon-plus"
@click="handleSelectGoods(eleIndex)">
选择产品
</el-button>
<el-button v-if="item.name == 'upgradeGoodsId' && formData.groundingGoodsList.length > 1"
style="float: right;"
type="text"
@click="delGroundingGoods(eleIndex)">
删除
</el-button>
</el-form-item>
</div>
</div>
</div>
</div>
<!-- 套餐信息/门店信息 -->
<div v-else>
<div v-for="(item, index) in i.formBlock" :key="index">
<!-- 下拉框/输入框 -->
<div v-if="(item.type === 'input' || item.type === 'select')">
<el-form-item :id="item.name"
:class="item.isDisabled ? 'dis-in-block is-required' : 'dis-in-block'"
:label="item.label ? `${item.unit ? (`${item.label}(元)/件`) : item.label}:` : ''"
:label-width="item.label ? '180px' : '0px'"
:prop="item.isDisabled ? '' : item.name"
:style="{ 'margin-bottom': !item.type ? '0px' : '22px' }">
<template v-if="item.type === 'input'">
<el-input v-model.trim="formData[item.name]"
clearable
:disabled="item.isDisabled"
:maxlength="item.maxlength"
:placeholder="item.placeholder || item.label"
:style="{ width: item.width || formItemWidth }"
@blur="blur(item)"
@input="input($event, item)">
</el-input>
</template>
<template v-if="item.type == 'select'">
<el-select :ref="`selectRefs_${item.name}`"
v-model="formData[item.name]"
:clearable="item.isClear"
filterable
:placeholder="`请选择${item.label}`"
:style="{ width: item.width || formItemWidth }"
@change="selectAddAttr($event, item)">
<el-option v-for="subItem in item.optionList"
:key="subItem[item.optionId]"
:disabled="item.name == 'baseSceneCode' && subItem[item.optionScene] != 0 && subItem[item.optionScene] != 1"
:label="subItem[item.optionLabel]"
:value="subItem[item.optionId]" />
</el-select>
</template>
</el-form-item>
</div>
<!-- 财务校验 -->
<div v-if="item.type === 'flagRadio'">
<el-form-item :id="item.name"
class="dis-in-block"
:label="item.label ? `${item.label}:` : ''"
:label-width="item.label ? '180px' : '0px'"
:prop="item.name"
:style="{ 'margin-bottom': !item.type ? '0px' : '22px' }">
<el-radio-group v-model="formData[item.name]">
<el-radio v-for="(subItem, subIndex) in item.radioGroupList"
:key="subIndex"
:label="subItem.value">
{{
subItem.label }}
</el-radio>
</el-radio-group>
<el-tooltip class="item"
effect="dark"
placement="top">
<template #content>
<p style="width: 260px;">
<i class="el-icon-info"></i>开启财务规则校验,该产品的清分及对账规则只能应用具体产品规则,若不满足所在订单自动挂单,需进行手动发起清分及对账计算
</p>
</template>
<i class="el-icon-info" style="margin-left: 20px;"></i>
</el-tooltip>
</el-form-item>
</div>
<!-- 按钮 -->
<div v-if="item.type === 'button'">
<el-form-item :id="item.name"
class="dis-in-block"
:label="item.label ? `${item.label}:` : ''"
:label-width="item.label ? '180px' : '0px'"
:prop="item.name"
:style="{ 'margin-bottom': !item.type ? '0px' : '22px' }">
<el-button icon="el-icon-plus" @click="handleClick">
选择上架门店
</el-button>
<RelateStoreTable v-if="$$(formData.merchantGoodsRefList, 'length')"
ref="relateStoreTable"
:is-hide="true"
:merchant-goods-ref-list="formData.merchantGoodsRefList"
@handleDelete="handleDelete"
@updateInventory="handleUpdateInventory">
</RelateStoreTable>
</el-form-item>
</div>
<!-- 上传凭证 -->
<div v-if="item.type === 'upload'" class="upload-box">
<el-form-item :id="item.name"
class="dis-in-block"
:label="item.label ? `${item.label}:` : ''"
:label-width="item.label ? '180px' : '0px'"
:prop="item.name"
:style="{ 'margin-bottom': !item.type ? '0px' : '22px' }">
<template>
<el-upload accept=".jpg,.png,.pdf"
action=""
:auto-upload="false"
class="upload-file"
drag
:file-list="uploadFileList"
:limit="30"
multiple
:on-change="e => handleFileChange(e, item)"
:on-exceed="hanldeOnExceed"
:show-file-list="false">
<i class="el-icon-upload"></i>
<div class="el-upload__text">
点击或将文件拖拽到此区域上传
</div>
<div class="item-tips text-tips">
{{ item.topTips }}
</div>
<div class="item-tips">
{{ item.tips }}
</div>
</el-upload>
<!-- 文件列表区域 -->
<div class="file-box">
<div v-for="(subItem, subIndex) in formData[item.name]" :key="subIndex">
<div v-if="!filterEmpty(subItem.uploadProgress) || subItem.voucherFileUrl" class="file-item">
<div class="file-content" @click="handleFileView(subItem)">
<el-progress define-back-color="#F5F7FA"
:percentage="subItem.uploadProgress"
:show-text="false"
stroke-linecap="butt"
:stroke-width="26"
text-color="#333333"
:text-inside="true">
</el-progress>
<div class="file-name">
{{ subItem.fileName }}
</div>
</div>
<i v-if="!subItem.voucherFileUrl"
class="el-icon-close del-icon"
@click="doCancel(item, subIndex)">
</i>
<i v-if="subItem.voucherFileUrl"
class="el-icon-delete"
@click="handleFileDelete(item, subIndex)">
</i>
</div>
</div>
</div>
</template>
</el-form-item>
</div>
</div>
</div>
</div>
</div>
<el-form-item style="margin-top: 40px;text-align: center;">
<el-button :disabled="$store.state.d2admin.loading.value"
type="primary"
@click="handleUp(1)">
保存并上架
</el-button>
<!-- 草稿状态/已下架/新增显示 -->
<el-button v-if="filterEmpty(formData.status) || formData.status == 3"
class="width_100"
:disabled="$store.state.d2admin.loading.value"
plain
type="primary"
@click="handleUp(2)">
存草稿
</el-button>
<el-button class="width_100 cancel-btn" @click="handleClose">
取消
</el-button>
</el-form-item>
</el-form>
<!-- store-api (精品升级 次新车升配 售后众筹 查询嘀加的门店数据 getMerchantList 售后会员权益升级 售前延保 售后延保 二手车 查询账户中心所有4s店 getAccountMerchantList -->
<RelateStoreDialog v-if="relateStoreVisible"
ref="formRelateStore"
:is-hide="true"
:relate-store-visible="relateStoreVisible"
:selected-base-scene-code="formData.baseSceneCode"
:selected-scene-type="selectedSceneType"
:store-api="filterBaseSceneCodeBySceneType([1, 2, 3]).includes(formData.baseSceneCode) ? getMerchantList : getAccountMerchantList"
:store-search-form="storeSearchForm"
:store-selected="storeSelected"
@handleRelateStoreClose="handleRelateStoreClose"
@handleRelateStoreConfirm="handleRelateStoreConfirm">
<template #default>
<el-row>
<el-form ref="relate"
:inline="true"
:model="storeSearchForm">
<el-form-item label="门店名称:">
<el-input v-model.trim="storeSearchForm.merchantName"
clearable
placeholder="门店名称"
@keydown.native="handleStoreInput" />
</el-form-item>
<el-form-item label="门店商户号:">
<el-input v-model.trim="storeSearchForm.merchantId"
clearable
placeholder="门店商户号"
@keydown.native="handleStoreInput" />
</el-form-item>
<el-form-item label="服务对接:">
<el-input v-model.trim="storeSearchForm.yqMerchantName"
clearable
placeholder="服务对接"
@keydown.native="handleStoreInput" />
</el-form-item>
<el-form-item label="服务对接商户号:">
<el-input v-model.trim="storeSearchForm.yqMerchantId"
clearable
placeholder="服务对接商户号"
@keydown.native="handleStoreInput" />
</el-form-item>
<el-button type="primary" @click="handleSearchStore">
搜索
</el-button>
</el-form>
</el-row>
</template>
</RelateStoreDialog>
<ElImageViewer v-if="imgViewerVisible"
:initial-index="initialIndex"
:on-close="closeImgViewer"
:url-list="imageFileArr" />
<SelectGoodsDialog v-if="selectGoodsVisible"
:package-select-ids="packageSelectIds"
:select-goods-visible="selectGoodsVisible"
:merchant-id-list="formData.merchantGoodsRefList"
:upgrade-goods-id="formData.groundingGoodsList[selectGoodIndex].upgradeGoodsId"
@handleSelectGoodsClose="handleSelectGoodsClose"
@handleSelectGoodsConfirm="handleSelectGoodsConfirm">
</SelectGoodsDialog>
</div>
</template>
<script>
import { mapActions } from "vuex";
import { getAccountMerchantList, getMerchantList } from "@/api/merchant";
import { uploadImg, uploadPDF } from "@/api/sys.base";
import { limitPrice } from "@/common/format";
import { deepClone } from "@/common/util";
import { baseConfig } from "@/main";
import ellipsisPopover from "../../components/ellipsisPopover.vue";
import selectGoodsDialog from "../../components/selectGoodsDialog.vue";
import { convertYuanToWan, filterSpecsStr } from "../../filterOption";
import relateStoreDialog from "../../grounding/components/relateStoreDialog.vue";
import relateStoreTable from "../../grounding/components/relateStoreTable.vue";
import { crowdUpgradeSupplyModeList, packageGoodsForm, upgradeSupplyModeList } from "../../grounding/constants/data";
import { getOperationCost } from "@api/grounding"
export default {
name: "GroundingForm",
components: {
RelateStoreDialog: relateStoreDialog,
RelateStoreTable: relateStoreTable,
ElImageViewer: () => import("element-ui/packages/image/src/image-viewer"),
SelectGoodsDialog: selectGoodsDialog,
EllipsisPopover: ellipsisPopover,
},
directives: {
"el-select-loadmore": {
bind(el, binding) {
const SELECTWRAP_DOM = el.querySelector(
".el-select-dropdown .el-select-dropdown__wrap",
);
SELECTWRAP_DOM.addEventListener("scroll", function () {
const condition
= this.scrollHeight - this.scrollTop <= this.clientHeight;
if (condition) {
binding.value();
}
});
},
},
},
props: {
// add - 新增;edit - 编辑
addOrEdit: {
type: String,
default: "add",
},
formItemWidth: {
type: String,
default: "100%",
},
formRef: {
type: String,
default: "",
},
originData: {
type: Object,
default: () => {
return {};
},
},
formList: {
type: Array,
default: () => { },
},
positionTypeList: { // 太阳膜产品部位
type: Array,
default: () => [],
},
goodsSelectList: {
type: Array,
default: () => [],
},
sceneCodeList: {
type: Array
}
},
data() {
return {
getMerchantList,
getAccountMerchantList,
equitySceneType: baseConfig.equitySceneType || [],
extendedPosiType: baseConfig.extendedPosiType || [], // 延保类
membraneTypeList: baseConfig.membraneTypeList,
formData: {},
reg: {
numReg: /^[1-9]\d*$/,
priceReg: /^\d[\d.]*$/,
},
show: false,
rules: {
packageName: [{ required: true, message: "请输入套餐名称", trigger: "blur" }],
merchantGoodsRefList: [{ required: true, message: "请选择上架门店", trigger: "change" }],
baseSceneCode: [{ required: true, message: "请选择业务场景", trigger: "change" }],
upgradeGoodsId: [{ required: true, message: "请选择上架产品", trigger: "change" }],
position: [{ required: true, message: "请选择上架部位", trigger: "change" }],
sellPrice: [{ required: true, message: "请输入售价", trigger: "blur" }],
upgradeSupplyMode: [{ required: true, message: "请选择升级/产品供应模式", trigger: "change" }],
upgradeProductCost: [{ required: true, message: "请输入产品、升级成本", trigger: "blur" }],
recoveryCost: [{ required: true, message: "请输入回收成本", trigger: "blur" }],
virtualAccountCost: [{ required: true, message: "请输入虚拟对账成本", trigger: "blur" }],
djCost: [{ required: true, message: "请输入嘀加成本", trigger: "blur" }],
thirdPartyCost: [{ required: true, message: "请输入第三方成本", trigger: "blur" }],
financeCheckFlag: [{ required: true, message: "请选择是否开启财务规则校验", trigger: "change" }],
},
storeSelected: [],
relateStoreVisible: false,
storeSearchForm: {
merchantName: "",
merchantId: "",
yqMerchantName: "",
yqMerchantId: "",
},
uploadFileList: [],
imageFileArr: [],
imgViewerVisible: false,
initialIndex: 0,
selectGoodsVisible: false,
selectGoodIndex: null,
filterSpecsStr,
selectedSceneType: ''
};
},
watch: {
"formData.baseSceneCode": {
handler(newVal, oldVal) {
this.oldBaseSceneCode = oldVal || newVal;
},
},
"formData.voucherList": {
handler(newVal) {
if (newVal) {
this.uploadFileList = newVal.filter(v => !this.filterEmpty(v.uploadProgress) || v.voucherFileUrl); // 文件列表
const imageFileArr = newVal.filter(v => v.voucherFileUrl && (v.voucherFileUrl.includes(".png") || v.voucherFileUrl.includes("jpg")));
this.imageFileArr = imageFileArr.map((item) => {
return item.voucherFileUrl;
});
}
},
deep: true,
},
"formData.groundingGoodsList": {
handler(newVal) {
if (newVal) {
// 建议售价,最低售价,升级产品成本,回收成本,虚拟对账成本,嘀加成本,第三方成本合计计算
const acc = { sellPrice: "", minSellPrice: "", upgradeProductCost: "", recoveryCost: "", virtualAccountCost: "", djCost: "", thirdPartyCost: "" };
newVal.forEach((val, index) => {
acc.sellPrice = !this.filterEmpty(val.sellPrice) || !this.filterEmpty(acc.sellPrice) ? this.subStr(acc.sellPrice, Number(val.sellPrice)) : "";
acc.minSellPrice = !this.filterEmpty(val.minSellPrice) || !this.filterEmpty(acc.minSellPrice) ? this.subStr(acc.minSellPrice, Number(val.minSellPrice)) : "";
acc.djCost = !this.filterEmpty(val.djCost) || !this.filterEmpty(acc.djCost) ? this.subStr(acc.djCost, Number(val.djCost)) : "";
acc.thirdPartyCost = !this.filterEmpty(val.thirdPartyCost) || !this.filterEmpty(acc.thirdPartyCost) ? this.subStr(acc.thirdPartyCost, Number(val.thirdPartyCost)) : "";
acc.upgradeProductCost = !this.filterEmpty(val.upgradeProductCost) || !this.filterEmpty(acc.upgradeProductCost) ? this.subStr(acc.upgradeProductCost, Number(val.upgradeProductCost)) : "";
acc.recoveryCost = !this.filterEmpty(val.recoveryCost) || !this.filterEmpty(acc.recoveryCost) ? this.subStr(acc.recoveryCost, Number(val.recoveryCost)) : "";
acc.virtualAccountCost = !this.filterEmpty(val.virtualAccountCost) || !this.filterEmpty(acc.virtualAccountCost) ? this.subStr(acc.virtualAccountCost, Number(val.virtualAccountCost)) : "";
this.$set(this.formList[2].formBlock, index, packageGoodsForm);
this.filterForm(index);
});
this.formData.sellPrice = acc.sellPrice;
this.formData.minSellPrice = acc.minSellPrice;
this.formData.djCost = acc.djCost;
this.formData.thirdPartyCost = acc.thirdPartyCost;
this.formData.upgradeProductCost = acc.upgradeProductCost;
this.formData.recoveryCost = acc.recoveryCost;
this.formData.virtualAccountCost = acc.virtualAccountCost;
this.checkMinPrice();
}
},
deep: true,
},
},
mounted() {
this.formData = deepClone(this.originData);
this.checkMinPrice();
},
methods: {
...mapActions({
get: "d2admin/base/get",
}),
filterBaseSceneCodeBySceneType(targetTypes) {
const types = [].concat(targetTypes)
return this.sceneCodeList?.flatMap(val =>
types.includes(val.sceneType) ? [val.baseSceneCode] : []
) || []
},
checkMinPrice() {
let _rules = this.rules;
this.formData?.groundingGoodsList?.forEach((item, index) => {
_rules["minSellPrice" + index] = [
{ required: true, message: "请输入最低售价", trigger: "blur" },
{
required: true,
trigger: "blur",
validator: (rule, value, callback) => {
(+value > +item.sellPrice) ? callback(new Error("最低售价不能大于售价")) : callback();
},
},
];
});
},
handleSelectGoods(eleIndex) {
const _this = this;
if (!_this.formData.merchantGoodsRefList?.length) {
return this.$message.warning("请选择上架门店");
}
this.selectGoodIndex = eleIndex;
this.selectGoodsVisible = true;
this.packageSelectIds = this.formData.groundingGoodsList?.map(v => v.upgradeGoodsId) || [];
},
async handleSelectGoodsConfirm(selectedData) {
const costResult = await getOperationCost({commodityCode: selectedData?.commodityCode, merchantIdList: this.formData?.merchantGoodsRefList?.map(v => {return v.merchantId})})
const _formData = this.formData.groundingGoodsList[this.selectGoodIndex];
const _valueObj = selectedData;
const { goodsTypeName, secondaryGoodsTypeName, thirdLevelGoodsTypeName } = _valueObj?.goodsInfo || {};
const types = [goodsTypeName, secondaryGoodsTypeName, thirdLevelGoodsTypeName];
const result = types.filter(type => type).join("-");
_formData.upgradeGoods = {
..._valueObj,
goodsName: _valueObj.goodsInfo.goodsName,
tempGoodsTypeName: result,
serviceItemNames: _valueObj?.upgradeGoodsServiceItemsList?.map((item) => {
return this.extendedPosiType.includes(_valueObj?.goodsInfo?.goodsType)
? item.serviceName
: `${item.serviceName}-${item.serviceGrade}/${item.servicePeriod}${(item.serviceItemId) ? `/${convertYuanToWan(item.minPrice)}-${convertYuanToWan(item.maxPrice)}万` : ""}`;
})?.join(","), // 服务项目
specificationData: this.filterSpecsStr(_valueObj),
djCost: _valueObj?.djCost,
carTypeConfigName: _valueObj?.carTypeConfigList?.map(item => item.seriesName).join("/"),
upgradeCommodityCode: _valueObj?.commodityCode,
operationCost: costResult?.operationCost
};
_formData.goodsType = _valueObj?.goodsInfo?.goodsType,
_formData.upgradeGoodsId = _valueObj.id;
_formData.productType = []; // 切换上架产品 将服务类型清空
_formData.baseSupplyMode = ""; // 切换上架产品 将基础供货模式清空
_formData.upgradeSupplyMode = ""; // 切换上架产品 将升级/产品供货模式清空
_formData.supplierCode = _valueObj?.goodsInfo?.supplierCode; // 供应方 判断是否需要走审核流程
if (!this.filterEmpty(_valueObj?.djCost))
_formData.djCost = _valueObj?.djCost; // 嘀加成本 产品信息自带数据
this.handleSelectGoodsClose();
this.updateMerchantGoodsRefList();
},
// 上架产品加入上架门店
updateMerchantGoodsRefList() {
// 在重新生成产品列表前,先同步当前的表格数据状态
if (this.$refs.relateStoreTable && this.$refs.relateStoreTable[0]) {
const currentTableData = this.$refs.relateStoreTable[0].tableData || [];
this.syncTableDataToFormData(currentTableData);
}
let _formData = [];
this.formData.groundingGoodsList.forEach((item) => {
if (item?.id || item?.upgradeGoods?.id) {
_formData.push({
merchantGoodsId: item?.id || item?.upgradeGoods?.id,
upgradeGoodsName: item.upgradeGoods?.upgradeGoodsName,
inventoryType: item.inventoryType || 2,
});
}
});
// 遍历已有的门店,如果门店里已经有某些产品了,保留它们的 inventoryType
let merchantGoodsRefList = this.formData.merchantGoodsRefList.map((merchant) => {
const newInventoryTypeRefList = _formData.map((newGoods) => {
// 去老数据里找找看这个产品原来在不在
const oldGoods = (merchant.inventoryTypeRefList || []).find(g => g.merchantGoodsId === newGoods.merchantGoodsId);
if (oldGoods) {
// 如果老数据有,保留老数据的库存模式
return {
...newGoods,
inventoryType: oldGoods.inventoryType,
};
}
// 如果没有,就用新的默认值
return newGoods;
});
return {
...merchant,
inventoryTypeRefList: newInventoryTypeRefList,
};
});
this.formData.merchantGoodsRefList = merchantGoodsRefList;
},
handleAddMerchantGoods() {
let _formData = [];
this.formData.groundingGoodsList.forEach((item) => {
_formData.push({
merchantGoodsId: item.id,
upgradeGoodsName: item.upgradeGoods?.upgradeGoodsName,
inventoryType: item.inventoryType || 2,
});
});
this.formData.merchantGoodsRefList.forEach((item) => {
if (!item.inventoryTypeRefList || item.inventoryTypeRefList.length == 0) {
item.inventoryTypeRefList = _formData;
}
});
},
handleSelectGoodsClose() {
this.selectGoodsVisible = false;
},
filterForm(index) {
const { formList, formData } = this;
const itemData = formData?.groundingGoodsList[index];
// 1 太阳膜 2 (售后众筹场景产品)
const shopType = itemData?.goodsType == 1 ? "1" : this.filterBaseSceneCodeBySceneType(3)?.includes(itemData?.baseSceneCode) ? "2" : "";
const shopForm = deepClone(formList[2].formBlock[index]);
const spliceForm = shopType == "1" ? ["giftCost", "recoveryCost", "virtualAccountCost", "djCost", "thirdPartyCost"]
: shopType == "2" ? ["warrantyType", "giftCost", "recoveryCost", "virtualAccountCost", "djCost", "thirdPartyCost"]
// 权益/延保类 无升级成本 新增嘀加成本和第三方成本
: this.equitySceneType.includes(itemData?.goodsType) || this.extendedPosiType.includes(itemData?.goodsType)
? ["warrantyType", "upgradeSupplyMode", "giftCost", "recoveryCost", "virtualAccountCost", "upgradeProductCost"]
: ["warrantyType", "upgradeSupplyMode", "giftCost", "recoveryCost", "virtualAccountCost", "djCost", "thirdPartyCost"];
// 回收成本:升级/产品供货模式选择“门店回收原厂+嘀加”时展示
if (itemData.upgradeSupplyMode == 4) {
spliceForm.includes("recoveryCost") && spliceForm.splice(spliceForm.indexOf("recoveryCost"), 1);
}
// 虚拟对账成本:升级/产品供货模式选择“门店套码+嘀加”“ 服务商自采+嘀加”时展示
if (itemData.upgradeSupplyMode == 3 || itemData.upgradeSupplyMode == 5) {
spliceForm.includes("virtualAccountCost") && spliceForm.splice(spliceForm.indexOf("virtualAccountCost"), 1);
}
const newForm = shopForm.filter(v => !spliceForm?.includes(v.name));
this.$set(this.formList[2].formBlock, index, newForm);
this.$nextTick(() => {
const _formBlock = this.formList[2].formBlock[index];
// 售后众筹场景 升级产品供货模式
const formIndex = _formBlock.findIndex(subItem => subItem.name == "upgradeSupplyMode");
if (this.filterBaseSceneCodeBySceneType(3)?.includes(itemData.baseSceneCode)) {
if (formIndex >= 0)
this.$set(_formBlock[formIndex], "radioGroupList", crowdUpgradeSupplyModeList);
}
// 太阳膜类 升级产品供货模式(优先级高)
if (shopType == 1) {
// 由1.3场景 切换到太阳膜 已选升级供货模式为2 的清除掉 太阳膜供货模式没有2
if (itemData.upgradeSupplyMode == 2)
this.itemData.upgradeSupplyMode = "";
if (formIndex > -1)
this.$set(_formBlock[formIndex], "radioGroupList", upgradeSupplyModeList);
}
// 非权益/延保类,将滴加成本和第三方成本情况
if (!this.equitySceneType.includes(itemData?.goodsType) && !this.extendedPosiType.includes(itemData?.goodsType)) {
this.$set(this.formData.groundingGoodsList[index], "djCost", "");
this.$set(this.formData.groundingGoodsList[index], "thirdPartyCost", "");
} else {
this.$set(this.formData.groundingGoodsList[index], "warrantyType", "");
this.$set(this.formData.groundingGoodsList[index], "upgradeSupplyMode", "");
this.$set(this.formData.groundingGoodsList[index], "recoveryCost", "");
this.$set(this.formData.groundingGoodsList[index], "virtualAccountCost", "");
this.$set(this.formData.groundingGoodsList[index], "upgradeProductCost", "");
}
// 当产品信息自带嘀加成本时,将输入框置灰
if (!this.filterEmpty(this.formData.groundingGoodsList[index]?.upgradeGoods?.djCost) && _formBlock[_formBlock.findIndex(subItem => subItem.name == "djCost")]) {
this.$set(_formBlock[_formBlock.findIndex(subItem => subItem.name == "djCost")], "isDisabled", true);
}
this.show = true;
this.$refs[this.formRef + "d2FormRuleForm"] && this.$refs[this.formRef + "d2FormRuleForm"].clearValidate();
});
},
// 上传上架凭证
handleFileChange(e, targetItem) {
setTimeout(() => {
let reader = new FileReader();
let fileInfo = e.raw;
if (!fileInfo.name.includes(".pdf") && !fileInfo.name.includes(".png") && !fileInfo.name.includes(".jpg")) {
return this.$message({
message: "文件格式不支持上传",
type: "warning",
});
}
reader.readAsDataURL(fileInfo);
reader.onload = (e) => {
const _formData = this.formData;
_formData[targetItem.name].push({
voucherFileUrl: "",
uploadProgress: 0,
fileName: fileInfo.name?.substring(0, 128),
fileSize: fileInfo.size,
cancelAxios: {},
});
const index = _formData[targetItem.name].length - 1;
const fileData = e.target.result;
const base64 = fileInfo.name.split(".")[fileInfo.name.split(".").length - 1] + "@" + fileData.split(",")[1];
const requestEvent = fileInfo.type == "application/pdf" ? uploadPDF : uploadImg;
requestEvent({
file: base64,
onProcess: (e) => { // 上传进度
const { loaded, total } = e;
const uploadPrecent = ((loaded / total) * 100) | 0;
_formData[targetItem.name][index].uploadProgress = uploadPrecent;
},
cancelFun: _formData[targetItem.name][index].cancelAxios, // 取消上传
}).then((res) => {
_formData[targetItem.name][index].voucherFileUrl = res; // 文件地址
}).catch(() => {
this.clearItem(targetItem, index); // 上传失败将内容清空 不删除数组 防止其它上传进度 找不到对应下标
});
};
}, 50);
},
// 修改升级产品供货模式
upgradeSupplyModeChange(e, index) {
this.$set(this.formData.groundingGoodsList[index], "recoveryCost", "");
this.$set(this.formData.groundingGoodsList[index], "virtualAccountCost", "");
},
// 限制上传文件个数
hanldeOnExceed() {
this.$message({
message: "最多可上传30个文件",
type: "warning",
});
},
// 添加产品
addGroundingGoods() {
const groundingGoodsList = this.formData.groundingGoodsList;
groundingGoodsList?.unshift({
upgradeGoodsId: "", // 产品id
goodsAlias: "", // 商品别名
position: "", // 上架部位
sellPrice: "", // 参考售价
minSellPrice: "", // 最低售价
upgradeProductCost: "", // 产品升级成本
recoveryCost: "", // 回收成本
virtualAccountCost: "", // 虚拟对账成本
warrantyType: "", // 质保卡类型
upgradeSupplyMode: "", // 升级/产品供货模式
djCost: "", // 嘀加成本
thirdPartyCost: "", // 第三方成本
validMinSellPriceFlag: false,
});
let arr = this.formList[2].formBlock;
arr?.unshift(packageGoodsForm);
this.$set(this.formList[2], "formBlock", arr);
},
delGroundingGoods(index) {
const groundingGoodsList = this.formData.groundingGoodsList;
const deletedGoodsId = groundingGoodsList[index]?.id || groundingGoodsList[index]?.upgradeGoods?.id;
groundingGoodsList?.splice(index, 1);
// 同步删除商户列表中的对应产品
if (deletedGoodsId) {
this.formData.merchantGoodsRefList = this.formData.merchantGoodsRefList.map((merchant) => {
if (merchant.inventoryTypeRefList) {
merchant.inventoryTypeRefList = merchant.inventoryTypeRefList.filter(
goods => goods.merchantGoodsId !== deletedGoodsId,
);
}
return merchant;
});
// 触发更新视图
this.updateMerchantGoodsRefList();
}
},
// 删除文件
handleFileDelete(targetItem, subIndex) {
this.clearItem(targetItem, subIndex);
},
// 预览文件
handleFileView(item) {
if (!item.voucherFileUrl)
return;
if (item?.voucherFileUrl.includes(".pdf")) { // pdf文件直接打开新窗口预览
window.open(item.voucherFileUrl);
} else {
this.imgViewerVisible = true;
this.imageFileArr.forEach((val, index) => {
if (val == item.voucherFileUrl)
this.initialIndex = index;
});
}
},
// 关闭文件预览
closeImgViewer() {
this.imgViewerVisible = false;
},
// 取消上传
doCancel(targetItem, subIndex) {
const _formData = this.formData;
const cancelUploadObj = _formData[targetItem.name][subIndex].cancelAxios;
cancelUploadObj && cancelUploadObj.cancel && cancelUploadObj.cancel();
this.clearItem(targetItem, subIndex);
},
// 清空上传文件数组项内容
clearItem(targetItem, subIndex) {
this.$set(this.formData[targetItem.name][subIndex], "voucherFileUrl", "");
this.$set(this.formData[targetItem.name][subIndex], "uploadProgress", "");
},
// 选择上架门店
handleClick() {
const _this = this;
if (_this.filterEmpty(_this.formData.baseSceneCode)) {
return this.$message.warning("请选择业务场景");
}
_this.storeSelected = deepClone(_this.formData.merchantGoodsRefList);
_this.relateStoreVisible = true;
},
handleRelateStoreConfirm(selectedData) {
if (!selectedData.length) {
this.$message({
message: "请选择关联门店",
type: "warning",
showClose: true,
});
return true;
}
// 合并保留旧的 inventoryTypeRefList 数据,防止已选的库存模式丢失
const oldMerchantList = this.formData.merchantGoodsRefList || [];
const mergedData = selectedData.map((newMerchant) => {
const oldMerchant = oldMerchantList.find(m => m.merchantId === newMerchant.merchantId);
if (oldMerchant) {
return {
...newMerchant,
inventoryTypeRefList: deepClone(oldMerchant.inventoryTypeRefList) || [],
};
}
return newMerchant;
});
this.formData.merchantGoodsRefList = mergedData;
this.updateMerchantGoodsRefList();
// 上架门店选中变更 清除已选上架产品
this.clearGroundingGoodsList()
this.relateStoreVisible = false;
},
clearGroundingGoodsList() {
this.formData.groundingGoodsList = [{ // 上架产品集合
upgradeGoodsId: "", // 产品id
goodsAlias: "", // 商品别名
position: "", // 上架部位
sellPrice: "", // 参考售价
minSellPrice: "", // 最低售价
warrantyType: "", // 质保卡类型
upgradeSupplyMode: "", // 升级产品供货模式
upgradeProductCost: "", // 升级产品成本
recoveryCost: "", // 回收成本
virtualAccountCost: "", // 虚拟对账成本
djCost: "", // 嘀加成本
thirdPartyCost: "", // 第三方成本
validMinSellPriceFlag: false, // 是否校验最低价
}]
},
handleRelateStoreClose() {
this.relateStoreVisible = false;
},
handleStoreInput(e) {
(e.keyCode === 13) && this.handleSearchStore();
},
// 门店搜索
handleSearchStore() {
this.$refs.formRelateStore.handleCurrentChange(1);
},
// 删除上架门店
handleDelete(item) {
// 在删除前,需要将当前组件内的子组件的表格数据同步回 formData
// 否则如果只是纯粹 filter,会导致没保存的值又丢失了
if (this.$refs.relateStoreTable && this.$refs.relateStoreTable[0]) {
const currentTableData = this.$refs.relateStoreTable[0].tableData || [];
this.syncTableDataToFormData(currentTableData);
}
const filterArr = this.formData.merchantGoodsRefList.filter(i => i.merchantId !== item.merchantId);
this.$set(this.formData, "merchantGoodsRefList", filterArr);
// 上架门店选中变更 清除已选上架产品
this.clearGroundingGoodsList()
this.updateMerchantGoodsRefList();
},
syncTableDataToFormData(tableData) {
const merchantGoodsMap = {};
tableData.forEach((item) => {
if (!merchantGoodsMap[item.merchantId]) {
merchantGoodsMap[item.merchantId] = {
merchantId: item.merchantId,
merchantName: item.merchantName,
inventoryTypeRefList: [],
};
}
merchantGoodsMap[item.merchantId].inventoryTypeRefList.push({
merchantGoodsId: item?.merchantGoodsId || item?.upgradeGoods?.id,
merchantId: item?.merchantId,
merchantName: item?.merchantName,
inventoryType: item.inventoryType,
});
});
// 将分组后的数据合并回 formData.merchantGoodsRefList
this.formData.merchantGoodsRefList = this.formData.merchantGoodsRefList.map((merchant) => {
if (merchantGoodsMap[merchant.merchantId]) {
return {
...merchant,
inventoryTypeRefList: merchantGoodsMap[merchant.merchantId].inventoryTypeRefList,
};
}
return merchant;
});
},
handleUpdateInventory(row) {
const merchant = this.formData.merchantGoodsRefList.find(m => m.merchantId === row.merchantId);
if (merchant && merchant.inventoryTypeRefList) {
const goods = merchant.inventoryTypeRefList.find(g => g.merchantGoodsId === row.merchantGoodsId);
if (goods) {
goods.inventoryType = row.inventoryType;
}
}
},
getRelateStoreTableData() {
if (this.$refs.relateStoreTable) {
return this.$refs.relateStoreTable[0].tableData || [];
}
return [];
},
// 下拉加载更多 下拉框显示隐藏触发
visibleChange(data) {
this.$emit("visibleChange", data);
},
interestsLoadmore() {
this.$emit("interestsLoadmore");
},
remoteMethod(query) {
this.$emit("remoteMethod", query);
},
// 修复直接调用可以会因为没有对应方法报错的问题
input(event, item, eleIndex) {
item.handleInput && this.handleInput(event, item, eleIndex);
},
blur(item) {
},
// 价格计算精度丢失处理
subStr(num1, num2) {
let r1, r2, m, n;
try {
r1 = num1.toString().split(".")[1].length;
} catch (e) {
r1 = 0;
}
try {
r2 = num2.toString().split(".")[1].length;
} catch (e) {
r2 = 0;
}
m = 10 ** Math.max(r1, r2);
n = (r1 >= r2) ? r1 : r2;
return ((num1 * m + num2 * m) / m).toFixed(n);
},
// 价格过滤
handleInput(e, item, eleIndex) {
e = e.replace(/[^\d.]/g, "");
let oldValue = `${this.formData.groundingGoodsList[eleIndex]["old" + item.name]}`;
this.$set(this.formData.groundingGoodsList[eleIndex], `${item.name}`, limitPrice(e, oldValue, 6, 2, 0));
this.$set(this.formData.groundingGoodsList[eleIndex], `old${item.name}`, this.formData.groundingGoodsList[eleIndex][item.name]);
},
// 选择框-添加其他属性
selectAddAttr(value, targetItem, eleIndex) {
const _formData = this.filterEmpty(eleIndex) ? this.formData : this.formData.groundingGoodsList[eleIndex];
if (targetItem.name == "merchantId") {
let _tempVal = targetItem.optionList.find(item => item.merchantId === value);
_formData.merchantName = _tempVal.merchantName;
}
// 切换业务场景 将选中的上架门店清空
if (targetItem.name === "baseSceneCode") {
const _formData = this.formData;
this.selectedSceneType = `${targetItem?.optionList?.find(val => val.baseSceneCode == value)?.sceneType}`
if (!this.filterEmpty(this.oldBaseSceneCode)) {
// 清空门店弹窗搜索条件
this.storeSearchForm = {
merchantName: "",
merchantId: "",
yqMerchantName: "",
yqMerchantId: "",
};
if (_formData.merchantGoodsRefList?.length) {
this.$confirm("切换业务场景,将清空上架门店,是否继续", "提示", {
confirmButtonText: "确定",
type: "warning",
}).then(() => {
_formData.baseSceneCode = value;
this.selectedSceneType = `${targetItem?.optionList?.find(val => val.baseSceneCode == value)?.sceneType}`
this.$nextTick(() => {
this.$refs.selectRefs_baseSceneCode[0].blur();
_formData.merchantGoodsRefList = [];
// 上架门店选中变更 清除已选上架产品
this.clearGroundingGoodsList()
this.$forceUpdate();
});
}).catch(() => {
_formData.baseSceneCode = this.oldBaseSceneCode;
this.selectedSceneType = `${targetItem?.optionList?.find(val => val.baseSceneCode == this.oldBaseSceneCode)?.sceneType}`
this.$nextTick(() => {
this.$refs.selectRefs_baseSceneCode[0].blur();
});
});
}
}
}
},
handleClose() {
this.$emit("handleClose");
},
jumpScroll(idName) {
document.getElementById(idName).scrollIntoView();
},
filterEmpty(data) {
return (data ?? "") === "";
},
// 处理金额补零
priceFilter(num) {
let pow = 10 ** 2;
if (this.filterEmpty(num))
return "-";
return `${(Math.round(num * pow) / pow).toFixed(2)}元`;
},
handleUp(e) {
this.$refs[this.formRef + "d2FormRuleForm"].validate((valid, options) => {
if (valid) {
this.$emit("handleAddConfirm", { ...this.formData, num: e });
} else {
let needRuleList = Object.keys(options);
this.jumpScroll(needRuleList[0]);
return true;
}
});
},
},
};
</script>
<style lang="scss" scoped>
.package-form {
.package-form-block {
margin: 20px 0px;
background: #ffffff;
.title {
height: 50px;
line-height: 50px;
padding: 0 20px;
border-bottom: 1px solid #e5e5e5;
font-size: 16px;
font-weight: 600;
color: #333333;
display: flex;
align-items: center;
justify-content: space-between;
}
.groundingGoods-item {
padding-top: 15px;
border-bottom: 1px solid #e5e5e5;
}
.groundingGoods-item:last-child {
border: none;
}
.dis-in-block {
display: inline-block;
width: 100%;
}
.upload-file {
::v-deep .el-upload-dragger {
display: flex;
flex-flow: column;
justify-content: center;
align-items: center;
width: 300px;
height: 160px;
background: #f7f7f7;
.el-icon-upload {
margin: 0;
}
.el-upload__text {
font-size: 14px;
color: #000000;
}
.item-tips {
font-size: 12px;
color: #999999;
height: 22px;
line-height: 22px;
}
.text-tips {
font-size: 14px;
}
}
}
.file-box {
width: 350px;
.file-item {
margin-top: 6px;
position: relative;
box-sizing: border-box;
display: flex;
justify-content: space-between;
align-items: center;
cursor: pointer;
::v-deep .el-progress-bar {
width: 320px;
background: #ffffff;
border: 1px solid #f4f6fc;
border-radius: 4px;
.el-progress-bar__outer {
background: transparent;
border-radius: 4px;
.el-progress-bar__inner {
background: #f5f7fa;
border-radius: 4px;
}
}
}
::v-deep .el-image-viewer__wrapper {
width: 100vw;
height: 100vh;
}
.file-name {
position: absolute;
left: 12px;
top: 6px;
transform: translateY(-50%);
color: #333333;
font-size: 14px;
max-width: 300px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.image-file {
z-index: -1;
}
}
.file-item:first-child {
margin-top: 15px;
.file-name {
position: absolute;
left: 12px;
top: 15px;
transform: translateY(-50%);
color: #333333;
font-size: 14px;
}
}
}
.check-min-price {
margin: 0 6px 0 15px;
}
.tips-text {
color: #999999;
}
}
}
.incid_box {
margin-left: 180px;
background: #f9f9f9;
border-radius: 8px;
display: flex;
flex-wrap: wrap;
padding: 15px;
margin-bottom: 22px;
font-size: 14px;
color: #333333;
.item {
width: 33%;
display: flex;
align-items: center;
margin: 10px 0;
.label {
flex-shrink: 0;
color: #666666;
width: 150px;
text-align: right;
}
.value {
width: calc(100% - 150px);
}
.text-hide {
width: calc(100% - 150px);
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
}
.flex_1 {
flex: 0 0 100%;
}
}
.width_100 {
display: inline-block;
width: 100px;
}
.el-select-dropdown__item {
.goodName {
color: #333333;
}
.typeName {
margin-left: 8px;
font-size: 12px;
color: #999999;
}
}
.el-select-dropdown__item.selected {
span {
color: #2a58ad;
}
}
::v-deep .el-radio__original {
display: none !important;
}
::v-deep .el-radio:focus:not(.is-focus):not(:active):not(.is-disabled) .el-radio__inner {
box-shadow: none !important;
}
</style>