groundingForm.vue
40.2 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
<!-- 表单 -->
<template>
<div class="grounding-form" v-if="show">
<el-form :model="formData" :rules="rules" :ref="formRef + 'd2FormRuleForm'">
<slot name="title" />
<div v-for="(i, idx) in formList" :key="idx" class="grounding-form-block">
<p v-show="i.title" class="title">
{{ i.title }}
</p>
<div style="padding: 20px;">
<div v-for="(item, index) in i.formBlock" :key="index">
<!-- 单选 -->
<!-- 太阳膜类商品 上架部位 -->
<div v-if="item.type === 'radio' && formData['goodsType'] == 1 && !item.index">
<el-form-item :prop="item.name" :label="item.label ? item.label + ':' : ''" :id="item.name"
:label-width="item.label ? '180px' : '0px'" class="dis-in-block"
: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.confId">{{
subItem.confName }}</el-radio>
</el-radio-group>
</el-form-item>
</div>
<!-- 1.3场景显示升级/产品供货模式 -->
<div
v-if="item.type === 'radio' && item.index && ((formData['productType'] && formData['productType'].includes(item.index)) || ((formData['goodsType'] && formData['goodsType'] != 1) && (formData['sceneType'] && formData['sceneType'] == 3)))">
<el-form-item :prop="item.name" :label="item.label ? item.label + ':' : ''" :id="item.name"
:label-width="item.label ? '180px' : '0px'" class="dis-in-block"
: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.confId">{{
subItem.confName }}</el-radio>
</el-radio-group>
</el-form-item>
</div>
<!-- 商品附带信息 -->
<div v-if="formData['upgradeGoodsId'] && item.type === 'incidBox'">
<div class="incid_box">
<div class="item" v-for="(subItem, subIndex) in item.detailInfo" :key="subIndex">
<div class="label">{{ subItem.unit ? (membraneTypeList.includes(formData[item.key]) ? subItem.label +
`(元)/${subItem.value == 'purchasePrice' ? '卷' : '车'}` : (subItem.label + '(元)/件')) : subItem.label }}:
</div>
<div class="value">
<ellipsis-popover :content="subItem.unit ? priceFilter(formData.upgradeGoods[subItem.value]) : formData.upgradeGoods[subItem.value] || ''"></ellipsis-popover>
</div>
</div>
<!-- 权益/延保非第三方展示 -->
<div class="item" v-if="(equitySceneType.includes(formData[item.key]) || extendedPosiType.includes(formData[item.key])) && !baseConfig.supplierCode.includes(`${formData.supplierCode}`)">
<div class="label">嘀加成本元/件:</div>
<div class="value">
<ellipsis-popover :content="priceFilter(formData.upgradeGoods['djCost']) || '-'"></ellipsis-popover>
</div>
</div>
<!-- 商品分类 1太阳膜/延保类 -->
<div class="item" v-if="formData[item.key] == 1">
<div class="label">部位:</div>
<div class="value">
<ellipsis-popover :content="formData.upgradeGoods['positionNames'] || ''"></ellipsis-popover>
</div>
</div>
<!-- 商品分类 权益类(供应方为非第三方) -->
<div class="item" v-if="equitySceneType.includes(formData[item.key]) && !baseConfig.supplierCode.includes(`${formData.supplierCode}`)">
<div class="label">服务项目:</div>
<div class="value">
<ellipsis-popover :content="formData.upgradeGoods['serviceItemNames'] || ''"></ellipsis-popover>
</div>
</div>
<!-- 商品分类 权益升级 -->
<div class="item" v-if="equitySceneType.includes(formData[item.key])">
<div class="label">实体卡:</div>
<div class="value">{{ formData.upgradeGoods['entityCardFlag'] == 'Y' ? '是' : '否' }}</div>
</div>
<!-- 质保年限 膜类展示-->
<div class="item" v-if="membraneTypeList.includes(formData[item.key])">
<div class="label">质保年限/年:</div>
<div class="value">
<ellipsis-popover :content="`${formData.upgradeGoods['warrantyPeriod']}年` || ''"></ellipsis-popover>
</div>
</div>
</div>
</div>
<!-- 下拉框/输入框 -->
<div v-if="item.type === 'input' || item.type === 'select' || item.type === 'searchSelect'">
<el-form-item :prop="item.name"
:label="item.label ? (item.unit ? (membraneTypeList.includes(formData['goodsType']) ? item.label + `(元)/车` : (item.label + '(元)/件')) : item.label) + ':' : ''"
:id="item.name" :label-width="item.label ? '180px' : '0px'" class="dis-in-block"
:style="{ 'margin-bottom': !item.type ? '0px' : '22px' }">
<template v-if="item.type === 'input'">
<el-input v-model.trim="formData[item.name]" :placeholder="item.label"
:maxlength="item.maxlength" :style="{ 'width': item.width || formItemWidth }" :disabled="item.isDisabled"
clearable @input="input($event, item)" @blur="blur(item)">
</el-input>
<template v-if="item.name == 'minSellPrice'">
<el-checkbox @change="changeCheckMinprice" v-model="formData['validMinSellPriceFlag']" class="check-min-price"></el-checkbox>
<span class="tips-text">勾选时提单校验最低价</span>
</template>
</template>
<!-- 选择框 -->
<el-select v-else-if="item.type === 'select'" v-model="formData[item.name]" :clearable="item.isClear"
:ref="'selectRefs_' + item.name" :placeholder="'请选择' + item.label" @change="selectAddAttr($event, item)"
:style="{ 'width': item.width || formItemWidth }" filterable>
<el-option v-for="subItem in item.optionList" :key="subItem[item.optionId]"
:label="subItem[item.optionLabel]" :value="subItem[item.optionId]" />
</el-select>
<!-- <el-select v-else-if="item.type === 'searchSelect'" v-model="formData[item.name]"
:clearable="item.isClear" :placeholder="'请选择' + item.label" @change="selectAddAttr($event, item)"
:style="{ 'width': item.width || formItemWidth }" remote reserve-keyword @visible-change="visibleChange"
:remote-method="remoteMethod" v-el-select-loadmore="interestsLoadmore" filterable>
<el-option v-for="subItem in item.optionList" :key="subItem[item.optionId]"
:label="`${subItem[item.optionNameLabel]}\xa0\xa0${subItem[item.optionTypeNameLabel]}`"
:value="subItem[item.optionId]">
<span class="goodName">{{ subItem[item.optionNameLabel] }}</span>
<span class="typeName">{{ subItem[item.optionTypeNameLabel] }}</span>
</el-option>
</el-select> -->
<el-button v-else-if="item.type === 'searchSelect'" icon="el-icon-plus" @click="handleSelectGoods">选择商品</el-button>
</el-form-item>
</div>
<!-- 财务规则校验 -->
<div v-if="item.type === 'flagRadio'">
<el-form-item :prop="item.name"
:label="item.label ? item.label + ':' : ''"
:id="item.name" :label-width="item.label ? '180px' : '0px'" class="dis-in-block"
: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 slot="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 :prop="item.name" :label="item.label ? item.label + ':' : ''" :id="item.name"
:label-width="item.label ? '180px' : '0px'" class="dis-in-block"
:style="{ 'margin-bottom': !item.type ? '0px' : '22px' }">
<el-button icon="el-icon-plus" @click="handleClick">选择上架门店</el-button>
<relateStoreTable v-if="$$(formData['merchantGoodsRefList'], 'length')"
:merchant-goods-ref-list="formData['merchantGoodsRefList']" @handleDelete="handleDelete">
</relateStoreTable>
</el-form-item>
</div>
<!-- 多选 -->
<div v-if="item.type === 'check'">
<el-form-item :prop="item.name" :label="item.label ? item.label + ':' : ''" :id="item.name"
:label-width="item.label ? '180px' : '0px'" class="dis-in-block"
:style="{ 'margin-bottom': !item.type ? '0px' : '22px' }">
<span slot="label">
{{ item.label }}
<!-- content="Top Left 提示文字" -->
<el-tooltip class="item" effect="dark" placement="top-start">
<template slot="content">
<p>说明:基础产品应用于客户战败(不升级)订单中,升级产品应用于客户升级订单中</p>
</template>
<i class="el-icon-info"></i>
</el-tooltip>
:
</span>
<el-checkbox-group v-model="formData[item.name]">
<el-checkbox v-for="(subItem, subIndex) in item.checkGroupList" :key="subIndex" :label="subItem.confId">
{{ subItem.confName }}
</el-checkbox>
</el-checkbox-group>
</el-form-item>
</div>
<!-- 上传凭证 -->
<div v-if="item.type === 'upload'" class="upload-box">
<el-form-item :prop="item.name" :label="item.label ? item.label + ':' : ''" :id="item.name"
class="dis-in-block" :label-width="item.label ? '180px' : '0px'"
:style="{ 'margin-bottom': !item.type ? '0px' : '22px' }">
<template>
<el-upload action="" accept=".jpg,.png,.pdf" class="upload-file" drag :show-file-list="false"
:file-list="uploadFileList" :limit="30" :auto-upload="false"
:on-change="e => handleFileChange(e, item)" :on-exceed="hanldeOnExceed" multiple>
<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 class="file-item" v-if="!filterEmpty(subItem.uploadProgress) || subItem.voucherFileUrl">
<div class="file-content" @click="handleFileView(subItem)">
<el-progress define-back-color="#F5F7FA" :text-inside="true" text-color="#333333"
:show-text="false" :stroke-width="26" stroke-linecap="butt"
:percentage="subItem.uploadProgress"></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>
<el-form-item style="margin-top: 40px;text-align: center;">
<el-button type="primary" @click="handleUp(1)" :disabled="$store.state.d2admin.loading.value">
保存并上架
</el-button>
<!-- 草稿状态/已下架/新增显示 -->
<el-button type="primary" plain class="width_100" @click="handleUp(2)"
:disabled="$store.state.d2admin.loading.value" v-if="filterEmpty(formData.status) || formData.status == 3">
存草稿
</el-button>
<el-button type="primary" v-if="addOrEdit == 'add'" @click="handleUp(3)"
:disabled="$store.state.d2admin.loading.value">
保存并继续新增
</el-button>
<el-button class="width_100 cancel-btn" @click="handleClose">
取消
</el-button>
</el-form-item>
</el-form>
<!-- store-api (1精品升级 2次新车转化 3售后众筹 查询嘀加的门店数据 getList)(0会员/权益升级 4积分商城 查询账户中心所有4s店 getAccountMerchantList -->
<relate-store-dialog v-if="relateStoreVisible" ref="formRelateStore" :relate-store-visible="relateStoreVisible"
:store-api="[1, 2, 3].includes(formData.sceneType) ? getList : getAccountMerchantList"
:store-search-form="storeSearchForm" :store-selected="storeSelected" :selected-scene="formData.sceneType"
@handleRelateStoreConfirm="handleRelateStoreConfirm" @handleRelateStoreClose="handleRelateStoreClose">
<el-row slot>
<el-form :model="storeSearchForm" ref="relate" :inline="true">
<el-form-item label="门店名称:">
<el-input v-model.trim="storeSearchForm.merchantName" placeholder="门店名称" @keydown.native="handleStoreInput"
clearable />
</el-form-item>
<el-form-item label="门店商户号:">
<el-input v-model.trim="storeSearchForm.merchantId" placeholder="门店商户号" @keydown.native="handleStoreInput"
clearable />
</el-form-item>
<el-form-item label="服务对接:">
<el-input v-model.trim="storeSearchForm.yqMerchantName" placeholder="服务对接" @keydown.native="handleStoreInput"
clearable />
</el-form-item>
<el-form-item label="服务对接商户号:">
<el-input v-model.trim="storeSearchForm.yqMerchantId" placeholder="服务对接商户号" @keydown.native="handleStoreInput"
clearable />
</el-form-item>
<el-button type="primary" @click="handleSearchStore">搜索</el-button>
</el-form>
</el-row>
</relate-store-dialog>
<el-image-viewer v-if="imgViewerVisible" :on-close="closeImgViewer" :url-list="imageFileArr"
:initial-index="initialIndex" />
<select-goods-dialog v-if="selectGoodsVisible" :select-goods-visible="selectGoodsVisible" @handleSelectGoodsConfirm="handleSelectGoodsConfirm"
@handleSelectGoodsClose="handleSelectGoodsClose" :upgrade-goods-id="formData.upgradeGoodsId"></select-goods-dialog>
</div>
</template>
<script>
import { deepClone } from '@/common/util'
import { limitPrice } from '@/common/format'
import { mapActions } from 'vuex'
import { uploadImg, uploadPDF } from '@/api/sys.base'
// import { getSceneTypeListByMerchantId } from '@api/grounding'
import { upgradeSupplyModeList, crowdUpgradeSupplyModeList } from "../constants/data"
import { baseConfig } from "@/main"
import relateStoreDialog from "./relateStoreDialog.vue"
import relateStoreTable from './relateStoreTable.vue'
import { getList, getAccountMerchantList } from '@/api/merchant'
import selectGoodsDialog from '../../components/selectGoodsDialog.vue'
import ellipsisPopover from '../../components/ellipsisPopover.vue'
import { filterSpecsStr } from '../../filterOption'
export default {
name: 'GroundingForm',
components: {
relateStoreDialog,
relateStoreTable,
'el-image-viewer': () => import('element-ui/packages/image/src/image-viewer'),
selectGoodsDialog,
ellipsisPopover
},
data() {
return {
getList,
getAccountMerchantList,
equitySceneType: baseConfig.equitySceneType || [],
extendedPosiType: baseConfig.extendedPosiType || [], // 延保类
membraneTypeList: baseConfig.membraneTypeList,
formData: {},
reg: {
numReg: /^[1-9]\d*$/,
priceReg: /^\d[\d\.]*$/
},
show: false,
rules: {
merchantGoodsRefList: [{ required: true, message: '请选择上架门店', trigger: 'change' }],
sceneType: [{ required: true, message: '请选择业务场景', trigger: 'change' }],
upgradeGoodsId: [{ required: true, message: '请选择上架商品', trigger: 'change' }],
position: [{ required: true, message: '请选择上架部位', trigger: 'change' }],
productType: [{ required: true, message: '请选择产品类型', trigger: 'change' }],
baseSupplyMode: [{ required: true, message: '请选择基础产品供货模式', trigger: 'change' }],
upgradeSupplyMode: [{ required: true, message: '请选择升级/产品供货模式', trigger: 'change' }],
sellPrice: [{ required: true, message: '请输入售价', trigger: 'blur' }, {
validator: (rule, value, callback) => {
(+value <= 0) ? callback(new Error('售价需大于0')) : callback()
}
}],
minSellPrice: [
{ required: true, message: '请输入最低售价', trigger: 'blur' },
{
required: true,
trigger: 'blur',
validator: (rule, value, callback) => {
(+value > +this.formData.sellPrice) ? callback(new Error('最低售价不能大于售价')) : callback()
}
}
],
upgradeProductCost: [{ required: true, message: '请输入产品、升级成本', trigger: 'blur' }
// {
// validator: (rule, value, callback) => {
// (+value <= 0) ? callback(new Error('产品、升级成本需大于0')) : callback()
// }
// }
],
giftCost: [{ required: true, message: '请输入赠送成本', trigger: 'blur' }],
recoveryCost: [{ required: true, message: '请输入回收成本', trigger: 'blur' }],
virtualAccountCost: [{ required: true, message: '请输入虚拟对账成本', trigger: 'blur' }],
warrantyType: [{ required: true, message: '请选择质保卡类型', trigger: 'change' }],
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: ''
},
selectDisabled: false,
dialogObj: {},
uploadFileList: [],
imageFileArr: [],
imgViewerVisible: false,
initialIndex: 0,
selectGoodsVisible: false,
filterSpecsStr
}
},
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: () => { }
},
secondGoodsList: {
type: Array,
default: () => { }
},
positionTypeList: { // 太阳膜商品部位
type: Array,
default: () => []
}
},
watch: {
originData: {
handler(newVal) {
if (newVal) {
this.formData = deepClone(this.originData)
}
},
deep: true
},
formData: {
handler(newVal) {
if (newVal) {
this.filterEditForm()
}
},
deep: true
},
// 'formData.merchantId': {
// handler(newValue, oldValue) {
// if (newValue && newValue !== oldValue) this.getSceneTypeList(newValue)
// },
// deep: true
// },
'formData.sceneType': {
handler(newVal, oldVal) {
this.oldSceneType = 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
}
},
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()
}
})
}
}
},
mounted() {
this.formData = deepClone(this.originData)
this.copyFormList = deepClone(this.formList)
this.filterEditForm()
},
methods: {
...mapActions({
get: 'd2admin/base/get'
}),
handleFileChange(e, targetItem) {
setTimeout(() => {
var reader = new FileReader()
var 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)
},
hanldeOnExceed() {
this.$message({
message: '最多可上传30个文件',
type: 'warning'
})
},
setProgressText(item) {
return () => {
return item.name
}
},
// 删除文件
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)
},
filterEmpty(data) {
return (data ?? '') === ''
},
// 清空上传文件数组项内容
clearItem(targetItem, subIndex) {
this.$set(this.formData[targetItem.name][subIndex], 'voucherFileUrl', '')
this.$set(this.formData[targetItem.name][subIndex], 'uploadProgress', '')
},
// 过滤form表单显示内容
filterEditForm() {
const { copyFormList, formData } = this
// 1 太阳膜 2 (1.3场景商品)
const shopType = formData?.goodsType == 1 ? '1' : formData?.sceneType == 3 ? '2' : ''
const shopForm = deepClone(copyFormList[0].formBlock)
const spliceForm = shopType == '1' ? ['giftCost', 'recoveryCost', 'virtualAccountCost', 'djCost', 'thirdPartyCost'] :
shopType == '2' ? ['productType', 'warrantyType', 'baseSupplyMode', 'giftCost', 'recoveryCost', 'virtualAccountCost', 'djCost', 'thirdPartyCost'] :
// 权益/延保类 无升级成本 新增嘀加成本和第三方成本
this.equitySceneType.includes(formData?.goodsType) || this.extendedPosiType.includes(formData?.goodsType) ?
['productType', 'warrantyType', 'baseSupplyMode', 'upgradeSupplyMode', 'giftCost', 'recoveryCost', 'virtualAccountCost', 'upgradeProductCost'] :
['productType', 'warrantyType', 'baseSupplyMode', 'upgradeSupplyMode', 'giftCost', 'recoveryCost', 'virtualAccountCost', 'djCost', 'thirdPartyCost']
// 未勾选基础商品类型
if (!formData.productType?.includes(1)) spliceForm.push('baseSupplyMode')
// 赠送成本:仅产品类型选择“基础产品”时展示
if (formData.productType?.includes(1)) spliceForm.indexOf('giftCost') > -1 && spliceForm.splice(spliceForm.indexOf('giftCost'), 1)
// 回收成本:仅产品类型选择“升级产品”且升级/产品供货模式选择“门店回收原厂+嘀加”时展示
if (formData.productType?.includes(2) && formData.upgradeSupplyMode == 4) {
spliceForm.indexOf('recoveryCost') > -1 && spliceForm.splice(spliceForm.indexOf('recoveryCost'), 1)
}
// 虚拟对账成本:仅产品类型选择“升级产品”且升级/产品供货模式选择“门店套码+嘀加”“ 服务商自采+嘀加”时展示
if ((formData.productType?.includes(2) && formData.upgradeSupplyMode == 3) || (formData.productType?.includes(2) && formData.upgradeSupplyMode == 5)) {
spliceForm.indexOf('virtualAccountCost') > -1 && spliceForm.splice(spliceForm.indexOf('virtualAccountCost'), 1)
}
// 仅选中基础产品类型 不展示 售价字段
if (formData.productType?.length == 1 && formData.productType?.includes(1)) spliceForm.push('sellPrice', 'minSellPrice', 'upgradeProductCost', 'upgradeSupplyMode')
const newForm = shopForm.filter(v => !spliceForm?.includes(v.name))
this.$set(this.formList[0], 'formBlock', newForm)
this.$nextTick(() => {
// 1.3场景 升级产品供货模式
const formIndex = this.formList[0].formBlock.findIndex(subItem => subItem.name == 'upgradeSupplyMode')
if (formData.sceneType == 3) {
if (formIndex >= 0) this.$set(this.formList[0].formBlock[formIndex], 'radioGroupList', crowdUpgradeSupplyModeList)
}
// 太阳膜类 升级产品供货模式(优先级高)
if (shopType == 1) {
// 由1.3场景 切换到太阳膜 已选升级供货模式为2 的清除掉 太阳膜供货模式没有2
if (formData.upgradeSupplyMode == 2) this.formData.upgradeSupplyMode = ''
if (formIndex > -1) this.$set(this.formList[0].formBlock[formIndex], 'radioGroupList', upgradeSupplyModeList)
// 上架部位
this.formData?.positionNamesArr?.forEach(val => {
val.confId = val.position
})
this.$set(this.formList[0].formBlock[this.formList[0].formBlock.findIndex(subItem => subItem.name == 'position')], 'radioGroupList', this.formData?.positionNamesArr || [])
}
// 延保类
if (this.extendedPosiType.includes(formData?.goodsType)) {
this.formData?.positionNamesArr?.forEach(val => {
val.confId = val.position
})
this.$set(this.formList[0].formBlock[this.formList[0].formBlock.findIndex(subItem => subItem.name == 'position')], 'radioGroupList', this.formData?.positionNamesArr || [])
}
// 当商品信息自带嘀加成本时,将输入框置灰
if (!this.filterEmpty(formData?.upgradeGoods?.djCost)) {
this.$set(this.formList[0].formBlock?.find(v => v.name == 'djCost'), 'isDisabled', true)
}
this.show = true
this.$refs[this.formRef + 'd2FormRuleForm'] && this.$refs[this.formRef + 'd2FormRuleForm'].clearValidate()
})
},
handleSelectGoods() {
this.selectGoodsVisible = true
},
handleSelectGoodsConfirm(selectedData) {
const _formData = this.formData
const _valueObj = selectedData
const _positionNamesArr = deepClone(this.positionTypeList).filter(val => (_valueObj?.position?.split(','))?.includes(val.position + '')) || []
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 `${item.serviceName}-${item.serviceGrade}/${item.servicePeriod}` })?.join(','), // 服务项目
positionNames: _positionNamesArr.length ? _positionNamesArr.map(subItem => { return subItem?.confName }).join('/') : '',
specificationData: this.filterSpecsStr(_valueObj),
djCost: _valueObj?.djCost,
carTypeConfigName: _valueObj?.carTypeConfigList?.map(item => item.seriesName).join('/'),
upgradeCommodityCode: _valueObj?.commodityCode
}
_formData.goodsType = _valueObj?.goodsInfo?.goodsType,
_formData.upgradeGoodsId = _valueObj.id
_formData.positionNamesArr = _positionNamesArr
_formData.productType = [] // 切换上架商品 将服务类型清空
_formData.baseSupplyMode = '' // 切换上架商品 将基础供货模式清空
_formData.upgradeSupplyMode = '' // 切换上架商品 将升级/产品供货模式清空
_formData.supplierCode = _valueObj?.goodsInfo?.supplierCode // 供应方 判断是否需要走审核流程
if (!this.filterEmpty(_valueObj?.djCost)) _formData.djCost = _valueObj?.djCost // 嘀加成本 商品信息自带数据
this.handleSelectGoodsClose()
},
handleSelectGoodsClose() {
this.selectGoodsVisible = false
},
// 选择上架门店
handleClick() {
const _this = this
if (_this.filterEmpty(_this.formData.sceneType)) {
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
}
this.formData.merchantGoodsRefList = selectedData
this.relateStoreVisible = false
},
handleRelateStoreClose() {
this.relateStoreVisible = false
},
handleStoreInput(e) {
(e.keyCode === 13) && this.handleSearchStore()
},
// 门店搜索
handleSearchStore() {
this.$refs.formRelateStore.handleCurrentChange(1)
},
// 删除上架门店
handleDelete(item) {
const filterArr = this.formData.merchantGoodsRefList.filter(i => i.merchantId !== item.merchantId)
this.$set(this.formData, 'merchantGoodsRefList', filterArr)
},
// 下拉加载更多 下拉框显示隐藏触发
visibleChange(data) {
this.$emit('visibleChange', data)
},
interestsLoadmore() {
this.$emit('interestsLoadmore')
},
remoteMethod(query) {
this.$emit('remoteMethod', query)
},
// 修复直接调用可以会因为没有对应方法报错的问题
input(event, item) {
item.handleInput && this.handleInput(event, item)
},
blur(item) {
item.handleBlur && item.handleBlur()
},
// 价格过滤
handleInput(e, item) {
e = e.replace(/[^\d.]/g, '')
let oldValue = `${this.formData['old' + item.name]}`
this.$set(this.formData, `${item.name}`, limitPrice(e, oldValue, 6, 2, 0))
this.$set(this.formData, `old${item.name}`, this.formData[item.name])
},
// 选择框-添加其他属性
selectAddAttr(value, targetItem) {
const _formData = this.formData
if (targetItem.name == 'merchantId') {
var _tempVal = targetItem.optionList.find(item => item.merchantId === value)
_formData.merchantName = _tempVal.merchantName
}
// 切换业务场景 将选中的上架门店清空
if (targetItem.name === 'sceneType') {
const _formData = this.formData
if (!this.filterEmpty(this.oldSceneType)) {
// 清空门店弹窗搜索条件
this.storeSearchForm = {
merchantName: '',
merchantId: '',
yqMerchantName: '',
yqMerchantId: ''
}
if (_formData.merchantGoodsRefList?.length) {
this.$confirm('切换业务场景,将清空上架门店,是否继续', '提示', {
confirmButtonText: '确定',
type: 'warning'
}).then(() => {
_formData.sceneType = value
this.$nextTick(() => {
this.$refs.selectRefs_sceneType[0].blur()
_formData.merchantGoodsRefList = []
this.$forceUpdate()
})
}).catch(() => {
_formData.sceneType = this.oldSceneType
this.$nextTick(() => {
this.$refs.selectRefs_sceneType[0].blur()
})
})
}
}
}
},
handleClose() {
this.$emit('handleClose')
},
jumpScroll(idName) {
document.getElementById(idName).scrollIntoView()
},
filterEmpty(data) {
return (data ?? '') === ''
},
// 处理金额补零
priceFilter(num) {
var pow = Math.pow(10, 2)
if (this.filterEmpty(num)) return '-'
return `${(Math.round(num * pow) / pow).toFixed(2)}元`
},
// 商品是否校验最低价
changeCheckMinprice(e) {
this.formData.validMinSellPrice = e ? 'Y' : 'N'
},
handleUp(e) {
this.$refs[this.formRef + 'd2FormRuleForm'].validate((valid, options) => {
if (valid) {
this.$emit('handleAddConfirm', { ...this.formData, num: e })
} else {
var needRuleList = Object.keys(options)
this.jumpScroll(needRuleList[0])
return true
}
})
}
}
}
</script>
<style lang="scss" scoped>
.grounding-form {
.grounding-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;
}
.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>