From ad375cff4f500bba81a22164cfcd06d1afa1c0e8 Mon Sep 17 00:00:00 2001 From: "han\\hanst" Date: Fri, 31 Jul 2026 14:05:14 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BD=93=E9=A1=B9=E7=9B=AE=E7=BC=96=E7=A0=81?= =?UTF-8?q?=E4=B8=8D=E4=B8=BA=E7=A9=BA=E6=97=B6=EF=BC=8C=E9=9C=80=E8=A6=81?= =?UTF-8?q?=E5=88=B0erf=5Fexp=5Fapply=E8=A1=A8=E6=9F=A5=E6=89=BE=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E7=BC=96=E7=A0=81=3Derf=5Fexp=5Fapply=E7=9A=84project?= =?UTF-8?q?=5Fno=E7=9A=84=E6=95=B0=E6=8D=AE=EF=BC=9B=E4=BD=9C=E4=B8=BA?= =?UTF-8?q?=E6=89=93=E6=A0=B7=E5=8D=95=E5=8F=B7=E7=9A=84=E4=B8=8B=E6=8B=89?= =?UTF-8?q?=E6=A1=86=EF=BC=8C=E6=98=BE=E7=A4=BA=E7=9A=84=E6=98=AFerf=5Fexp?= =?UTF-8?q?=5Fapply=E7=9A=84apply=5Fno=EF=BC=88=E4=B9=9F=E5=B0=B1=E6=98=AF?= =?UTF-8?q?=E8=AF=B4=E8=AF=95=E9=AA=8C=E5=8D=95=E5=85=B6=E5=AE=9E=E5=B0=B1?= =?UTF-8?q?=E6=98=AFTracking=E7=9A=84=E6=89=93=E6=A0=B7=E5=8D=95=EF=BC=89;?= =?UTF-8?q?=E9=80=89=E6=8B=A9=E6=9F=90=E4=B8=80=E4=B8=AA=E6=89=93=E6=A0=B7?= =?UTF-8?q?=E5=8D=95=E5=90=8E=E5=9B=9E=E5=A1=AB=E6=89=93=E6=A0=B7=E5=8D=95?= =?UTF-8?q?=E5=8F=B7=E5=92=8C=E9=A2=84=E8=AE=A1=E5=AE=8C=E6=88=90=E6=97=B6?= =?UTF-8?q?=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sampleTracking/projectProofTracking.vue | 229 +++++++++++++++++- 1 file changed, 226 insertions(+), 3 deletions(-) diff --git a/src/views/modules/sampleTracking/projectProofTracking.vue b/src/views/modules/sampleTracking/projectProofTracking.vue index 892da68..d645eff 100644 --- a/src/views/modules/sampleTracking/projectProofTracking.vue +++ b/src/views/modules/sampleTracking/projectProofTracking.vue @@ -297,7 +297,7 @@ - + @@ -513,7 +513,22 @@ - + + + @@ -642,7 +657,22 @@ - + + + @@ -842,6 +872,7 @@ import { updateProofTrackingComments, updateProofTrackingProcess } from '@/api/sampleTracking/sampleTracking' +import { searchExpApplyList } from '@/api/erf/erf' import { getCustomerNo, saveNewCustomer } from '@/api/eam/eamProject.js' import { getSiteAndBuByUserName } from '@/api/eam/eam.js' import { @@ -1071,10 +1102,16 @@ export default { oneKeyDialogMode: 'create', saveOneKeyLoading: false, oneKeyForm: {}, + oneKeyProofingApplyOptions: [], + oneKeyProofingApplyLoading: false, + oneKeyProofingApplyQueryToken: 0, proofDialogVisible: false, proofSaveLoading: false, proofDialogData: this.getDefaultProofDialogData(), + proofDialogApplyOptions: [], + proofDialogApplyLoading: false, + proofDialogApplyQueryToken: 0, processDialogVisible: false, saveProcessLoading: false, @@ -2100,6 +2137,181 @@ export default { isBlankValue (value) { return value == null || String(value).trim() === '' }, + normalizeProjectNo (projectNo) { + if (this.isBlankValue(projectNo)) { + return '' + } + return String(projectNo).trim() + }, + queryApplyOptionsByProjectNo (projectNo) { + const normalizedProjectNo = this.normalizeProjectNo(projectNo) + if (!normalizedProjectNo) { + return Promise.resolve([]) + } + return searchExpApplyList({ + projectNo: normalizedProjectNo, + page: 1, + limit: 500 + }).then(({ data }) => { + if (!(data && data.code === 0)) { + throw new Error((data && data.msg) || '查询试验单失败') + } + const pageList = (data.page && data.page.list) || [] + const matchedProjectNo = normalizedProjectNo.toUpperCase() + const optionMap = {} + const optionRows = [] + pageList.forEach(item => { + if (!item || this.isBlankValue(item.applyNo)) { + return + } + const applyStatus = this.isBlankValue(item.status) ? '' : String(item.status).trim() + // 业务要求:已完成的试验单不允许继续作为 tracking 打样单号使用。 + if (applyStatus === '草稿' || applyStatus === '已完成') { + return + } + const rowProjectNo = this.normalizeProjectNo(item.projectNo).toUpperCase() + // searchExpApplyList 按模糊 project_no 查询,这里再次做等值过滤,确保与 tracking 项目编码一一对应。 + if (rowProjectNo !== matchedProjectNo) { + return + } + const applyNo = String(item.applyNo).trim() + if (optionMap[applyNo]) { + return + } + optionMap[applyNo] = true + optionRows.push({ + applyNo: applyNo, + expectedFinishDate: this.formatDate(item.expectedFinishDate) + }) + }) + return optionRows + }) + }, + handleOneKeyProjectNoBlur () { + const projectNo = this.normalizeProjectNo(this.oneKeyForm.projectNo) + if (!projectNo) { + this.oneKeyProofingApplyQueryToken += 1 + this.oneKeyProofingApplyLoading = false + this.oneKeyProofingApplyOptions = [] + this.oneKeyForm.proofingNo = '' + this.oneKeyForm.requiredDeliveryDate = '' + return + } + this.loadOneKeyProofingApplyOptions(projectNo, { keepCurrentIfMissing: false }) + }, + handleOneKeyProofingNoChange (proofingNo) { + const selectedNo = this.isBlankValue(proofingNo) ? '' : String(proofingNo).trim() + if (!selectedNo) { + this.oneKeyForm.requiredDeliveryDate = '' + return + } + const matched = this.oneKeyProofingApplyOptions.find(item => item && item.applyNo === selectedNo) + if (!matched) { + return + } + this.oneKeyForm.proofingNo = matched.applyNo + this.oneKeyForm.requiredDeliveryDate = matched.expectedFinishDate || '' + }, + loadOneKeyProofingApplyOptions (projectNo, options) { + const queryOptions = options || {} + const normalizedProjectNo = this.normalizeProjectNo(projectNo) + const currentProofingNo = this.isBlankValue(this.oneKeyForm.proofingNo) + ? '' + : String(this.oneKeyForm.proofingNo).trim() + const queryToken = this.oneKeyProofingApplyQueryToken + 1 + this.oneKeyProofingApplyQueryToken = queryToken + if (!normalizedProjectNo) { + this.oneKeyProofingApplyLoading = false + this.oneKeyProofingApplyOptions = [] + return Promise.resolve([]) + } + this.oneKeyProofingApplyLoading = true + return this.queryApplyOptionsByProjectNo(normalizedProjectNo).then(optionRows => { + if (queryToken !== this.oneKeyProofingApplyQueryToken) { + return optionRows + } + const nextOptions = optionRows.slice() + const keepCurrentIfMissing = !!queryOptions.keepCurrentIfMissing + if (currentProofingNo) { + const hasCurrent = nextOptions.some(item => item && item.applyNo === currentProofingNo) + if (!hasCurrent && keepCurrentIfMissing) { + // 历史记录可能早于 ERF 规范化,保留原打样单号避免编辑场景被强制清空。 + nextOptions.unshift({ + applyNo: currentProofingNo, + expectedFinishDate: this.formatDate(this.oneKeyForm.requiredDeliveryDate) + }) + } + if (!hasCurrent && !keepCurrentIfMissing) { + this.oneKeyForm.proofingNo = '' + this.oneKeyForm.requiredDeliveryDate = '' + } + } + this.oneKeyProofingApplyOptions = nextOptions + if (currentProofingNo) { + this.handleOneKeyProofingNoChange(currentProofingNo) + } + return nextOptions + }).catch((e) => { + if (queryToken === this.oneKeyProofingApplyQueryToken) { + this.oneKeyProofingApplyOptions = [] + this.$message.error((e && e.message) || '查询试验单异常') + } + return [] + }).finally(() => { + if (queryToken === this.oneKeyProofingApplyQueryToken) { + this.oneKeyProofingApplyLoading = false + } + }) + }, + handleProofDialogProofingNoChange (proofingNo) { + const selectedNo = this.isBlankValue(proofingNo) ? '' : String(proofingNo).trim() + if (!selectedNo) { + this.proofDialogData.requiredDeliveryDate = '' + return + } + const matched = this.proofDialogApplyOptions.find(item => item && item.applyNo === selectedNo) + if (!matched) { + return + } + this.proofDialogData.proofingNo = matched.applyNo + this.proofDialogData.requiredDeliveryDate = matched.expectedFinishDate || '' + }, + loadProofDialogApplyOptions (projectNo) { + const normalizedProjectNo = this.normalizeProjectNo(projectNo) + const queryToken = this.proofDialogApplyQueryToken + 1 + this.proofDialogApplyQueryToken = queryToken + if (!normalizedProjectNo) { + this.proofDialogApplyLoading = false + this.proofDialogApplyOptions = [] + this.proofDialogData.proofingNo = '' + this.proofDialogData.requiredDeliveryDate = '' + return Promise.resolve([]) + } + this.proofDialogApplyLoading = true + return this.queryApplyOptionsByProjectNo(normalizedProjectNo).then(optionRows => { + if (queryToken !== this.proofDialogApplyQueryToken) { + return optionRows + } + this.proofDialogApplyOptions = optionRows + const currentProofingNo = this.isBlankValue(this.proofDialogData.proofingNo) + ? '' + : String(this.proofDialogData.proofingNo).trim() + if (currentProofingNo) { + this.handleProofDialogProofingNoChange(currentProofingNo) + } + return optionRows + }).catch((e) => { + if (queryToken === this.proofDialogApplyQueryToken) { + this.proofDialogApplyOptions = [] + this.$message.error((e && e.message) || '查询试验单异常') + } + return [] + }).finally(() => { + if (queryToken === this.proofDialogApplyQueryToken) { + this.proofDialogApplyLoading = false + } + }) + }, getBuOptionValue (site, buNo) { const rawBuNo = buNo == null ? '' : String(buNo).trim() if (!rawBuNo) { @@ -2276,6 +2488,9 @@ export default { const dialogMode = mode === 'edit' ? 'edit' : 'create' this.oneKeyDialogMode = dialogMode if (dialogMode !== 'edit') { + this.oneKeyProofingApplyQueryToken += 1 + this.oneKeyProofingApplyLoading = false + this.oneKeyProofingApplyOptions = [] this.oneKeyForm = this.getEmptyOneKeyForm() if (this.userBuList.length > 0) { this.oneKeyForm.buNo = this.userBuList[0].buNo || '' @@ -2331,7 +2546,11 @@ export default { throw new Error('未找到对应的项目物料信息,无法修改') } this.oneKeyForm = this.buildOneKeyEditForm(current, projectRows[0], partRows[0]) + this.oneKeyProofingApplyQueryToken += 1 + this.oneKeyProofingApplyLoading = false + this.oneKeyProofingApplyOptions = [] this.oneKeyDialogVisible = true + this.loadOneKeyProofingApplyOptions(this.oneKeyForm.projectNo, { keepCurrentIfMissing: true }) }).catch((e) => { this.$message.error((e && e.message) || '加载项目/物料/打样信息异常') this.oneKeyDialogMode = 'create' @@ -2392,6 +2611,9 @@ export default { this.currentRow = current const projectPartId = this.getTrackingProjectPartId(current) || current.id const projectCategory = this.getProjectCategoryValue(current) + this.proofDialogApplyQueryToken += 1 + this.proofDialogApplyLoading = false + this.proofDialogApplyOptions = [] this.proofDialogData = Object.assign(this.getDefaultProofDialogData(), { trackingId: null, site: current.site || this.$store.state.user.site, @@ -2424,6 +2646,7 @@ export default { this.$message.warning('未获取到项目分类,请手动选择') } this.proofDialogVisible = true + this.loadProofDialogApplyOptions(this.proofDialogData.projectNo) }, validateSyncToNpiRow (row) { const projectPartId = this.getTrackingProjectPartId(row)