diff --git a/src/views/modules/quote/index.vue b/src/views/modules/quote/index.vue index 54addef..1690534 100644 --- a/src/views/modules/quote/index.vue +++ b/src/views/modules/quote/index.vue @@ -22,6 +22,7 @@ import OssComponents from "../oss/ossComponents.vue"; import quotationProjectInformation from "../quotation/sellForQuotation/quotationProjectInformation.vue"; import { quotationInformationSearchByAnyField, + searchProjectInfoList, searchQuotationByQuotationNo } from "../../../api/quotation/quotationInformation"; import PriceCheckProperties from "../quotation/priceCheckProperties.vue"; @@ -103,6 +104,7 @@ export default { chipPrice:'', approvalUsername: '', nodeId: '', + annualSales: undefined, }, quoteForm:{ }, @@ -1163,15 +1165,19 @@ export default { this.saveQuote.projectDesc = '' this.saveQuote.finalCustomerNo = '' this.saveQuote.finalCustomerDesc = '' + this.saveQuote.annualSales = undefined + this.$set(this.saveQuote, 'annualSales', undefined) return } this.saveQuote.projectDesc = data.rows[0].projectName this.saveQuote.finalCustomerNo = data.rows[0].finalCustomerId this.saveQuote.finalCustomerDesc = data.rows[0].finalCustomerName + this.assignAnnualSalesFromProject(data.rows[0], this.saveQuote.projectNo) }else { this.saveQuote.projectDesc = '' this.saveQuote.finalCustomerNo = '' this.saveQuote.finalCustomerDesc = '' + this.$set(this.saveQuote, 'annualSales', undefined) } }else { this.$message.warning(data.msg) @@ -1267,6 +1273,7 @@ export default { case 104: this.saveQuote.projectNo = val.project_id this.saveQuote.projectDesc = val.project_name + this.assignAnnualSalesFromProject(val, val.project_id) break; case 2000: this.saveQuote.purchase = val.username @@ -1361,7 +1368,7 @@ export default { this.insideInquiryVisible = true }, dblclickInsideInquiry(row){ - this.assertProjectCompleted(row.projectId).then(() => { + this.assertProjectCompleted(row.projectId).then((project) => { this.saveQuote.insideInquiryNo = row.quotationNo this.saveQuote.customerNo = row.customerNo this.saveQuote.customerDesc = row.customerDesc @@ -1373,11 +1380,51 @@ export default { this.saveQuote.finalCustomerDesc = row.finalCustomerName this.saveQuote.purchase = row.tracker this.saveQuote.purchaseName = row.trackerName + this.assignAnnualSalesFromProject(project, row.projectId) this.insideInquiryVisible = false }).catch((msg) => { this.$message.warning(typeof msg === 'string' ? msg : '校验项目状态失败') }) }, + pickProjectAmount(project) { + if (!project) { + return undefined + } + const raw = project.projectAmount != null && project.projectAmount !== '' + ? project.projectAmount + : project.project_amount + if (raw == null || raw === '') { + return undefined + } + const amount = Number(raw) + return Number.isNaN(amount) ? undefined : amount + }, + assignAnnualSalesFromProject(project, projectId) { + const amount = this.pickProjectAmount(project) + if (amount != null) { + this.$set(this.saveQuote, 'annualSales', amount) + return + } + const id = projectId || (project && (project.projectId || project.project_id)) || (this.saveQuote && this.saveQuote.projectNo) + if (!id) { + this.$set(this.saveQuote, 'annualSales', undefined) + return + } + searchProjectInfoList({ + site: this.$store.state.user.site, + projectId: id + }).then(({data}) => { + if (!(data && data.code === 0 && data.rows && data.rows.length)) { + this.$set(this.saveQuote, 'annualSales', undefined) + return + } + const currentId = String(this.saveQuote.projectNo || id).toUpperCase() + const row = data.rows.find(item => String(item.projectId || item.project_id || '').toUpperCase() === currentId) || data.rows[0] + this.$set(this.saveQuote, 'annualSales', this.pickProjectAmount(row)) + }).catch(() => { + this.$set(this.saveQuote, 'annualSales', undefined) + }) + }, assertProjectCompleted(projectId) { return new Promise((resolve, reject) => { if (!projectId) { @@ -1579,6 +1626,7 @@ export default { this.saveQuote.projectDesc = '' this.saveQuote.finalCustomerNo = '' this.saveQuote.finalCustomerDesc = '' + this.$set(this.saveQuote, 'annualSales', undefined) } }, 'saveQuote.quoter'(newVal, oldVal){ @@ -1829,7 +1877,7 @@ export default { - +