From d381961a9ab23c0efbfd0efb71eab70f1bb57008 Mon Sep 17 00:00:00 2001 From: zxy Date: Tue, 14 Apr 2026 16:58:20 +0800 Subject: [PATCH] =?UTF-8?q?fix(techproc):=20=E4=BF=AE=E5=A4=8D=E5=B7=A5?= =?UTF-8?q?=E5=BA=8F=E8=A1=A8=E5=8D=95=E5=88=9D=E5=A7=8B=E5=8C=96=E5=8F=8A?= =?UTF-8?q?=E9=80=89=E6=8B=A9=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/views/example/techproc/form.vue | 53 +++++++++++++++++-- 1 file changed, 49 insertions(+), 4 deletions(-) diff --git a/jnpf-java-boot/jnpf-web/src/views/example/techproc/form.vue b/jnpf-java-boot/jnpf-web/src/views/example/techproc/form.vue index f87b38a..c59fe37 100644 --- a/jnpf-java-boot/jnpf-web/src/views/example/techproc/form.vue +++ b/jnpf-java-boot/jnpf-web/src/views/example/techproc/form.vue @@ -29,6 +29,7 @@
工序信息
{ this.$refs.formRef.resetFields(); if (this.dataForm.id) { @@ -117,7 +129,9 @@ export default { }).then(res => { this.dataForm = res.data // 将存储的编码拼接转换为名称拼接显示 - this.convertCodeToName(res.data.techProc) + this.techProcDisplay = this.convertCodeToName(res.data.techProc) + // 自动选中表格中的工序 + this.setSelectedRows(res.data.procList || res.data.techProc) this.loading = false }) } else { @@ -132,20 +146,50 @@ export default { method: 'get' }).then(res => { this.procList = res.data || []; + this.procListLoaded = true; + // 如果有等待编辑的ID,继续初始化 + if (this.pendingEditId && this.dialogVisible) { + this.doInit(); + } }); }, // 将编码拼接转换为名称拼接显示 convertCodeToName(codeStr) { if (!codeStr) { - this.techProcDisplay = '' - return + return '' } const codes = codeStr.split('_') const names = codes.map(code => { const proc = this.procList.find(item => item.procCd === code) return proc ? proc.procName : code }) - this.techProcDisplay = names.join('_') + return names.join('_') + }, + // 设置表格选中行 + setSelectedRows(procCodes) { + if (!procCodes || !this.$refs.procTable) { + return + } + + let codes = [] + if (Array.isArray(procCodes)) { + // 如果是数组 + codes = procCodes + } else if (typeof procCodes === 'string') { + // 如果是编码拼接字符串 + codes = procCodes.split('_') + } + + if (codes.length > 0) { + const selectedRows = this.procList.filter(item => codes.includes(item.procCd)) + this.selectedProcs = selectedRows + // 延迟执行以确保表格已渲染 + setTimeout(() => { + selectedRows.forEach(row => { + this.$refs.procTable.toggleRowSelection(row, true) + }) + }, 100) + } }, // 工序选择变化处理 - 按列表顺序排列 handleProcSelectionChange(val) { @@ -192,6 +236,7 @@ export default { }, handleClose() { this.dialogVisible = false; + this.pendingEditId = null; this.$emit('refresh',true) }, changeData(model, index) {