Showing
14 changed files
with
802 additions
and
39 deletions
| @@ -230,7 +230,7 @@ import SingleSelectSheet from '@/components/single-select/index.vue' | @@ -230,7 +230,7 @@ import SingleSelectSheet from '@/components/single-select/index.vue' | ||
| 230 | import RelateSelectSheet from '@/components/relate-select/index.vue' | 230 | import RelateSelectSheet from '@/components/relate-select/index.vue' |
| 231 | import ProductRel from './productRel.vue' | 231 | import ProductRel from './productRel.vue' |
| 232 | import CitySelector from '@/components/city-selector/index.vue' | 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 | import { getDicByCodes } from '@/utils/dic' | 234 | import { getDicByCodes } from '@/utils/dic' |
| 235 | import { formatCurrencyToChinese } from '@/utils/common' | 235 | import { formatCurrencyToChinese } from '@/utils/common' |
| 236 | import { workshopQueryApi } from '@/api/devManage' | 236 | import { workshopQueryApi } from '@/api/devManage' |
| @@ -242,6 +242,8 @@ export default { | @@ -242,6 +242,8 @@ export default { | ||
| 242 | components: { SingleSelectSheet, RelateSelectSheet, ProductRel, CitySelector }, | 242 | components: { SingleSelectSheet, RelateSelectSheet, ProductRel, CitySelector }, |
| 243 | data() { | 243 | data() { |
| 244 | return { | 244 | return { |
| 245 | + copyId: '', | ||
| 246 | + operateType: 'ADD', | ||
| 245 | form: { | 247 | form: { |
| 246 | code: '', | 248 | code: '', |
| 247 | supplier: '', | 249 | supplier: '', |
| @@ -296,13 +298,22 @@ export default { | @@ -296,13 +298,22 @@ export default { | ||
| 296 | regionOptions: [], | 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 | created() { | 309 | created() { |
| 300 | this.loadSuppliers() | 310 | this.loadSuppliers() |
| 301 | this.loadExtraOptions() | 311 | this.loadExtraOptions() |
| 302 | this.initCode() | 312 | this.initCode() |
| 303 | this.getDept() | 313 | this.getDept() |
| 304 | this.loadRegionOptions() | 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 | this.$nextTick(() => { | 317 | this.$nextTick(() => { |
| 307 | if (Array.isArray(this.form.destinationId) && this.form.destinationId.length) { | 318 | if (Array.isArray(this.form.destinationId) && this.form.destinationId.length) { |
| 308 | this.initDestinationLabel() | 319 | this.initDestinationLabel() |
| @@ -351,6 +362,83 @@ export default { | @@ -351,6 +362,83 @@ export default { | ||
| 351 | }, | 362 | }, |
| 352 | }, | 363 | }, |
| 353 | methods: { | 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 | async loadRegionOptions() { | 442 | async loadRegionOptions() { |
| 355 | try { | 443 | try { |
| 356 | const res = await getArea() | 444 | const res = await getArea() |
| @@ -554,8 +642,9 @@ export default { | @@ -554,8 +642,9 @@ export default { | ||
| 554 | }, | 642 | }, |
| 555 | async onSubmit() { | 643 | async onSubmit() { |
| 556 | if (!this.validateRequired()) return | 644 | if (!this.validateRequired()) return |
| 645 | + const isCopy = !!this.copyId | ||
| 557 | const confirmRes = await new Promise(resolve => { | 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 | if (!(confirmRes && confirmRes.confirm)) return | 649 | if (!(confirmRes && confirmRes.confirm)) return |
| 561 | const clean = (obj) => { | 650 | const clean = (obj) => { |
| @@ -575,6 +664,7 @@ export default { | @@ -575,6 +664,7 @@ export default { | ||
| 575 | const destination = destinationId && destinationId.length > 0 ? destinationId[destinationId.length - 1] : ''; | 664 | const destination = destinationId && destinationId.length > 0 ? destinationId[destinationId.length - 1] : ''; |
| 576 | const payload = clean({ | 665 | const payload = clean({ |
| 577 | ...formForSubmit, | 666 | ...formForSubmit, |
| 667 | + operateType: isCopy ? 'COPY' : 'ADD', | ||
| 578 | destination, | 668 | destination, |
| 579 | type: 'INTL_STD_CONTRACT', | 669 | type: 'INTL_STD_CONTRACT', |
| 580 | totalQuantity: this.totalQuantity, | 670 | totalQuantity: this.totalQuantity, |
| @@ -586,10 +676,10 @@ export default { | @@ -586,10 +676,10 @@ export default { | ||
| 586 | 676 | ||
| 587 | try { | 677 | try { |
| 588 | await createContractApi(payload) | 678 | await createContractApi(payload) |
| 589 | - uni.showToast({ title: '新增成功', icon: 'none' }) | 679 | + uni.showToast({ title: isCopy ? '复制成功' : '新增成功', icon: 'none' }) |
| 590 | setTimeout(() => { uni.redirectTo({ url: '/pages/contract_foreign_std/index' }) }, 400) | 680 | setTimeout(() => { uni.redirectTo({ url: '/pages/contract_foreign_std/index' }) }, 400) |
| 591 | } catch (e) { | 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 | validateRequired() { | 685 | validateRequired() { |
| @@ -219,6 +219,12 @@ export default { | @@ -219,6 +219,12 @@ export default { | ||
| 219 | visible: true, | 219 | visible: true, |
| 220 | event: 'auditDetail' | 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,6 +240,7 @@ export default { | ||
| 234 | { ...this.buttons[3], visible: (s === 'STANDARD' && this.$auth.hasPermi('contract-manage:foreign-trade-standard-contract:upload-seal')) }, | 240 | { ...this.buttons[3], visible: (s === 'STANDARD' && this.$auth.hasPermi('contract-manage:foreign-trade-standard-contract:upload-seal')) }, |
| 235 | { ...this.buttons[5], visible: (s === 'STANDARD' && this.$auth.hasPermi('contract-manage:foreign-trade-standard-contract:review')) }, | 241 | { ...this.buttons[5], visible: (s === 'STANDARD' && this.$auth.hasPermi('contract-manage:foreign-trade-standard-contract:review')) }, |
| 236 | { ...this.buttons[4], visible: (s === 'STANDARD' && e && t === 'AUDIT' && this.$auth.hasPermi('contract-manage:foreign-trade-standard-contract:approve')) }, | 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,10 +370,21 @@ export default { | ||
| 363 | if (e === 'uploadSeal') return this.uploadContract(this.detail.id || '', 'seal') | 370 | if (e === 'uploadSeal') return this.uploadContract(this.detail.id || '', 'seal') |
| 364 | if (e === 'audit') return this.onAudit(btn && btn.params) | 371 | if (e === 'audit') return this.onAudit(btn && btn.params) |
| 365 | if (e === 'auditDetail') return this.onAuditDetail(btn && btn.params) | 372 | if (e === 'auditDetail') return this.onAuditDetail(btn && btn.params) |
| 373 | + if (e === 'copy') return this.onCopy(btn && btn.params) | ||
| 366 | }, | 374 | }, |
| 367 | getBusinessId() { | 375 | getBusinessId() { |
| 368 | return (this.detail && (this.detail.id || this.detail.code)) || '' | 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 | onAudit() { | 388 | onAudit() { |
| 371 | const CACHE_KEY = 'sourceBusinessId' | 389 | const CACHE_KEY = 'sourceBusinessId' |
| 372 | uni.setStorageSync(CACHE_KEY, this.getBusinessId()) | 390 | uni.setStorageSync(CACHE_KEY, this.getBusinessId()) |
| @@ -566,4 +584,4 @@ export default { | @@ -566,4 +584,4 @@ export default { | ||
| 566 | .upload-row { | 584 | .upload-row { |
| 567 | margin-top: 20rpx; | 585 | margin-top: 20rpx; |
| 568 | } | 586 | } |
| 569 | -</style> | ||
| 587 | +</style> |
| @@ -233,7 +233,7 @@ import SingleSelectSheet from '@/components/single-select/index.vue' | @@ -233,7 +233,7 @@ import SingleSelectSheet from '@/components/single-select/index.vue' | ||
| 233 | import RelateSelectSheet from '@/components/relate-select/index.vue' | 233 | import RelateSelectSheet from '@/components/relate-select/index.vue' |
| 234 | import ProductRel from './productRel.vue' | 234 | import ProductRel from './productRel.vue' |
| 235 | import CitySelector from '@/components/city-selector/index.vue' | 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 | import { getDicByCodes } from '@/utils/dic' | 237 | import { getDicByCodes } from '@/utils/dic' |
| 238 | import { formatCurrencyToChinese } from '@/utils/common' | 238 | import { formatCurrencyToChinese } from '@/utils/common' |
| 239 | import { workshopQueryApi } from '@/api/devManage' | 239 | import { workshopQueryApi } from '@/api/devManage' |
| @@ -244,6 +244,8 @@ export default { | @@ -244,6 +244,8 @@ export default { | ||
| 244 | components: { SingleSelectSheet, RelateSelectSheet, ProductRel, CitySelector }, | 244 | components: { SingleSelectSheet, RelateSelectSheet, ProductRel, CitySelector }, |
| 245 | data() { | 245 | data() { |
| 246 | return { | 246 | return { |
| 247 | + copyId: '', | ||
| 248 | + operateType: 'ADD', | ||
| 247 | form: { | 249 | form: { |
| 248 | code: '', | 250 | code: '', |
| 249 | supplier: '', | 251 | supplier: '', |
| @@ -298,13 +300,22 @@ export default { | @@ -298,13 +300,22 @@ export default { | ||
| 298 | regionOptions: [], | 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 | created() { | 311 | created() { |
| 302 | this.loadSuppliers() | 312 | this.loadSuppliers() |
| 303 | this.loadExtraOptions() | 313 | this.loadExtraOptions() |
| 304 | this.initCode() | 314 | this.initCode() |
| 305 | this.getDept() | 315 | this.getDept() |
| 306 | this.loadRegionOptions() | 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 | this.$nextTick(() => { | 319 | this.$nextTick(() => { |
| 309 | if (Array.isArray(this.form.destinationId) && this.form.destinationId.length) { | 320 | if (Array.isArray(this.form.destinationId) && this.form.destinationId.length) { |
| 310 | this.initDestinationLabel() | 321 | this.initDestinationLabel() |
| @@ -353,6 +364,82 @@ export default { | @@ -353,6 +364,82 @@ export default { | ||
| 353 | }, | 364 | }, |
| 354 | }, | 365 | }, |
| 355 | methods: { | 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 | async loadRegionOptions() { | 443 | async loadRegionOptions() { |
| 357 | try { | 444 | try { |
| 358 | const res = await getArea() | 445 | const res = await getArea() |
| @@ -558,8 +645,9 @@ export default { | @@ -558,8 +645,9 @@ export default { | ||
| 558 | }, | 645 | }, |
| 559 | async onSubmit() { | 646 | async onSubmit() { |
| 560 | if (!this.validateRequired()) return | 647 | if (!this.validateRequired()) return |
| 648 | + const isCopy = !!this.copyId | ||
| 561 | const confirmRes = await new Promise(resolve => { | 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 | if (!(confirmRes && confirmRes.confirm)) return | 652 | if (!(confirmRes && confirmRes.confirm)) return |
| 565 | const clean = (obj) => { | 653 | const clean = (obj) => { |
| @@ -579,6 +667,7 @@ export default { | @@ -579,6 +667,7 @@ export default { | ||
| 579 | const destination = destinationId && destinationId.length > 0 ? destinationId[destinationId.length - 1] : ''; | 667 | const destination = destinationId && destinationId.length > 0 ? destinationId[destinationId.length - 1] : ''; |
| 580 | const payload = clean({ | 668 | const payload = clean({ |
| 581 | ...formForSubmit, | 669 | ...formForSubmit, |
| 670 | + operateType: isCopy ? 'COPY' : 'ADD', | ||
| 582 | destination, | 671 | destination, |
| 583 | type: 'INTL_INVENTORY_AGMT', | 672 | type: 'INTL_INVENTORY_AGMT', |
| 584 | totalQuantity: this.totalQuantity, | 673 | totalQuantity: this.totalQuantity, |
| @@ -590,10 +679,10 @@ export default { | @@ -590,10 +679,10 @@ export default { | ||
| 590 | 679 | ||
| 591 | try { | 680 | try { |
| 592 | await createContractApi(payload) | 681 | await createContractApi(payload) |
| 593 | - uni.showToast({ title: '新增成功', icon: 'none' }) | 682 | + uni.showToast({ title: isCopy ? '复制成功' : '新增成功', icon: 'none' }) |
| 594 | setTimeout(() => { uni.redirectTo({ url: '/pages/contract_foreign_stock/index' }) }, 400) | 683 | setTimeout(() => { uni.redirectTo({ url: '/pages/contract_foreign_stock/index' }) }, 400) |
| 595 | } catch (e) { | 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 | validateRequired() { | 688 | validateRequired() { |
| @@ -279,6 +279,12 @@ export default { | @@ -279,6 +279,12 @@ export default { | ||
| 279 | variant: 'outline', | 279 | variant: 'outline', |
| 280 | event: 'uploadSeal' | 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,6 +310,7 @@ export default { | ||
| 304 | { ...this.buttons[6], visible: (s === 'FORMAL' && e && t === 'AUDIT' && this.$auth.hasPermi('contract-manage:foreign-trade-inventory-contract:approve')) }, | 310 | { ...this.buttons[6], visible: (s === 'FORMAL' && e && t === 'AUDIT' && this.$auth.hasPermi('contract-manage:foreign-trade-inventory-contract:approve')) }, |
| 305 | { ...this.buttons[7], visible: (s === 'STANDARD' && e && t === 'AUDIT' && this.$auth.hasPermi('contract-manage:foreign-trade-inventory-contract:approve')) }, | 311 | { ...this.buttons[7], visible: (s === 'STANDARD' && e && t === 'AUDIT' && this.$auth.hasPermi('contract-manage:foreign-trade-inventory-contract:approve')) }, |
| 306 | { ...this.buttons[8], visible: (s === 'STANDARD' && f && a === 'AUDIT' && this.$auth.hasPermi('contract-manage:foreign-trade-inventory-contract:standard-approve')) }, | 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,8 +458,22 @@ export default { | ||
| 451 | if (e === 'auditDetail2') return this.onAuditDetail(this.detail.parentId || '', 'FORMAL_CONTRACT') | 458 | if (e === 'auditDetail2') return this.onAuditDetail(this.detail.parentId || '', 'FORMAL_CONTRACT') |
| 452 | if (e === 'auditDetail3') return this.onAuditDetail(this.detail.id || '', 'STANDARD_CONTRACT') | 459 | if (e === 'auditDetail3') return this.onAuditDetail(this.detail.id || '', 'STANDARD_CONTRACT') |
| 453 | if (e === 'uploadSeal') return this.uploadContract(this.detail.id || '', 'seal') | 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 | onAudit(id, type) { | 477 | onAudit(id, type) { |
| 457 | const CACHE_KEY = 'sourceBusinessId' | 478 | const CACHE_KEY = 'sourceBusinessId' |
| 458 | const TYPE = 'contractType' | 479 | const TYPE = 'contractType' |
| @@ -655,4 +676,4 @@ export default { | @@ -655,4 +676,4 @@ export default { | ||
| 655 | .upload-row { | 676 | .upload-row { |
| 656 | margin-top: 20rpx; | 677 | margin-top: 20rpx; |
| 657 | } | 678 | } |
| 658 | -</style> | ||
| 679 | +</style> |
| @@ -231,7 +231,7 @@ import SingleSelectSheet from '@/components/single-select/index.vue' | @@ -231,7 +231,7 @@ import SingleSelectSheet from '@/components/single-select/index.vue' | ||
| 231 | import RelateSelectSheet from '@/components/relate-select/index.vue' | 231 | import RelateSelectSheet from '@/components/relate-select/index.vue' |
| 232 | import ProductRel from './productRel.vue' | 232 | import ProductRel from './productRel.vue' |
| 233 | import CitySelector from '@/components/city-selector/index.vue' | 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 | import { getDicByCodes } from '@/utils/dic' | 235 | import { getDicByCodes } from '@/utils/dic' |
| 236 | import { formatCurrencyToChinese } from '@/utils/common' | 236 | import { formatCurrencyToChinese } from '@/utils/common' |
| 237 | import { workshopQueryApi } from '@/api/devManage' | 237 | import { workshopQueryApi } from '@/api/devManage' |
| @@ -242,6 +242,8 @@ export default { | @@ -242,6 +242,8 @@ export default { | ||
| 242 | components: { SingleSelectSheet, RelateSelectSheet, ProductRel, CitySelector }, | 242 | components: { SingleSelectSheet, RelateSelectSheet, ProductRel, CitySelector }, |
| 243 | data() { | 243 | data() { |
| 244 | return { | 244 | return { |
| 245 | + copyId: '', | ||
| 246 | + operateType: 'ADD', | ||
| 245 | form: { | 247 | form: { |
| 246 | code: '', | 248 | code: '', |
| 247 | supplier: '', | 249 | supplier: '', |
| @@ -296,13 +298,22 @@ export default { | @@ -296,13 +298,22 @@ export default { | ||
| 296 | regionOptions: [], | 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 | created() { | 309 | created() { |
| 300 | this.loadSuppliers() | 310 | this.loadSuppliers() |
| 301 | this.loadExtraOptions() | 311 | this.loadExtraOptions() |
| 302 | this.initCode() | 312 | this.initCode() |
| 303 | this.getDept() | 313 | this.getDept() |
| 304 | this.loadRegionOptions() | 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 | this.$nextTick(() => { | 317 | this.$nextTick(() => { |
| 307 | if (Array.isArray(this.form.destinationId) && this.form.destinationId.length) { | 318 | if (Array.isArray(this.form.destinationId) && this.form.destinationId.length) { |
| 308 | this.initDestinationLabel() | 319 | this.initDestinationLabel() |
| @@ -350,6 +361,83 @@ export default { | @@ -350,6 +361,83 @@ export default { | ||
| 350 | }, | 361 | }, |
| 351 | }, | 362 | }, |
| 352 | methods: { | 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 | async loadRegionOptions() { | 441 | async loadRegionOptions() { |
| 354 | try { | 442 | try { |
| 355 | const res = await getArea() | 443 | const res = await getArea() |
| @@ -556,8 +644,9 @@ export default { | @@ -556,8 +644,9 @@ export default { | ||
| 556 | async onSubmit() { | 644 | async onSubmit() { |
| 557 | if (this.$refs.productRel && !this.$refs.productRel.validate()) return | 645 | if (this.$refs.productRel && !this.$refs.productRel.validate()) return |
| 558 | if (!this.validateRequired()) return | 646 | if (!this.validateRequired()) return |
| 647 | + const isCopy = !!this.copyId | ||
| 559 | const confirmRes = await new Promise(resolve => { | 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 | if (!(confirmRes && confirmRes.confirm)) return | 651 | if (!(confirmRes && confirmRes.confirm)) return |
| 563 | const clean = (obj) => { | 652 | const clean = (obj) => { |
| @@ -577,6 +666,7 @@ export default { | @@ -577,6 +666,7 @@ export default { | ||
| 577 | const destination = destinationId && destinationId.length > 0 ? destinationId[destinationId.length - 1] : ''; | 666 | const destination = destinationId && destinationId.length > 0 ? destinationId[destinationId.length - 1] : ''; |
| 578 | const payload = clean({ | 667 | const payload = clean({ |
| 579 | ...formForSubmit, | 668 | ...formForSubmit, |
| 669 | + operateType: isCopy ? 'COPY' : 'ADD', | ||
| 580 | destination, | 670 | destination, |
| 581 | type: 'INTL_OPEN_SPEC_AGMT', | 671 | type: 'INTL_OPEN_SPEC_AGMT', |
| 582 | totalQuantity: this.totalQuantity, | 672 | totalQuantity: this.totalQuantity, |
| @@ -588,10 +678,10 @@ export default { | @@ -588,10 +678,10 @@ export default { | ||
| 588 | 678 | ||
| 589 | try { | 679 | try { |
| 590 | await createContractApi(payload) | 680 | await createContractApi(payload) |
| 591 | - uni.showToast({ title: '新增成功', icon: 'none' }) | 681 | + uni.showToast({ title: isCopy ? '复制成功' : '新增成功', icon: 'none' }) |
| 592 | setTimeout(() => { uni.redirectTo({ url: '/pages/contract_foreign_unplan/index' }) }, 400) | 682 | setTimeout(() => { uni.redirectTo({ url: '/pages/contract_foreign_unplan/index' }) }, 400) |
| 593 | } catch (e) { | 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 | validateRequired() { | 687 | validateRequired() { |
| @@ -285,6 +285,12 @@ export default { | @@ -285,6 +285,12 @@ export default { | ||
| 285 | variant: 'outline', | 285 | variant: 'outline', |
| 286 | event: 'uploadSeal' | 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,6 +317,7 @@ export default { | ||
| 311 | { ...this.buttons[7], visible: (s === 'FORMAL' && e && a === 'AUDIT' && this.$auth.hasPermi('contract-manage:foreign-trade-unlocked-contract:approve')) }, //审核正式合同 | 317 | { ...this.buttons[7], visible: (s === 'FORMAL' && e && a === 'AUDIT' && this.$auth.hasPermi('contract-manage:foreign-trade-unlocked-contract:approve')) }, //审核正式合同 |
| 312 | { ...this.buttons[8], visible: (s === 'STANDARD' && e && a === 'AUDIT' && this.$auth.hasPermi('contract-manage:foreign-trade-unlocked-contract:approve')) }, //审核正式合同 | 318 | { ...this.buttons[8], visible: (s === 'STANDARD' && e && a === 'AUDIT' && this.$auth.hasPermi('contract-manage:foreign-trade-unlocked-contract:approve')) }, //审核正式合同 |
| 313 | { ...this.buttons[9], visible: (s === 'STANDARD' && f && t === 'AUDIT' && this.$auth.hasPermi('contract-manage:foreign-trade-unlocked-contract:standard-approve')) }, //审核标准合同 | 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,6 +473,20 @@ export default { | ||
| 466 | if (e === 'auditDetail2') return this.onAuditDetail(this.detail.parentId || '', 'FORMAL_CONTRACT') | 473 | if (e === 'auditDetail2') return this.onAuditDetail(this.detail.parentId || '', 'FORMAL_CONTRACT') |
| 467 | if (e === 'auditDetail3') return this.onAuditDetail(this.detail.id || '', 'STANDARD_CONTRACT') | 474 | if (e === 'auditDetail3') return this.onAuditDetail(this.detail.id || '', 'STANDARD_CONTRACT') |
| 468 | if (e === 'uploadSeal') return this.uploadContract(this.detail.id || '', 'seal') | 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 | onAudit(id, type) { | 491 | onAudit(id, type) { |
| 471 | const CACHE_KEY = 'sourceBusinessId' | 492 | const CACHE_KEY = 'sourceBusinessId' |
| @@ -667,4 +688,4 @@ export default { | @@ -667,4 +688,4 @@ export default { | ||
| 667 | .upload-row { | 688 | .upload-row { |
| 668 | margin-top: 20rpx; | 689 | margin-top: 20rpx; |
| 669 | } | 690 | } |
| 670 | -</style> | ||
| 691 | +</style> |
| @@ -231,7 +231,7 @@ import SingleSelectSheet from '@/components/single-select/index.vue' | @@ -231,7 +231,7 @@ import SingleSelectSheet from '@/components/single-select/index.vue' | ||
| 231 | import RelateSelectSheet from '@/components/relate-select/index.vue' | 231 | import RelateSelectSheet from '@/components/relate-select/index.vue' |
| 232 | import ProductRel from './productRel.vue' | 232 | import ProductRel from './productRel.vue' |
| 233 | import CitySelector from '@/components/city-selector/index.vue' | 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 | import { getDicByCodes } from '@/utils/dic' | 235 | import { getDicByCodes } from '@/utils/dic' |
| 236 | import { formatCurrencyToChinese } from '@/utils/common' | 236 | import { formatCurrencyToChinese } from '@/utils/common' |
| 237 | import { workshopQueryApi } from '@/api/devManage' | 237 | import { workshopQueryApi } from '@/api/devManage' |
| @@ -242,6 +242,8 @@ export default { | @@ -242,6 +242,8 @@ export default { | ||
| 242 | components: { SingleSelectSheet, RelateSelectSheet, ProductRel, CitySelector }, | 242 | components: { SingleSelectSheet, RelateSelectSheet, ProductRel, CitySelector }, |
| 243 | data() { | 243 | data() { |
| 244 | return { | 244 | return { |
| 245 | + copyId: '', | ||
| 246 | + operateType: 'ADD', | ||
| 245 | form: { | 247 | form: { |
| 246 | code: '', | 248 | code: '', |
| 247 | supplier: '', | 249 | supplier: '', |
| @@ -299,13 +301,22 @@ export default { | @@ -299,13 +301,22 @@ export default { | ||
| 299 | rawProductGradeList: [], | 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 | created() { | 312 | created() { |
| 303 | this.loadSuppliers() | 313 | this.loadSuppliers() |
| 304 | this.loadExtraOptions() | 314 | this.loadExtraOptions() |
| 305 | this.initCode() | 315 | this.initCode() |
| 306 | this.getDept() | 316 | this.getDept() |
| 307 | this.loadRegionOptions() | 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 | this.$nextTick(() => { | 320 | this.$nextTick(() => { |
| 310 | if (Array.isArray(this.form.destinationId) && this.form.destinationId.length) { | 321 | if (Array.isArray(this.form.destinationId) && this.form.destinationId.length) { |
| 311 | this.initDestinationLabel() | 322 | this.initDestinationLabel() |
| @@ -353,6 +364,83 @@ export default { | @@ -353,6 +364,83 @@ export default { | ||
| 353 | }, | 364 | }, |
| 354 | }, | 365 | }, |
| 355 | methods: { | 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 | async loadRegionOptions() { | 444 | async loadRegionOptions() { |
| 357 | try { | 445 | try { |
| 358 | const res = await getArea() | 446 | const res = await getArea() |
| @@ -567,8 +655,9 @@ export default { | @@ -567,8 +655,9 @@ export default { | ||
| 567 | }, | 655 | }, |
| 568 | async onSubmit() { | 656 | async onSubmit() { |
| 569 | if (!this.validateRequired()) return | 657 | if (!this.validateRequired()) return |
| 658 | + const isCopy = !!this.copyId | ||
| 570 | const confirmRes = await new Promise(resolve => { | 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 | if (!(confirmRes && confirmRes.confirm)) return | 662 | if (!(confirmRes && confirmRes.confirm)) return |
| 574 | const clean = (obj) => { | 663 | const clean = (obj) => { |
| @@ -588,6 +677,7 @@ export default { | @@ -588,6 +677,7 @@ export default { | ||
| 588 | const destination = destinationId && destinationId.length > 0 ? destinationId[destinationId.length - 1] : ''; | 677 | const destination = destinationId && destinationId.length > 0 ? destinationId[destinationId.length - 1] : ''; |
| 589 | const payload = clean({ | 678 | const payload = clean({ |
| 590 | ...formForSubmit, | 679 | ...formForSubmit, |
| 680 | + operateType: isCopy ? 'COPY' : 'ADD', | ||
| 591 | destination, | 681 | destination, |
| 592 | type: 'PROCESS_STD_AGMT', | 682 | type: 'PROCESS_STD_AGMT', |
| 593 | totalQuantity: this.totalQuantity, | 683 | totalQuantity: this.totalQuantity, |
| @@ -601,10 +691,10 @@ export default { | @@ -601,10 +691,10 @@ export default { | ||
| 601 | 691 | ||
| 602 | try { | 692 | try { |
| 603 | await createContractApi(payload) | 693 | await createContractApi(payload) |
| 604 | - uni.showToast({ title: '新增成功', icon: 'none' }) | 694 | + uni.showToast({ title: isCopy ? '复制成功' : '新增成功', icon: 'none' }) |
| 605 | setTimeout(() => { uni.redirectTo({ url: '/pages/contract_process/index' }) }, 400) | 695 | setTimeout(() => { uni.redirectTo({ url: '/pages/contract_process/index' }) }, 400) |
| 606 | } catch (e) { | 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 | validateRequired() { | 700 | validateRequired() { |
| @@ -210,6 +210,12 @@ export default { | @@ -210,6 +210,12 @@ export default { | ||
| 210 | visible: true, | 210 | visible: true, |
| 211 | event: 'auditDetail' | 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,6 +230,7 @@ export default { | ||
| 224 | { ...this.buttons[2], visible: (s !== 'DELETED' && t !== 'AUDIT' && t !== 'PASS' && this.$auth.hasPermi('contract-manage:processed-standard-contract:upload')) }, | 230 | { ...this.buttons[2], visible: (s !== 'DELETED' && t !== 'AUDIT' && t !== 'PASS' && this.$auth.hasPermi('contract-manage:processed-standard-contract:upload')) }, |
| 225 | { ...this.buttons[4], visible: (s === 'STANDARD' && this.$auth.hasPermi('contract-manage:processed-standard-contract:review')) }, | 231 | { ...this.buttons[4], visible: (s === 'STANDARD' && this.$auth.hasPermi('contract-manage:processed-standard-contract:review')) }, |
| 226 | { ...this.buttons[3], visible: (s === 'STANDARD' && e && t === 'AUDIT' && this.$auth.hasPermi('contract-manage:processed-standard-contract:approve')) }, | 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,6 +353,20 @@ export default { | ||
| 346 | if (e === 'upload') return this.uploadContract(this.detail.id || '') | 353 | if (e === 'upload') return this.uploadContract(this.detail.id || '') |
| 347 | if (e === 'audit') return this.onAudit(this.detail.id || '', 'PROCESS_STD_AGMT') | 354 | if (e === 'audit') return this.onAudit(this.detail.id || '', 'PROCESS_STD_AGMT') |
| 348 | if (e === 'auditDetail') return this.onAuditDetail(this.detail.id || '', 'PROCESS_STD_AGMT') | 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 | onAudit(id, type) { | 371 | onAudit(id, type) { |
| 351 | const CACHE_KEY = 'sourceBusinessId' | 372 | const CACHE_KEY = 'sourceBusinessId' |
| @@ -533,4 +554,4 @@ export default { | @@ -533,4 +554,4 @@ export default { | ||
| 533 | .upload-row { | 554 | .upload-row { |
| 534 | margin-top: 20rpx; | 555 | margin-top: 20rpx; |
| 535 | } | 556 | } |
| 536 | -</style> | ||
| 557 | +</style> |
| @@ -227,7 +227,7 @@ import SingleSelectSheet from '@/components/single-select/index.vue' | @@ -227,7 +227,7 @@ import SingleSelectSheet from '@/components/single-select/index.vue' | ||
| 227 | import RelateSelectSheet from '@/components/relate-select/index.vue' | 227 | import RelateSelectSheet from '@/components/relate-select/index.vue' |
| 228 | import ProductRel from './productRel.vue' | 228 | import ProductRel from './productRel.vue' |
| 229 | import CitySelector from '@/components/city-selector/index.vue' | 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 | import { getDicByCodes } from '@/utils/dic' | 231 | import { getDicByCodes } from '@/utils/dic' |
| 232 | import { formatCurrencyToChinese } from '@/utils/common' | 232 | import { formatCurrencyToChinese } from '@/utils/common' |
| 233 | import { workshopQueryApi } from '@/api/devManage' | 233 | import { workshopQueryApi } from '@/api/devManage' |
| @@ -238,6 +238,8 @@ export default { | @@ -238,6 +238,8 @@ export default { | ||
| 238 | components: { SingleSelectSheet, RelateSelectSheet, ProductRel, CitySelector }, | 238 | components: { SingleSelectSheet, RelateSelectSheet, ProductRel, CitySelector }, |
| 239 | data() { | 239 | data() { |
| 240 | return { | 240 | return { |
| 241 | + copyId: '', | ||
| 242 | + operateType: 'ADD', | ||
| 241 | form: { | 243 | form: { |
| 242 | code: '', | 244 | code: '', |
| 243 | supplier: '', | 245 | supplier: '', |
| @@ -292,13 +294,22 @@ export default { | @@ -292,13 +294,22 @@ export default { | ||
| 292 | regionOptions: [], | 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 | created() { | 305 | created() { |
| 296 | this.loadSuppliers() | 306 | this.loadSuppliers() |
| 297 | this.loadExtraOptions() | 307 | this.loadExtraOptions() |
| 298 | this.initCode() | 308 | this.initCode() |
| 299 | this.getDept() | 309 | this.getDept() |
| 300 | this.loadRegionOptions() | 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 | this.$nextTick(() => { | 313 | this.$nextTick(() => { |
| 303 | if (Array.isArray(this.form.destinationId) && this.form.destinationId.length) { | 314 | if (Array.isArray(this.form.destinationId) && this.form.destinationId.length) { |
| 304 | this.initDestinationLabel() | 315 | this.initDestinationLabel() |
| @@ -347,6 +358,83 @@ export default { | @@ -347,6 +358,83 @@ export default { | ||
| 347 | }, | 358 | }, |
| 348 | }, | 359 | }, |
| 349 | methods: { | 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 | async loadRegionOptions() { | 438 | async loadRegionOptions() { |
| 351 | try { | 439 | try { |
| 352 | const res = await getArea() | 440 | const res = await getArea() |
| @@ -552,8 +640,9 @@ export default { | @@ -552,8 +640,9 @@ export default { | ||
| 552 | }, | 640 | }, |
| 553 | async onSubmit() { | 641 | async onSubmit() { |
| 554 | if (!this.validateRequired()) return | 642 | if (!this.validateRequired()) return |
| 643 | + const isCopy = !!this.copyId | ||
| 555 | const confirmRes = await new Promise(resolve => { | 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 | if (!(confirmRes && confirmRes.confirm)) return | 647 | if (!(confirmRes && confirmRes.confirm)) return |
| 559 | const clean = (obj) => { | 648 | const clean = (obj) => { |
| @@ -573,6 +662,7 @@ export default { | @@ -573,6 +662,7 @@ export default { | ||
| 573 | const destination = destinationId && destinationId.length > 0 ? destinationId[destinationId.length - 1] : ''; | 662 | const destination = destinationId && destinationId.length > 0 ? destinationId[destinationId.length - 1] : ''; |
| 574 | const payload = clean({ | 663 | const payload = clean({ |
| 575 | ...formForSubmit, | 664 | ...formForSubmit, |
| 665 | + operateType: this.copyId ? 'COPY' : 'ADD', | ||
| 576 | destination, | 666 | destination, |
| 577 | type: 'DISTRIB_STD', | 667 | type: 'DISTRIB_STD', |
| 578 | totalQuantity: this.totalQuantity, | 668 | totalQuantity: this.totalQuantity, |
| @@ -584,10 +674,10 @@ export default { | @@ -584,10 +674,10 @@ export default { | ||
| 584 | 674 | ||
| 585 | try { | 675 | try { |
| 586 | await createContractApi(payload) | 676 | await createContractApi(payload) |
| 587 | - uni.showToast({ title: '新增成功', icon: 'none' }) | 677 | + uni.showToast({ title: isCopy ? '复制成功' : '新增成功', icon: 'none' }) |
| 588 | setTimeout(() => { uni.redirectTo({ url: '/pages/contract_retail/index' }) }, 400) | 678 | setTimeout(() => { uni.redirectTo({ url: '/pages/contract_retail/index' }) }, 400) |
| 589 | } catch (e) { | 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 | validateRequired() { | 683 | validateRequired() { |
| @@ -209,6 +209,12 @@ export default { | @@ -209,6 +209,12 @@ export default { | ||
| 209 | visible: true, | 209 | visible: true, |
| 210 | event: 'auditDetail' | 210 | event: 'auditDetail' |
| 211 | }, | 211 | }, |
| 212 | + { | ||
| 213 | + text: '复制', | ||
| 214 | + visible: true, | ||
| 215 | + variant: 'outline', | ||
| 216 | + event: 'copy' | ||
| 217 | + } | ||
| 212 | ], | 218 | ], |
| 213 | statusStyle: statusStyle, | 219 | statusStyle: statusStyle, |
| 214 | dicOptions: { AUDIT_STATUS: [] } | 220 | dicOptions: { AUDIT_STATUS: [] } |
| @@ -225,6 +231,7 @@ export default { | @@ -225,6 +231,7 @@ export default { | ||
| 225 | { ...this.buttons[2], visible: (s !== 'DELETED' && t !== 'AUDIT' && t !== 'PASS' && this.$auth.hasPermi('contract-manage:distribution-standard-contract:upload')) }, | 231 | { ...this.buttons[2], visible: (s !== 'DELETED' && t !== 'AUDIT' && t !== 'PASS' && this.$auth.hasPermi('contract-manage:distribution-standard-contract:upload')) }, |
| 226 | { ...this.buttons[4], visible: (s === 'STANDARD' && this.$auth.hasPermi('contract-manage:distribution-standard-contract:review')) }, | 232 | { ...this.buttons[4], visible: (s === 'STANDARD' && this.$auth.hasPermi('contract-manage:distribution-standard-contract:review')) }, |
| 227 | { ...this.buttons[3], visible: (s === 'STANDARD' && e && t === 'AUDIT' && this.$auth.hasPermi('contract-manage:distribution-standard-contract:approve')) }, | 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,10 +370,21 @@ export default { | ||
| 363 | if (e === 'upload') return this.onUpload(btn && btn.params) | 370 | if (e === 'upload') return this.onUpload(btn && btn.params) |
| 364 | if (e === 'audit') return this.onAudit(btn && btn.params) | 371 | if (e === 'audit') return this.onAudit(btn && btn.params) |
| 365 | if (e === 'auditDetail') return this.onAuditDetail(btn && btn.params) | 372 | if (e === 'auditDetail') return this.onAuditDetail(btn && btn.params) |
| 373 | + if (e === 'copy') return this.onCopy(btn && btn.params) | ||
| 366 | }, | 374 | }, |
| 367 | getBusinessId() { | 375 | getBusinessId() { |
| 368 | return (this.detail && (this.detail.id || this.detail.code)) || '' | 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 | onAudit() { | 388 | onAudit() { |
| 371 | const CACHE_KEY = 'sourceBusinessId' | 389 | const CACHE_KEY = 'sourceBusinessId' |
| 372 | uni.setStorageSync(CACHE_KEY, this.getBusinessId()) | 390 | uni.setStorageSync(CACHE_KEY, this.getBusinessId()) |
| @@ -225,7 +225,7 @@ import SingleSelectSheet from '@/components/single-select/index.vue' | @@ -225,7 +225,7 @@ import SingleSelectSheet from '@/components/single-select/index.vue' | ||
| 225 | import RelateSelectSheet from '@/components/relate-select/index.vue' | 225 | import RelateSelectSheet from '@/components/relate-select/index.vue' |
| 226 | import ProductRel from './productRel.vue' | 226 | import ProductRel from './productRel.vue' |
| 227 | import CitySelector from '@/components/city-selector/index.vue' | 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 | import { getDicByCodes } from '@/utils/dic' | 229 | import { getDicByCodes } from '@/utils/dic' |
| 230 | import { formatCurrencyToChinese } from '@/utils/common' | 230 | import { formatCurrencyToChinese } from '@/utils/common' |
| 231 | import { workshopQueryApi } from '@/api/devManage' | 231 | import { workshopQueryApi } from '@/api/devManage' |
| @@ -236,6 +236,8 @@ export default { | @@ -236,6 +236,8 @@ export default { | ||
| 236 | components: { SingleSelectSheet, RelateSelectSheet, ProductRel, CitySelector }, | 236 | components: { SingleSelectSheet, RelateSelectSheet, ProductRel, CitySelector }, |
| 237 | data() { | 237 | data() { |
| 238 | return { | 238 | return { |
| 239 | + copyId: '', | ||
| 240 | + operateType: 'ADD', | ||
| 239 | form: { | 241 | form: { |
| 240 | code: '', | 242 | code: '', |
| 241 | supplier: '', | 243 | supplier: '', |
| @@ -290,13 +292,22 @@ export default { | @@ -290,13 +292,22 @@ export default { | ||
| 290 | regionOptions: [], | 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 | created() { | 303 | created() { |
| 294 | this.loadSuppliers() | 304 | this.loadSuppliers() |
| 295 | this.loadExtraOptions() | 305 | this.loadExtraOptions() |
| 296 | this.initCode() | 306 | this.initCode() |
| 297 | this.getDept() | 307 | this.getDept() |
| 298 | this.loadRegionOptions() | 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 | this.$nextTick(() => { | 311 | this.$nextTick(() => { |
| 301 | if (Array.isArray(this.form.destinationId) && this.form.destinationId.length) { | 312 | if (Array.isArray(this.form.destinationId) && this.form.destinationId.length) { |
| 302 | this.initDestinationLabel() | 313 | this.initDestinationLabel() |
| @@ -344,6 +355,83 @@ export default { | @@ -344,6 +355,83 @@ export default { | ||
| 344 | }, | 355 | }, |
| 345 | }, | 356 | }, |
| 346 | methods: { | 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 | async loadRegionOptions() { | 435 | async loadRegionOptions() { |
| 348 | try { | 436 | try { |
| 349 | const res = await getArea() | 437 | const res = await getArea() |
| @@ -549,8 +637,9 @@ export default { | @@ -549,8 +637,9 @@ export default { | ||
| 549 | }, | 637 | }, |
| 550 | async onSubmit() { | 638 | async onSubmit() { |
| 551 | if (!this.validateRequired()) return | 639 | if (!this.validateRequired()) return |
| 640 | + const isCopy = !!this.copyId | ||
| 552 | const confirmRes = await new Promise(resolve => { | 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 | if (!(confirmRes && confirmRes.confirm)) return | 644 | if (!(confirmRes && confirmRes.confirm)) return |
| 556 | const clean = (obj) => { | 645 | const clean = (obj) => { |
| @@ -570,6 +659,7 @@ export default { | @@ -570,6 +659,7 @@ export default { | ||
| 570 | const destination = destinationId && destinationId.length > 0 ? destinationId[destinationId.length - 1] : ''; | 659 | const destination = destinationId && destinationId.length > 0 ? destinationId[destinationId.length - 1] : ''; |
| 571 | const payload = clean({ | 660 | const payload = clean({ |
| 572 | ...formForSubmit, | 661 | ...formForSubmit, |
| 662 | + operateType: this.copyId ? 'COPY' : 'ADD', | ||
| 573 | destination, | 663 | destination, |
| 574 | type: 'DIST_STOCK_CONTRACT', | 664 | type: 'DIST_STOCK_CONTRACT', |
| 575 | totalQuantity: this.totalQuantity, | 665 | totalQuantity: this.totalQuantity, |
| @@ -581,10 +671,10 @@ export default { | @@ -581,10 +671,10 @@ export default { | ||
| 581 | 671 | ||
| 582 | try { | 672 | try { |
| 583 | await createContractApi(payload) | 673 | await createContractApi(payload) |
| 584 | - uni.showToast({ title: '新增成功', icon: 'none' }) | 674 | + uni.showToast({ title: isCopy ? '复制成功' : '新增成功', icon: 'none' }) |
| 585 | setTimeout(() => { uni.redirectTo({ url: '/pages/contract_stock/index' }) }, 400) | 675 | setTimeout(() => { uni.redirectTo({ url: '/pages/contract_stock/index' }) }, 400) |
| 586 | } catch (e) { | 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 | validateRequired() { | 680 | validateRequired() { |
| @@ -266,6 +266,12 @@ export default { | @@ -266,6 +266,12 @@ export default { | ||
| 266 | visible: true, | 266 | visible: true, |
| 267 | event: 'auditDetail3' | 267 | event: 'auditDetail3' |
| 268 | }, | 268 | }, |
| 269 | + { | ||
| 270 | + text: '复制', | ||
| 271 | + visible: true, | ||
| 272 | + variant: 'outline', | ||
| 273 | + event: 'copy' | ||
| 274 | + } | ||
| 269 | ], | 275 | ], |
| 270 | uploadId: '', | 276 | uploadId: '', |
| 271 | uploadType: 'formal', | 277 | uploadType: 'formal', |
| @@ -292,6 +298,7 @@ export default { | @@ -292,6 +298,7 @@ export default { | ||
| 292 | { ...this.buttons[6], visible: (s === 'FORMAL' && e && t === 'AUDIT' && this.$auth.hasPermi('contract-manage:distribution-inventory-contract:approve')) }, | 298 | { ...this.buttons[6], visible: (s === 'FORMAL' && e && t === 'AUDIT' && this.$auth.hasPermi('contract-manage:distribution-inventory-contract:approve')) }, |
| 293 | { ...this.buttons[7], visible: (s === 'STANDARD' && e && t === 'AUDIT' && this.$auth.hasPermi('contract-manage:distribution-inventory-contract:approve')) }, | 299 | { ...this.buttons[7], visible: (s === 'STANDARD' && e && t === 'AUDIT' && this.$auth.hasPermi('contract-manage:distribution-inventory-contract:approve')) }, |
| 294 | { ...this.buttons[8], visible: (s === 'STANDARD' && f && a === 'AUDIT' && this.$auth.hasPermi('contract-manage:distribution-inventory-contract:standard-approve')) }, | 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,6 +433,8 @@ export default { | ||
| 426 | if (e === 'auditDetail1') return this.onAuditDetail(this.detail.id || '', 'FORMAL_CONTRACT') | 433 | if (e === 'auditDetail1') return this.onAuditDetail(this.detail.id || '', 'FORMAL_CONTRACT') |
| 427 | if (e === 'auditDetail2') return this.onAuditDetail(this.detail.parentId || '', 'FORMAL_CONTRACT') | 434 | if (e === 'auditDetail2') return this.onAuditDetail(this.detail.parentId || '', 'FORMAL_CONTRACT') |
| 428 | if (e === 'auditDetail3') return this.onAuditDetail(this.detail.id || '', 'STANDARD_CONTRACT') | 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 | onAudit(id, type) { | 439 | onAudit(id, type) { |
| 431 | const CACHE_KEY = 'sourceBusinessId' | 440 | const CACHE_KEY = 'sourceBusinessId' |
| @@ -434,6 +443,11 @@ export default { | @@ -434,6 +443,11 @@ export default { | ||
| 434 | uni.setStorageSync(CACHE_KEY, id) | 443 | uni.setStorageSync(CACHE_KEY, id) |
| 435 | uni.navigateTo({ url: '/pages/flow/audit' }) | 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 | onAuditDetail(id, type) { | 451 | onAuditDetail(id, type) { |
| 438 | const CACHE_KEY = 'sourceBusinessId' | 452 | const CACHE_KEY = 'sourceBusinessId' |
| 439 | const TYPE = 'contractType' | 453 | const TYPE = 'contractType' |
| @@ -227,7 +227,7 @@ import SingleSelectSheet from '@/components/single-select/index.vue' | @@ -227,7 +227,7 @@ import SingleSelectSheet from '@/components/single-select/index.vue' | ||
| 227 | import RelateSelectSheet from '@/components/relate-select/index.vue' | 227 | import RelateSelectSheet from '@/components/relate-select/index.vue' |
| 228 | import ProductRel from './productRel.vue' | 228 | import ProductRel from './productRel.vue' |
| 229 | import CitySelector from '@/components/city-selector/index.vue' | 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 | import { getDicByCodes } from '@/utils/dic' | 231 | import { getDicByCodes } from '@/utils/dic' |
| 232 | import { formatCurrencyToChinese } from '@/utils/common' | 232 | import { formatCurrencyToChinese } from '@/utils/common' |
| 233 | import { workshopQueryApi } from '@/api/devManage' | 233 | import { workshopQueryApi } from '@/api/devManage' |
| @@ -238,6 +238,8 @@ export default { | @@ -238,6 +238,8 @@ export default { | ||
| 238 | components: { SingleSelectSheet, RelateSelectSheet, ProductRel, CitySelector }, | 238 | components: { SingleSelectSheet, RelateSelectSheet, ProductRel, CitySelector }, |
| 239 | data() { | 239 | data() { |
| 240 | return { | 240 | return { |
| 241 | + copyId: '', | ||
| 242 | + operateType: 'ADD', | ||
| 241 | form: { | 243 | form: { |
| 242 | code: '', | 244 | code: '', |
| 243 | supplier: '', | 245 | supplier: '', |
| @@ -292,13 +294,22 @@ export default { | @@ -292,13 +294,22 @@ export default { | ||
| 292 | regionOptions: [], | 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 | created() { | 305 | created() { |
| 296 | this.loadSuppliers() | 306 | this.loadSuppliers() |
| 297 | this.loadExtraOptions() | 307 | this.loadExtraOptions() |
| 298 | this.initCode() | 308 | this.initCode() |
| 299 | this.getDept() | 309 | this.getDept() |
| 300 | this.loadRegionOptions() | 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 | this.$nextTick(() => { | 313 | this.$nextTick(() => { |
| 303 | if (Array.isArray(this.form.destinationId) && this.form.destinationId.length) { | 314 | if (Array.isArray(this.form.destinationId) && this.form.destinationId.length) { |
| 304 | this.initDestinationLabel() | 315 | this.initDestinationLabel() |
| @@ -348,6 +359,83 @@ export default { | @@ -348,6 +359,83 @@ export default { | ||
| 348 | }, | 359 | }, |
| 349 | }, | 360 | }, |
| 350 | methods: { | 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 | async loadRegionOptions() { | 439 | async loadRegionOptions() { |
| 352 | try { | 440 | try { |
| 353 | const res = await getArea() | 441 | const res = await getArea() |
| @@ -553,8 +641,9 @@ export default { | @@ -553,8 +641,9 @@ export default { | ||
| 553 | }, | 641 | }, |
| 554 | async onSubmit() { | 642 | async onSubmit() { |
| 555 | if (!this.validateRequired()) return | 643 | if (!this.validateRequired()) return |
| 644 | + const isCopy = !!this.copyId | ||
| 556 | const confirmRes = await new Promise(resolve => { | 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 | if (!(confirmRes && confirmRes.confirm)) return | 648 | if (!(confirmRes && confirmRes.confirm)) return |
| 560 | const clean = (obj) => { | 649 | const clean = (obj) => { |
| @@ -574,6 +663,7 @@ export default { | @@ -574,6 +663,7 @@ export default { | ||
| 574 | const destination = destinationId && destinationId.length > 0 ? destinationId[destinationId.length - 1] : ''; | 663 | const destination = destinationId && destinationId.length > 0 ? destinationId[destinationId.length - 1] : ''; |
| 575 | const payload = clean({ | 664 | const payload = clean({ |
| 576 | ...formForSubmit, | 665 | ...formForSubmit, |
| 666 | + operateType: isCopy ? 'COPY' : 'ADD', | ||
| 577 | destination, | 667 | destination, |
| 578 | type: 'DRAFT_DIST_AGMT', | 668 | type: 'DRAFT_DIST_AGMT', |
| 579 | totalQuantity: this.totalQuantity, | 669 | totalQuantity: this.totalQuantity, |
| @@ -585,10 +675,10 @@ export default { | @@ -585,10 +675,10 @@ export default { | ||
| 585 | 675 | ||
| 586 | try { | 676 | try { |
| 587 | await createContractApi(payload) | 677 | await createContractApi(payload) |
| 588 | - uni.showToast({ title: '新增成功', icon: 'none' }) | 678 | + uni.showToast({ title: isCopy ? '复制成功' : '新增成功', icon: 'none' }) |
| 589 | setTimeout(() => { uni.redirectTo({ url: '/pages/contract_unplan/index' }) }, 400) | 679 | setTimeout(() => { uni.redirectTo({ url: '/pages/contract_unplan/index' }) }, 400) |
| 590 | } catch (e) { | 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 | validateRequired() { | 684 | validateRequired() { |
| @@ -271,6 +271,12 @@ export default { | @@ -271,6 +271,12 @@ export default { | ||
| 271 | visible: true, | 271 | visible: true, |
| 272 | event: 'auditDetail3' | 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,6 +302,7 @@ export default { | ||
| 296 | { ...this.buttons[7], visible: (s === 'FORMAL' && e && t === 'AUDIT' && this.$auth.hasPermi('contract-manage:distribution-unlocked-contract:approve')) }, | 302 | { ...this.buttons[7], visible: (s === 'FORMAL' && e && t === 'AUDIT' && this.$auth.hasPermi('contract-manage:distribution-unlocked-contract:approve')) }, |
| 297 | { ...this.buttons[8], visible: (s === 'STANDARD' && e && t === 'AUDIT' && this.$auth.hasPermi('contract-manage:distribution-unlocked-contract:approve')) }, | 303 | { ...this.buttons[8], visible: (s === 'STANDARD' && e && t === 'AUDIT' && this.$auth.hasPermi('contract-manage:distribution-unlocked-contract:approve')) }, |
| 298 | { ...this.buttons[9], visible: (s === 'STANDARD' && f && a === 'AUDIT' && this.$auth.hasPermi('contract-manage:distribution-unlocked-contract:standard-approve')) }, | 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,6 +452,20 @@ export default { | ||
| 445 | if (e === 'auditDetail1') return this.onAuditDetail(this.detail.id || '', 'FORMAL_CONTRACT') | 452 | if (e === 'auditDetail1') return this.onAuditDetail(this.detail.id || '', 'FORMAL_CONTRACT') |
| 446 | if (e === 'auditDetail2') return this.onAuditDetail(this.detail.parentId || '', 'FORMAL_CONTRACT') | 453 | if (e === 'auditDetail2') return this.onAuditDetail(this.detail.parentId || '', 'FORMAL_CONTRACT') |
| 447 | if (e === 'auditDetail3') return this.onAuditDetail(this.detail.id || '', 'STANDARD_CONTRACT') | 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 | onAudit(id, type) { | 470 | onAudit(id, type) { |
| 450 | const CACHE_KEY = 'sourceBusinessId' | 471 | const CACHE_KEY = 'sourceBusinessId' |