|
...
|
...
|
@@ -34,7 +34,7 @@ |
|
34
|
34
|
</template>
|
|
35
|
35
|
</uni-list-item>
|
|
36
|
36
|
|
|
37
|
|
- <!-- <ProductRel mode="add" :orderDateBase="form.orderDate" v-model="productLineList" @change="onProductsChange" :options="productList" /> -->
|
|
|
37
|
+ <ProductRel mode="add" :orderDateBase="form.orderDate" :list="productLineList" @change="onProductsChange" :options="productList" />
|
|
38
|
38
|
|
|
39
|
39
|
<uni-list-item title="合计人民币金额(大写)">
|
|
40
|
40
|
<template v-slot:footer>
|
|
...
|
...
|
@@ -196,7 +196,7 @@ import SingleSelectSheet from '@/components/single-select/index.vue' |
|
196
|
196
|
import RelateSelectSheet from '@/components/relate-select/index.vue'
|
|
197
|
197
|
import ProductRel from './productRel.vue'
|
|
198
|
198
|
import CitySelector from '@/components/city-selector/index.vue'
|
|
199
|
|
-import { getContractApi } from '@/api/contract'
|
|
|
199
|
+import { getContractApi, updateContractApi } from '@/api/contract'
|
|
200
|
200
|
import { getDicByCodes } from '@/utils/dic'
|
|
201
|
201
|
import { formatCurrencyToChinese } from '@/utils/common'
|
|
202
|
202
|
|
|
...
|
...
|
@@ -251,6 +251,7 @@ export default { |
|
251
|
251
|
sumAmountExcl: 0,
|
|
252
|
252
|
sumTotal: 0,
|
|
253
|
253
|
productLineList: [],
|
|
|
254
|
+ newProductLineList: [],
|
|
254
|
255
|
productList: []
|
|
255
|
256
|
}
|
|
256
|
257
|
},
|
|
...
|
...
|
@@ -333,6 +334,7 @@ export default { |
|
333
|
334
|
},
|
|
334
|
335
|
onProductsChange(products) {
|
|
335
|
336
|
const list = Array.isArray(products) ? products : []
|
|
|
337
|
+ this.newProductLineList = list
|
|
336
|
338
|
const sumQ = list.reduce((acc, it) => acc + (parseFloat(it.quantity) || 0), 0)
|
|
337
|
339
|
const sumE = list.reduce((acc, it) => acc + (parseFloat(it.amountExcludingTax) || 0), 0)
|
|
338
|
340
|
const sumT = list.reduce((acc, it) => acc + (parseFloat(it.totalAmount) || 0), 0)
|
|
...
|
...
|
@@ -411,17 +413,66 @@ export default { |
|
411
|
413
|
this.form.executionStandardRemarks = ''
|
|
412
|
414
|
}
|
|
413
|
415
|
},
|
|
|
416
|
+ validateRequired() {
|
|
|
417
|
+ const checks = [
|
|
|
418
|
+ { key: 'code', label: '编号' },
|
|
|
419
|
+ { key: 'supplier', label: '供方' },
|
|
|
420
|
+ { key: 'buyer', label: '需方' },
|
|
|
421
|
+ { key: 'orderDate', label: '订货日期' }
|
|
|
422
|
+ ]
|
|
|
423
|
+ for (const it of checks) {
|
|
|
424
|
+ const val = this.form[it.key]
|
|
|
425
|
+ const empty = (val === undefined || val === null || (typeof val === 'string' && val.trim() === '') || (typeof val === 'number' && isNaN(val)))
|
|
|
426
|
+ if (empty) { uni.showToast({ title: `请先选择${it.label}`, icon: 'none' }); return false }
|
|
|
427
|
+ }
|
|
|
428
|
+ if (!Array.isArray(this.productLineList) || this.productLineList.length === 0) {
|
|
|
429
|
+ uni.showToast({ title: '请至少添加一条产品明细', icon: 'none' }); return false
|
|
|
430
|
+ }
|
|
|
431
|
+ for (const [idx, it] of this.productLineList.entries()) {
|
|
|
432
|
+ if (!it.productName || !it.quantity || !it.unitPrice) {
|
|
|
433
|
+ uni.showToast({ title: `第${idx + 1}条明细未完整填写`, icon: 'none' }); return false
|
|
|
434
|
+ }
|
|
|
435
|
+ }
|
|
|
436
|
+ return true
|
|
|
437
|
+ },
|
|
414
|
438
|
async onSubmit() {
|
|
415
|
|
-
|
|
416
|
|
- const { destinationLabel, destinationId, ...formForSubmit } = this.form;
|
|
417
|
|
- // 区id
|
|
418
|
|
- const destination = destinationId && destinationId.length > 0 ? destinationId[destinationId.length - 1] : '';
|
|
419
|
|
- const payload = {
|
|
|
439
|
+ console.log('onSubmit__payload', payload)
|
|
|
440
|
+ if (!this.validateRequired()) return
|
|
|
441
|
+ const confirmRes = await new Promise(resolve => {
|
|
|
442
|
+ uni.showModal({ title: '提示', content: '确定保存当前经销未锁规合同吗?', confirmText: '确定', cancelText: '取消', success: resolve })
|
|
|
443
|
+ })
|
|
|
444
|
+ if (!(confirmRes && confirmRes.confirm)) return
|
|
|
445
|
+ const clean = (obj) => {
|
|
|
446
|
+ const out = {}
|
|
|
447
|
+ Object.keys(obj || {}).forEach(k => {
|
|
|
448
|
+ const v = obj[k]
|
|
|
449
|
+ const isEmptyString = typeof v === 'string' && v.trim() === ''
|
|
|
450
|
+ const isUndef = v === undefined || v === null
|
|
|
451
|
+ const isNaNNumber = typeof v === 'number' && isNaN(v)
|
|
|
452
|
+ if (!(isEmptyString || isUndef || isNaNNumber)) out[k] = v
|
|
|
453
|
+ })
|
|
|
454
|
+ return out
|
|
|
455
|
+ }
|
|
|
456
|
+ const lines = (this.newProductLineList || []).map(it => clean(it))
|
|
|
457
|
+ const { destinationLabel, destinationId, ...formForSubmit } = this.form;
|
|
|
458
|
+ const destination = destinationId && destinationId.length > 0 ? destinationId[destinationId.length - 1] : '';
|
|
|
459
|
+ const payload = clean({
|
|
420
|
460
|
...formForSubmit,
|
|
|
461
|
+ id: this.form.id,
|
|
421
|
462
|
destination,
|
|
|
463
|
+ type: 'DISTRIB_STD',
|
|
|
464
|
+ sumQuantity: this.sumQuantity,
|
|
|
465
|
+ sumAmountExcl: this.sumAmountExcl,
|
|
|
466
|
+ sumTotal: this.sumTotal,
|
|
|
467
|
+ contractDistributorLineList: lines
|
|
|
468
|
+ })
|
|
|
469
|
+ try {
|
|
|
470
|
+ await updateContractApi(payload)
|
|
|
471
|
+ uni.showToast({ title: '保存成功', icon: 'none' })
|
|
|
472
|
+ setTimeout(() => { uni.redirectTo({ url: '/pages/contract_retail/index' }) }, 400)
|
|
|
473
|
+ } catch (e) {
|
|
|
474
|
+ uni.showToast({ title: '提交失败', icon: 'none' })
|
|
422
|
475
|
}
|
|
423
|
|
- console.log('onSubmit__payload', payload)
|
|
424
|
|
- uni.showToast({ title: '暂未接入保存接口', icon: 'none' })
|
|
425
|
476
|
}
|
|
426
|
477
|
}
|
|
427
|
478
|
}
|
...
|
...
|
|