Showing
14 changed files
with
802 additions
and
39 deletions
| ... | ... | @@ -230,7 +230,7 @@ import SingleSelectSheet from '@/components/single-select/index.vue' |
| 230 | 230 | import RelateSelectSheet from '@/components/relate-select/index.vue' |
| 231 | 231 | import ProductRel from './productRel.vue' |
| 232 | 232 | import CitySelector from '@/components/city-selector/index.vue' |
| 233 | -import { getRetailCodeApi, createContractApi, getCustomerRemarks,getCustomerSpecificQualityRequirements,getDeptApi } from '@/api/contract' | |
| 233 | +import { getRetailCodeApi, createContractApi, getCustomerRemarks, getCustomerSpecificQualityRequirements, getDeptApi, getContractApi } from '@/api/contract' | |
| 234 | 234 | import { getDicByCodes } from '@/utils/dic' |
| 235 | 235 | import { formatCurrencyToChinese } from '@/utils/common' |
| 236 | 236 | import { workshopQueryApi } from '@/api/devManage' |
| ... | ... | @@ -242,6 +242,8 @@ export default { |
| 242 | 242 | components: { SingleSelectSheet, RelateSelectSheet, ProductRel, CitySelector }, |
| 243 | 243 | data() { |
| 244 | 244 | return { |
| 245 | + copyId: '', | |
| 246 | + operateType: 'ADD', | |
| 245 | 247 | form: { |
| 246 | 248 | code: '', |
| 247 | 249 | supplier: '', |
| ... | ... | @@ -296,13 +298,22 @@ export default { |
| 296 | 298 | regionOptions: [], |
| 297 | 299 | } |
| 298 | 300 | }, |
| 301 | + onLoad(query) { | |
| 302 | + const copyId = (query && query.copyId) ? String(query.copyId) : '' | |
| 303 | + this.copyId = copyId | |
| 304 | + this.operateType = copyId ? 'COPY' : 'ADD' | |
| 305 | + uni.setNavigationBarTitle({ | |
| 306 | + title: copyId ? '复制外贸标准合同' : '新增外贸标准合同' | |
| 307 | + }) | |
| 308 | + }, | |
| 299 | 309 | created() { |
| 300 | 310 | this.loadSuppliers() |
| 301 | 311 | this.loadExtraOptions() |
| 302 | 312 | this.initCode() |
| 303 | 313 | this.getDept() |
| 304 | 314 | this.loadRegionOptions() |
| 305 | - this.form.orderDate = this.formatDate(new Date()) | |
| 315 | + if (!this.copyId) this.form.orderDate = this.formatDate(new Date()) | |
| 316 | + if (this.copyId) this.loadCopyDetail(this.copyId) | |
| 306 | 317 | this.$nextTick(() => { |
| 307 | 318 | if (Array.isArray(this.form.destinationId) && this.form.destinationId.length) { |
| 308 | 319 | this.initDestinationLabel() |
| ... | ... | @@ -351,6 +362,83 @@ export default { |
| 351 | 362 | }, |
| 352 | 363 | }, |
| 353 | 364 | methods: { |
| 365 | + async loadCopyDetail(id) { | |
| 366 | + const rid = (id !== undefined && id !== null) ? String(id) : '' | |
| 367 | + if (!rid) return | |
| 368 | + try { | |
| 369 | + const res = await getContractApi(rid) | |
| 370 | + const data = res && res.data ? res.data : {} | |
| 371 | + const includesPackagingFeeName = data.includesPackagingFeeName || (data.includesPackagingFee ? '是' : '否') | |
| 372 | + const includesTransportFeeName = data.includesTransportFeeName || (data.includesTransportFee ? '是' : '否') | |
| 373 | + const m = { ...data, includesPackagingFeeName, includesTransportFeeName } | |
| 374 | + | |
| 375 | + const code = this.form.code | |
| 376 | + this.form = { | |
| 377 | + ...this.form, | |
| 378 | + supplier: m.supplier || '', | |
| 379 | + supplierName: m.supplierName || '', | |
| 380 | + buyer: m.buyer || (m.customer && m.customer.id) || '', | |
| 381 | + buyerName: m.buyerName || (m.customer && m.customer.name) || '', | |
| 382 | + stockUpCompanyId: m.stockUpCompanyId || '', | |
| 383 | + stockUpCompanyName: m.stockUpCompanyName || '', | |
| 384 | + deptName: m.deptName || this.form.deptName, | |
| 385 | + deptId: m.deptId || this.form.deptId, | |
| 386 | + region: m.region || '', | |
| 387 | + regionName: m.regionName || '', | |
| 388 | + orderDate: m.orderDate || this.form.orderDate, | |
| 389 | + deliveryDate: m.deliveryDate || '', | |
| 390 | + designatedConsignee: m.designatedConsignee || '', | |
| 391 | + specialTerms: m.specialTerms || '', | |
| 392 | + specialTermsName: m.specialTermsName || '', | |
| 393 | + executionStandard: m.executionStandard || '', | |
| 394 | + executionStandardName: m.executionStandardName || '', | |
| 395 | + executionStandardRemarks: m.executionStandardRemarks || '', | |
| 396 | + includesPackagingFee: !!m.includesPackagingFee, | |
| 397 | + includesPackagingFeeName, | |
| 398 | + includesTransportFee: !!m.includesTransportFee, | |
| 399 | + includesTransportFeeName, | |
| 400 | + unit: m.unit || this.form.unit, | |
| 401 | + totalAmountCapital: m.totalAmountCapital || '', | |
| 402 | + depositInfo: m.depositInfo || '', | |
| 403 | + packagingRequirements: m.packagingRequirements || '', | |
| 404 | + paymentTerms: m.paymentTerms || '', | |
| 405 | + transportMode: m.transportMode || '', | |
| 406 | + destinationId: (m.provinceId && m.cityId && m.districtId) ? [m.provinceId, m.cityId, m.districtId] : (Array.isArray(m.destinationId) ? m.destinationId : []), | |
| 407 | + destinationLabel: (m.provinceName && m.cityName && m.districtName) ? `${m.provinceName} / ${m.cityName} / ${m.districtName}` : (m.destinationLabel || ''), | |
| 408 | + specialInstructions: m.specialInstructions || '', | |
| 409 | + remarks: m.remarks || '', | |
| 410 | + pieceWeightHead: m.pieceWeightHead || '', | |
| 411 | + surface: m.surface || '', | |
| 412 | + tolerance: m.tolerance || '', | |
| 413 | + performance: m.performance || '', | |
| 414 | + component: m.component || '', | |
| 415 | + packaging: m.packaging || '', | |
| 416 | + workshopId: m.workshopId || '', | |
| 417 | + workshopIdName: m.workshopName || m.workshopIdName || '', | |
| 418 | + code, | |
| 419 | + } | |
| 420 | + | |
| 421 | + const lines = Array.isArray(m.contractDistributorLineList) ? m.contractDistributorLineList : [] | |
| 422 | + await this.$nextTick() | |
| 423 | + const comp = this.$refs.productRel | |
| 424 | + if (comp && typeof comp.defaultItem === 'function') { | |
| 425 | + const nextItems = (lines.length ? lines : [{}]).map(x => ({ | |
| 426 | + ...comp.defaultItem(), | |
| 427 | + ...x, | |
| 428 | + sampleOrder: !!x.sampleOrder, | |
| 429 | + collapsed: true | |
| 430 | + })) | |
| 431 | + if (!lines.length && nextItems[0]) nextItems[0].collapsed = false | |
| 432 | + comp.items = nextItems | |
| 433 | + if (typeof comp.recalculateAll === 'function') comp.recalculateAll() | |
| 434 | + if (typeof comp.emitChange === 'function') comp.emitChange() | |
| 435 | + } else { | |
| 436 | + this.onProductsChange(lines) | |
| 437 | + } | |
| 438 | + } catch (e) { | |
| 439 | + uni.showToast({ title: '复制失败,请稍后重试', icon: 'none' }) | |
| 440 | + } | |
| 441 | + }, | |
| 354 | 442 | async loadRegionOptions() { |
| 355 | 443 | try { |
| 356 | 444 | const res = await getArea() |
| ... | ... | @@ -554,8 +642,9 @@ export default { |
| 554 | 642 | }, |
| 555 | 643 | async onSubmit() { |
| 556 | 644 | if (!this.validateRequired()) return |
| 645 | + const isCopy = !!this.copyId | |
| 557 | 646 | const confirmRes = await new Promise(resolve => { |
| 558 | - uni.showModal({ title: '提示', content: '确定新增外贸标准合同吗?', confirmText: '确定', cancelText: '取消', success: resolve }) | |
| 647 | + uni.showModal({ title: '提示', content: isCopy ? '确定复制外贸标准合同吗?' : '确定新增外贸标准合同吗?', confirmText: '确定', cancelText: '取消', success: resolve }) | |
| 559 | 648 | }) |
| 560 | 649 | if (!(confirmRes && confirmRes.confirm)) return |
| 561 | 650 | const clean = (obj) => { |
| ... | ... | @@ -575,6 +664,7 @@ export default { |
| 575 | 664 | const destination = destinationId && destinationId.length > 0 ? destinationId[destinationId.length - 1] : ''; |
| 576 | 665 | const payload = clean({ |
| 577 | 666 | ...formForSubmit, |
| 667 | + operateType: isCopy ? 'COPY' : 'ADD', | |
| 578 | 668 | destination, |
| 579 | 669 | type: 'INTL_STD_CONTRACT', |
| 580 | 670 | totalQuantity: this.totalQuantity, |
| ... | ... | @@ -586,10 +676,10 @@ export default { |
| 586 | 676 | |
| 587 | 677 | try { |
| 588 | 678 | await createContractApi(payload) |
| 589 | - uni.showToast({ title: '新增成功', icon: 'none' }) | |
| 679 | + uni.showToast({ title: isCopy ? '复制成功' : '新增成功', icon: 'none' }) | |
| 590 | 680 | setTimeout(() => { uni.redirectTo({ url: '/pages/contract_foreign_std/index' }) }, 400) |
| 591 | 681 | } catch (e) { |
| 592 | - uni.showToast({ title: e.msg ||'提交失败', icon: 'none' }) | |
| 682 | + uni.showToast({ title: e.msg || (isCopy ? '复制失败' : '提交失败'), icon: 'none' }) | |
| 593 | 683 | } |
| 594 | 684 | }, |
| 595 | 685 | validateRequired() { | ... | ... |
| ... | ... | @@ -219,6 +219,12 @@ export default { |
| 219 | 219 | visible: true, |
| 220 | 220 | event: 'auditDetail' |
| 221 | 221 | }, |
| 222 | + { | |
| 223 | + text: '复制', | |
| 224 | + visible: true, | |
| 225 | + variant: 'outline', | |
| 226 | + event: 'copy' | |
| 227 | + }, | |
| 222 | 228 | ], |
| 223 | 229 | } |
| 224 | 230 | }, |
| ... | ... | @@ -234,6 +240,7 @@ export default { |
| 234 | 240 | { ...this.buttons[3], visible: (s === 'STANDARD' && this.$auth.hasPermi('contract-manage:foreign-trade-standard-contract:upload-seal')) }, |
| 235 | 241 | { ...this.buttons[5], visible: (s === 'STANDARD' && this.$auth.hasPermi('contract-manage:foreign-trade-standard-contract:review')) }, |
| 236 | 242 | { ...this.buttons[4], visible: (s === 'STANDARD' && e && t === 'AUDIT' && this.$auth.hasPermi('contract-manage:foreign-trade-standard-contract:approve')) }, |
| 243 | + { ...this.buttons[6], visible: (s !== 'DELETED' && this.$auth.hasPermi('contract-manage:foreign-trade-standard-contract:copy')) }, | |
| 237 | 244 | ] |
| 238 | 245 | } |
| 239 | 246 | }, |
| ... | ... | @@ -363,10 +370,21 @@ export default { |
| 363 | 370 | if (e === 'uploadSeal') return this.uploadContract(this.detail.id || '', 'seal') |
| 364 | 371 | if (e === 'audit') return this.onAudit(btn && btn.params) |
| 365 | 372 | if (e === 'auditDetail') return this.onAuditDetail(btn && btn.params) |
| 373 | + if (e === 'copy') return this.onCopy(btn && btn.params) | |
| 366 | 374 | }, |
| 367 | 375 | getBusinessId() { |
| 368 | 376 | return (this.detail && (this.detail.id || this.detail.code)) || '' |
| 369 | 377 | }, |
| 378 | + onCopy() { | |
| 379 | + const id = this.getBusinessId() | |
| 380 | + if (!id) { | |
| 381 | + uni.showToast({ title: '未获取到合同ID,无法复制', icon: 'none' }) | |
| 382 | + return | |
| 383 | + } | |
| 384 | + uni.navigateTo({ | |
| 385 | + url: '/pages/contract_foreign_std/add?copyId=' + encodeURIComponent(id) | |
| 386 | + }) | |
| 387 | + }, | |
| 370 | 388 | onAudit() { |
| 371 | 389 | const CACHE_KEY = 'sourceBusinessId' |
| 372 | 390 | uni.setStorageSync(CACHE_KEY, this.getBusinessId()) |
| ... | ... | @@ -566,4 +584,4 @@ export default { |
| 566 | 584 | .upload-row { |
| 567 | 585 | margin-top: 20rpx; |
| 568 | 586 | } |
| 569 | -</style> | |
| \ No newline at end of file | ||
| 587 | +</style> | ... | ... |
| ... | ... | @@ -233,7 +233,7 @@ import SingleSelectSheet from '@/components/single-select/index.vue' |
| 233 | 233 | import RelateSelectSheet from '@/components/relate-select/index.vue' |
| 234 | 234 | import ProductRel from './productRel.vue' |
| 235 | 235 | import CitySelector from '@/components/city-selector/index.vue' |
| 236 | -import { getRetailCodeApi, createContractApi, getCustomerSpecificQualityRequirements,getCustomerRemarks, getDeptApi } from '@/api/contract' | |
| 236 | +import { getRetailCodeApi, createContractApi, getCustomerSpecificQualityRequirements, getCustomerRemarks, getDeptApi, getContractApi } from '@/api/contract' | |
| 237 | 237 | import { getDicByCodes } from '@/utils/dic' |
| 238 | 238 | import { formatCurrencyToChinese } from '@/utils/common' |
| 239 | 239 | import { workshopQueryApi } from '@/api/devManage' |
| ... | ... | @@ -244,6 +244,8 @@ export default { |
| 244 | 244 | components: { SingleSelectSheet, RelateSelectSheet, ProductRel, CitySelector }, |
| 245 | 245 | data() { |
| 246 | 246 | return { |
| 247 | + copyId: '', | |
| 248 | + operateType: 'ADD', | |
| 247 | 249 | form: { |
| 248 | 250 | code: '', |
| 249 | 251 | supplier: '', |
| ... | ... | @@ -298,13 +300,22 @@ export default { |
| 298 | 300 | regionOptions: [], |
| 299 | 301 | } |
| 300 | 302 | }, |
| 303 | + onLoad(query) { | |
| 304 | + const copyId = (query && query.copyId) ? String(query.copyId) : '' | |
| 305 | + this.copyId = copyId | |
| 306 | + this.operateType = copyId ? 'COPY' : 'ADD' | |
| 307 | + uni.setNavigationBarTitle({ | |
| 308 | + title: copyId ? '复制外贸库存合同' : '新增外贸库存合同' | |
| 309 | + }) | |
| 310 | + }, | |
| 301 | 311 | created() { |
| 302 | 312 | this.loadSuppliers() |
| 303 | 313 | this.loadExtraOptions() |
| 304 | 314 | this.initCode() |
| 305 | 315 | this.getDept() |
| 306 | 316 | this.loadRegionOptions() |
| 307 | - this.form.orderDate = this.formatDate(new Date()) | |
| 317 | + if (!this.copyId) this.form.orderDate = this.formatDate(new Date()) | |
| 318 | + if (this.copyId) this.loadCopyDetail(this.copyId) | |
| 308 | 319 | this.$nextTick(() => { |
| 309 | 320 | if (Array.isArray(this.form.destinationId) && this.form.destinationId.length) { |
| 310 | 321 | this.initDestinationLabel() |
| ... | ... | @@ -353,6 +364,82 @@ export default { |
| 353 | 364 | }, |
| 354 | 365 | }, |
| 355 | 366 | methods: { |
| 367 | + async loadCopyDetail(id) { | |
| 368 | + const rid = (id !== undefined && id !== null) ? String(id) : '' | |
| 369 | + if (!rid) return | |
| 370 | + try { | |
| 371 | + const res = await getContractApi(rid) | |
| 372 | + const data = res && res.data ? res.data : {} | |
| 373 | + const includesPackagingFeeName = data.includesPackagingFeeName || (data.includesPackagingFee ? '是' : '否') | |
| 374 | + const includesTransportFeeName = data.includesTransportFeeName || (data.includesTransportFee ? '是' : '否') | |
| 375 | + const m = { ...data, includesPackagingFeeName, includesTransportFeeName } | |
| 376 | + | |
| 377 | + const code = this.form.code | |
| 378 | + this.form = { | |
| 379 | + ...this.form, | |
| 380 | + supplier: m.supplier || '', | |
| 381 | + supplierName: m.supplierName || '', | |
| 382 | + buyer: m.buyer || (m.customer && m.customer.id) || '', | |
| 383 | + buyerName: m.buyerName || (m.customer && m.customer.name) || '', | |
| 384 | + stockUpCompanyId: m.stockUpCompanyId || '', | |
| 385 | + stockUpCompanyName: m.stockUpCompanyName || '', | |
| 386 | + deptName: m.deptName || this.form.deptName, | |
| 387 | + deptId: m.deptId || this.form.deptId, | |
| 388 | + region: m.region || '', | |
| 389 | + regionName: m.regionName || '', | |
| 390 | + orderDate: m.orderDate || this.form.orderDate, | |
| 391 | + deliveryDate: m.deliveryDate || '', | |
| 392 | + designatedConsignee: m.designatedConsignee || '', | |
| 393 | + specialTerms: m.specialTerms || '', | |
| 394 | + specialTermsName: m.specialTermsName || '', | |
| 395 | + executionStandard: m.executionStandard || '', | |
| 396 | + executionStandardName: m.executionStandardName || '', | |
| 397 | + executionStandardRemarks: m.executionStandardRemarks || '', | |
| 398 | + includesPackagingFee: !!m.includesPackagingFee, | |
| 399 | + includesPackagingFeeName, | |
| 400 | + includesTransportFee: !!m.includesTransportFee, | |
| 401 | + includesTransportFeeName, | |
| 402 | + unit: m.unit || this.form.unit, | |
| 403 | + totalAmountCapital: m.totalAmountCapital || '', | |
| 404 | + depositInfo: m.depositInfo || '', | |
| 405 | + packagingRequirements: m.packagingRequirements || '', | |
| 406 | + paymentTerms: m.paymentTerms || '', | |
| 407 | + transportMode: m.transportMode || '', | |
| 408 | + destinationId: (m.provinceId && m.cityId && m.districtId) ? [m.provinceId, m.cityId, m.districtId] : (Array.isArray(m.destinationId) ? m.destinationId : []), | |
| 409 | + destinationLabel: (m.provinceName && m.cityName && m.districtName) ? `${m.provinceName} / ${m.cityName} / ${m.districtName}` : (m.destinationLabel || ''), | |
| 410 | + specialInstructions: m.specialInstructions || '', | |
| 411 | + remarks: m.remarks || '', | |
| 412 | + packaging: m.packaging || '', | |
| 413 | + performance: m.performance || '', | |
| 414 | + pieceWeightHead: m.pieceWeightHead || '', | |
| 415 | + surface: m.surface || '', | |
| 416 | + tolerance: m.tolerance || '', | |
| 417 | + workshopId: m.workshopId || '', | |
| 418 | + workshopIdName: m.workshopName || m.workshopIdName || '', | |
| 419 | + code, | |
| 420 | + } | |
| 421 | + | |
| 422 | + const lines = Array.isArray(m.contractDistributorLineList) ? m.contractDistributorLineList : [] | |
| 423 | + await this.$nextTick() | |
| 424 | + const comp = this.$refs.productRel | |
| 425 | + if (comp && typeof comp.defaultItem === 'function') { | |
| 426 | + const nextItems = (lines.length ? lines : [{}]).map(x => ({ | |
| 427 | + ...comp.defaultItem(), | |
| 428 | + ...x, | |
| 429 | + sampleOrder: !!x.sampleOrder, | |
| 430 | + collapsed: true | |
| 431 | + })) | |
| 432 | + if (!lines.length && nextItems[0]) nextItems[0].collapsed = false | |
| 433 | + comp.items = nextItems | |
| 434 | + if (typeof comp.recalculateAll === 'function') comp.recalculateAll() | |
| 435 | + if (typeof comp.emitChange === 'function') comp.emitChange() | |
| 436 | + } else { | |
| 437 | + this.onProductsChange(lines) | |
| 438 | + } | |
| 439 | + } catch (e) { | |
| 440 | + uni.showToast({ title: '复制失败,请稍后重试', icon: 'none' }) | |
| 441 | + } | |
| 442 | + }, | |
| 356 | 443 | async loadRegionOptions() { |
| 357 | 444 | try { |
| 358 | 445 | const res = await getArea() |
| ... | ... | @@ -558,8 +645,9 @@ export default { |
| 558 | 645 | }, |
| 559 | 646 | async onSubmit() { |
| 560 | 647 | if (!this.validateRequired()) return |
| 648 | + const isCopy = !!this.copyId | |
| 561 | 649 | const confirmRes = await new Promise(resolve => { |
| 562 | - uni.showModal({ title: '提示', content: '确定新增外贸库存合同吗?', confirmText: '确定', cancelText: '取消', success: resolve }) | |
| 650 | + uni.showModal({ title: '提示', content: isCopy ? '确定复制外贸库存合同吗?' : '确定新增外贸库存合同吗?', confirmText: '确定', cancelText: '取消', success: resolve }) | |
| 563 | 651 | }) |
| 564 | 652 | if (!(confirmRes && confirmRes.confirm)) return |
| 565 | 653 | const clean = (obj) => { |
| ... | ... | @@ -579,6 +667,7 @@ export default { |
| 579 | 667 | const destination = destinationId && destinationId.length > 0 ? destinationId[destinationId.length - 1] : ''; |
| 580 | 668 | const payload = clean({ |
| 581 | 669 | ...formForSubmit, |
| 670 | + operateType: isCopy ? 'COPY' : 'ADD', | |
| 582 | 671 | destination, |
| 583 | 672 | type: 'INTL_INVENTORY_AGMT', |
| 584 | 673 | totalQuantity: this.totalQuantity, |
| ... | ... | @@ -590,10 +679,10 @@ export default { |
| 590 | 679 | |
| 591 | 680 | try { |
| 592 | 681 | await createContractApi(payload) |
| 593 | - uni.showToast({ title: '新增成功', icon: 'none' }) | |
| 682 | + uni.showToast({ title: isCopy ? '复制成功' : '新增成功', icon: 'none' }) | |
| 594 | 683 | setTimeout(() => { uni.redirectTo({ url: '/pages/contract_foreign_stock/index' }) }, 400) |
| 595 | 684 | } catch (e) { |
| 596 | - uni.showToast({ title: e.msg ||'提交失败', icon: 'none' }) | |
| 685 | + uni.showToast({ title: e.msg || (isCopy ? '复制失败' : '提交失败'), icon: 'none' }) | |
| 597 | 686 | } |
| 598 | 687 | }, |
| 599 | 688 | validateRequired() { | ... | ... |
| ... | ... | @@ -279,6 +279,12 @@ export default { |
| 279 | 279 | variant: 'outline', |
| 280 | 280 | event: 'uploadSeal' |
| 281 | 281 | }, |
| 282 | + { | |
| 283 | + text: '复制', | |
| 284 | + visible: true, | |
| 285 | + variant: 'outline', | |
| 286 | + event: 'copy' | |
| 287 | + }, | |
| 282 | 288 | ], |
| 283 | 289 | } |
| 284 | 290 | }, |
| ... | ... | @@ -304,6 +310,7 @@ export default { |
| 304 | 310 | { ...this.buttons[6], visible: (s === 'FORMAL' && e && t === 'AUDIT' && this.$auth.hasPermi('contract-manage:foreign-trade-inventory-contract:approve')) }, |
| 305 | 311 | { ...this.buttons[7], visible: (s === 'STANDARD' && e && t === 'AUDIT' && this.$auth.hasPermi('contract-manage:foreign-trade-inventory-contract:approve')) }, |
| 306 | 312 | { ...this.buttons[8], visible: (s === 'STANDARD' && f && a === 'AUDIT' && this.$auth.hasPermi('contract-manage:foreign-trade-inventory-contract:standard-approve')) }, |
| 313 | + { ...this.buttons[13], visible: (s !== 'DELETED' && this.$auth.hasPermi('contract-manage:foreign-trade-inventory-contract:copy')) }, | |
| 307 | 314 | ] |
| 308 | 315 | } |
| 309 | 316 | }, |
| ... | ... | @@ -451,8 +458,22 @@ export default { |
| 451 | 458 | if (e === 'auditDetail2') return this.onAuditDetail(this.detail.parentId || '', 'FORMAL_CONTRACT') |
| 452 | 459 | if (e === 'auditDetail3') return this.onAuditDetail(this.detail.id || '', 'STANDARD_CONTRACT') |
| 453 | 460 | if (e === 'uploadSeal') return this.uploadContract(this.detail.id || '', 'seal') |
| 461 | + if (e === 'copy') return this.onCopy(btn && btn.params) | |
| 454 | 462 | |
| 455 | 463 | }, |
| 464 | + getBusinessId() { | |
| 465 | + return (this.detail && (this.detail.id || this.detail.code)) || '' | |
| 466 | + }, | |
| 467 | + onCopy() { | |
| 468 | + const id = this.getBusinessId() | |
| 469 | + if (!id) { | |
| 470 | + uni.showToast({ title: '未获取到合同ID,无法复制', icon: 'none' }) | |
| 471 | + return | |
| 472 | + } | |
| 473 | + uni.navigateTo({ | |
| 474 | + url: '/pages/contract_foreign_stock/add?copyId=' + encodeURIComponent(id) | |
| 475 | + }) | |
| 476 | + }, | |
| 456 | 477 | onAudit(id, type) { |
| 457 | 478 | const CACHE_KEY = 'sourceBusinessId' |
| 458 | 479 | const TYPE = 'contractType' |
| ... | ... | @@ -655,4 +676,4 @@ export default { |
| 655 | 676 | .upload-row { |
| 656 | 677 | margin-top: 20rpx; |
| 657 | 678 | } |
| 658 | -</style> | |
| \ No newline at end of file | ||
| 679 | +</style> | ... | ... |
| ... | ... | @@ -231,7 +231,7 @@ import SingleSelectSheet from '@/components/single-select/index.vue' |
| 231 | 231 | import RelateSelectSheet from '@/components/relate-select/index.vue' |
| 232 | 232 | import ProductRel from './productRel.vue' |
| 233 | 233 | import CitySelector from '@/components/city-selector/index.vue' |
| 234 | -import { getRetailCodeApi, createContractApi, getCustomerRemarks,getCustomerSpecificQualityRequirements, getDeptApi } from '@/api/contract' | |
| 234 | +import { getRetailCodeApi, createContractApi, getCustomerRemarks, getCustomerSpecificQualityRequirements, getDeptApi, getContractApi } from '@/api/contract' | |
| 235 | 235 | import { getDicByCodes } from '@/utils/dic' |
| 236 | 236 | import { formatCurrencyToChinese } from '@/utils/common' |
| 237 | 237 | import { workshopQueryApi } from '@/api/devManage' |
| ... | ... | @@ -242,6 +242,8 @@ export default { |
| 242 | 242 | components: { SingleSelectSheet, RelateSelectSheet, ProductRel, CitySelector }, |
| 243 | 243 | data() { |
| 244 | 244 | return { |
| 245 | + copyId: '', | |
| 246 | + operateType: 'ADD', | |
| 245 | 247 | form: { |
| 246 | 248 | code: '', |
| 247 | 249 | supplier: '', |
| ... | ... | @@ -296,13 +298,22 @@ export default { |
| 296 | 298 | regionOptions: [], |
| 297 | 299 | } |
| 298 | 300 | }, |
| 301 | + onLoad(query) { | |
| 302 | + const copyId = (query && query.copyId) ? String(query.copyId) : '' | |
| 303 | + this.copyId = copyId | |
| 304 | + this.operateType = copyId ? 'COPY' : 'ADD' | |
| 305 | + uni.setNavigationBarTitle({ | |
| 306 | + title: copyId ? '复制外贸未锁规合同' : '新增外贸未锁规合同' | |
| 307 | + }) | |
| 308 | + }, | |
| 299 | 309 | created() { |
| 300 | 310 | this.loadSuppliers() |
| 301 | 311 | this.loadExtraOptions() |
| 302 | 312 | this.initCode() |
| 303 | 313 | this.getDept() |
| 304 | 314 | this.loadRegionOptions() |
| 305 | - this.form.orderDate = this.formatDate(new Date()) | |
| 315 | + if (!this.copyId) this.form.orderDate = this.formatDate(new Date()) | |
| 316 | + if (this.copyId) this.loadCopyDetail(this.copyId) | |
| 306 | 317 | this.$nextTick(() => { |
| 307 | 318 | if (Array.isArray(this.form.destinationId) && this.form.destinationId.length) { |
| 308 | 319 | this.initDestinationLabel() |
| ... | ... | @@ -350,6 +361,83 @@ export default { |
| 350 | 361 | }, |
| 351 | 362 | }, |
| 352 | 363 | methods: { |
| 364 | + async loadCopyDetail(id) { | |
| 365 | + const rid = (id !== undefined && id !== null) ? String(id) : '' | |
| 366 | + if (!rid) return | |
| 367 | + try { | |
| 368 | + const res = await getContractApi(rid) | |
| 369 | + const data = res && res.data ? res.data : {} | |
| 370 | + const includesPackagingFeeName = data.includesPackagingFeeName || (data.includesPackagingFee ? '是' : '否') | |
| 371 | + const includesTransportFeeName = data.includesTransportFeeName || (data.includesTransportFee ? '是' : '否') | |
| 372 | + const m = { ...data, includesPackagingFeeName, includesTransportFeeName } | |
| 373 | + | |
| 374 | + const code = this.form.code | |
| 375 | + this.form = { | |
| 376 | + ...this.form, | |
| 377 | + supplier: m.supplier || '', | |
| 378 | + supplierName: m.supplierName || '', | |
| 379 | + buyer: m.buyer || (m.customer && m.customer.id) || '', | |
| 380 | + buyerName: m.buyerName || (m.customer && m.customer.name) || '', | |
| 381 | + stockUpCompanyId: m.stockUpCompanyId || '', | |
| 382 | + stockUpCompanyName: m.stockUpCompanyName || '', | |
| 383 | + deptName: m.deptName || this.form.deptName, | |
| 384 | + deptId: m.deptId || this.form.deptId, | |
| 385 | + region: m.region || '', | |
| 386 | + regionName: m.regionName || '', | |
| 387 | + orderDate: m.orderDate || this.form.orderDate, | |
| 388 | + deliveryDate: m.deliveryDate || '', | |
| 389 | + designatedConsignee: m.designatedConsignee || '', | |
| 390 | + specialTerms: m.specialTerms || '', | |
| 391 | + specialTermsName: m.specialTermsName || '', | |
| 392 | + executionStandard: m.executionStandard || '', | |
| 393 | + executionStandardName: m.executionStandardName || '', | |
| 394 | + executionStandardRemarks: m.executionStandardRemarks || '', | |
| 395 | + includesPackagingFee: !!m.includesPackagingFee, | |
| 396 | + includesPackagingFeeName, | |
| 397 | + includesTransportFee: !!m.includesTransportFee, | |
| 398 | + includesTransportFeeName, | |
| 399 | + unit: m.unit || this.form.unit, | |
| 400 | + totalAmountCapital: m.totalAmountCapital || '', | |
| 401 | + depositInfo: m.depositInfo || '', | |
| 402 | + packagingRequirements: m.packagingRequirements || '', | |
| 403 | + paymentTerms: m.paymentTerms || '', | |
| 404 | + transportMode: m.transportMode || '', | |
| 405 | + destinationId: (m.provinceId && m.cityId && m.districtId) ? [m.provinceId, m.cityId, m.districtId] : (Array.isArray(m.destinationId) ? m.destinationId : []), | |
| 406 | + destinationLabel: (m.provinceName && m.cityName && m.districtName) ? `${m.provinceName} / ${m.cityName} / ${m.districtName}` : (m.destinationLabel || ''), | |
| 407 | + specialInstructions: m.specialInstructions || '', | |
| 408 | + remarks: m.remarks || '', | |
| 409 | + pieceWeightHead: m.pieceWeightHead || '', | |
| 410 | + surface: m.surface || '', | |
| 411 | + tolerance: m.tolerance || '', | |
| 412 | + performance: m.performance || '', | |
| 413 | + component: m.component || '', | |
| 414 | + packaging: m.packaging || '', | |
| 415 | + workshopId: m.workshopId || '', | |
| 416 | + workshopIdName: m.workshopName || m.workshopIdName || '', | |
| 417 | + code, | |
| 418 | + } | |
| 419 | + | |
| 420 | + const lines = Array.isArray(m.contractDistributorLineList) ? m.contractDistributorLineList : [] | |
| 421 | + await this.$nextTick() | |
| 422 | + const comp = this.$refs.productRel | |
| 423 | + if (comp && typeof comp.defaultItem === 'function') { | |
| 424 | + const nextItems = (lines.length ? lines : [{}]).map(x => ({ | |
| 425 | + ...comp.defaultItem(), | |
| 426 | + ...x, | |
| 427 | + sampleOrder: !!x.sampleOrder, | |
| 428 | + collapsed: true | |
| 429 | + })) | |
| 430 | + if (!lines.length && nextItems[0]) nextItems[0].collapsed = false | |
| 431 | + comp.items = nextItems | |
| 432 | + if (typeof comp.recalculateAll === 'function') comp.recalculateAll() | |
| 433 | + if (typeof comp.emitChange === 'function') comp.emitChange() | |
| 434 | + } else { | |
| 435 | + this.onProductsChange(lines) | |
| 436 | + } | |
| 437 | + } catch (e) { | |
| 438 | + uni.showToast({ title: '复制失败,请稍后重试', icon: 'none' }) | |
| 439 | + } | |
| 440 | + }, | |
| 353 | 441 | async loadRegionOptions() { |
| 354 | 442 | try { |
| 355 | 443 | const res = await getArea() |
| ... | ... | @@ -556,8 +644,9 @@ export default { |
| 556 | 644 | async onSubmit() { |
| 557 | 645 | if (this.$refs.productRel && !this.$refs.productRel.validate()) return |
| 558 | 646 | if (!this.validateRequired()) return |
| 647 | + const isCopy = !!this.copyId | |
| 559 | 648 | const confirmRes = await new Promise(resolve => { |
| 560 | - uni.showModal({ title: '提示', content: '确定新增外贸未锁规合同吗?', confirmText: '确定', cancelText: '取消', success: resolve }) | |
| 649 | + uni.showModal({ title: '提示', content: isCopy ? '确定复制外贸未锁规合同吗?' : '确定新增外贸未锁规合同吗?', confirmText: '确定', cancelText: '取消', success: resolve }) | |
| 561 | 650 | }) |
| 562 | 651 | if (!(confirmRes && confirmRes.confirm)) return |
| 563 | 652 | const clean = (obj) => { |
| ... | ... | @@ -577,6 +666,7 @@ export default { |
| 577 | 666 | const destination = destinationId && destinationId.length > 0 ? destinationId[destinationId.length - 1] : ''; |
| 578 | 667 | const payload = clean({ |
| 579 | 668 | ...formForSubmit, |
| 669 | + operateType: isCopy ? 'COPY' : 'ADD', | |
| 580 | 670 | destination, |
| 581 | 671 | type: 'INTL_OPEN_SPEC_AGMT', |
| 582 | 672 | totalQuantity: this.totalQuantity, |
| ... | ... | @@ -588,10 +678,10 @@ export default { |
| 588 | 678 | |
| 589 | 679 | try { |
| 590 | 680 | await createContractApi(payload) |
| 591 | - uni.showToast({ title: '新增成功', icon: 'none' }) | |
| 681 | + uni.showToast({ title: isCopy ? '复制成功' : '新增成功', icon: 'none' }) | |
| 592 | 682 | setTimeout(() => { uni.redirectTo({ url: '/pages/contract_foreign_unplan/index' }) }, 400) |
| 593 | 683 | } catch (e) { |
| 594 | - uni.showToast({ title: e.msg ||'新增失败', icon: 'none' }) | |
| 684 | + uni.showToast({ title: e.msg || (isCopy ? '复制失败' : '新增失败'), icon: 'none' }) | |
| 595 | 685 | } |
| 596 | 686 | }, |
| 597 | 687 | validateRequired() { | ... | ... |
| ... | ... | @@ -285,6 +285,12 @@ export default { |
| 285 | 285 | variant: 'outline', |
| 286 | 286 | event: 'uploadSeal' |
| 287 | 287 | }, |
| 288 | + { | |
| 289 | + text: '复制', | |
| 290 | + visible: true, | |
| 291 | + variant: 'outline', | |
| 292 | + event: 'copy' | |
| 293 | + }, | |
| 288 | 294 | ], |
| 289 | 295 | } |
| 290 | 296 | }, |
| ... | ... | @@ -311,6 +317,7 @@ export default { |
| 311 | 317 | { ...this.buttons[7], visible: (s === 'FORMAL' && e && a === 'AUDIT' && this.$auth.hasPermi('contract-manage:foreign-trade-unlocked-contract:approve')) }, //审核正式合同 |
| 312 | 318 | { ...this.buttons[8], visible: (s === 'STANDARD' && e && a === 'AUDIT' && this.$auth.hasPermi('contract-manage:foreign-trade-unlocked-contract:approve')) }, //审核正式合同 |
| 313 | 319 | { ...this.buttons[9], visible: (s === 'STANDARD' && f && t === 'AUDIT' && this.$auth.hasPermi('contract-manage:foreign-trade-unlocked-contract:standard-approve')) }, //审核标准合同 |
| 320 | + { ...this.buttons[14], visible: (s !== 'DELETED' && this.$auth.hasPermi('contract-manage:foreign-trade-unlocked-contract:copy')) }, | |
| 314 | 321 | ] |
| 315 | 322 | } |
| 316 | 323 | }, |
| ... | ... | @@ -466,6 +473,20 @@ export default { |
| 466 | 473 | if (e === 'auditDetail2') return this.onAuditDetail(this.detail.parentId || '', 'FORMAL_CONTRACT') |
| 467 | 474 | if (e === 'auditDetail3') return this.onAuditDetail(this.detail.id || '', 'STANDARD_CONTRACT') |
| 468 | 475 | if (e === 'uploadSeal') return this.uploadContract(this.detail.id || '', 'seal') |
| 476 | + if (e === 'copy') return this.onCopy(btn && btn.params) | |
| 477 | + }, | |
| 478 | + getBusinessId() { | |
| 479 | + return (this.detail && (this.detail.id || this.detail.code)) || '' | |
| 480 | + }, | |
| 481 | + onCopy() { | |
| 482 | + const id = this.getBusinessId() | |
| 483 | + if (!id) { | |
| 484 | + uni.showToast({ title: '未获取到合同ID,无法复制', icon: 'none' }) | |
| 485 | + return | |
| 486 | + } | |
| 487 | + uni.navigateTo({ | |
| 488 | + url: '/pages/contract_foreign_unplan/add?copyId=' + encodeURIComponent(id) | |
| 489 | + }) | |
| 469 | 490 | }, |
| 470 | 491 | onAudit(id, type) { |
| 471 | 492 | const CACHE_KEY = 'sourceBusinessId' |
| ... | ... | @@ -667,4 +688,4 @@ export default { |
| 667 | 688 | .upload-row { |
| 668 | 689 | margin-top: 20rpx; |
| 669 | 690 | } |
| 670 | -</style> | |
| \ No newline at end of file | ||
| 691 | +</style> | ... | ... |
| ... | ... | @@ -231,7 +231,7 @@ import SingleSelectSheet from '@/components/single-select/index.vue' |
| 231 | 231 | import RelateSelectSheet from '@/components/relate-select/index.vue' |
| 232 | 232 | import ProductRel from './productRel.vue' |
| 233 | 233 | import CitySelector from '@/components/city-selector/index.vue' |
| 234 | -import { getRetailCodeApi, createContractApi, getCustomerRemarks,getCustomerSpecificQualityRequirements, getDeptApi } from '@/api/contract' | |
| 234 | +import { getRetailCodeApi, createContractApi, getCustomerRemarks, getCustomerSpecificQualityRequirements, getDeptApi, getContractApi } from '@/api/contract' | |
| 235 | 235 | import { getDicByCodes } from '@/utils/dic' |
| 236 | 236 | import { formatCurrencyToChinese } from '@/utils/common' |
| 237 | 237 | import { workshopQueryApi } from '@/api/devManage' |
| ... | ... | @@ -242,6 +242,8 @@ export default { |
| 242 | 242 | components: { SingleSelectSheet, RelateSelectSheet, ProductRel, CitySelector }, |
| 243 | 243 | data() { |
| 244 | 244 | return { |
| 245 | + copyId: '', | |
| 246 | + operateType: 'ADD', | |
| 245 | 247 | form: { |
| 246 | 248 | code: '', |
| 247 | 249 | supplier: '', |
| ... | ... | @@ -299,13 +301,22 @@ export default { |
| 299 | 301 | rawProductGradeList: [], |
| 300 | 302 | } |
| 301 | 303 | }, |
| 304 | + onLoad(query) { | |
| 305 | + const copyId = (query && query.copyId) ? String(query.copyId) : '' | |
| 306 | + this.copyId = copyId | |
| 307 | + this.operateType = copyId ? 'COPY' : 'ADD' | |
| 308 | + uni.setNavigationBarTitle({ | |
| 309 | + title: copyId ? '复制加工标准合同' : '新增加工标准合同' | |
| 310 | + }) | |
| 311 | + }, | |
| 302 | 312 | created() { |
| 303 | 313 | this.loadSuppliers() |
| 304 | 314 | this.loadExtraOptions() |
| 305 | 315 | this.initCode() |
| 306 | 316 | this.getDept() |
| 307 | 317 | this.loadRegionOptions() |
| 308 | - this.form.orderDate = this.formatDate(new Date()) | |
| 318 | + if (!this.copyId) this.form.orderDate = this.formatDate(new Date()) | |
| 319 | + if (this.copyId) this.loadCopyDetail(this.copyId) | |
| 309 | 320 | this.$nextTick(() => { |
| 310 | 321 | if (Array.isArray(this.form.destinationId) && this.form.destinationId.length) { |
| 311 | 322 | this.initDestinationLabel() |
| ... | ... | @@ -353,6 +364,83 @@ export default { |
| 353 | 364 | }, |
| 354 | 365 | }, |
| 355 | 366 | methods: { |
| 367 | + async loadCopyDetail(id) { | |
| 368 | + const rid = (id !== undefined && id !== null) ? String(id) : '' | |
| 369 | + if (!rid) return | |
| 370 | + try { | |
| 371 | + const res = await getContractApi(rid) | |
| 372 | + const data = res && res.data ? res.data : {} | |
| 373 | + const includesPackagingFeeName = data.includesPackagingFeeName || (data.includesPackagingFee ? '是' : '否') | |
| 374 | + const includesTransportFeeName = data.includesTransportFeeName || (data.includesTransportFee ? '是' : '否') | |
| 375 | + const m = { ...data, includesPackagingFeeName, includesTransportFeeName } | |
| 376 | + | |
| 377 | + const code = this.form.code | |
| 378 | + this.form = { | |
| 379 | + ...this.form, | |
| 380 | + supplier: m.supplier || '', | |
| 381 | + supplierName: m.supplierName || '', | |
| 382 | + buyer: m.buyer || (m.customer && m.customer.id) || '', | |
| 383 | + buyerName: m.buyerName || (m.customer && m.customer.name) || '', | |
| 384 | + stockUpCompanyId: m.stockUpCompanyId || '', | |
| 385 | + stockUpCompanyName: m.stockUpCompanyName || '', | |
| 386 | + orderDate: m.orderDate || this.form.orderDate, | |
| 387 | + deliveryDate: m.deliveryDate || '', | |
| 388 | + designatedConsignee: m.designatedConsignee || '', | |
| 389 | + specialTerms: m.specialTerms || '', | |
| 390 | + specialTermsName: m.specialTermsName || '', | |
| 391 | + executionStandard: m.executionStandard || '', | |
| 392 | + executionStandardName: m.executionStandardName || '', | |
| 393 | + executionStandardRemarks: m.executionStandardRemarks || '', | |
| 394 | + includesPackagingFee: !!m.includesPackagingFee, | |
| 395 | + includesPackagingFeeName, | |
| 396 | + includesTransportFee: !!m.includesTransportFee, | |
| 397 | + includesTransportFeeName, | |
| 398 | + unit: m.unit || this.form.unit, | |
| 399 | + totalAmountCapital: m.totalAmountCapital || '', | |
| 400 | + depositInfo: m.depositInfo || '', | |
| 401 | + packagingRequirements: m.packagingRequirements || '', | |
| 402 | + paymentTerms: m.paymentTerms || '', | |
| 403 | + transportMode: m.transportMode || '', | |
| 404 | + destinationId: (m.provinceId && m.cityId && m.districtId) ? [m.provinceId, m.cityId, m.districtId] : (Array.isArray(m.destinationId) ? m.destinationId : []), | |
| 405 | + destinationLabel: (m.provinceName && m.cityName && m.districtName) ? `${m.provinceName} / ${m.cityName} / ${m.districtName}` : (m.destinationLabel || ''), | |
| 406 | + specialInstructions: m.specialInstructions || '', | |
| 407 | + remarks: m.remarks || '', | |
| 408 | + pieceWeightHead: m.pieceWeightHead || '', | |
| 409 | + surface: m.surface || '', | |
| 410 | + tolerance: m.tolerance || '', | |
| 411 | + performance: m.performance || '', | |
| 412 | + component: m.component || '', | |
| 413 | + packaging: m.packaging || '', | |
| 414 | + workshopId: m.workshopId || '', | |
| 415 | + workshopIdName: m.workshopName || m.workshopIdName || '', | |
| 416 | + region: m.region || '', | |
| 417 | + regionName: m.regionName || '', | |
| 418 | + deptName: m.deptName || this.form.deptName, | |
| 419 | + deptId: m.deptId || this.form.deptId, | |
| 420 | + code, | |
| 421 | + } | |
| 422 | + | |
| 423 | + const lines = Array.isArray(m.contractStdProcessingLineList) ? m.contractStdProcessingLineList : [] | |
| 424 | + await this.$nextTick() | |
| 425 | + const comp = this.$refs.productRel | |
| 426 | + if (comp && typeof comp.defaultItem === 'function') { | |
| 427 | + const nextItems = (lines.length ? lines : [{}]).map(x => ({ | |
| 428 | + ...comp.defaultItem(), | |
| 429 | + ...x, | |
| 430 | + sampleOrder: !!x.sampleOrder, | |
| 431 | + collapsed: true | |
| 432 | + })) | |
| 433 | + if (!lines.length && nextItems[0]) nextItems[0].collapsed = false | |
| 434 | + comp.items = nextItems | |
| 435 | + if (typeof comp.recalculateAll === 'function') comp.recalculateAll() | |
| 436 | + if (typeof comp.emitChange === 'function') comp.emitChange() | |
| 437 | + } else { | |
| 438 | + this.onProductsChange(lines) | |
| 439 | + } | |
| 440 | + } catch (e) { | |
| 441 | + uni.showToast({ title: '复制失败,请稍后重试', icon: 'none' }) | |
| 442 | + } | |
| 443 | + }, | |
| 356 | 444 | async loadRegionOptions() { |
| 357 | 445 | try { |
| 358 | 446 | const res = await getArea() |
| ... | ... | @@ -567,8 +655,9 @@ export default { |
| 567 | 655 | }, |
| 568 | 656 | async onSubmit() { |
| 569 | 657 | if (!this.validateRequired()) return |
| 658 | + const isCopy = !!this.copyId | |
| 570 | 659 | const confirmRes = await new Promise(resolve => { |
| 571 | - uni.showModal({ title: '提示', content: '确定新增加工标准合同吗?', confirmText: '确定', cancelText: '取消', success: resolve }) | |
| 660 | + uni.showModal({ title: '提示', content: isCopy ? '确定复制加工标准合同吗?' : '确定新增加工标准合同吗?', confirmText: '确定', cancelText: '取消', success: resolve }) | |
| 572 | 661 | }) |
| 573 | 662 | if (!(confirmRes && confirmRes.confirm)) return |
| 574 | 663 | const clean = (obj) => { |
| ... | ... | @@ -588,6 +677,7 @@ export default { |
| 588 | 677 | const destination = destinationId && destinationId.length > 0 ? destinationId[destinationId.length - 1] : ''; |
| 589 | 678 | const payload = clean({ |
| 590 | 679 | ...formForSubmit, |
| 680 | + operateType: isCopy ? 'COPY' : 'ADD', | |
| 591 | 681 | destination, |
| 592 | 682 | type: 'PROCESS_STD_AGMT', |
| 593 | 683 | totalQuantity: this.totalQuantity, |
| ... | ... | @@ -601,10 +691,10 @@ export default { |
| 601 | 691 | |
| 602 | 692 | try { |
| 603 | 693 | await createContractApi(payload) |
| 604 | - uni.showToast({ title: '新增成功', icon: 'none' }) | |
| 694 | + uni.showToast({ title: isCopy ? '复制成功' : '新增成功', icon: 'none' }) | |
| 605 | 695 | setTimeout(() => { uni.redirectTo({ url: '/pages/contract_process/index' }) }, 400) |
| 606 | 696 | } catch (e) { |
| 607 | - uni.showToast({ title: e.msg ||'新增失败', icon: 'none' }) | |
| 697 | + uni.showToast({ title: e.msg || (isCopy ? '复制失败' : '新增失败'), icon: 'none' }) | |
| 608 | 698 | } |
| 609 | 699 | }, |
| 610 | 700 | validateRequired() { | ... | ... |
| ... | ... | @@ -210,6 +210,12 @@ export default { |
| 210 | 210 | visible: true, |
| 211 | 211 | event: 'auditDetail' |
| 212 | 212 | }, |
| 213 | + { | |
| 214 | + text: '复制', | |
| 215 | + visible: true, | |
| 216 | + variant: 'outline', | |
| 217 | + event: 'copy' | |
| 218 | + }, | |
| 213 | 219 | ], |
| 214 | 220 | } |
| 215 | 221 | }, |
| ... | ... | @@ -224,6 +230,7 @@ export default { |
| 224 | 230 | { ...this.buttons[2], visible: (s !== 'DELETED' && t !== 'AUDIT' && t !== 'PASS' && this.$auth.hasPermi('contract-manage:processed-standard-contract:upload')) }, |
| 225 | 231 | { ...this.buttons[4], visible: (s === 'STANDARD' && this.$auth.hasPermi('contract-manage:processed-standard-contract:review')) }, |
| 226 | 232 | { ...this.buttons[3], visible: (s === 'STANDARD' && e && t === 'AUDIT' && this.$auth.hasPermi('contract-manage:processed-standard-contract:approve')) }, |
| 233 | + { ...this.buttons[5], visible: (s !== 'DELETED' && this.$auth.hasPermi('contract-manage:processed-standard-contract:copy')) }, | |
| 227 | 234 | ] |
| 228 | 235 | } |
| 229 | 236 | }, |
| ... | ... | @@ -346,6 +353,20 @@ export default { |
| 346 | 353 | if (e === 'upload') return this.uploadContract(this.detail.id || '') |
| 347 | 354 | if (e === 'audit') return this.onAudit(this.detail.id || '', 'PROCESS_STD_AGMT') |
| 348 | 355 | if (e === 'auditDetail') return this.onAuditDetail(this.detail.id || '', 'PROCESS_STD_AGMT') |
| 356 | + if (e === 'copy') return this.onCopy(btn && btn.params) | |
| 357 | + }, | |
| 358 | + getBusinessId() { | |
| 359 | + return (this.detail && (this.detail.id || this.detail.code)) || '' | |
| 360 | + }, | |
| 361 | + onCopy() { | |
| 362 | + const id = this.getBusinessId() | |
| 363 | + if (!id) { | |
| 364 | + uni.showToast({ title: '未获取到合同ID,无法复制', icon: 'none' }) | |
| 365 | + return | |
| 366 | + } | |
| 367 | + uni.navigateTo({ | |
| 368 | + url: '/pages/contract_process/add?copyId=' + encodeURIComponent(id) | |
| 369 | + }) | |
| 349 | 370 | }, |
| 350 | 371 | onAudit(id, type) { |
| 351 | 372 | const CACHE_KEY = 'sourceBusinessId' |
| ... | ... | @@ -533,4 +554,4 @@ export default { |
| 533 | 554 | .upload-row { |
| 534 | 555 | margin-top: 20rpx; |
| 535 | 556 | } |
| 536 | -</style> | |
| \ No newline at end of file | ||
| 557 | +</style> | ... | ... |
| ... | ... | @@ -227,7 +227,7 @@ import SingleSelectSheet from '@/components/single-select/index.vue' |
| 227 | 227 | import RelateSelectSheet from '@/components/relate-select/index.vue' |
| 228 | 228 | import ProductRel from './productRel.vue' |
| 229 | 229 | import CitySelector from '@/components/city-selector/index.vue' |
| 230 | -import { getRetailCodeApi, createContractApi, getCustomerRemarks,getCustomerSpecificQualityRequirements, getDeptApi } from '@/api/contract' | |
| 230 | +import { getRetailCodeApi, createContractApi, getCustomerRemarks, getCustomerSpecificQualityRequirements, getDeptApi, getContractApi } from '@/api/contract' | |
| 231 | 231 | import { getDicByCodes } from '@/utils/dic' |
| 232 | 232 | import { formatCurrencyToChinese } from '@/utils/common' |
| 233 | 233 | import { workshopQueryApi } from '@/api/devManage' |
| ... | ... | @@ -238,6 +238,8 @@ export default { |
| 238 | 238 | components: { SingleSelectSheet, RelateSelectSheet, ProductRel, CitySelector }, |
| 239 | 239 | data() { |
| 240 | 240 | return { |
| 241 | + copyId: '', | |
| 242 | + operateType: 'ADD', | |
| 241 | 243 | form: { |
| 242 | 244 | code: '', |
| 243 | 245 | supplier: '', |
| ... | ... | @@ -292,13 +294,22 @@ export default { |
| 292 | 294 | regionOptions: [], |
| 293 | 295 | } |
| 294 | 296 | }, |
| 297 | + onLoad(query) { | |
| 298 | + const copyId = (query && query.copyId) ? String(query.copyId) : '' | |
| 299 | + this.copyId = copyId | |
| 300 | + this.operateType = copyId ? 'COPY' : 'ADD' | |
| 301 | + uni.setNavigationBarTitle({ | |
| 302 | + title: copyId ? '复制经销标准合同' : '新增经销标准合同' | |
| 303 | + }) | |
| 304 | + }, | |
| 295 | 305 | created() { |
| 296 | 306 | this.loadSuppliers() |
| 297 | 307 | this.loadExtraOptions() |
| 298 | 308 | this.initCode() |
| 299 | 309 | this.getDept() |
| 300 | 310 | this.loadRegionOptions() |
| 301 | - this.form.orderDate = this.formatDate(new Date()) | |
| 311 | + if (!this.copyId) this.form.orderDate = this.formatDate(new Date()) | |
| 312 | + if (this.copyId) this.loadCopyDetail(this.copyId) | |
| 302 | 313 | this.$nextTick(() => { |
| 303 | 314 | if (Array.isArray(this.form.destinationId) && this.form.destinationId.length) { |
| 304 | 315 | this.initDestinationLabel() |
| ... | ... | @@ -347,6 +358,83 @@ export default { |
| 347 | 358 | }, |
| 348 | 359 | }, |
| 349 | 360 | methods: { |
| 361 | + async loadCopyDetail(id) { | |
| 362 | + const rid = (id !== undefined && id !== null) ? String(id) : '' | |
| 363 | + if (!rid) return | |
| 364 | + try { | |
| 365 | + const res = await getContractApi(rid) | |
| 366 | + const data = res && res.data ? res.data : {} | |
| 367 | + const includesPackagingFeeName = data.includesPackagingFeeName || (data.includesPackagingFee ? '是' : '否') | |
| 368 | + const includesTransportFeeName = data.includesTransportFeeName || (data.includesTransportFee ? '是' : '否') | |
| 369 | + const m = { ...data, includesPackagingFeeName, includesTransportFeeName } | |
| 370 | + | |
| 371 | + const code = this.form.code | |
| 372 | + this.form = { | |
| 373 | + ...this.form, | |
| 374 | + supplier: m.supplier || '', | |
| 375 | + supplierName: m.supplierName || '', | |
| 376 | + buyer: m.buyer || (m.customer && m.customer.id) || '', | |
| 377 | + buyerName: m.buyerName || (m.customer && m.customer.name) || '', | |
| 378 | + orderDate: m.orderDate || this.form.orderDate, | |
| 379 | + deliveryDate: m.deliveryDate || '', | |
| 380 | + designatedConsignee: m.designatedConsignee || '', | |
| 381 | + specialTerms: m.specialTerms || '', | |
| 382 | + specialTermsName: m.specialTermsName || '', | |
| 383 | + executionStandard: m.executionStandard || '', | |
| 384 | + executionStandardName: m.executionStandardName || '', | |
| 385 | + executionStandardRemarks: m.executionStandardRemarks || '', | |
| 386 | + includesPackagingFee: !!m.includesPackagingFee, | |
| 387 | + includesPackagingFeeName, | |
| 388 | + includesTransportFee: !!m.includesTransportFee, | |
| 389 | + includesTransportFeeName, | |
| 390 | + unit: m.unit || this.form.unit, | |
| 391 | + totalAmountCapital: m.totalAmountCapital || '', | |
| 392 | + depositInfo: m.depositInfo || '', | |
| 393 | + packagingRequirements: m.packagingRequirements || '', | |
| 394 | + paymentTerms: m.paymentTerms || '', | |
| 395 | + transportMode: m.transportMode || '', | |
| 396 | + destinationId: (m.provinceId && m.cityId && m.districtId) ? [m.provinceId, m.cityId, m.districtId] : (Array.isArray(m.destinationId) ? m.destinationId : []), | |
| 397 | + destinationLabel: (m.provinceName && m.cityName && m.districtName) ? `${m.provinceName} / ${m.cityName} / ${m.districtName}` : (m.destinationLabel || ''), | |
| 398 | + specialInstructions: m.specialInstructions || '', | |
| 399 | + remarks: m.remarks || '', | |
| 400 | + pieceWeightHead: m.pieceWeightHead || '', | |
| 401 | + surface: m.surface || '', | |
| 402 | + tolerance: m.tolerance || '', | |
| 403 | + performance: m.performance || '', | |
| 404 | + component: m.component || '', | |
| 405 | + packaging: m.packaging || '', | |
| 406 | + workshopId: m.workshopId || '', | |
| 407 | + workshopIdName: m.workshopName || m.workshopIdName || '', | |
| 408 | + stockUpCompanyId: m.stockUpCompanyId || '', | |
| 409 | + stockUpCompanyName: m.stockUpCompanyName || '', | |
| 410 | + region: m.region || '', | |
| 411 | + regionName: m.regionName || '', | |
| 412 | + deptName: m.deptName || this.form.deptName, | |
| 413 | + deptId: m.deptId || this.form.deptId, | |
| 414 | + code, | |
| 415 | + } | |
| 416 | + | |
| 417 | + const lines = Array.isArray(m.contractDistributorLineList) ? m.contractDistributorLineList : [] | |
| 418 | + await this.$nextTick() | |
| 419 | + const comp = this.$refs.productRel | |
| 420 | + if (comp && typeof comp.defaultItem === 'function') { | |
| 421 | + const nextItems = (lines.length ? lines : [{}]).map(x => ({ | |
| 422 | + ...comp.defaultItem(), | |
| 423 | + ...x, | |
| 424 | + sampleOrder: !!x.sampleOrder, | |
| 425 | + collapsed: true | |
| 426 | + })) | |
| 427 | + if (!lines.length && nextItems[0]) nextItems[0].collapsed = false | |
| 428 | + comp.items = nextItems | |
| 429 | + if (typeof comp.recalculateAll === 'function') comp.recalculateAll() | |
| 430 | + if (typeof comp.emitChange === 'function') comp.emitChange() | |
| 431 | + } else { | |
| 432 | + this.onProductsChange(lines) | |
| 433 | + } | |
| 434 | + } catch (e) { | |
| 435 | + uni.showToast({ title: '复制失败,请稍后重试', icon: 'none' }) | |
| 436 | + } | |
| 437 | + }, | |
| 350 | 438 | async loadRegionOptions() { |
| 351 | 439 | try { |
| 352 | 440 | const res = await getArea() |
| ... | ... | @@ -552,8 +640,9 @@ export default { |
| 552 | 640 | }, |
| 553 | 641 | async onSubmit() { |
| 554 | 642 | if (!this.validateRequired()) return |
| 643 | + const isCopy = !!this.copyId | |
| 555 | 644 | const confirmRes = await new Promise(resolve => { |
| 556 | - uni.showModal({ title: '提示', content: '确定新增经销标准合同吗?', confirmText: '确定', cancelText: '取消', success: resolve }) | |
| 645 | + uni.showModal({ title: '提示', content: isCopy ? '确定复制经销标准合同吗?' : '确定新增经销标准合同吗?', confirmText: '确定', cancelText: '取消', success: resolve }) | |
| 557 | 646 | }) |
| 558 | 647 | if (!(confirmRes && confirmRes.confirm)) return |
| 559 | 648 | const clean = (obj) => { |
| ... | ... | @@ -573,6 +662,7 @@ export default { |
| 573 | 662 | const destination = destinationId && destinationId.length > 0 ? destinationId[destinationId.length - 1] : ''; |
| 574 | 663 | const payload = clean({ |
| 575 | 664 | ...formForSubmit, |
| 665 | + operateType: this.copyId ? 'COPY' : 'ADD', | |
| 576 | 666 | destination, |
| 577 | 667 | type: 'DISTRIB_STD', |
| 578 | 668 | totalQuantity: this.totalQuantity, |
| ... | ... | @@ -584,10 +674,10 @@ export default { |
| 584 | 674 | |
| 585 | 675 | try { |
| 586 | 676 | await createContractApi(payload) |
| 587 | - uni.showToast({ title: '新增成功', icon: 'none' }) | |
| 677 | + uni.showToast({ title: isCopy ? '复制成功' : '新增成功', icon: 'none' }) | |
| 588 | 678 | setTimeout(() => { uni.redirectTo({ url: '/pages/contract_retail/index' }) }, 400) |
| 589 | 679 | } catch (e) { |
| 590 | - uni.showToast({ title: e.msg ||'新增失败', icon: 'none' }) | |
| 680 | + uni.showToast({ title: e.msg || (isCopy ? '复制失败' : '新增失败'), icon: 'none' }) | |
| 591 | 681 | } |
| 592 | 682 | }, |
| 593 | 683 | validateRequired() { | ... | ... |
| ... | ... | @@ -209,6 +209,12 @@ export default { |
| 209 | 209 | visible: true, |
| 210 | 210 | event: 'auditDetail' |
| 211 | 211 | }, |
| 212 | + { | |
| 213 | + text: '复制', | |
| 214 | + visible: true, | |
| 215 | + variant: 'outline', | |
| 216 | + event: 'copy' | |
| 217 | + } | |
| 212 | 218 | ], |
| 213 | 219 | statusStyle: statusStyle, |
| 214 | 220 | dicOptions: { AUDIT_STATUS: [] } |
| ... | ... | @@ -225,6 +231,7 @@ export default { |
| 225 | 231 | { ...this.buttons[2], visible: (s !== 'DELETED' && t !== 'AUDIT' && t !== 'PASS' && this.$auth.hasPermi('contract-manage:distribution-standard-contract:upload')) }, |
| 226 | 232 | { ...this.buttons[4], visible: (s === 'STANDARD' && this.$auth.hasPermi('contract-manage:distribution-standard-contract:review')) }, |
| 227 | 233 | { ...this.buttons[3], visible: (s === 'STANDARD' && e && t === 'AUDIT' && this.$auth.hasPermi('contract-manage:distribution-standard-contract:approve')) }, |
| 234 | + { ...this.buttons[5], visible: (s !== 'DELETED' && this.$auth.hasPermi('contract-manage:distribution-standard-contract:copy')) }, | |
| 228 | 235 | ] |
| 229 | 236 | } |
| 230 | 237 | }, |
| ... | ... | @@ -363,10 +370,21 @@ export default { |
| 363 | 370 | if (e === 'upload') return this.onUpload(btn && btn.params) |
| 364 | 371 | if (e === 'audit') return this.onAudit(btn && btn.params) |
| 365 | 372 | if (e === 'auditDetail') return this.onAuditDetail(btn && btn.params) |
| 373 | + if (e === 'copy') return this.onCopy(btn && btn.params) | |
| 366 | 374 | }, |
| 367 | 375 | getBusinessId() { |
| 368 | 376 | return (this.detail && (this.detail.id || this.detail.code)) || '' |
| 369 | 377 | }, |
| 378 | + onCopy() { | |
| 379 | + const id = this.getBusinessId() | |
| 380 | + if (!id) { | |
| 381 | + uni.showToast({ title: '未获取到合同ID,无法复制', icon: 'none' }) | |
| 382 | + return | |
| 383 | + } | |
| 384 | + uni.navigateTo({ | |
| 385 | + url: '/pages/contract_retail/add?copyId=' + encodeURIComponent(id) | |
| 386 | + }) | |
| 387 | + }, | |
| 370 | 388 | onAudit() { |
| 371 | 389 | const CACHE_KEY = 'sourceBusinessId' |
| 372 | 390 | uni.setStorageSync(CACHE_KEY, this.getBusinessId()) | ... | ... |
| ... | ... | @@ -225,7 +225,7 @@ import SingleSelectSheet from '@/components/single-select/index.vue' |
| 225 | 225 | import RelateSelectSheet from '@/components/relate-select/index.vue' |
| 226 | 226 | import ProductRel from './productRel.vue' |
| 227 | 227 | import CitySelector from '@/components/city-selector/index.vue' |
| 228 | -import { getRetailCodeApi, createContractApi,getCustomerRemarks,getCustomerSpecificQualityRequirements, getDeptApi } from '@/api/contract' | |
| 228 | +import { getRetailCodeApi, createContractApi,getCustomerRemarks,getCustomerSpecificQualityRequirements, getDeptApi,getContractApi } from '@/api/contract' | |
| 229 | 229 | import { getDicByCodes } from '@/utils/dic' |
| 230 | 230 | import { formatCurrencyToChinese } from '@/utils/common' |
| 231 | 231 | import { workshopQueryApi } from '@/api/devManage' |
| ... | ... | @@ -236,6 +236,8 @@ export default { |
| 236 | 236 | components: { SingleSelectSheet, RelateSelectSheet, ProductRel, CitySelector }, |
| 237 | 237 | data() { |
| 238 | 238 | return { |
| 239 | + copyId: '', | |
| 240 | + operateType: 'ADD', | |
| 239 | 241 | form: { |
| 240 | 242 | code: '', |
| 241 | 243 | supplier: '', |
| ... | ... | @@ -290,13 +292,22 @@ export default { |
| 290 | 292 | regionOptions: [], |
| 291 | 293 | } |
| 292 | 294 | }, |
| 295 | + onLoad(query) { | |
| 296 | + const copyId = (query && query.copyId) ? String(query.copyId) : '' | |
| 297 | + this.copyId = copyId | |
| 298 | + this.operateType = copyId ? 'COPY' : 'ADD' | |
| 299 | + uni.setNavigationBarTitle({ | |
| 300 | + title: copyId ? '复制经销库存合同' : '新增经销库存合同' | |
| 301 | + }) | |
| 302 | + }, | |
| 293 | 303 | created() { |
| 294 | 304 | this.loadSuppliers() |
| 295 | 305 | this.loadExtraOptions() |
| 296 | 306 | this.initCode() |
| 297 | 307 | this.getDept() |
| 298 | 308 | this.loadRegionOptions() |
| 299 | - this.form.orderDate = this.formatDate(new Date()) | |
| 309 | + if (!this.copyId) this.form.orderDate = this.formatDate(new Date()) | |
| 310 | + if (this.copyId) this.loadCopyDetail(this.copyId) | |
| 300 | 311 | this.$nextTick(() => { |
| 301 | 312 | if (Array.isArray(this.form.destinationId) && this.form.destinationId.length) { |
| 302 | 313 | this.initDestinationLabel() |
| ... | ... | @@ -344,6 +355,83 @@ export default { |
| 344 | 355 | }, |
| 345 | 356 | }, |
| 346 | 357 | methods: { |
| 358 | + async loadCopyDetail(id) { | |
| 359 | + const rid = (id !== undefined && id !== null) ? String(id) : '' | |
| 360 | + if (!rid) return | |
| 361 | + try { | |
| 362 | + const res = await getContractApi(rid) | |
| 363 | + const data = res && res.data ? res.data : {} | |
| 364 | + const includesPackagingFeeName = data.includesPackagingFeeName || (data.includesPackagingFee ? '是' : '否') | |
| 365 | + const includesTransportFeeName = data.includesTransportFeeName || (data.includesTransportFee ? '是' : '否') | |
| 366 | + const m = { ...data, includesPackagingFeeName, includesTransportFeeName } | |
| 367 | + | |
| 368 | + const code = this.form.code | |
| 369 | + this.form = { | |
| 370 | + ...this.form, | |
| 371 | + supplier: m.supplier || '', | |
| 372 | + supplierName: m.supplierName || '', | |
| 373 | + buyer: m.buyer || (m.customer && m.customer.id) || '', | |
| 374 | + buyerName: m.buyerName || (m.customer && m.customer.name) || '', | |
| 375 | + orderDate: m.orderDate || this.form.orderDate, | |
| 376 | + deliveryDate: m.deliveryDate || '', | |
| 377 | + designatedConsignee: m.designatedConsignee || '', | |
| 378 | + specialTerms: m.specialTerms || '', | |
| 379 | + specialTermsName: m.specialTermsName || '', | |
| 380 | + executionStandard: m.executionStandard || '', | |
| 381 | + executionStandardName: m.executionStandardName || '', | |
| 382 | + executionStandardRemarks: m.executionStandardRemarks || '', | |
| 383 | + includesPackagingFee: !!m.includesPackagingFee, | |
| 384 | + includesPackagingFeeName, | |
| 385 | + includesTransportFee: !!m.includesTransportFee, | |
| 386 | + includesTransportFeeName, | |
| 387 | + unit: m.unit || this.form.unit, | |
| 388 | + totalAmountCapital: m.totalAmountCapital || '', | |
| 389 | + depositInfo: m.depositInfo || '', | |
| 390 | + packagingRequirements: m.packagingRequirements || '', | |
| 391 | + paymentTerms: m.paymentTerms || '', | |
| 392 | + transportMode: m.transportMode || '', | |
| 393 | + destinationId: (m.provinceId && m.cityId && m.districtId) ? [m.provinceId, m.cityId, m.districtId] : (Array.isArray(m.destinationId) ? m.destinationId : []), | |
| 394 | + destinationLabel: (m.provinceName && m.cityName && m.districtName) ? `${m.provinceName} / ${m.cityName} / ${m.districtName}` : (m.destinationLabel || ''), | |
| 395 | + specialInstructions: m.specialInstructions || '', | |
| 396 | + remarks: m.remarks || '', | |
| 397 | + pieceWeightHead: m.pieceWeightHead || '', | |
| 398 | + surface: m.surface || '', | |
| 399 | + tolerance: m.tolerance || '', | |
| 400 | + performance: m.performance || '', | |
| 401 | + component: m.component || '', | |
| 402 | + packaging: m.packaging || '', | |
| 403 | + workshopId: m.workshopId || '', | |
| 404 | + workshopIdName: m.workshopName || m.workshopIdName || '', | |
| 405 | + stockUpCompanyId: m.stockUpCompanyId || '', | |
| 406 | + stockUpCompanyName: m.stockUpCompanyName || '', | |
| 407 | + region: m.region || '', | |
| 408 | + regionName: m.regionName || '', | |
| 409 | + deptName: m.deptName || this.form.deptName, | |
| 410 | + deptId: m.deptId || this.form.deptId, | |
| 411 | + code, | |
| 412 | + } | |
| 413 | + | |
| 414 | + const lines = Array.isArray(m.contractDistributorLineList) ? m.contractDistributorLineList : [] | |
| 415 | + await this.$nextTick() | |
| 416 | + const comp = this.$refs.productRel | |
| 417 | + if (comp && typeof comp.defaultItem === 'function') { | |
| 418 | + const nextItems = (lines.length ? lines : [{}]).map(x => ({ | |
| 419 | + ...comp.defaultItem(), | |
| 420 | + ...x, | |
| 421 | + sampleOrder: !!x.sampleOrder, | |
| 422 | + collapsed: true | |
| 423 | + })) | |
| 424 | + if (!lines.length && nextItems[0]) nextItems[0].collapsed = false | |
| 425 | + comp.items = nextItems | |
| 426 | + if (typeof comp.recalculateAll === 'function') comp.recalculateAll() | |
| 427 | + if (typeof comp.emitChange === 'function') comp.emitChange() | |
| 428 | + } else { | |
| 429 | + this.onProductsChange(lines) | |
| 430 | + } | |
| 431 | + } catch (e) { | |
| 432 | + uni.showToast({ title: '复制失败,请稍后重试', icon: 'none' }) | |
| 433 | + } | |
| 434 | + }, | |
| 347 | 435 | async loadRegionOptions() { |
| 348 | 436 | try { |
| 349 | 437 | const res = await getArea() |
| ... | ... | @@ -549,8 +637,9 @@ export default { |
| 549 | 637 | }, |
| 550 | 638 | async onSubmit() { |
| 551 | 639 | if (!this.validateRequired()) return |
| 640 | + const isCopy = !!this.copyId | |
| 552 | 641 | const confirmRes = await new Promise(resolve => { |
| 553 | - uni.showModal({ title: '提示', content: '确定新增经销库存合同吗?', confirmText: '确定', cancelText: '取消', success: resolve }) | |
| 642 | + uni.showModal({ title: '提示', content: isCopy ? '确定复制经销库存合同吗?' : '确定新增经销库存合同吗?', confirmText: '确定', cancelText: '取消', success: resolve }) | |
| 554 | 643 | }) |
| 555 | 644 | if (!(confirmRes && confirmRes.confirm)) return |
| 556 | 645 | const clean = (obj) => { |
| ... | ... | @@ -570,6 +659,7 @@ export default { |
| 570 | 659 | const destination = destinationId && destinationId.length > 0 ? destinationId[destinationId.length - 1] : ''; |
| 571 | 660 | const payload = clean({ |
| 572 | 661 | ...formForSubmit, |
| 662 | + operateType: this.copyId ? 'COPY' : 'ADD', | |
| 573 | 663 | destination, |
| 574 | 664 | type: 'DIST_STOCK_CONTRACT', |
| 575 | 665 | totalQuantity: this.totalQuantity, |
| ... | ... | @@ -581,10 +671,10 @@ export default { |
| 581 | 671 | |
| 582 | 672 | try { |
| 583 | 673 | await createContractApi(payload) |
| 584 | - uni.showToast({ title: '新增成功', icon: 'none' }) | |
| 674 | + uni.showToast({ title: isCopy ? '复制成功' : '新增成功', icon: 'none' }) | |
| 585 | 675 | setTimeout(() => { uni.redirectTo({ url: '/pages/contract_stock/index' }) }, 400) |
| 586 | 676 | } catch (e) { |
| 587 | - uni.showToast({ title: e.msg ||'新增失败', icon: 'none' }) | |
| 677 | + uni.showToast({ title: e.msg || (isCopy ? '复制失败' : '新增失败'), icon: 'none' }) | |
| 588 | 678 | } |
| 589 | 679 | }, |
| 590 | 680 | validateRequired() { | ... | ... |
| ... | ... | @@ -266,6 +266,12 @@ export default { |
| 266 | 266 | visible: true, |
| 267 | 267 | event: 'auditDetail3' |
| 268 | 268 | }, |
| 269 | + { | |
| 270 | + text: '复制', | |
| 271 | + visible: true, | |
| 272 | + variant: 'outline', | |
| 273 | + event: 'copy' | |
| 274 | + } | |
| 269 | 275 | ], |
| 270 | 276 | uploadId: '', |
| 271 | 277 | uploadType: 'formal', |
| ... | ... | @@ -292,6 +298,7 @@ export default { |
| 292 | 298 | { ...this.buttons[6], visible: (s === 'FORMAL' && e && t === 'AUDIT' && this.$auth.hasPermi('contract-manage:distribution-inventory-contract:approve')) }, |
| 293 | 299 | { ...this.buttons[7], visible: (s === 'STANDARD' && e && t === 'AUDIT' && this.$auth.hasPermi('contract-manage:distribution-inventory-contract:approve')) }, |
| 294 | 300 | { ...this.buttons[8], visible: (s === 'STANDARD' && f && a === 'AUDIT' && this.$auth.hasPermi('contract-manage:distribution-inventory-contract:standard-approve')) }, |
| 301 | + { ...this.buttons[12], visible: (s !== 'DELETED' && this.$auth.hasPermi('contract-manage:distribution-inventory-contract:copy')) }, | |
| 295 | 302 | ] |
| 296 | 303 | } |
| 297 | 304 | }, |
| ... | ... | @@ -426,6 +433,8 @@ export default { |
| 426 | 433 | if (e === 'auditDetail1') return this.onAuditDetail(this.detail.id || '', 'FORMAL_CONTRACT') |
| 427 | 434 | if (e === 'auditDetail2') return this.onAuditDetail(this.detail.parentId || '', 'FORMAL_CONTRACT') |
| 428 | 435 | if (e === 'auditDetail3') return this.onAuditDetail(this.detail.id || '', 'STANDARD_CONTRACT') |
| 436 | + if (e === 'copy') return this.onCopy(btn && btn.params) | |
| 437 | + | |
| 429 | 438 | }, |
| 430 | 439 | onAudit(id, type) { |
| 431 | 440 | const CACHE_KEY = 'sourceBusinessId' |
| ... | ... | @@ -434,6 +443,11 @@ export default { |
| 434 | 443 | uni.setStorageSync(CACHE_KEY, id) |
| 435 | 444 | uni.navigateTo({ url: '/pages/flow/audit' }) |
| 436 | 445 | }, |
| 446 | + onCopy(params) { | |
| 447 | + uni.navigateTo({ | |
| 448 | + url: '/pages/contract_stock/add?id=' + encodeURIComponent(params.id) || '' | |
| 449 | + }) | |
| 450 | + }, | |
| 437 | 451 | onAuditDetail(id, type) { |
| 438 | 452 | const CACHE_KEY = 'sourceBusinessId' |
| 439 | 453 | const TYPE = 'contractType' | ... | ... |
| ... | ... | @@ -227,7 +227,7 @@ import SingleSelectSheet from '@/components/single-select/index.vue' |
| 227 | 227 | import RelateSelectSheet from '@/components/relate-select/index.vue' |
| 228 | 228 | import ProductRel from './productRel.vue' |
| 229 | 229 | import CitySelector from '@/components/city-selector/index.vue' |
| 230 | -import { getRetailCodeApi, createContractApi, getCustomerRemarks,getCustomerSpecificQualityRequirements, getDeptApi } from '@/api/contract' | |
| 230 | +import { getRetailCodeApi, createContractApi, getCustomerRemarks, getCustomerSpecificQualityRequirements, getDeptApi, getContractApi } from '@/api/contract' | |
| 231 | 231 | import { getDicByCodes } from '@/utils/dic' |
| 232 | 232 | import { formatCurrencyToChinese } from '@/utils/common' |
| 233 | 233 | import { workshopQueryApi } from '@/api/devManage' |
| ... | ... | @@ -238,6 +238,8 @@ export default { |
| 238 | 238 | components: { SingleSelectSheet, RelateSelectSheet, ProductRel, CitySelector }, |
| 239 | 239 | data() { |
| 240 | 240 | return { |
| 241 | + copyId: '', | |
| 242 | + operateType: 'ADD', | |
| 241 | 243 | form: { |
| 242 | 244 | code: '', |
| 243 | 245 | supplier: '', |
| ... | ... | @@ -292,13 +294,22 @@ export default { |
| 292 | 294 | regionOptions: [], |
| 293 | 295 | } |
| 294 | 296 | }, |
| 297 | + onLoad(query) { | |
| 298 | + const copyId = (query && query.copyId) ? String(query.copyId) : '' | |
| 299 | + this.copyId = copyId | |
| 300 | + this.operateType = copyId ? 'COPY' : 'ADD' | |
| 301 | + uni.setNavigationBarTitle({ | |
| 302 | + title: copyId ? '复制经销未锁规合同' : '新增经销未锁规合同' | |
| 303 | + }) | |
| 304 | + }, | |
| 295 | 305 | created() { |
| 296 | 306 | this.loadSuppliers() |
| 297 | 307 | this.loadExtraOptions() |
| 298 | 308 | this.initCode() |
| 299 | 309 | this.getDept() |
| 300 | 310 | this.loadRegionOptions() |
| 301 | - this.form.orderDate = this.formatDate(new Date()) | |
| 311 | + if (!this.copyId) this.form.orderDate = this.formatDate(new Date()) | |
| 312 | + if (this.copyId) this.loadCopyDetail(this.copyId) | |
| 302 | 313 | this.$nextTick(() => { |
| 303 | 314 | if (Array.isArray(this.form.destinationId) && this.form.destinationId.length) { |
| 304 | 315 | this.initDestinationLabel() |
| ... | ... | @@ -348,6 +359,83 @@ export default { |
| 348 | 359 | }, |
| 349 | 360 | }, |
| 350 | 361 | methods: { |
| 362 | + async loadCopyDetail(id) { | |
| 363 | + const rid = (id !== undefined && id !== null) ? String(id) : '' | |
| 364 | + if (!rid) return | |
| 365 | + try { | |
| 366 | + const res = await getContractApi(rid) | |
| 367 | + const data = res && res.data ? res.data : {} | |
| 368 | + const includesPackagingFeeName = data.includesPackagingFeeName || (data.includesPackagingFee ? '是' : '否') | |
| 369 | + const includesTransportFeeName = data.includesTransportFeeName || (data.includesTransportFee ? '是' : '否') | |
| 370 | + const m = { ...data, includesPackagingFeeName, includesTransportFeeName } | |
| 371 | + | |
| 372 | + const code = this.form.code | |
| 373 | + this.form = { | |
| 374 | + ...this.form, | |
| 375 | + supplier: m.supplier || '', | |
| 376 | + supplierName: m.supplierName || '', | |
| 377 | + buyer: m.buyer || (m.customer && m.customer.id) || '', | |
| 378 | + buyerName: m.buyerName || (m.customer && m.customer.name) || '', | |
| 379 | + stockUpCompanyId: m.stockUpCompanyId || '', | |
| 380 | + stockUpCompanyName: m.stockUpCompanyName || '', | |
| 381 | + deptName: m.deptName || this.form.deptName, | |
| 382 | + deptId: m.deptId || this.form.deptId, | |
| 383 | + region: m.region || '', | |
| 384 | + regionName: m.regionName || '', | |
| 385 | + orderDate: m.orderDate || this.form.orderDate, | |
| 386 | + deliveryDate: m.deliveryDate || '', | |
| 387 | + designatedConsignee: m.designatedConsignee || '', | |
| 388 | + specialTerms: m.specialTerms || '', | |
| 389 | + specialTermsName: m.specialTermsName || '', | |
| 390 | + executionStandard: m.executionStandard || '', | |
| 391 | + executionStandardName: m.executionStandardName || '', | |
| 392 | + executionStandardRemarks: m.executionStandardRemarks || '', | |
| 393 | + includesPackagingFee: !!m.includesPackagingFee, | |
| 394 | + includesPackagingFeeName, | |
| 395 | + includesTransportFee: !!m.includesTransportFee, | |
| 396 | + includesTransportFeeName, | |
| 397 | + unit: m.unit || this.form.unit, | |
| 398 | + totalAmountCapital: m.totalAmountCapital || '', | |
| 399 | + depositInfo: m.depositInfo || '', | |
| 400 | + packagingRequirements: m.packagingRequirements || '', | |
| 401 | + paymentTerms: m.paymentTerms || '', | |
| 402 | + transportMode: m.transportMode || '', | |
| 403 | + destinationId: (m.provinceId && m.cityId && m.districtId) ? [m.provinceId, m.cityId, m.districtId] : (Array.isArray(m.destinationId) ? m.destinationId : []), | |
| 404 | + destinationLabel: (m.provinceName && m.cityName && m.districtName) ? `${m.provinceName} / ${m.cityName} / ${m.districtName}` : (m.destinationLabel || ''), | |
| 405 | + specialInstructions: m.specialInstructions || '', | |
| 406 | + remarks: m.remarks || '', | |
| 407 | + pieceWeightHead: m.pieceWeightHead || '', | |
| 408 | + surface: m.surface || '', | |
| 409 | + tolerance: m.tolerance || '', | |
| 410 | + performance: m.performance || '', | |
| 411 | + component: m.component || '', | |
| 412 | + packaging: m.packaging || '', | |
| 413 | + workshopId: m.workshopId || '', | |
| 414 | + workshopIdName: m.workshopName || m.workshopIdName || '', | |
| 415 | + code, | |
| 416 | + } | |
| 417 | + | |
| 418 | + const lines = Array.isArray(m.contractDistributorLineList) ? m.contractDistributorLineList : [] | |
| 419 | + await this.$nextTick() | |
| 420 | + const comp = this.$refs.productRel | |
| 421 | + if (comp && typeof comp.defaultItem === 'function') { | |
| 422 | + const nextItems = (lines.length ? lines : [{}]).map(x => ({ | |
| 423 | + ...comp.defaultItem(), | |
| 424 | + ...x, | |
| 425 | + sampleOrder: !!x.sampleOrder, | |
| 426 | + collapsed: true | |
| 427 | + })) | |
| 428 | + if (!lines.length && nextItems[0]) nextItems[0].collapsed = false | |
| 429 | + comp.items = nextItems | |
| 430 | + if (typeof comp.recalculateAll === 'function') comp.recalculateAll() | |
| 431 | + if (typeof comp.emitChange === 'function') comp.emitChange() | |
| 432 | + } else { | |
| 433 | + this.onProductsChange(lines) | |
| 434 | + } | |
| 435 | + } catch (e) { | |
| 436 | + uni.showToast({ title: '复制失败,请稍后重试', icon: 'none' }) | |
| 437 | + } | |
| 438 | + }, | |
| 351 | 439 | async loadRegionOptions() { |
| 352 | 440 | try { |
| 353 | 441 | const res = await getArea() |
| ... | ... | @@ -553,8 +641,9 @@ export default { |
| 553 | 641 | }, |
| 554 | 642 | async onSubmit() { |
| 555 | 643 | if (!this.validateRequired()) return |
| 644 | + const isCopy = !!this.copyId | |
| 556 | 645 | const confirmRes = await new Promise(resolve => { |
| 557 | - uni.showModal({ title: '提示', content: '确定新增经销未锁规合同吗?', confirmText: '确定', cancelText: '取消', success: resolve }) | |
| 646 | + uni.showModal({ title: '提示', content: isCopy ? '确定复制经销未锁规合同吗?' : '确定新增经销未锁规合同吗?', confirmText: '确定', cancelText: '取消', success: resolve }) | |
| 558 | 647 | }) |
| 559 | 648 | if (!(confirmRes && confirmRes.confirm)) return |
| 560 | 649 | const clean = (obj) => { |
| ... | ... | @@ -574,6 +663,7 @@ export default { |
| 574 | 663 | const destination = destinationId && destinationId.length > 0 ? destinationId[destinationId.length - 1] : ''; |
| 575 | 664 | const payload = clean({ |
| 576 | 665 | ...formForSubmit, |
| 666 | + operateType: isCopy ? 'COPY' : 'ADD', | |
| 577 | 667 | destination, |
| 578 | 668 | type: 'DRAFT_DIST_AGMT', |
| 579 | 669 | totalQuantity: this.totalQuantity, |
| ... | ... | @@ -585,10 +675,10 @@ export default { |
| 585 | 675 | |
| 586 | 676 | try { |
| 587 | 677 | await createContractApi(payload) |
| 588 | - uni.showToast({ title: '新增成功', icon: 'none' }) | |
| 678 | + uni.showToast({ title: isCopy ? '复制成功' : '新增成功', icon: 'none' }) | |
| 589 | 679 | setTimeout(() => { uni.redirectTo({ url: '/pages/contract_unplan/index' }) }, 400) |
| 590 | 680 | } catch (e) { |
| 591 | - uni.showToast({ title: e.msg ||'新增失败', icon: 'none' }) | |
| 681 | + uni.showToast({ title: e.msg || (isCopy ? '复制失败' : '新增失败'), icon: 'none' }) | |
| 592 | 682 | } |
| 593 | 683 | }, |
| 594 | 684 | validateRequired() { | ... | ... |
| ... | ... | @@ -271,6 +271,12 @@ export default { |
| 271 | 271 | visible: true, |
| 272 | 272 | event: 'auditDetail3' |
| 273 | 273 | }, |
| 274 | + { | |
| 275 | + text: '复制', | |
| 276 | + visible: true, | |
| 277 | + variant: 'outline', | |
| 278 | + event: 'copy' | |
| 279 | + }, | |
| 274 | 280 | ], |
| 275 | 281 | } |
| 276 | 282 | }, |
| ... | ... | @@ -296,6 +302,7 @@ export default { |
| 296 | 302 | { ...this.buttons[7], visible: (s === 'FORMAL' && e && t === 'AUDIT' && this.$auth.hasPermi('contract-manage:distribution-unlocked-contract:approve')) }, |
| 297 | 303 | { ...this.buttons[8], visible: (s === 'STANDARD' && e && t === 'AUDIT' && this.$auth.hasPermi('contract-manage:distribution-unlocked-contract:approve')) }, |
| 298 | 304 | { ...this.buttons[9], visible: (s === 'STANDARD' && f && a === 'AUDIT' && this.$auth.hasPermi('contract-manage:distribution-unlocked-contract:standard-approve')) }, |
| 305 | + { ...this.buttons[13], visible: (s !== 'DELETED' && this.$auth.hasPermi('contract-manage:distribution-unlocked-contract:copy')) }, | |
| 299 | 306 | ] |
| 300 | 307 | } |
| 301 | 308 | }, |
| ... | ... | @@ -445,6 +452,20 @@ export default { |
| 445 | 452 | if (e === 'auditDetail1') return this.onAuditDetail(this.detail.id || '', 'FORMAL_CONTRACT') |
| 446 | 453 | if (e === 'auditDetail2') return this.onAuditDetail(this.detail.parentId || '', 'FORMAL_CONTRACT') |
| 447 | 454 | if (e === 'auditDetail3') return this.onAuditDetail(this.detail.id || '', 'STANDARD_CONTRACT') |
| 455 | + if (e === 'copy') return this.onCopy(btn && btn.params) | |
| 456 | + }, | |
| 457 | + getBusinessId() { | |
| 458 | + return (this.detail && (this.detail.id || this.detail.code)) || '' | |
| 459 | + }, | |
| 460 | + onCopy() { | |
| 461 | + const id = this.getBusinessId() | |
| 462 | + if (!id) { | |
| 463 | + uni.showToast({ title: '未获取到合同ID,无法复制', icon: 'none' }) | |
| 464 | + return | |
| 465 | + } | |
| 466 | + uni.navigateTo({ | |
| 467 | + url: '/pages/contract_unplan/add?copyId=' + encodeURIComponent(id) | |
| 468 | + }) | |
| 448 | 469 | }, |
| 449 | 470 | onAudit(id, type) { |
| 450 | 471 | const CACHE_KEY = 'sourceBusinessId' | ... | ... |