fix(machineparam): 修复工艺参数管理表单功能

This commit is contained in:
zxy 2026-04-21 17:10:01 +08:00
parent 8c3c1bbe9f
commit 78f340ee9d
3 changed files with 64 additions and 12 deletions

View File

@ -31,13 +31,13 @@
<el-row :gutter="20">
<el-col :span="8">
<el-form-item label="产品名称" prop="matCode">
<JnpfSelect v-model="dataForm.matCode" placeholder="请选择物料" :options="materialOptions" filterable :props="materialProps" clearable @change="handleMaterialChange" :style="{ width: '100%' }">
<JnpfSelect v-model="dataForm.matCode" placeholder="请选择物料" :options="materialOptions" filterable :props="materialProps" :disabled="!!dataForm.id" clearable @change="handleMaterialChange" :style="{ width: '100%' }">
</JnpfSelect>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="规格型号" prop="spec">
<JnpfInput v-model="dataForm.spec" placeholder="请输入规格型号" clearable :style="{ width: '100%' }">
<JnpfInput v-model="dataForm.spec" placeholder="请输入规格型号" :disabled="!!dataForm.id" clearable :style="{ width: '100%' }">
</JnpfInput>
</el-form-item>
</el-col>
@ -58,9 +58,9 @@
</div>
<el-table :data="paramList" border style="width: 100%;" size="small">
<el-table-column type="index" label="序号" width="50" align="center"></el-table-column>
<el-table-column label="工艺参数名称(*)" prop="procParamName">
<el-table-column label="工艺参数名称(*)" prop="procParamId">
<template slot-scope="scope">
<JnpfSelect v-model="scope.row.procParamName" placeholder="请选择" :options="paramNameOptions" :props="{ label: 'label', value: 'value' }" filterable clearable>
<JnpfSelect v-model="scope.row.procParamId" placeholder="请选择" :options="paramNameOptions" :props="{ label: 'label', value: 'value' }" filterable clearable @change="(val) => handleProcParamNameChange(val, scope.row)">
</JnpfSelect>
</template>
</el-table-column>
@ -217,7 +217,45 @@ export default {
url: `/api/example/machineparam/${this.dataForm.id}`,
method: 'get'
}).then(res => {
this.dataForm = res.data;
const data = res.data;
//
this.dataForm = {
...data,
procCd: String(data.procCd || ''),
machineCd: String(data.machineCd || ''),
matCode: String(data.matCode || ''),
enabledStatus: String(data.enabledStatus || '1'),
};
//
if (data.detailList && Array.isArray(data.detailList)) {
this.paramList = data.detailList.map(item => {
// 使ID
let procParamId = String(item.procParamId || item.paramId || '');
const paramName = item.procParamName || item.paramName;
// IDID
if (!procParamId && paramName) {
const paramOption = this.paramNameOptions.find(opt => opt.label === paramName);
if (paramOption) {
procParamId = paramOption.value;
}
}
return {
procParamId: procParamId || undefined,
procParamName: paramName,
standardValue: item.standardValue,
lowerLimit: item.lowerLimit || item.minValue,
upperLimit: item.upperLimit || item.maxValue,
dev: item.dev || item.deviation,
procParamUnit: item.procParamUnit || item.unit,
isAlert: String(item.isAlert || item.isWarning || '0'),
remark: item.remark,
};
});
} else {
this.paramList = [];
}
this.loading = false;
}).catch(() => {
this.loading = false;
@ -225,6 +263,7 @@ export default {
} else {
this.loading = false;
this.resetFormData();
this.paramList = [];
}
});
},
@ -259,18 +298,19 @@ export default {
const list = res.data || [];
this.paramNameOptions = list.map(item => ({
label: item.name || '',
value: item.id || '',
value: String(item.id || ''),
}));
});
},
addParamItem() {
this.paramList.push({
procParamId: undefined,
procParamName: undefined,
procParamUnit: undefined,
standardValue: undefined,
lowerLimit: undefined,
upperLimit: undefined,
dev: undefined,
procParamUnit: undefined,
isAlert: '0',
remark: undefined,
});
@ -278,6 +318,14 @@ export default {
removeParamItem(index) {
this.paramList.splice(index, 1);
},
handleProcParamNameChange(val, row) {
const item = this.paramNameOptions.find(opt => opt.value === val);
if (item) {
row.procParamName = item.label;
} else {
row.procParamName = undefined;
}
},
loadProcList() {
request({
url: `/api/example/proc/getProcList`,
@ -301,7 +349,7 @@ export default {
this.materialList = res.data || [];
this.materialOptions = this.materialList.map(item => ({
label: `${item.matName}`,
value: item.id,
value: String(item.id),
matName: item.name,
id: item.id,
spec: item.spec
@ -317,7 +365,7 @@ export default {
this.machineList = res.data || [];
this.machineOptions = this.machineList.map(item => ({
label: `${item.name}`,
value: item.id,
value: String(item.id),
machineName: item.name,
id: item.id
}));

View File

@ -63,6 +63,7 @@
</div>
</div>
<JNPF-Form v-if="formVisible" ref="JNPFForm" @refresh="refresh" />
<JNPFDetail v-if="detailVisible" ref="JNPFDetail" @refresh="refresh" />
</div>
</template>
@ -70,6 +71,7 @@
import request from "@/utils/request";
import { mapGetters } from "vuex";
import JNPFForm from "./form";
import JNPFDetail from "./detail";
import jnpf from "@/utils/jnpf";
import { enabledStatusOptions, getLabel } from '../common/dict'
@ -77,6 +79,7 @@ export default {
name: "machineparam",
components: {
JNPFForm,
JNPFDetail,
},
data() {
return {
@ -102,6 +105,7 @@ export default {
sidx: "",
},
formVisible: false,
detailVisible: false,
enabledStatusOptions,
enabledStatusProps: { label: "fullName", value: "id" },
specOptions: [],
@ -145,9 +149,9 @@ export default {
});
},
handleDetail(id) {
this.formVisible = true;
this.detailVisible = true;
this.$nextTick(() => {
this.$refs.JNPFForm.init(id, 'detail');
this.$refs.JNPFDetail.init(id);
});
},
handleDelete(id) {

View File

@ -224,7 +224,7 @@ export default {
},
handleClose() {
this.dialogVisible = false;
this.$emit('refresh', false)
this.$emit('refresh', true)
},
}
}