copy.vue
35.3 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
<template>
<view class="page">
<scroll-view class="scroll" scroll-y>
<uni-list>
<!-- 编号 -->
<uni-list-item class="select-item" :class="form.code ? 'is-filled' : 'is-empty'">
<template v-slot:body>
<view class="item-title"><text class="required">*</text><text>编号</text></view>
</template>
<template v-slot:footer>
<view class="serial-number-row">
<text class="readonly-text value-code">{{ form.code }}</text>
<button class="generate-btn" @click="initCode">点此生成</button>
</view>
</template>
</uni-list-item>
<!-- 供应商名称 -->
<uni-list-item class="select-item" :class="form.supplierId ? 'is-filled' : 'is-empty'" clickable
@click="openSupplierSheet" :rightText="form.supplierName || '请选择供应商名称'" showArrow>
<template v-slot:body>
<view class="item-title"><text class="required">*</text><text>供应商名称</text></view>
</template>
</uni-list-item>
<!-- 采购处(带出,禁用) -->
<uni-list-item title="采购处">
<template v-slot:footer>
<uni-easyinput v-model="form.purchaseDepartmentName" :inputBorder="false" disabled placeholder="选择供应商后自动带出" />
</template>
</uni-list-item>
<!-- 区域(带出,禁用) -->
<uni-list-item title="区域">
<template v-slot:footer>
<uni-easyinput v-model="form.regionName" :inputBorder="false" disabled placeholder="选择供应商后自动带出" />
</template>
</uni-list-item>
<!-- 报价时效 -->
<uni-list-item>
<template v-slot:body>
<view class="item-title"><text class="required">*</text><text>报价时效</text></view>
</template>
<template v-slot:footer>
<uni-easyinput v-model="form.validityPeriod" :inputBorder="false" placeholder="请输入报价时效" />
</template>
</uni-list-item>
<!-- 报价人(禁用) -->
<uni-list-item title="报价人">
<template v-slot:footer>
<uni-easyinput v-model="form.quoterName" :inputBorder="false" disabled placeholder="自动获取" />
</template>
</uni-list-item>
<!-- 是否长单操作 -->
<uni-list-item class="select-item" :class="typeof form.longTermOperation === 'boolean' ? 'is-filled' : 'is-empty'" clickable
@click="openSheet('longTermOperation')" :rightText="boolText(form.longTermOperation)" showArrow>
<template v-slot:body>
<view class="item-title"><text class="required">*</text><text>是否长单操作</text></view>
</template>
</uni-list-item>
<!-- 是否终端客户 -->
<uni-list-item class="select-item" :class="typeof form.terminalCustomer === 'boolean' ? 'is-filled' : 'is-empty'" clickable
@click="openSheet('terminalCustomer')" :rightText="boolText(form.terminalCustomer)" showArrow>
<template v-slot:body>
<view class="item-title"><text class="required">*</text><text>是否终端客户</text></view>
</template>
</uni-list-item>
<!-- 是否未点价 -->
<uni-list-item class="select-item" :class="typeof form.priced === 'boolean' ? 'is-filled' : 'is-empty'" clickable
@click="openSheet('priced')" :rightText="boolText(form.priced)" showArrow>
<template v-slot:body>
<view class="item-title"><text class="required">*</text><text>是否未点价</text></view>
</template>
</uni-list-item>
<!-- 点价截止日期 - 仅在 是否未点价 = 是 时显示且必填 -->
<uni-list-item v-if="form.priced === true" class="select-item" :class="form.pricingDeadline ? 'is-filled' : 'is-empty'">
<template v-slot:body>
<view class="item-title"><text class="required">*</text><text>点价截止日期</text></view>
</template>
<template v-slot:footer>
<uni-datetime-picker type="date" v-model="form.pricingDeadline" />
</template>
</uni-list-item>
<!-- 是否暂定价 - 仅在 是否未点价 = 是 时显示 -->
<uni-list-item v-if="form.priced === true" class="select-item" :class="typeof form.temporaryPrice === 'boolean' ? 'is-filled' : 'is-empty'" clickable
@click="openSheet('temporaryPrice')" :rightText="boolText(form.temporaryPrice)" showArrow>
<template v-slot:body>
<view class="item-title"><text>是否暂定价</text></view>
</template>
</uni-list-item>
<!-- 其他费用凭票到厂另行结算 -->
<uni-list-item class="select-item" :class="typeof form.otherExpenseSettlement === 'boolean' ? 'is-filled' : 'is-empty'" clickable
@click="openSheet('otherExpenseSettlement')" :rightText="boolText(form.otherExpenseSettlement)" showArrow>
<template v-slot:body>
<view class="item-title"><text class="required">*</text><text>其他费用凭票到厂另行结算</text></view>
</template>
</uni-list-item>
<!-- 交提货方式 -->
<uni-list-item class="select-item" :class="form.deliveryMode ? 'is-filled' : 'is-empty'" clickable
@click="openDictSheet('deliveryMode', 'DELIVERY_METHOD', '交提货方式')" :rightText="getDeliveryMethodLabel() || '请选择交提货方式'" showArrow>
<template v-slot:body>
<view class="item-title"><text class="required">*</text><text>交提货方式</text></view>
</template>
</uni-list-item>
<!-- 是否通货买断 -->
<uni-list-item class="select-item" :class="typeof form.commodityBuyout === 'boolean' ? 'is-filled' : 'is-empty'" clickable
@click="openSheet('commodityBuyout')" :rightText="boolText(form.commodityBuyout)" showArrow>
<template v-slot:body>
<view class="item-title"><text class="required">*</text><text>是否通货买断</text></view>
</template>
</uni-list-item>
<!-- 是否质量买断 -->
<uni-list-item class="select-item" :class="typeof form.qualityBuyout === 'boolean' ? 'is-filled' : 'is-empty'" clickable
@click="openSheet('qualityBuyout')" :rightText="boolText(form.qualityBuyout)" showArrow>
<template v-slot:body>
<view class="item-title"><text class="required">*</text><text>是否质量买断</text></view>
</template>
</uni-list-item>
<!-- 是否数量买断 -->
<uni-list-item class="select-item" :class="typeof form.quantityBuyout === 'boolean' ? 'is-filled' : 'is-empty'" clickable
@click="openSheet('quantityBuyout')" :rightText="boolText(form.quantityBuyout)" showArrow>
<template v-slot:body>
<view class="item-title"><text class="required">*</text><text>是否数量买断</text></view>
</template>
</uni-list-item>
<!-- 是否送货上门 -->
<uni-list-item class="select-item" :class="typeof form.doorDelivery === 'boolean' ? 'is-filled' : 'is-empty'" clickable
@click="openSheet('doorDelivery')" :rightText="boolText(form.doorDelivery)" showArrow>
<template v-slot:body>
<view class="item-title"><text class="required">*</text><text>是否送货上门</text></view>
</template>
</uni-list-item>
<!-- 装车费 -->
<uni-list-item title="装车费">
<template v-slot:footer>
<uni-easyinput v-model="form.loadingFee" type="digit" :inputBorder="false" placeholder="请输入装车费" />
</template>
</uni-list-item>
<!-- 开票品种 -->
<uni-list-item>
<template v-slot:body>
<view class="item-title"><text class="required">*</text><text>开票品种</text></view>
</template>
<template v-slot:footer>
<uni-easyinput v-model="form.invoiceProductName" :inputBorder="false" placeholder="请输入开票品种" />
</template>
</uni-list-item>
<!-- 交货日期 -->
<uni-list-item>
<template v-slot:body>
<view class="item-title"><text class="required">*</text><text>交货日期</text></view>
</template>
<template v-slot:footer>
<uni-datetime-picker type="date" v-model="form.deliveryDate" />
</template>
</uni-list-item>
<!-- 结算方式 -->
<uni-list-item>
<template v-slot:body>
<view class="item-title"><text class="required">*</text><text>结算方式</text></view>
</template>
<template v-slot:footer>
<uni-easyinput v-model="form.settlementMethod" :inputBorder="false" placeholder="请输入结算方式" />
</template>
</uni-list-item>
<!-- 结算比例(%) -->
<uni-list-item>
<template v-slot:body>
<view class="item-title"><text class="required">*</text><text>结算比例(%)</text></view>
</template>
<template v-slot:footer>
<uni-easyinput v-model="form.settlementRatio" type="digit" :inputBorder="false" placeholder="请输入结算比例" @blur="onRatioBlur" />
</template>
</uni-list-item>
<!-- 协调事由 -->
<uni-list-item title="协调事由">
<template v-slot:footer>
<uni-easyinput v-model="form.coordinationReason" :inputBorder="false" placeholder="请输入协调事由" disabled />
</template>
</uni-list-item>
<!-- 票类状况 -->
<uni-list-item title="票类状况">
<template v-slot:footer>
<uni-easyinput v-model="form.invoiceTypeStatus" :inputBorder="false" placeholder="请输入票类状况" disabled />
</template>
</uni-list-item>
<!-- 明细信息 -->
<ProductRel ref="productRel" mode="add" :options="productList" :priced="form.priced" :list="productLineList" @change="onProductsChange" />
</uni-list>
<!-- 料质状况模块(明细下方) -->
<view class="material-condition-section">
<view class="section-header">
<image class="opCollapse" src="/static/images/title.png" />
<text class="section-title">料质状况</text>
</view>
<view class="section-content">
<view class="form-row">
<text class="form-label">是否启用料质状况</text>
<view class="bool-btns">
<view class="bool-btn" :class="{ active: form.materialConditionEnabled === true }" @click="form.materialConditionEnabled = true">是</view>
<view class="bool-btn" :class="{ active: form.materialConditionEnabled === false }" @click="form.materialConditionEnabled = false">否</view>
</view>
</view>
<template v-if="form.materialConditionEnabled">
<view v-for="mc in materialConditionConfigs" :key="mc.field" class="material-group">
<text class="material-label">{{ mc.label }}</text>
<view class="tag-list">
<view
v-for="opt in getDictOptions(mc.dictCode)"
:key="opt.code"
class="tag-btn"
:class="{ active: isTagSelected(mc.field, opt.code) }"
@click="toggleTag(mc.field, opt.code)"
>
{{ opt.name }}
</view>
</view>
</view>
</template>
</view>
</view>
<!-- 备注模块 -->
<view class="remark-section">
<view class="section-header">
<image class="opCollapse" src="/static/images/title.png" />
<text class="section-title">备注</text>
</view>
<view class="section-content">
<uni-easyinput v-model="form.remark" type="textarea" :inputBorder="false" placeholder="请输入备注" maxlength="2000" />
</view>
</view>
<view class="footer">
<button class="btn submit" type="primary" @click="onSubmit">提交</button>
</view>
</scroll-view>
<SingleSelectSheet :visible.sync="sheet.visible" :title="sheet.title" :options="sheet.options"
v-model="sheet.value" @confirm="onSheetConfirm" />
<RelateSelectSheet :visible.sync="supplierSheet.visible" :title="supplierSheet.title"
:fetchFn="supplierSheet.fetchFn" :display-fields="supplierSheet.displayFields"
:multiple="false" row-key="id" :selectedKeys.sync="supplierSheet.selectedKeys"
@confirm="onSupplierConfirm" />
</view>
</template>
<script>
import SingleSelectSheet from '@/components/single-select/index.vue'
import RelateSelectSheet from '@/components/relate-select/index.vue'
import ProductRel from './productRel.vue'
import { salesmanQuotationDetailApi, salesmanQuotationGenerateCodeApi, salesmanQuotationSaveApi, breedRelationshipQueryApi } from '@/api/procure-manage/salesmanQuotation.js'
import { domesticCustomerCreditQueryApi } from '@/api/procure-manage/domesticCustomerCredit.js'
import { getDicByCodes } from '@/utils/dic.js'
export default {
name: 'CopySalesPrice',
components: { SingleSelectSheet, RelateSelectSheet, ProductRel },
data() {
return {
sourceId: '',
form: {
code: '',
supplierId: '',
supplierName: '',
purchaseDepartmentName: '',
regionName: '',
validityPeriod: '',
quoterName: '',
longTermOperation: false,
terminalCustomer: false,
priced: true,
pricingDeadline: '',
temporaryPrice: null,
otherExpenseSettlement: false,
deliveryMode: '',
commodityBuyout: false,
qualityBuyout: false,
quantityBuyout: false,
doorDelivery: false,
loadingFee: '',
invoiceProductName: '',
deliveryDate: '',
settlementMethod: '',
settlementRatio: '',
coordinationReason: '',
invoiceTypeStatus: '',
materialConditionEnabled: false,
materialConditionCopperRice: [],
materialConditionBrightCopper: [],
materialConditionFirstClass: [],
materialConditionSecondClass: [],
materialConditionTinCoated: [],
materialConditionScrap: [],
materialConditionWhiteYellow: [],
materialConditionPhosphorCopper: [],
remark: ''
},
productList: [],
productLineList: [],
sheet: { visible: false, title: '请选择', options: [], value: '', field: '' },
supplierSheet: {
visible: false,
title: '选择供应商',
fetchFn: null,
displayFields: [
{ label: '单位名称', field: 'unitName' },
{ label: '采购处', field: 'purchaseDepartmentName' },
{ label: '区域', field: 'regionName' }
],
selectedKeys: []
},
materialConditionConfigs: [
{ field: 'materialConditionCopperRice', label: '铜米', dictCode: 'COPPER_RICE' },
{ field: 'materialConditionBrightCopper', label: '光亮铜', dictCode: 'BRIGHT_COPPER' },
{ field: 'materialConditionFirstClass', label: '一特', dictCode: 'FIRST_CLASS' },
{ field: 'materialConditionSecondClass', label: '二特', dictCode: 'SECOND_CLASS' },
{ field: 'materialConditionTinCoated', label: '镀锡紫', dictCode: 'TIN_COATED' },
{ field: 'materialConditionScrap', label: '角料', dictCode: 'SCRAP' },
{ field: 'materialConditionWhiteYellow', label: '镀白黄', dictCode: 'WHITE_YELLOW' },
{ field: 'materialConditionPhosphorCopper', label: '磷铜', dictCode: 'PHOSPHOR_COPPER' }
],
dictData: {}
}
},
onLoad(query) {
this.sourceId = (query && query.id) || ''
this.supplierSheet.fetchFn = this.fetchSuppliers.bind(this)
this.loadProducts()
this.loadDictData()
this.loadSourceDetail()
this.initCode()
},
methods: {
async loadDictData() {
try {
const codes = [...this.materialConditionConfigs.map(mc => mc.dictCode), 'DELIVERY_METHOD']
const res = await getDicByCodes(codes)
this.dictData = res || {}
} catch (e) {
this.dictData = {}
}
},
getDictOptions(dictCode) {
const data = this.dictData[dictCode]
return (data && data.data) ? data.data : []
},
isTagSelected(field, code) {
const selected = this.form[field]
return Array.isArray(selected) && selected.includes(code)
},
toggleTag(field, code) {
let selected = this.form[field]
if (!Array.isArray(selected)) {
selected = []
}
const index = selected.indexOf(code)
if (index > -1) {
selected.splice(index, 1)
} else {
selected.push(code)
}
this.$set(this.form, field, [...selected])
},
async initCode() {
try {
const res = await salesmanQuotationGenerateCodeApi()
this.form.code = (res && res.data) ? res.data : ''
} catch (e) {
this.form.code = ''
}
},
async loadProducts() {
try {
const res = await breedRelationshipQueryApi({ pageIndex: 1, pageSize: 9999 })
const _data = res && res.data ? res.data : {}
const list = _data.datas || _data.list || _data.records || []
this.productList = list.map(it => ({
label: it.productName || it.name || '',
value: it.productId || it.id || '',
lossRate: it.fixedLossRate != null ? it.fixedLossRate : (it.lossRate != null ? it.lossRate : (it.attritionRate != null ? it.attritionRate : ''))
}))
} catch (e) {
this.productList = []
}
},
async loadSourceDetail() {
if (!this.sourceId) return
try {
const res = await salesmanQuotationDetailApi({ id: this.sourceId })
const d = (res && res.data) ? res.data : {}
// 清空 id 和 code,复制为新增
delete d.id
delete d.code
// 清空明细行的 id 和 itemId
const lineList = Array.isArray(d.quotationLineList) ? d.quotationLineList : (Array.isArray(d.salesmanQuotationLineList) ? d.salesmanQuotationLineList : [])
lineList.forEach(it => {
delete it.id
delete it.itemId
})
const materialFields = this.materialConditionConfigs.map(mc => mc.field)
materialFields.forEach(f => {
const v = d[f]
d[f] = (typeof v === 'string' && v) ? v.split(',').filter(Boolean) : (Array.isArray(v) ? v : [])
})
this.form = { ...this.form, ...d }
this.productLineList = lineList
} catch (e) {
uni.showToast({ title: '加载源数据失败', icon: 'none' })
}
},
fetchSuppliers({ pageIndex, pageSize, extra }) {
const name = (extra && (extra.name || extra.keyword || extra.key)) || ''
const params = {
pageIndex,
pageSize,
available: true,
unitName: name,
status: 'PASS',
freeze: false
}
return domesticCustomerCreditQueryApi(params).then(res => {
const _data = res && res.data ? res.data : {}
const records = _data.datas || _data.list || _data.records || []
const totalCount = _data.totalCount || _data.count || 0
const hasNext = _data.hasNext || false
return { records, totalCount, hasNext }
}).catch(() => ({ records: [], totalCount: 0, hasNext: false }))
},
openSupplierSheet() {
this.supplierSheet.selectedKeys = this.form.supplierId ? [this.form.supplierId] : []
this.supplierSheet.visible = true
},
onSupplierConfirm({ items }) {
const first = (items && items.length > 0) ? items[0] : null
if (!first) return
this.form.supplierId = first.id || ''
this.form.supplierName = first.unitName || ''
this.form.purchaseDepartmentName = first.purchaseDepartmentName || ''
this.form.regionName = first.regionName || ''
},
boolText(v) {
if (typeof v !== 'boolean') return '请选择'
return v ? '是' : '否'
},
openSheet(field) {
const opts = [{ label: '是', value: true }, { label: '否', value: false }]
const cur = this.form[field]
const match = opts.find(o => o.value === cur)
const titleMap = {
longTermOperation: '是否长单操作',
terminalCustomer: '是否终端客户',
priced: '是否未点价',
temporaryPrice: '是否暂定价',
otherExpenseSettlement: '其他费用凭票到厂另行结算',
commodityBuyout: '是否通货买断',
qualityBuyout: '是否质量买断',
quantityBuyout: '是否数量买断',
doorDelivery: '是否送货上门'
}
this.sheet = { visible: true, title: titleMap[field] || '请选择', options: opts, value: match ? match.value : '', field, isDict: false }
},
openDictSheet(field, dictCode, title) {
const raw = this.getDictOptions(dictCode) || []
const opts = raw.map(o => ({ label: o.name || o.label || '', value: o.code != null ? o.code : (o.value != null ? o.value : '') }))
const cur = this.form[field]
const match = opts.find(o => String(o.value) === String(cur))
this.sheet = { visible: true, title: title || '请选择', options: opts, value: match ? match.value : '', field, isDict: true }
},
getDeliveryMethodLabel() {
const opts = this.getDictOptions('DELIVERY_METHOD') || []
const m = opts.find(o => String(o.code != null ? o.code : o.value) === String(this.form.deliveryMode))
return m ? (m.name || m.label || '') : ''
},
onSheetConfirm({ value }) {
const field = this.sheet.field
if (!field) return
if (this.sheet.isDict) {
this.form[field] = value
} else {
this.form[field] = !!value
if (field === 'priced' && value === true) {
this.form.pricingDeadline = ''
}
}
},
onRatioBlur() {
let v = parseFloat(this.form.settlementRatio)
if (isNaN(v)) v = ''
else v = Math.round(v * 100) / 100
this.form.settlementRatio = v
},
onProductsChange(products) {
this.productLineList = Array.isArray(products) ? products : []
},
validateRequired() {
const stringChecks = [
{ key: 'code', msg: '请输入编号' },
{ key: 'supplierId', msg: '请选择供应商' },
{ key: 'validityPeriod', msg: '请输入报价时效' },
{ key: 'deliveryMode', msg: '请选择交提货方式' },
{ key: 'invoiceProductName', msg: '请输入开票品种' },
{ key: 'deliveryDate', msg: '请选择交货日期' },
{ key: 'settlementMethod', msg: '请输入结算方式' },
{ key: 'settlementRatio', msg: '请输入结算比例' }
]
for (const it of stringChecks) {
const val = this.form[it.key]
const empty = (val === undefined || val === null || (typeof val === 'string' && val.trim() === ''))
if (empty) { uni.showToast({ title: it.msg, icon: 'none' }); return false }
}
const boolChecks = [
{ key: 'longTermOperation', msg: '请选择是否长单操作' },
{ key: 'terminalCustomer', msg: '请选择是否终端客户' },
{ key: 'priced', msg: '请选择是否未点价' },
{ key: 'otherExpenseSettlement', msg: '请选择其他费用凭票到厂另行结算' },
{ key: 'commodityBuyout', msg: '请选择是否通货买断' },
{ key: 'qualityBuyout', msg: '请选择是否质量买断' },
{ key: 'quantityBuyout', msg: '请选择是否数量买断' },
{ key: 'doorDelivery', msg: '请选择是否送货上门' }
]
for (const it of boolChecks) {
if (typeof this.form[it.key] !== 'boolean') {
uni.showToast({ title: it.msg, icon: 'none' })
return false
}
}
if (this.form.priced === true && !this.form.pricingDeadline) {
uni.showToast({ title: '请选择点价截止日期', icon: 'none' })
return false
}
const list = Array.isArray(this.productLineList) ? this.productLineList : []
if (list.length === 0) {
uni.showToast({ title: '请添加产品明细', icon: 'none' })
return false
}
if (this.$refs.productRel && !this.$refs.productRel.validate(this.form.priced)) return false
return true
},
async onSubmit() {
if (!this.validateRequired()) return
const confirmRes = await new Promise(resolve => {
uni.showModal({ title: '提示', content: '确定复制提交吗?', confirmText: '确定', cancelText: '取消', success: resolve })
})
if (!(confirmRes && confirmRes.confirm)) return
const clean = (obj) => {
const out = {}
Object.keys(obj || {}).forEach(k => {
const v = obj[k]
const isEmptyString = typeof v === 'string' && v.trim() === ''
const isUndef = v === undefined || v === null
const isNaNNumber = typeof v === 'number' && isNaN(v)
if (!(isEmptyString || isUndef || isNaNNumber)) out[k] = v
})
return out
}
const lines = (this.productLineList || []).map(it => {
const c = clean(it)
delete c.id
delete c.itemId
return c
})
const materialFields = this.materialConditionConfigs.map(mc => mc.field)
const formCopy = { ...this.form }
delete formCopy.id
materialFields.forEach(f => {
const arr = formCopy[f]
formCopy[f] = Array.isArray(arr) ? arr.join(',') : (arr || '')
})
const payload = clean({
...formCopy,
quotationLineList: lines
})
try {
await salesmanQuotationSaveApi(payload)
uni.showToast({ title: '复制成功', icon: 'none' })
try { uni.setStorageSync('SALES_PRICE_LIST_NEED_REFRESH', '1') } catch (e) {}
setTimeout(() => { uni.redirectTo({ url: '/pages/sales-price/index' }) }, 400)
} catch (e) {
uni.showToast({ title: e.msg || '复制失败', icon: 'none' })
}
}
}
}
</script>
<style lang="scss" scoped>
.page {
display: flex;
flex-direction: column;
height: 100%;
}
.scroll {
flex: 1;
padding: 12rpx 0 392rpx !important;
}
.footer {
z-index: 2;
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);
.btn {
height: 80rpx;
line-height: 80rpx;
border-radius: 12rpx;
font-size: 32rpx;
}
.submit {
background: $theme-primary;
color: #fff;
}
}
::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: 240rpx;
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;
}
}
.serial-number-row {
display: flex;
align-items: center;
.generate-btn {
margin-left: 24rpx;
height: 48rpx;
line-height: 48rpx;
padding: 0 24rpx;
font-size: 24rpx;
border-radius: 8rpx;
background: $theme-primary;
color: #fff;
}
}
}
}
}
.readonly-text {
color: rgba(0, 0, 0, 0.9);
font-size: 32rpx;
line-height: 48rpx;
text-align: right;
white-space: pre-wrap;
word-break: break-all;
}
.value-code {
width: 260rpx;
text-align: left;
}
.material-condition-section,
.remark-section {
margin-top: 20rpx;
background: #fff;
}
.section-header {
display: flex;
align-items: center;
padding: 24rpx 32rpx;
border-bottom: 1rpx solid #f0f0f0;
}
.section-title {
font-size: 32rpx;
color: rgba(0, 0, 0, 0.9);
font-weight: 600;
}
.opCollapse {
width: 32rpx;
height: 28rpx;
margin-right: 16rpx;
margin-top: 8rpx;
}
.section-content {
padding: 32rpx;
}
.form-row {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 24rpx;
}
.form-row:last-child {
margin-bottom: 0;
}
.form-label {
font-size: 32rpx;
color: rgba(0, 0, 0, 0.9);
}
.bool-btns {
display: flex;
gap: 20rpx;
}
.bool-btn {
padding: 12rpx 40rpx;
border: 1rpx solid #ddd;
border-radius: 8rpx;
font-size: 28rpx;
color: #666;
background: #fff;
}
.bool-btn.active {
background: $theme-primary;
border-color: $theme-primary;
color: #fff;
}
.material-group {
margin-top: 32rpx;
}
.material-label {
display: block;
font-size: 30rpx;
color: rgba(0, 0, 0, 0.9);
margin-bottom: 20rpx;
}
.tag-list {
display: flex;
flex-wrap: wrap;
gap: 16rpx;
}
.tag-btn {
padding: 12rpx 24rpx;
border: 1rpx solid #ddd;
border-radius: 8rpx;
font-size: 28rpx;
color: #666;
background: #fff;
}
.tag-btn.active {
background: $theme-primary;
border-color: $theme-primary;
color: #fff;
}
::v-deep .uni-easyinput {
width: 100%;
&__content {
background: #f8f8f8 !important;
border-radius: 8rpx;
&-input {
font-size: 30rpx;
}
}
}
</style>