From 5558910d5cbd51f975605760996dc6bac0335f9f Mon Sep 17 00:00:00 2001 From: zxy Date: Tue, 21 Apr 2026 17:57:28 +0800 Subject: [PATCH] =?UTF-8?q?feat(machineparam):=20=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E8=AF=A6=E6=83=85=E9=A1=B5=E9=9D=A2=E5=B9=B6=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E8=A1=A8=E5=8D=95=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/views/example/machineparam/detail.vue | 229 ++++++++++++++++++ .../src/views/example/machineparam/form.vue | 91 +++++-- 2 files changed, 297 insertions(+), 23 deletions(-) create mode 100644 jnpf-java-boot/jnpf-web/src/views/example/machineparam/detail.vue diff --git a/jnpf-java-boot/jnpf-web/src/views/example/machineparam/detail.vue b/jnpf-java-boot/jnpf-web/src/views/example/machineparam/detail.vue new file mode 100644 index 0000000..933fa27 --- /dev/null +++ b/jnpf-java-boot/jnpf-web/src/views/example/machineparam/detail.vue @@ -0,0 +1,229 @@ + + + diff --git a/jnpf-java-boot/jnpf-web/src/views/example/machineparam/form.vue b/jnpf-java-boot/jnpf-web/src/views/example/machineparam/form.vue index 88644fe..6c70a24 100644 --- a/jnpf-java-boot/jnpf-web/src/views/example/machineparam/form.vue +++ b/jnpf-java-boot/jnpf-web/src/views/example/machineparam/form.vue @@ -56,12 +56,13 @@ 工艺参数信息 新 增 - + @@ -190,6 +191,7 @@ export default { machineProps: { label: "label", value: "value" }, paramList: [], paramNameOptions: [], + paramTableKey: 0, isAlertOptions: [ { label: '是', value: '0' }, { label: '否', value: '1' }, @@ -291,15 +293,21 @@ export default { this.loadParamNameOptions(); }, loadParamNameOptions() { - request({ - url: `/api/example/procparam/getSelect`, - method: 'get' - }).then(res => { - const list = res.data || []; - this.paramNameOptions = list.map(item => ({ - label: item.name || '', - value: String(item.id || ''), - })); + return new Promise((resolve) => { + request({ + url: `/api/example/procparam/getSelect`, + method: 'get' + }).then(res => { + const list = res.data || []; + this.paramNameOptions = list.map(item => ({ + label: item.name || '', + value: String(item.id || ''), + unit: item.unit || '', + })); + resolve(); + }).catch(() => { + resolve(); + }); }); }, addParamItem() { @@ -319,11 +327,34 @@ export default { this.paramList.splice(index, 1); }, handleProcParamNameChange(val, row) { - const item = this.paramNameOptions.find(opt => opt.value === val); - if (item) { - row.procParamName = item.label; + if (!val) { + row.procParamName = undefined; + row.procParamUnit = undefined; + return; + } + + const isDuplicate = this.paramList.some(item => + item !== row && item.procParamId === val + ); + + if (isDuplicate) { + this.$message.error('工艺参数名称不能重复'); + const index = this.paramList.indexOf(row); + if (index !== -1) { + this.$set(this.paramList[index], 'procParamId', null); + this.$set(this.paramList[index], 'procParamName', undefined); + this.$set(this.paramList[index], 'procParamUnit', undefined); + } + return; + } + + const paramItem = this.paramNameOptions.find(opt => opt.value === val); + if (paramItem) { + row.procParamName = paramItem.label; + row.procParamUnit = paramItem.unit || ''; } else { row.procParamName = undefined; + row.procParamUnit = undefined; } }, loadProcList() { @@ -381,31 +412,39 @@ export default { this.dataForm.spec = ''; } }, + isEmpty(value) { + return value === null || value === undefined || value === '' || value === 'undefined'; + }, dataFormSubmit() { - // 验证表格必填字段 + if (this.paramList.length === 0) { + this.$message.error('请至少添加一条工艺参数'); + return; + } + + // 验证表格必填字段(所有行都需要验证) for (let i = 0; i < this.paramList.length; i++) { const item = this.paramList[i]; - if (!item.procParamName) { + if (this.isEmpty(item.procParamName)) { this.$message.error(`第 ${i + 1} 行工艺参数名称不能为空`); return; } - if (!item.standardValue) { + if (this.isEmpty(item.standardValue)) { this.$message.error(`第 ${i + 1} 行标准值不能为空`); return; } - if (!item.lowerLimit) { + if (this.isEmpty(item.lowerLimit)) { this.$message.error(`第 ${i + 1} 行下限值不能为空`); return; } - if (!item.upperLimit) { + if (this.isEmpty(item.upperLimit)) { this.$message.error(`第 ${i + 1} 行上限值不能为空`); return; } - if (!item.procParamUnit) { + if (this.isEmpty(item.procParamUnit)) { this.$message.error(`第 ${i + 1} 行单位不能为空`); return; } - if (!item.isAlert) { + if (this.isEmpty(item.isAlert)) { this.$message.error(`第 ${i + 1} 行是否预警不能为空`); return; } @@ -421,6 +460,12 @@ export default { const material = this.materialOptions.find(item => item.value === this.dataForm.matCode); const machine = this.machineOptions.find(item => item.value === this.dataForm.machineCd); + // 过滤掉空行 + const validParamList = this.paramList.filter(item => + item.procParamId || item.procParamName || item.standardValue || + item.lowerLimit || item.upperLimit || item.procParamUnit + ); + const submitData = { ...this.dataForm, procName: proc ? proc.procName : undefined, @@ -429,7 +474,7 @@ export default { mateId: material ? material.id : undefined, machineName: machine ? machine.machineName : undefined, machineId: machine ? machine.id : undefined, - detailList: this.paramList, + detailList: validParamList, }; request({