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 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 工艺参数信息
+
+
+
+
+
+
+
+
+
+
+
+ {{ scope.row.isAlert === '0' ? '是' : '否' }}
+
+
+
+
+
+
+
+
+
+
+
+
+
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 @@
工艺参数信息
新 增
-
+
- handleProcParamNameChange(val, scope.row)">
-
+ handleProcParamNameChange(val, scope.row)" style="width: 100%">
+
+
@@ -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({