add.vue
32.6 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
<template>
<view class="page">
<scroll-view class="scroll" scroll-y>
<uni-list>
<view class="title-header">
<image class="title-header_icon" src="/static/images/title.png" />
<span>基本资料</span>
</view>
<uni-list-item title="单位名称">
<template v-slot:footer>
<uni-easyinput v-model="form.unitName" placeholder="请输入单位名称" :inputBorder="false" />
</template>
</uni-list-item>
<uni-list-item class="select-item" :class="form.companyNatureName ? 'is-filled' : 'is-empty'" clickable
@click="openMultiSheet('companyNature')" :rightText="displayLabel('companyNatureName')" showArrow>
<template v-slot:body>
<view class="item-title"><text>公司性质</text></view>
</template>
</uni-list-item>
<uni-list-item v-if="showCompanyNatureOther" class="mgb10" title="其他">
<template v-slot:footer>
<uni-easyinput v-model="form.companyNatureOther" placeholder="请输入其他公司性质" :inputBorder="false" />
</template>
</uni-list-item>
<uni-list-item title="开户行">
<template v-slot:footer>
<uni-easyinput v-model="form.bankName" placeholder="请输入开户行" :inputBorder="false" />
</template>
</uni-list-item>
<uni-list-item title="账号">
<template v-slot:footer>
<uni-easyinput v-model="form.bankAccount" placeholder="请输入账号" :inputBorder="false" />
</template>
</uni-list-item>
<uni-list-item class="amount-item">
<template v-slot:body>
<view class="item-title"><text>注册资金</text></view>
</template>
<template v-slot:footer>
<view class="amount-row">
<uni-easyinput type="digit" v-model="form.registeredCapital" placeholder="请输入" :inputBorder="false" />
<text class="unit">万元</text>
</view>
</template>
</uni-list-item>
<uni-list-item title="法人代表">
<template v-slot:footer>
<uni-easyinput v-model="form.legalRepresentative" placeholder="请输入法人代表" :inputBorder="false" />
</template>
</uni-list-item>
<uni-list-item title="公司成立时间">
<template v-slot:footer>
<uni-datetime-picker type="date" v-model="form.companyEstablishedTime" />
</template>
</uni-list-item>
<uni-list-item title="地址">
<template v-slot:footer>
<uni-easyinput v-model="form.address" placeholder="请输入地址" :inputBorder="false" />
</template>
</uni-list-item>
<uni-list-item title="业务负责人">
<template v-slot:footer>
<uni-easyinput v-model="form.businessPrincipal" placeholder="请输入业务负责人" :inputBorder="false" />
</template>
</uni-list-item>
<uni-list-item title="职务">
<template v-slot:footer>
<uni-easyinput v-model="form.businessPrincipalPosition" placeholder="请输入职务" :inputBorder="false" />
</template>
</uni-list-item>
<uni-list-item title="电话">
<template v-slot:footer>
<uni-easyinput type="number" v-model="form.businessPrincipalPhone" placeholder="请输入手机号码" :inputBorder="false" />
</template>
</uni-list-item>
<uni-list-item class="mgb10" title="法人与业务负责人关系">
<template v-slot:footer>
<uni-easyinput v-model="form.legalBusinessRelation" placeholder="请输入" :inputBorder="false" />
</template>
</uni-list-item>
<view class="title-header">
<image class="title-header_icon" src="/static/images/title.png" />
<span>资产状况</span>
</view>
<uni-list-item title="生产厂房及办公楼产权">
<template v-slot:footer>
<uni-easyinput v-model="form.factoryOfficeProperty" placeholder="请输入" :inputBorder="false" />
</template>
</uni-list-item>
<uni-list-item title="生产厂房及办公楼面积">
<template v-slot:footer>
<uni-easyinput v-model="form.factoryOfficeArea" placeholder="请输入" :inputBorder="false" />
</template>
</uni-list-item>
<uni-list-item title="仓库或货场产权">
<template v-slot:footer>
<uni-easyinput v-model="form.warehouseYardProperty" placeholder="请输入" :inputBorder="false" />
</template>
</uni-list-item>
<uni-list-item title="仓库或货场产权面积">
<template v-slot:footer>
<uni-easyinput v-model="form.warehouseYardArea" placeholder="请输入" :inputBorder="false" />
</template>
</uni-list-item>
<uni-list-item title="主要生产设备">
<template v-slot:footer>
<uni-easyinput type="textarea" v-model="form.mainEquipment" placeholder="请输入" :inputBorder="false" maxlength="2000" />
</template>
</uni-list-item>
<uni-list-item class="mgb10" title="正常库存量">
<template v-slot:footer>
<uni-easyinput v-model="form.normalInventory" placeholder="请输入" :inputBorder="false" />
</template>
</uni-list-item>
<view class="title-header">
<image class="title-header_icon" src="/static/images/title.png" />
<span>生产经营环节风险调查</span>
</view>
<uni-list-item title="主要品种">
<template v-slot:footer>
<uni-easyinput v-model="form.mainVarieties" placeholder="请输入" :inputBorder="false" />
</template>
</uni-list-item>
<uni-list-item title="月度收购量">
<template v-slot:footer>
<uni-easyinput v-model="form.monthlyPurchaseVolume" placeholder="请输入" :inputBorder="false" />
</template>
</uni-list-item>
<uni-list-item class="select-item" :class="form.purchaseSource ? 'is-filled' : 'is-empty'" clickable
@click="openSheet('purchaseSource')" :rightText="displayLabel('purchaseSource')" showArrow>
<template v-slot:body>
<view class="item-title"><text>收购来源</text></view>
</template>
</uni-list-item>
<uni-list-item title="入库品名">
<template v-slot:footer>
<uni-easyinput v-model="form.stockInProductName" placeholder="请输入" :inputBorder="false" />
</template>
</uni-list-item>
<uni-list-item title="产品名称">
<template v-slot:footer>
<uni-easyinput v-model="form.productName" placeholder="请输入" :inputBorder="false" />
</template>
</uni-list-item>
<uni-list-item title="产能">
<template v-slot:footer>
<uni-easyinput v-model="form.capacity" placeholder="请输入" :inputBorder="false" />
</template>
</uni-list-item>
<uni-list-item title="销售渠道">
<template v-slot:footer>
<uni-easyinput v-model="form.salesChannel" placeholder="请输入" :inputBorder="false" />
</template>
</uni-list-item>
<uni-list-item class="select-item" :class="form.operationMode ? 'is-filled' : 'is-empty'" clickable
@click="openSheet('operationMode')" :rightText="displayLabel('operationMode')" showArrow>
<template v-slot:body>
<view class="item-title"><text>操作方式</text></view>
</template>
</uni-list-item>
<uni-list-item class="select-item" :class="form.hasPreferentialPolicy === true || form.hasPreferentialPolicy === false ? 'is-filled' : 'is-empty'" clickable
@click="openSheet('hasPreferentialPolicy')" :rightText="displayLabel('hasPreferentialPolicy')" showArrow>
<template v-slot:body>
<view class="item-title"><text>是否享有优惠政策</text></view>
</template>
</uni-list-item>
<uni-list-item class="select-item" :class="form.investInFutures === true || form.investInFutures === false ? 'is-filled' : 'is-empty'" clickable
@click="openSheet('investInFutures')" :rightText="displayLabel('investInFutures')" showArrow>
<template v-slot:body>
<view class="item-title"><text>是否投资期货</text></view>
</template>
</uni-list-item>
<uni-list-item class="select-item" :class="form.hasPenaltyRecord === true || form.hasPenaltyRecord === false ? 'is-filled' : 'is-empty'" clickable
@click="openSheet('hasPenaltyRecord')" :rightText="displayLabel('hasPenaltyRecord')" showArrow>
<template v-slot:body>
<view class="item-title"><text>是否有被处罚记录</text></view>
</template>
</uni-list-item>
<uni-list-item class="select-item" :class="form.businessScopeMatch === true || form.businessScopeMatch === false ? 'is-filled' : 'is-empty'" clickable
@click="openSheet('businessScopeMatch')" :rightText="displayLabel('businessScopeMatch')" showArrow>
<template v-slot:body>
<view class="item-title"><text>实际经营范围与法定经营范围是否相符</text></view>
</template>
</uni-list-item>
<uni-list-item title="常见料质问题">
<template v-slot:footer>
<uni-easyinput type="textarea" v-model="form.commonMaterialIssue" placeholder="请输入" :inputBorder="false" maxlength="2000" />
</template>
</uni-list-item>
<uni-list-item class="mgb10" title="合作中的其它问题">
<template v-slot:footer>
<uni-easyinput type="textarea" v-model="form.otherIssue" placeholder="请输入" :inputBorder="false" maxlength="2000" />
</template>
</uni-list-item>
<view class="title-header">
<image class="title-header_icon" src="/static/images/title.png" />
<span>与我司的合作状况</span>
</view>
<uni-list-item title="首次合作年份">
<template v-slot:footer>
<uni-easyinput type="digit" v-model="form.firstCooperationYear" placeholder="请输入4位年份" :inputBorder="false" />
</template>
</uni-list-item>
<uni-list-item class="select-item" :class="form.isNewDevelopment ? 'is-filled' : 'is-empty'" clickable
@click="openSheet('isNewDevelopment')" :rightText="displayLabel('isNewDevelopment')" showArrow>
<template v-slot:body>
<view class="item-title"><text>是否新开发</text></view>
</template>
</uni-list-item>
<uni-list-item class="select-item" :class="form.hasFailedPlanRecord === true || form.hasFailedPlanRecord === false ? 'is-filled' : 'is-empty'" clickable
@click="openSheet('hasFailedPlanRecord')" :rightText="displayLabel('hasFailedPlanRecord')" showArrow>
<template v-slot:body>
<view class="item-title"><text>是否有计划落空的不良记录</text></view>
</template>
</uni-list-item>
<uni-list-item class="select-item" :class="form.hasPlanPerformanceIssue === true || form.hasPlanPerformanceIssue === false ? 'is-filled' : 'is-empty'" clickable
@click="openSheet('hasPlanPerformanceIssue')" :rightText="displayLabel('hasPlanPerformanceIssue')" showArrow>
<template v-slot:body>
<view class="item-title"><text>是否有计划履行不到位现象</text></view>
</template>
</uni-list-item>
<uni-list-item title="进销账务如何处理">
<template v-slot:footer>
<uni-easyinput type="textarea" v-model="form.accountingProcess" placeholder="请输入" :inputBorder="false" maxlength="2000" />
</template>
</uni-list-item>
<uni-list-item class="select-item" :class="form.invoiceNameMatch === true || form.invoiceNameMatch === false ? 'is-filled' : 'is-empty'" clickable
@click="openSheet('invoiceNameMatch')" :rightText="displayLabel('invoiceNameMatch')" showArrow>
<template v-slot:body>
<view class="item-title"><text>开票品名与出库单品名是否一致</text></view>
</template>
</uni-list-item>
<uni-list-item class="select-item" :class="form.outboundProcessStandard === true || form.outboundProcessStandard === false ? 'is-filled' : 'is-empty'" clickable
@click="openSheet('outboundProcessStandard')" :rightText="displayLabel('outboundProcessStandard')" showArrow>
<template v-slot:body>
<view class="item-title"><text>出库流程是否规范</text></view>
</template>
</uni-list-item>
<uni-list-item class="mgb10" title="运输方式">
<template v-slot:footer>
<uni-easyinput v-model="form.transportMode" placeholder="请输入" :inputBorder="false" />
</template>
</uni-list-item>
<view class="title-header">
<image class="title-header_icon" src="/static/images/title.png" />
<span>其他</span>
</view>
<uni-list-item title="资信调查人">
<template v-slot:footer>
<uni-easyinput v-model="form.investigatorName" disabled placeholder="" :inputBorder="false" />
</template>
</uni-list-item>
<uni-list-item class="select-item" :class="form.purchaseDepartment ? 'is-filled' : 'is-empty'" clickable
@click="openSheet('purchaseDepartment')" :rightText="displayLabel('purchaseDepartment')" showArrow>
<template v-slot:body>
<view class="item-title"><text>采购处</text></view>
</template>
</uni-list-item>
<uni-list-item title="评审有效期">
<template v-slot:footer>
<uni-datetime-picker type="date" v-model="form.reviewValidUntil" />
</template>
</uni-list-item>
<uni-list-item class="mgb10" title="附件">
<template v-slot:footer>
<view class="attach-box">
<view v-for="(f, idx) in attachmentFiles" :key="idx" class="attach-row">
<FileUpload :value="f" @input="onAttachmentInput(idx, $event)" />
<text class="attach-del" @click.stop="removeAttachment(idx)">删除</text>
</view>
<view class="attach-row">
<FileUpload :value="newAttachment" @input="onAddAttachment" />
</view>
</view>
</template>
</uni-list-item>
</uni-list>
</scroll-view>
<view class="footer">
<button class="btn submit" type="primary" :disabled="submitting" @click="onSubmit">{{ submitting ? '提交中...' : '提交' }}</button>
</view>
<SingleSelectSheet :visible.sync="sheet.visible" :title="sheet.title" :options="sheet.options" v-model="sheet.value"
@confirm="onSheetConfirm" />
<MultiSelectSheet :visible.sync="multiSheet.visible" :title="multiSheet.title" :options="multiSheet.options"
v-model="multiSheet.value" @confirm="onMultiSheetConfirm" />
</view>
</template>
<script>
import FileUpload from '@/components/file-upload/index.vue'
import SingleSelectSheet from '@/components/single-select/index.vue'
import MultiSelectSheet from '@/components/multi-select/index.vue'
import { getDicByCodes, getDicName } from '@/utils/dic.js'
import { domesticCustomerCreditSaveApi, getPurchaseDeptApi } from '@/api/procure-manage/domesticCustomerCredit.js'
export default {
name: 'DomesticTradeAdd',
components: { FileUpload, SingleSelectSheet, MultiSelectSheet },
data() {
return {
submitting: false,
newAttachment: { id: '', name: '' },
attachmentFiles: [],
sheet: { visible: false, title: '', options: [], field: '', value: '' },
multiSheet: { visible: false, title: '', options: [], field: '', value: '' },
dicOptions: {
COMPANY_NATURE: [],
DEVELOP_NEW: [],
OPERATION_METHOD: [],
PURCHASE_SOURCE: []
},
yesNoOptions: [
{ label: '是', value: true },
{ label: '否', value: false }
],
companyNatureOptions: [],
operationMethodOptions: [],
developNewOptions: [],
purchaseSourceOptions: [],
purchaseDeptOptions: [],
form: {
unitName: '',
companyNature: '',
companyNatureName: '',
companyNatureOther: '',
bankName: '',
bankAccount: '',
registeredCapital: '',
legalRepresentative: '',
companyEstablishedTime: '',
address: '',
businessPrincipal: '',
businessPrincipalPosition: '',
businessPrincipalPhone: '',
legalBusinessRelation: '',
factoryOfficeProperty: '',
factoryOfficeArea: '',
warehouseYardProperty: '',
warehouseYardArea: '',
mainEquipment: '',
normalInventory: '',
mainVarieties: '',
monthlyPurchaseVolume: '',
purchaseSource: '',
stockInProductName: '',
productName: '',
capacity: '',
salesChannel: '',
hasPreferentialPolicy: null,
investInFutures: null,
hasPenaltyRecord: null,
businessScopeMatch: null,
commonMaterialIssue: '',
otherIssue: '',
firstCooperationYear: '',
isNewDevelopment: '',
operationMode: '',
hasFailedPlanRecord: null,
hasPlanPerformanceIssue: null,
accountingProcess: '',
invoiceNameMatch: null,
outboundProcessStandard: null,
transportMode: '',
attachmentFileIds: '',
attachmentFileNames: '',
investigatorId: '',
investigatorName: '',
purchaseDepartment: '',
reviewValidUntil: ''
}
}
},
created() {
this.loadDicData()
this.loadPurchaseDeptOptions()
const u = (this.$store && this.$store.state && this.$store.state.user) ? this.$store.state.user : {}
this.form.investigatorId = u && u.id ? String(u.id) : ''
this.form.investigatorName = u && u.name ? String(u.name) : ''
},
computed: {
showCompanyNatureOther() {
const v = String(this.form.companyNature || '')
return v.split(',').includes('OTHER')
}
},
methods: {
async loadDicData() {
try {
const results = await getDicByCodes(['COMPANY_NATURE', 'DEVELOP_NEW', 'OPERATION_METHOD', 'PURCHASE_SOURCE'])
const next = {
COMPANY_NATURE: (results.COMPANY_NATURE && results.COMPANY_NATURE.data) || [],
DEVELOP_NEW: (results.DEVELOP_NEW && results.DEVELOP_NEW.data) || [],
OPERATION_METHOD: (results.OPERATION_METHOD && results.OPERATION_METHOD.data) || [],
PURCHASE_SOURCE: (results.PURCHASE_SOURCE && results.PURCHASE_SOURCE.data) || []
}
this.dicOptions = next
this.companyNatureOptions = this.dicToSheetOptions(next.COMPANY_NATURE)
this.developNewOptions = this.dicToSheetOptions(next.DEVELOP_NEW)
this.operationMethodOptions = this.dicToSheetOptions(next.OPERATION_METHOD)
this.purchaseSourceOptions = this.dicToSheetOptions(next.PURCHASE_SOURCE)
this.form.companyNatureName = this.labelsOfOptions(this.companyNatureOptions, this.form.companyNature)
} catch (e) {
this.dicOptions = { COMPANY_NATURE: [], DEVELOP_NEW: [], OPERATION_METHOD: [], PURCHASE_SOURCE: [] }
this.companyNatureOptions = []
this.developNewOptions = []
this.operationMethodOptions = []
this.purchaseSourceOptions = []
uni.showToast({ title: '字典加载失败', icon: 'none' })
}
},
async loadPurchaseDeptOptions() {
try {
const res = await getPurchaseDeptApi()
const list = (res && res.data) ? res.data : []
this.purchaseDeptOptions = (Array.isArray(list) ? list : []).map(it => ({
label: it && it.name != null ? String(it.name) : '',
value: it && it.id != null ? String(it.id) : ''
})).filter(it => it.value)
} catch (e) {
this.purchaseDeptOptions = []
}
},
getOptionLabel(options, value) {
const v = value == null ? '' : String(value)
if (!v) return ''
const found = (options || []).find(o => String(o.value) === v)
return found ? String(found.label || '') : ''
},
dicToSheetOptions(items) {
const list = Array.isArray(items) ? items : []
return list.map(it => ({ label: it && it.name != null ? String(it.name) : '', value: it && it.code != null ? String(it.code) : '' })).filter(it => it.value)
},
labelsOfOptions(options, csv) {
const v = csv == null ? '' : String(csv)
if (!v) return ''
const parts = v.split(',').filter(Boolean)
if (!parts.length) return ''
const labels = []
;(options || []).forEach(opt => {
const ov = opt && opt.value != null ? String(opt.value) : ''
if (ov && parts.includes(ov)) labels.push(opt.label != null ? String(opt.label) : '')
})
return labels.filter(Boolean).join(',') || ''
},
displayLabel(field) {
const m = this.form || {}
const map = {
companyNatureName: '请选择公司性质',
purchaseSource: '请选择',
operationMode: '请选择',
isNewDevelopment: '请选择',
purchaseDepartment: '请选择',
hasPreferentialPolicy: '请选择',
investInFutures: '请选择',
hasPenaltyRecord: '请选择',
businessScopeMatch: '请选择',
hasFailedPlanRecord: '请选择',
hasPlanPerformanceIssue: '请选择',
invoiceNameMatch: '请选择',
outboundProcessStandard: '请选择'
}
if (field === 'companyNatureName') {
const val = m[field]
return val ? String(val) : map[field]
}
if (field === 'purchaseSource') {
const v = m.purchaseSource
return v ? getDicName('PURCHASE_SOURCE', String(v), this.dicOptions.PURCHASE_SOURCE) : map[field]
}
if (field === 'operationMode') {
const v = m.operationMode
return v ? getDicName('OPERATION_METHOD', String(v), this.dicOptions.OPERATION_METHOD) : map[field]
}
if (field === 'isNewDevelopment') {
const v = m.isNewDevelopment
return v ? getDicName('DEVELOP_NEW', String(v), this.dicOptions.DEVELOP_NEW) : map[field]
}
if (field === 'purchaseDepartment') {
const label = this.getOptionLabel(this.purchaseDeptOptions, m.purchaseDepartment)
return label || map[field]
}
const v = m[field]
if (v === true) return '是'
if (v === false) return '否'
return map[field] || '请选择'
},
openSheet(field) {
const map = {
purchaseSource: { title: '收购来源', options: this.purchaseSourceOptions },
operationMode: { title: '操作方式', options: this.operationMethodOptions },
isNewDevelopment: { title: '是否新开发', options: this.developNewOptions },
purchaseDepartment: { title: '采购处', options: this.purchaseDeptOptions },
hasPreferentialPolicy: { title: '是否享有优惠政策', options: this.yesNoOptions },
investInFutures: { title: '是否投资期货', options: this.yesNoOptions },
hasPenaltyRecord: { title: '是否有被处罚记录', options: this.yesNoOptions },
businessScopeMatch: { title: '实际经营范围与法定经营范围是否相符', options: this.yesNoOptions },
hasFailedPlanRecord: { title: '是否有计划落空的不良记录', options: this.yesNoOptions },
hasPlanPerformanceIssue: { title: '是否有计划履行不到位现象', options: this.yesNoOptions },
invoiceNameMatch: { title: '开票品名与出库单品名是否一致', options: this.yesNoOptions },
outboundProcessStandard: { title: '出库流程是否规范', options: this.yesNoOptions }
}
const cfg = map[field]
if (!cfg) return
const current = this.form[field]
const match = (cfg.options || []).find(o => String(o.value) === String(current))
this.sheet = {
...this.sheet,
visible: true,
title: cfg.title,
options: cfg.options || [],
field,
value: match ? match.value : current
}
},
openMultiSheet(field) {
if (field !== 'companyNature') return
this.multiSheet = {
...this.multiSheet,
visible: true,
title: '公司性质',
options: this.companyNatureOptions || [],
field,
value: this.form.companyNature || ''
}
},
onSheetConfirm({ value, label }) {
const field = this.sheet.field
if (!field) return
this.form[field] = value
this.sheet.visible = false
},
onMultiSheetConfirm({ value, label }) {
const field = this.multiSheet.field
if (field === 'companyNature') {
const normalized = this.normalizeCompanyNature(value)
this.form.companyNature = normalized.value
this.form.companyNatureName = normalized.label
if (!this.showCompanyNatureOther) this.form.companyNatureOther = ''
}
this.multiSheet.visible = false
},
normalizeCompanyNature(valueStr) {
const selected = (valueStr ? String(valueStr).split(',').filter(Boolean) : [])
const finalSelected = selected.slice(0)
const orderedValues = []
const orderedLabels = []
;(this.companyNatureOptions || []).forEach(opt => {
const v = opt && opt.value != null ? String(opt.value) : ''
if (v && finalSelected.includes(v)) {
orderedValues.push(v)
orderedLabels.push(opt.label != null ? String(opt.label) : '')
}
})
return { value: orderedValues.join(','), label: orderedLabels.join(',') }
},
removeAttachment(idx) {
const list = Array.isArray(this.attachmentFiles) ? this.attachmentFiles.slice(0) : []
list.splice(idx, 1)
this.attachmentFiles = list
},
onAddAttachment(val) {
const payload = val || { id: '', name: '' }
if (!payload.id) return
const list = Array.isArray(this.attachmentFiles) ? this.attachmentFiles.slice(0) : []
list.push(payload)
this.attachmentFiles = list
this.newAttachment = { id: '', name: '' }
},
onAttachmentInput(idx, val) {
const list = Array.isArray(this.attachmentFiles) ? this.attachmentFiles.slice(0) : []
list[idx] = val || { id: '', name: '' }
this.attachmentFiles = list
},
validate() {
const requiredTextFields = [
{ key: 'unitName', label: '单位名称' },
{ key: 'companyNature', label: '公司性质' },
{ key: 'bankName', label: '开户行' },
{ key: 'bankAccount', label: '账号' },
{ key: 'legalRepresentative', label: '法人代表' },
{ key: 'companyEstablishedTime', label: '公司成立时间' },
{ key: 'address', label: '地址' },
{ key: 'businessPrincipal', label: '业务负责人' },
{ key: 'businessPrincipalPosition', label: '职务' },
{ key: 'businessPrincipalPhone', label: '电话' },
{ key: 'legalBusinessRelation', label: '法人与业务负责人关系' },
{ key: 'factoryOfficeProperty', label: '生产厂房及办公楼产权' },
{ key: 'factoryOfficeArea', label: '生产厂房及办公楼面积' },
{ key: 'warehouseYardProperty', label: '仓库或货场产权' },
{ key: 'warehouseYardArea', label: '仓库或货场产权面积' },
{ key: 'mainEquipment', label: '主要生产设备' },
{ key: 'normalInventory', label: '正常库存量' },
{ key: 'mainVarieties', label: '主要品种' },
{ key: 'monthlyPurchaseVolume', label: '月度收购量' },
{ key: 'purchaseSource', label: '收购来源' },
{ key: 'stockInProductName', label: '入库品名' },
{ key: 'productName', label: '产品名称' },
{ key: 'capacity', label: '产能' },
{ key: 'salesChannel', label: '销售渠道' },
{ key: 'firstCooperationYear', label: '首次合作年份' },
{ key: 'isNewDevelopment', label: '是否新开发' },
{ key: 'operationMode', label: '操作方式' },
{ key: 'accountingProcess', label: '进销账务如何处理' },
{ key: 'transportMode', label: '运输方式' },
{ key: 'commonMaterialIssue', label: '常见料质问题' },
{ key: 'otherIssue', label: '合作中的其它问题' },
{ key: 'purchaseDepartment', label: '采购处' },
{ key: 'reviewValidUntil', label: '评审有效期' },
{ key: 'investigatorId', label: '资信调查人ID' }
]
for (let i = 0; i < requiredTextFields.length; i++) {
const f = requiredTextFields[i]
const v = this.form && this.form[f.key]
if (v == null || String(v).trim() === '') {
uni.showToast({ title: `${f.label}必填`, icon: 'none' })
return false
}
}
const registeredCapital = Number(this.form.registeredCapital)
if (!Number.isFinite(registeredCapital) || registeredCapital < 0) {
uni.showToast({ title: '注册资金请填写数字', icon: 'none' })
return false
}
const requiredBoolFields = [
{ key: 'hasPreferentialPolicy', label: '是否享有优惠政策' },
{ key: 'investInFutures', label: '是否投资期货' },
{ key: 'hasPenaltyRecord', label: '是否有被处罚记录' },
{ key: 'businessScopeMatch', label: '经营范围是否相符' },
{ key: 'hasFailedPlanRecord', label: '计划落空不良记录' },
{ key: 'hasPlanPerformanceIssue', label: '计划履行不到位现象' },
{ key: 'invoiceNameMatch', label: '开票品名是否一致' },
{ key: 'outboundProcessStandard', label: '出库流程是否规范' }
]
for (let i = 0; i < requiredBoolFields.length; i++) {
const f = requiredBoolFields[i]
const v = this.form && this.form[f.key]
if (!(v === true || v === false)) {
uni.showToast({ title: `请选择${f.label}`, icon: 'none' })
return false
}
}
const files = Array.isArray(this.attachmentFiles) ? this.attachmentFiles.filter(it => it && it.id) : []
if (!files.length) {
uni.showToast({ title: '请上传附件', icon: 'none' })
return false
}
const phone = String(this.form.businessPrincipalPhone || '').trim()
if (phone && !/^1\d{10}$/.test(phone)) {
uni.showToast({ title: '电话请输入11位手机号', icon: 'none' })
return false
}
const year = String(this.form.firstCooperationYear || '').trim()
if (year && !/^\d{4}$/.test(year)) {
uni.showToast({ title: '首次合作年份请填写4位年份', icon: 'none' })
return false
}
return true
},
buildPayload() {
const payload = { ...this.form }
if (!this.showCompanyNatureOther) payload.companyNatureOther = ''
delete payload.companyNatureName
delete payload.investigatorName
payload.registeredCapital = Number(payload.registeredCapital)
const files = (Array.isArray(this.attachmentFiles) ? this.attachmentFiles : []).filter(it => it && it.id)
payload.attachmentFileIds = files.map(it => String(it.id || '')).filter(Boolean).join(',')
payload.attachmentFileNames = files.map(it => String(it.name || '')).filter(Boolean).join(',')
return payload
},
async onSubmit() {
if (this.submitting) return
if (!this.validate()) return
this.submitting = true
const payload = this.buildPayload()
try {
await domesticCustomerCreditSaveApi(payload)
uni.showToast({ title: '提交成功', icon: 'success' })
try { uni.setStorageSync('DOMESTIC_TRADE_LIST_NEED_REFRESH', '1') } catch (e) {}
setTimeout(() => { uni.navigateBack() }, 300)
} catch (e) {
uni.showToast({ title: (e && e.msg) || '提交失败', icon: 'none' })
} finally {
this.submitting = false
}
},
}
}
</script>
<style lang="scss" scoped>
.page {
display: flex;
flex-direction: column;
height: 100%;
}
.scroll {
flex: 1;
padding: 12rpx 0 160rpx;
}
.footer {
position: fixed;
left: 0;
right: 0;
bottom: 0;
padding: 32rpx;
padding-bottom: calc(32rpx + env(safe-area-inset-bottom));
background: #fff;
box-shadow: 0 -8rpx 24rpx rgba(0, 0, 0, 0.06);
z-index: 10;
.btn {
height: 80rpx;
line-height: 80rpx;
border-radius: 12rpx;
font-size: 32rpx;
}
.submit {
background: $theme-primary;
color: #fff;
}
}
.title-header {
display: flex;
align-items: center;
padding: 24rpx 32rpx 12rpx;
background-color: #ffffff;
.title-header_icon {
width: 36rpx;
height: 36rpx;
margin-right: 12rpx;
}
span {
font-size: 34rpx;
font-weight: 600;
color: rgba(0, 0, 0, 0.9);
}
}
.mgb10 {
margin-bottom: 20rpx;
}
.amount-row {
display: flex;
align-items: center;
gap: 12rpx;
.unit, .prefix, .suffix {
font-size: 28rpx;
color: rgba(0, 0, 0, 0.6);
white-space: nowrap;
}
}
.attach-box {
display: flex;
flex-direction: column;
align-items: flex-end;
gap: 16rpx;
width: 100%;
}
.attach-row {
width: 100%;
display: flex;
justify-content: flex-end;
align-items: center;
gap: 20rpx;
}
.attach-del {
font-size: 28rpx;
color: #D54941;
}
::v-deep .uni-list {
.uni-easyinput {
display: flex;
.uni-input-input {
color: rgba(0, 0, 0, 0.9);
}
}
.uni-input-placeholder {
z-index: 1;
}
.uni-input-input {
background-color: #ffffff;
}
background: transparent;
&-item {
&__extra-text {
font-size: 32rpx;
}
&__content-title {
font-size: 32rpx;
color: rgba(0, 0, 0, 0.9);
}
&__container {
padding: 32rpx;
.uni-easyinput {
&__placeholder-class {
font-size: 32rpx;
color: rgba(0, 0, 0, 0.4);
}
&__content {
border: none;
background-color: #ffffff !important;
&-input {
padding-left: 0 !important;
height: 48rpx;
line-height: 48rpx;
font-size: 32rpx;
}
.content-clear-icon {
font-size: 44rpx !important;
}
}
}
.item-title,
.uni-list-item__content {
flex: none;
min-height: 48rpx;
line-height: 48rpx;
font-size: 32rpx;
position: relative;
width: 210rpx;
margin-right: 32rpx;
color: rgba(0, 0, 0, 0.9);
.required {
color: red;
position: absolute;
top: 50%;
transform: translateY(-50%);
left: -16rpx;
}
}
}
&.select-item {
&.is-empty {
.uni-list-item__extra-text {
color: rgba(0, 0, 0, 0.4) !important;
}
}
&.is-filled {
.uni-list-item__extra-text {
color: rgba(0, 0, 0, 0.9) !important;
}
}
}
&.mgb10 {
margin-bottom: 20rpx;
}
}
}
</style>