singleSpecificationForm.vue
40 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
<template>
<div class="singleSpecification-form">
<div class="content_box">
<div class="table-wrapper">
<table class="table-spesc" cellspacing="0" cellpadding="0">
<tbody class="table_content">
<tr
style=" background: #F2F4F7; height: 40px;">
<td style="width: 75px;">
<el-checkbox :indeterminate="isIndeterminate" v-model="allChecked" @change="handleAllChecked"></el-checkbox>
</td>
<td>
<span class="color-red">*</span>
<span>商品</span>
</td>
<td>
<span>编码</span>
</td>
<td>
<span>第三方编码</span>
</td>
<!-- 仅太阳膜展示 -->
<td v-if="goodsInfoData.goodsType == 1">
<span class="color-red">*</span>
<span>部位</span>
</td>
<!-- 仅权益升级类目且供应方位广联直营展示 -->
<td v-if="equitySceneType.includes(goodsInfoData.goodsType) && !baseConfig.supplierCode.includes(`${goodsInfoData.supplierCode}`)">
<span class="color-red">*</span>
<span>服务项目</span>
<img v-if="$$(goodsInfoData.goodsSpecificationSingleList,'length') && goodsInfoData.goodsSpecificationSingleList.filter(item => item.checked).length > 0"
src="@/assets/icon-edit.png"
style="cursor: pointer;margin-left: 5px;width: 16px;height: 16px;vertical-align: middle;"
@click="serviceSelectFocus()" />
</td>
<!-- 仅选择同步到采购商城展示 -->
<td v-if="goodsInfoData.shoppingMallFlag !== '0'">
<span class="color-red">*</span>
<!-- 膜类单位是卷 其余为件 -->
<span>{{ membraneTypeList.includes(goodsInfoData.goodsType) ? '采购价(元)/卷' : '采购价(元)/件' }}</span>
</td>
<td>
<!-- 膜类单位是车 其余为件 -->
<span>{{ membraneTypeList.includes(goodsInfoData.goodsType) ? '参考售价(元)/车' : '参考售价(元)/件' }}</span>
</td>
<!-- 延保/权益 非第三方展示 -->
<td v-if="(extendedPosiType.includes(goodsInfoData.goodsType) || equitySceneType.includes(goodsInfoData.goodsType)) && !baseConfig.supplierCode.includes(`${goodsInfoData.supplierCode}`)">
<span class="color-red">*</span>
<span>嘀加成本(元)/件</span>
</td>
<td>
<span>适用车型</span>
<img v-if="$$(goodsInfoData.goodsSpecificationSingleList,'length') && goodsInfoData.goodsSpecificationSingleList.filter(item => item.checked).length > 0"
src="@/assets/icon-edit.png"
style="cursor: pointer;margin-left: 5px;width: 16px;height: 16px;vertical-align: middle;"
@click="carSeriesSelectFocus()" />
</td>
<td>
<span>库存下限预警/{{ membraneTypeList.includes(goodsInfoData.goodsType) ? '米' : '件' }}</span>
</td>
<td>
<span>库存上限预警/{{ membraneTypeList.includes(goodsInfoData.goodsType) ? '米' : '件' }}</span>
</td>
<!-- 仅权益升级类目展示 -->
<td v-if="equitySceneType.includes(goodsInfoData.goodsType)">
<span class="color-red">*</span>
<span>实体卡</span>
</td>
<!-- 仅太阳膜 车衣 改色膜 展示 -->
<td v-if="membraneTypeList.includes(goodsInfoData.goodsType)">
<span class="color-red">*</span>
<span>质保年限/年</span>
</td>
<td style="width: 60px;"><span>操作</span></td>
</tr>
</tbody>
</table>
<table v-if="$$(goodsInfoData.goodsSpecificationSingleList,'length')" class="table-spesc content-table" cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 40px; line-height: 40px; "
v-for="(subItem, subIndex) in goodsInfoData.goodsSpecificationSingleList"
:key="subIndex">
<td style="width: 75px;">
<el-checkbox v-model="subItem.checked" @change="event => handleChecked(event, subIndex)"></el-checkbox>
</td>
<td>
<span style="display: flex;align-items: center;justify-content: center;overflow: hidden;" v-if="!subItem.editGoodNameInput">
<span style="max-width: 160px;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;">{{ subItem.specificationData }}</span>
<img src="@/assets/icon-edit.png" style="cursor: pointer;margin-left: 5px;width: 16px;height: 16px;" @click="editSpecificationData(subIndex)" />
</span>
<el-input v-else placeholder="商品名称"
size="small"
:class="{ 'w-150-per': true, 'border-red': (filterEmpty(subItem.specificationData) && subItem.specificationDataEmpty) || subItem.specificationDataError }"
maxlength="50"
:ref="'specificationDataInput' + subIndex"
v-model.trim="subItem.specificationData"
@blur="handleGoodsNameBlur($event, subIndex)">
<el-popover v-if="(filterEmpty(subItem.specificationData) && subItem.specificationDataEmpty) || subItem.specificationDataError "
slot="suffix"
placement="top"
title
width="90"
trigger="hover"
:content="subItem.specificationDataError ? '商品名称不可包含;~;特殊字符' : '商品名称是必填项'">
<i class="el-icon-warning color-red"
slot="reference" />
</el-popover>
</el-input>
</td>
<td>
<el-input placeholder="请输入"
size="small"
:class="{ 'w-150-per': true, 'w-150-per': true }"
v-model.trim="subItem.type"
maxlength="20"
@input="handleTypeInput($event, subIndex)">
</el-input>
</td>
<td>
<el-input placeholder="请输入"
size="small"
:class="{ 'w-150-per': true, 'w-150-per': true }"
v-model.trim="subItem.thirdPartyCode"
maxlength="50">
</el-input>
</td>
<td v-if="goodsInfoData.goodsType == 1">
<el-select placeholder="部位"
size="small"
multiple
collapse-tags
:class="{ 'w-150-per': true, 'border-red': filterEmpty(subItem.position) && subItem.positionEmpty }"
style="width: 180px;"
v-model="subItem.position"
@change="changePosition($event, subIndex)">
<el-option v-for="childItem in productPositionTypeList"
:key="childItem.position"
:label="childItem.confName"
:value="childItem.position" />
<el-popover v-if="filterEmpty(subItem.position) && subItem.positionEmpty"
slot="suffix"
placement="top"
title
width="90"
trigger="hover"
content="部位是必填项">
<i class="el-icon-warning color-red"
slot="reference" />
</el-popover>
</el-select>
</td>
<!-- 延保服务项目 -->
<!-- <td v-if="extendedPosiType.includes(goodsInfoData.goodsType) && !baseConfig.supplierCode.includes(`${goodsInfoData.supplierCode}`)">
<template v-if="!$$(subItem.extendServiceItemArr, 'length')">
<el-button size="small" @click="extendServiceSelectFocus(subIndex)" icon="el-icon-plus">选择服务项目</el-button>
<el-popover v-if="filterEmpty(subItem.extendServiceItemArr) && subItem.extendServiceItemArrEmpty"
slot="suffix"
placement="top"
title
width="90"
trigger="hover"
content="服务项目是必填项">
<i class="el-icon-warning color-red"
slot="reference" />
</el-popover>
</template>
<template v-else>
<span style="display: flex;align-items: center;justify-content: center;overflow: hidden;">
<span style="max-width: 160px;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;">{{ $$(subItem.extendServiceItemArr[0], 'serviceName') }}</span>
<img src="@/assets/icon-edit.png" style="cursor: pointer;margin-left: 5px;width: 16px;height: 16px;" @click="extendServiceSelectFocus(subIndex)" />
</span>
</template>
</td> -->
<!-- 权益服务项目 -->
<td v-if="equitySceneType.includes(goodsInfoData.goodsType) && !baseConfig.supplierCode.includes(`${goodsInfoData.supplierCode}`)">
<el-select placeholder="服务项目"
size="small"
:class="{ 'w-150-per': true, 'border-red': filterEmpty(subItem.serviceItemArr) && subItem.serviceItemArrEmpty }"
style="width: 150px;transform: translateX(0);"
v-model="subItem.serviceItemArr"
multiple
:ref="'serviceSelect' + subIndex"
collapse-tags
@focus="serviceSelectFocus($event, subIndex)"
popper-class="service_select_class"
:popper-append-to-body="false">
<el-popover v-if="filterEmpty(subItem.serviceItemArr) && subItem.serviceItemArrEmpty"
slot="suffix"
placement="top"
title
width="90"
trigger="hover"
content="服务项目是必填项">
<i class="el-icon-warning color-red"
slot="reference" />
</el-popover>
</el-select>
</td>
<td v-if="goodsInfoData.shoppingMallFlag !== '0'">
<el-input placeholder="请输入"
size="small"
:class="{ 'w-150-per': true, 'border-red': filterEmpty(subItem.purchasePrice) && subItem.purchasePriceEmpty }"
v-model="subItem.purchasePrice"
@input="handlePrice($event, subIndex, 'purchasePrice')"
@blur="handlePurchasePriceBlur($event, subIndex)">
<el-popover v-if="filterEmpty(subItem.purchasePrice) && subItem.purchasePriceEmpty"
slot="suffix"
placement="top"
title
width="90"
trigger="hover"
content="采购价是必填项">
<i class="el-icon-warning color-red"
slot="reference" />
</el-popover>
</el-input>
</td>
<td>
<el-input placeholder="请输入"
size="small"
v-model="subItem.upgradePrice"
:class="{ 'w-150-per': true }"
@input="handlePrice($event, subIndex, 'upgradePrice')">
</el-input>
</td>
<td v-if="(extendedPosiType.includes(goodsInfoData.goodsType) || equitySceneType.includes(goodsInfoData.goodsType)) && !baseConfig.supplierCode.includes(`${goodsInfoData.supplierCode}`)">
<el-input placeholder="请输入"
size="small"
:disabled="goodsInfoData.scrmFlag == 'Y'"
v-model="subItem.djCost"
:class="{ 'w-150-per': true, 'border-red': filterEmpty(subItem.djCost) && subItem.djCostEmpty }"
@input="handlePrice($event, subIndex, 'djCost')">
<el-popover v-if="filterEmpty(subItem.djCost) && subItem.djCostEmpty"
slot="suffix"
placement="top"
title
width="90"
trigger="hover"
content="嘀加成本是必填项">
<i class="el-icon-warning color-red"
slot="reference" />
</el-popover>
</el-input>
</td>
<td>
<el-select placeholder="适用车型"
size="small"
:class="{ 'w-150-per': true }"
style="width: 150px;transform: translateX(0);"
v-model="subItem.selectCarSerise"
multiple
:ref="'carSeriesSelect' + subIndex"
collapse-tags
@focus="carSeriesSelectFocus($event, subIndex)"
popper-class="service_select_class"
clearable
:disabled="goodsInfoData.scrmFlag == 'Y'"
:popper-append-to-body="false">
</el-select>
</td>
<td>
<el-input placeholder="请输入"
size="small"
style="transform: translateX(0);"
v-model="subItem.warningValue"
:class="{ 'w-150-per': true }"
@input="handleWarningValueInput($event, subIndex, 'warningValue')">
</el-input>
</td>
<td>
<el-input placeholder="请输入"
size="small"
style="transform: translateX(0);"
v-model="subItem.warningValueMax"
:class="{ 'w-150-per': true }"
@input="handleWarningValueInput($event, subIndex, 'warningValueMax')">
</el-input>
</td>
<!-- 仅权益升级类目展示 -->
<td v-if="equitySceneType.includes(goodsInfoData.goodsType)">
<el-switch
v-model="subItem.entityCardFlag">
</el-switch>
</td>
<td v-if="membraneTypeList.includes(goodsInfoData.goodsType)">
<div style="transform: translateX(10px);">
<el-input
placeholder="请输入"
size="small"
v-model="subItem.warrantyPeriod"
:class="{ 'w-150-per': true, 'border-red': filterEmpty(subItem.warrantyPeriod) && subItem.warrantyPeriodEmpty }"
@input="handleWarrantyPeriodInput($event, subIndex)"
@blur="handleWarrantyPeriodBlur($event, subIndex)">
<el-popover v-if="filterEmpty(subItem.warrantyPeriod) && subItem.warrantyPeriodEmpty"
slot="suffix"
placement="top"
title
width="90"
trigger="hover"
content="质保年限是必填项">
<i class="el-icon-warning color-red" slot="reference" />
</el-popover>
</el-input>
</div>
</td>
<td style="width: 60px;">
<!-- SPU状态是草稿/SKU上架为待审核状态/SKU是待上架状态 -->
<el-button type="text"
:disabled="subItem.merchantGoodsInfos && subItem.merchantGoodsInfos.length > 0"
@click="delgoodsSpecificationSingleList(subIndex)">删除
</el-button>
</td>
</tr>
</tbody>
</table>
</div>
<div style="margin-top: 10px;">共<span
class="tip-text">{{ goodsInfoData.goodsSpecificationSingleList.length }}</span>件规格商品。价格区间<span
class="tip-text">¥{{ minPrice }}~{{ maxPrice }}</span>
</div>
</div>
<service-items-dialog v-if="serviceItemsVisible"
ref="formRelateService"
:relate-service-visible="serviceItemsVisible"
:service-api="getProductServiceItems"
:service-search-form="serviceItemsSearchForm"
:service-selected="serviceSelected"
:service-index="serviceSelectIndex"
@handleRelateServiceConfirm="handleRelateServiceConfirm"
@handleRelateServiceClose="handleRelateServiceClose">
<el-row slot>
<el-form
:model="serviceItemsSearchForm"
ref="relate"
:inline="true">
<el-form-item label="服务项目:">
<el-input
v-model.trim="serviceItemsSearchForm.serviceName"
placeholder="服务项目"
@keydown.native="handleServiceInput"
clearable />
</el-form-item>
<el-form-item label="等级:">
<el-input
v-model.trim="serviceItemsSearchForm.serviceGrade"
placeholder="等级"
@keydown.native="handleServiceInput"
clearable />
</el-form-item>
<el-button type="primary" @click="handleSearchService">搜索</el-button>
</el-form>
</el-row>
</service-items-dialog>
<!-- 延保服务项目 -->
<extend-service-items-dialog v-if="extendServiceItemsVisible"
ref="extendRelateService"
:relate-service-visible="extendServiceItemsVisible"
:service-api="getExtendServiceItems"
:extend-service-items-search-form="extendServiceItemsSearchForm"
:service-selected="extendServiceSelected"
:service-index="extendServiceSelectIndex"
@handleExtendServiceConfirm="handleExtendServiceConfirm"
@handleextendServiceClose="handleextendServiceClose"
:extend-service-part-list="extendServicePartList">
<el-row slot>
<el-form
:model="extendServiceItemsSearchForm"
ref="relate"
:inline="true">
<el-form-item label="服务项目:">
<el-input
v-model.trim="extendServiceItemsSearchForm.serviceName"
placeholder="服务项目"
maxlength="50"
@keydown.native="handleextendServiceInput"
clearable />
</el-form-item>
<el-form-item label="保障部件:">
<el-select filterable v-model="extendServiceItemsSearchForm.supportPosition">
<el-option
v-for="(item, index) in extendServicePartList"
:key="index"
:label="item"
:value="index">
</el-option>
</el-select>
</el-form-item>
<el-button type="primary" @click="handleSearchextendService">搜索</el-button>
</el-form>
</el-row>
</extend-service-items-dialog>
<!-- 适用车型 -->
<car-series-dialog v-if="carSeriesVisible"
ref="carSeries"
:car-series-visible="carSeriesVisible"
:car-series-api="getCarSeriesList"
:car-series-search-form="carSeriesSearchForm"
:car-series-selected="carSeriesSelected"
:service-index="carSeriesIndex"
@handleCarSeriesConfirm="handleCarSeriesConfirm"
@handleCarSeriesClose="handleCarSeriesClose">
<el-row slot>
<el-form
:model="carSeriesSearchForm"
ref="relate"
:inline="true">
<el-form-item label="车系:">
<el-input
v-model.trim="carSeriesSearchForm.seriesName"
placeholder="请输入车系名称"
maxlength="50"
clearable />
</el-form-item>
<el-form-item label="所属子品牌:">
<el-input
v-model.trim="carSeriesSearchForm.childName"
placeholder="请输入车系名称"
maxlength="50"
clearable />
</el-form-item>
<el-form-item label="所属品牌:">
<el-input
v-model.trim="carSeriesSearchForm.brandName"
placeholder="请输入车系名称"
maxlength="50"
clearable />
</el-form-item>
<el-button type="primary" @click="handleSearchCarSerise">搜索</el-button>
</el-form>
</el-row>
</car-series-dialog>
</div>
</template>
<script>
import { limitPrice } from '@/common/format'
import { mapGetters, mapMutations, mapActions } from 'vuex'
import { deepClone } from "@/common/util"
import { baseConfig } from '@/main'
import serviceItemsDialog from "./serviceItemsDialog.vue"
import { getExtendServiceItems, getProductServiceItems, getCarSeriesList } from '@api/productManage'
import { BaseData } from '@/common/constants.js'
import extendServiceItemsDialog from './extendServiceItemsDialog.vue'
import carSeriesDialog from './carSeriesDialog.vue'
export default {
name: 'SingleSpecificationForm',
components: {
serviceItemsDialog,
extendServiceItemsDialog,
carSeriesDialog
},
data() {
return {
equitySceneType: baseConfig.equitySceneType || [], // 权益类目
extendedPosiType: baseConfig.extendedPosiType || [], // 延保类
reg: {
priceReg: /^\d[\d\.]*$/
},
minPrice: 0,
maxPrice: 0,
productPositionTypeList: [],
membraneTypeList: baseConfig.membraneTypeList,
serviceItemsVisible: false,
serviceItemsSearchForm: {
serviceName: '',
serviceGrade: ''
},
getExtendServiceItems,
getProductServiceItems,
getCarSeriesList,
serviceSelected: [],
serviceSelectIndex: null,
positionTypeList: [], // 太阳膜类商品部位
serviceYearsVisible: false, // 批量服务时间弹窗
extendServiceSelected: [],
extendServiceSelectIndex: null,
extendServiceItemsVisible: false,
extendServiceItemsSearchForm: {
serviceName: '',
supportPosition: 0
},
supportPositionList: [], // 部件筛选项数据
allChecked: false,
carSeriesVisible: false,
carSeriesSearchForm: {
seriesName: '',
childName: '',
brandName: '',
needCarType: false
},
carSeriesSelected: [],
carSeriesIndex: null
}
},
props: {
productServiceItemList: {
type: Array,
default: () => []
},
extendServicePartList: {
type: Array,
default: () => []
}
},
watch: {
'goodsInfoData.goodsSpecificationSingleList': {
handler(newValue) {
const priceArr = []
newValue.forEach((item, index) => {
priceArr.push(Number(item.upgradePrice))
this.filterService(item, index) // 处理显示权益服务项目
this.filterTableSelectNum(item, index) // 处理显示适用车型
})
this.minPrice = priceArr.length ? Math.min(...priceArr) : 0
this.maxPrice = priceArr.length ? Math.max(...priceArr) : 0
},
deep: true
},
'goodsInfoData.goodsPositionList': {
handler(newValue) {
this.productPositionTypeList = this.positionTypeList.filter(v => newValue?.indexOf(v.position) > -1)
this.goodsInfoData.goodsSpecificationSingleList?.forEach(val => {
val?.position?.forEach((v, index) => {
if (!this.productPositionTypeList?.map(v => v.position)?.includes(v)) val.position.splice(index, 1)
})
})
},
deep: true
},
// 商品table 宽度
'goodsInfoData.goodsType': {
handler(newVal) {
if (newVal) {
if (this.goodsInfoData?.goodsType == 1) { // 太阳膜
this.productPositionTypeList = this.positionTypeList.filter(v => this?.goodsInfoData?.goodsPositionList?.indexOf(v.position) > -1)
} else {
this.productPositionTypeList = []
}
this.goodsInfoData?.goodsSpecificationSingleList?.forEach((item, index) => {
this.filterService(item, index)
})
}
},
deep: true
},
'goodsInfoData.supplierCode': {
handler(newVal) {
if (newVal) {
this.goodsInfoData?.goodsSpecificationSingleList?.forEach((item, index) => {
this.filterService(item, index)
})
}
},
deep: true
}
},
computed: {
...mapGetters('goodsInfoData', { goodsInfoData: 'getGoodsInfoData' }),
isIndeterminate() {
return this.goodsInfoData?.goodsSpecificationSingleList?.filter(item => item.checked).length > 0 && !this.goodsInfoData?.goodsSpecificationSingleList?.every(item => item.checked)
}
},
mounted() {
const priceArr = []
this.goodsInfoData?.goodsSpecificationSingleList.forEach((item, index) => {
priceArr.push(Number(item.upgradePrice))
this.filterService(item, index)
this.filterTableSelectNum(item, index)
})
this.minPrice = priceArr.length ? Math.min(...priceArr) : 0
this.maxPrice = priceArr.length ? Math.max(...priceArr) : 0
this.getBaseData()
},
methods: {
...mapMutations('goodsInfoData', ['setUpdateGoodsInfo']),
...mapActions({
get: 'd2admin/base/get'
}),
async getBaseData() {
this.positionTypeList = await this.get(BaseData.positionTypeList)
},
// 处理显示服务项目数量
filterService(item, index) {
this.$nextTick(() => {
const selectRefs = this.$refs['serviceSelect' + index] && this.$refs['serviceSelect' + index][0]
if (item?.serviceItemArr?.length) {
if (item?.serviceItemArr?.length > 1) {
const tagSpan = selectRefs?.$el.querySelector(
`.el-select__tags > span>span:nth-child(1)`
)
const numSpan = selectRefs?.$el.querySelector(
`.el-select__tags > span>span:nth-child(2)`
)
setTimeout(() => {
if (tagSpan && numSpan) {
tagSpan.style.display = "none"
numSpan.style.display = 'inline-block'
numSpan.innerHTML = `+${item?.serviceItemArr?.length}`
}
}, 60)// 延迟执行(否则获取不到dom)
} else {
const tagSpan = selectRefs?.$el?.querySelector(
`.el-select__tags > span>span:nth-child(1)`
)
setTimeout(() => {
if (tagSpan) {
tagSpan.innerHTML = `+${item?.serviceItemArr?.length}`
tagSpan.style.display = "inline-block"
}
}, 60)// 延迟执行(否则获取不到dom)
}
}
})
},
// 处理显示适用车型数量
filterTableSelectNum(item, index) {
this.$nextTick(() => {
const selectRefs = this.$refs['carSeriesSelect' + index] && this.$refs['carSeriesSelect' + index][0]
if (item?.selectCarSerise?.length) {
if (item?.selectCarSerise?.length > 1) {
const tagSpan = selectRefs?.$el.querySelector(
`.el-select__tags > span>span:nth-child(1)`
)
const numSpan = selectRefs?.$el.querySelector(
`.el-select__tags > span>span:nth-child(2)`
)
setTimeout(() => {
if (tagSpan && numSpan) {
tagSpan.style.display = "none"
numSpan.style.display = 'inline-block'
numSpan.innerHTML = `+${item?.selectCarSerise?.length}`
}
}, 60)// 延迟执行(否则获取不到dom)
} else {
const tagSpan = selectRefs?.$el?.querySelector(
`.el-select__tags > span>span:nth-child(1)`
)
setTimeout(() => {
if (tagSpan) {
tagSpan.innerHTML = `+${item?.selectCarSerise?.length}`
tagSpan.style.display = "inline-block"
}
}, 60)// 延迟执行(否则获取不到dom)
}
}
})
},
// 权益服务项目
serviceSelectFocus(e, index) {
this.serviceSelected = this.goodsInfoData.goodsSpecificationSingleList[index]?.serviceItemArr
this.serviceSelectIndex = index
this.serviceItemsVisible = true
},
handleRelateServiceConfirm(data) {
// 批量操作权益服务项目
if (this.filterEmpty(this.serviceSelectIndex)) {
this.goodsInfoData?.goodsSpecificationSingleList.map(v => {
if (v.checked) {
v.serviceItemArr = data
v.djCost = data.reduce((v, i) => {
return v + i.standardSalesCost
}, 0)
}
return v
})
return this.serviceItemsVisible = false
}
const index = this.serviceSelectIndex
let djCost = 0
data.forEach(v => { // 嘀加成本通过已选服务项目的销售成本自动累计
djCost += v.standardSalesCost
})
if (!data?.length) djCost = ''
this.$set(this.goodsInfoData.goodsSpecificationSingleList[index], 'serviceItemArr', data)
// 暂时放开嘀加成本与服务项目联动累加
// this.$set(this.goodsInfoData.goodsSpecificationSingleList[index], 'djCost', djCost)
this.serviceSelectIndex = null
this.serviceSelected = []
this.serviceItemsVisible = false
},
handleRelateServiceClose() {
this.serviceItemsVisible = false
},
handleServiceInput(e) {
(e.keyCode === 13) && this.handleSearchStore()
},
// 权益服务项目搜索
handleSearchService() {
this.$refs.formRelateService.handleCurrentChange(1)
},
// 延保服务项目
extendServiceSelectFocus(index) {
this.extendServiceSelected = this.goodsInfoData.goodsSpecificationSingleList[index]?.extendServiceItemArr
this.extendServiceSelectIndex = index
this.extendServiceItemsVisible = !this.extendServiceItemsVisible
this.extendServiceItemsSearchForm = {
serviceName: '',
supportPosition: 0
}
},
handleExtendServiceConfirm(data) {
if (this.filterEmpty(this.extendServiceSelectIndex)) {
this.goodsInfoData?.goodsSpecificationSingleList.map(v => {
if (v.checked) {
v.extendServiceItemArr = data
}
return v
})
return this.extendServiceItemsVisible = false
}
this.$set(this.goodsInfoData.goodsSpecificationSingleList[this.extendServiceSelectIndex], 'extendServiceItemArr', data)
this.handleextendServiceClose()
},
handleextendServiceClose() {
this.extendServiceItemsVisible = false
},
handleextendServiceInput(e) {
(e.keyCode === 13) && this.handleSearchextendService()
},
// 延保服务项目搜索
handleSearchextendService() {
this.$refs.extendRelateService?.handleCurrentChange(1)
},
// 适用车型
carSeriesSelectFocus(e, index) {
this.carSeriesSelected = this.goodsInfoData.goodsSpecificationSingleList[index]?.selectCarSerise
this.carSeriesIndex = index
this.carSeriesVisible = !this.carSeriesVisible
this.carSeriesSearchForm = {
seriesName: '',
childName: '',
brandName: '',
needCarType: false
}
},
handleCarSeriesConfirm(data) {
if (this.filterEmpty(this.carSeriesIndex)) {
this.goodsInfoData?.goodsSpecificationSingleList.map(v => {
if (v.checked) {
v.selectCarSerise = data
}
return v
})
return this.carSeriesVisible = false
}
const index = this.carSeriesIndex
this.$set(this.goodsInfoData.goodsSpecificationSingleList[index], 'selectCarSerise', data)
this.carSeriesIndex = null
this.carSeriesSelected = []
this.carSeriesVisible = false
},
// 车型搜索
handleSearchCarSerise() {
this.$refs.carSeries?.handleCurrentChange(1)
},
handleCarSeriesClose() {
this.carSeriesVisible = false
},
// 新增商品
addShop() {
if (!this.goodsInfoData.specificationSingleDetailList.length) {
this.goodsInfoData.specificationSingleDetailList = [
{
specificationName: '商品',
specificationValueList: []
}
]
}
this.goodsInfoData.goodsSpecificationSingleList.push({
id: '',
position: [],
purchasePrice: '',
specificationData: '',
specsValueList: [],
type: '',
thirdPartyCode: '',
upgradePrice: '',
djCost: '',
warningValue: '',
warningValueMax: '',
serviceItemArr: [],
extendServiceItemArr: [],
serviceYears: '',
warrantyPeriod: '5',
entityCardFlag: false,
editGoodNameInput: true,
selectCarSerise: [],
checked: false
})
this.goodsInfoData.specificationSingleDetailList[0]?.specificationValueList.push({
specificationValue: ''
})
this.setUpdateGoodsInfo(this.goodsInfoData)
},
filterEmpty(data) {
return data instanceof Array ? data.length <= 0 : (data ?? '') === ''
},
// 全选商品
handleAllChecked(e) {
this.goodsInfoData?.goodsSpecificationSingleList?.forEach(val => {
val.checked = e
})
},
handleChecked(e, index) {
this.$set(this.goodsInfoData.goodsSpecificationSingleList[index], 'checked', e)
this.allChecked = this.goodsInfoData?.goodsSpecificationSingleList?.every(item => item.checked)
},
delgoodsSpecificationSingleList(i) {
this.goodsInfoData.goodsSpecificationSingleList.splice(i, 1)
this.goodsInfoData.specificationSingleDetailList[0]?.specificationValueList.splice(i, 1)
this.setUpdateGoodsInfo(this.goodsInfoData)
},
handleGoodsNameBlur(e, index) {
if (e.target.value.indexOf(';~;') > -1) {
return this.$set(this.goodsInfoData.goodsSpecificationSingleList[index], 'specificationDataError', true)
}
if (this.filterEmpty(e.target.value)) {
return this.$set(this.goodsInfoData.goodsSpecificationSingleList[index], 'specificationDataEmpty', true)
}
// 将商品名称回填到规格数组中
this.$set(this.goodsInfoData.specificationSingleDetailList[0]?.specificationValueList[index], 'specificationValue', e.target.value)
this.$set(this.goodsInfoData.goodsSpecificationSingleList[index], 'editGoodNameInput', false)
this.setUpdateGoodsInfo(this.goodsInfoData)
},
// 编辑商品名称
editSpecificationData(index) {
const _this = this
_this.$set(this.goodsInfoData.goodsSpecificationSingleList[index], 'editGoodNameInput', true)
_this.$nextTick(() => {
_this.$refs['specificationDataInput' + index][0].focus()
})
},
// 校验价格
handlePrice(newValue, index, key) {
newValue = newValue.replace(/[^\d.]/g, '')
let oldValue = `${this.goodsInfoData.goodsSpecificationSingleList[index][`old${key}`]}`
this.$set(this.goodsInfoData.goodsSpecificationSingleList[index], key, limitPrice(newValue, oldValue, 6, 2, 0))
this.$set(this.goodsInfoData.goodsSpecificationSingleList[index], `old${key}`, this.goodsInfoData.goodsSpecificationSingleList[index][key])
},
// 选择部位
changePosition(e, index) {
this.$set(this.goodsInfoData.goodsSpecificationSingleList[index], 'position', e)
},
// 校验商品编码
handleTypeInput(newValue, index) {
if (!/^[a-zA-Z0-9]*$/.test(newValue)) {
this.$set(this.goodsInfoData.goodsSpecificationSingleList[index], 'type', newValue.replace(/[^a-zA-Z0-9]/g, ''))
}
},
handlePurchasePriceBlur(e, index) {
const newValue = e.target.value
if (!newValue) this.$set(this.goodsInfoData.goodsSpecificationSingleList[index], 'purchasePriceEmpty', true)
},
// 库存预警
handleWarningValueInput(newValue, index, key) {
newValue = newValue.replace(/[^\d.]/g, '')
let oldValue = `${this.goodsInfoData.goodsSpecificationSingleList[index][`old${key}`]}`
this.$set(this.goodsInfoData.goodsSpecificationSingleList[index], key, limitPrice(newValue, oldValue, 3, 1, 0))
this.$set(this.goodsInfoData.goodsSpecificationSingleList[index], `old${key}`, this.goodsInfoData.goodsSpecificationSingleList[index][key])
},
// 质保
handleWarrantyPeriodInput(newValue, index) {
newValue = newValue.replace(/[^\d.]/g, '')
let oldValue = `${this.goodsInfoData.goodsSpecificationSingleList[index]['oldwarrantyPeriod']}`
this.$set(this.goodsInfoData.goodsSpecificationSingleList[index], 'warrantyPeriod', limitPrice(newValue, oldValue, 2, 1, 0))
this.$set(this.goodsInfoData.goodsSpecificationSingleList[index], 'oldwarrantyPeriod', this.goodsInfoData.goodsSpecificationSingleList[index]['warrantyPeriod'])
},
handleWarrantyPeriodBlur(e, index) {
const newValue = e.target.value
if (!newValue) this.$set(this.goodsInfoData.goodsSpecificationSingleList[index], 'warrantyPeriodEmpty', true)
}
}
}
</script>
<style lang="scss" scoped>
.singleSpecification-form{
.content_box{
font-size: 14px;
margin-top: 10px;
.sepce-box {
margin: 10px 0;
.specs-item {
color: #666666;
margin-right: 20px;
}
}
.tip-text {
color: #2a58ad;
}
.table-wrapper{
max-height: 450px;
overflow: auto;
.table-spesc {
width: 100%;
text-align: center;
border: 1px solid #E8E8EA;
position: relative;
.table_content{
table-layout: fixed;
border-collapse: separate;
}
tr{
display: flex;
flex-wrap: nowrap;
border-bottom: 1px solid #E8E8EA;
td{
display: inline-block;
text-align: center;
vertical-align: middle;
width: 220px;
height: 100%;
line-height: 40px;
border-right: 1px solid #E8E8EA;
span{
display: inline-block;
vertical-align: middle;
}
}
td:last-child{
border-right: none;
}
}
.w-150-per {
width: 150px;
.el-input__inner {
padding: 0 10px;
}
}
.w-90-per{
width: 90px;
}
.color-red{
color: #eb4e4e;
font-size: 14px;
margin-right: 4px;
cursor: pointer;
}
}
}
.content-table {
color: #666666;
max-height: 400px;
overflow-y: overlay;
}
}
}
::v-deep .border-red {
.el-input__inner {
border: 1px solid #eb4e4e;
}
}
::v-deep .service_select_class{
display: none;
}
</style>