fix(machineparam): 修复工艺参数管理表单功能
This commit is contained in:
parent
8c3c1bbe9f
commit
78f340ee9d
@ -31,13 +31,13 @@
|
|||||||
<el-row :gutter="20">
|
<el-row :gutter="20">
|
||||||
<el-col :span="8">
|
<el-col :span="8">
|
||||||
<el-form-item label="产品名称" prop="matCode">
|
<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>
|
</JnpfSelect>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="8">
|
<el-col :span="8">
|
||||||
<el-form-item label="规格型号" prop="spec">
|
<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>
|
</JnpfInput>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
@ -58,9 +58,9 @@
|
|||||||
</div>
|
</div>
|
||||||
<el-table :data="paramList" border style="width: 100%;" size="small">
|
<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 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">
|
<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>
|
</JnpfSelect>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
@ -217,7 +217,45 @@ export default {
|
|||||||
url: `/api/example/machineparam/${this.dataForm.id}`,
|
url: `/api/example/machineparam/${this.dataForm.id}`,
|
||||||
method: 'get'
|
method: 'get'
|
||||||
}).then(res => {
|
}).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;
|
||||||
|
|
||||||
|
// 如果没有ID但有名称,根据名称查找对应的ID
|
||||||
|
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;
|
this.loading = false;
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
@ -225,6 +263,7 @@ export default {
|
|||||||
} else {
|
} else {
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
this.resetFormData();
|
this.resetFormData();
|
||||||
|
this.paramList = [];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@ -259,18 +298,19 @@ export default {
|
|||||||
const list = res.data || [];
|
const list = res.data || [];
|
||||||
this.paramNameOptions = list.map(item => ({
|
this.paramNameOptions = list.map(item => ({
|
||||||
label: item.name || '',
|
label: item.name || '',
|
||||||
value: item.id || '',
|
value: String(item.id || ''),
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
addParamItem() {
|
addParamItem() {
|
||||||
this.paramList.push({
|
this.paramList.push({
|
||||||
|
procParamId: undefined,
|
||||||
procParamName: undefined,
|
procParamName: undefined,
|
||||||
|
procParamUnit: undefined,
|
||||||
standardValue: undefined,
|
standardValue: undefined,
|
||||||
lowerLimit: undefined,
|
lowerLimit: undefined,
|
||||||
upperLimit: undefined,
|
upperLimit: undefined,
|
||||||
dev: undefined,
|
dev: undefined,
|
||||||
procParamUnit: undefined,
|
|
||||||
isAlert: '0',
|
isAlert: '0',
|
||||||
remark: undefined,
|
remark: undefined,
|
||||||
});
|
});
|
||||||
@ -278,6 +318,14 @@ export default {
|
|||||||
removeParamItem(index) {
|
removeParamItem(index) {
|
||||||
this.paramList.splice(index, 1);
|
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() {
|
loadProcList() {
|
||||||
request({
|
request({
|
||||||
url: `/api/example/proc/getProcList`,
|
url: `/api/example/proc/getProcList`,
|
||||||
@ -301,7 +349,7 @@ export default {
|
|||||||
this.materialList = res.data || [];
|
this.materialList = res.data || [];
|
||||||
this.materialOptions = this.materialList.map(item => ({
|
this.materialOptions = this.materialList.map(item => ({
|
||||||
label: `${item.matName}`,
|
label: `${item.matName}`,
|
||||||
value: item.id,
|
value: String(item.id),
|
||||||
matName: item.name,
|
matName: item.name,
|
||||||
id: item.id,
|
id: item.id,
|
||||||
spec: item.spec
|
spec: item.spec
|
||||||
@ -317,7 +365,7 @@ export default {
|
|||||||
this.machineList = res.data || [];
|
this.machineList = res.data || [];
|
||||||
this.machineOptions = this.machineList.map(item => ({
|
this.machineOptions = this.machineList.map(item => ({
|
||||||
label: `${item.name}`,
|
label: `${item.name}`,
|
||||||
value: item.id,
|
value: String(item.id),
|
||||||
machineName: item.name,
|
machineName: item.name,
|
||||||
id: item.id
|
id: item.id
|
||||||
}));
|
}));
|
||||||
|
|||||||
@ -63,6 +63,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<JNPF-Form v-if="formVisible" ref="JNPFForm" @refresh="refresh" />
|
<JNPF-Form v-if="formVisible" ref="JNPFForm" @refresh="refresh" />
|
||||||
|
<JNPFDetail v-if="detailVisible" ref="JNPFDetail" @refresh="refresh" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -70,6 +71,7 @@
|
|||||||
import request from "@/utils/request";
|
import request from "@/utils/request";
|
||||||
import { mapGetters } from "vuex";
|
import { mapGetters } from "vuex";
|
||||||
import JNPFForm from "./form";
|
import JNPFForm from "./form";
|
||||||
|
import JNPFDetail from "./detail";
|
||||||
import jnpf from "@/utils/jnpf";
|
import jnpf from "@/utils/jnpf";
|
||||||
import { enabledStatusOptions, getLabel } from '../common/dict'
|
import { enabledStatusOptions, getLabel } from '../common/dict'
|
||||||
|
|
||||||
@ -77,6 +79,7 @@ export default {
|
|||||||
name: "machineparam",
|
name: "machineparam",
|
||||||
components: {
|
components: {
|
||||||
JNPFForm,
|
JNPFForm,
|
||||||
|
JNPFDetail,
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@ -102,6 +105,7 @@ export default {
|
|||||||
sidx: "",
|
sidx: "",
|
||||||
},
|
},
|
||||||
formVisible: false,
|
formVisible: false,
|
||||||
|
detailVisible: false,
|
||||||
enabledStatusOptions,
|
enabledStatusOptions,
|
||||||
enabledStatusProps: { label: "fullName", value: "id" },
|
enabledStatusProps: { label: "fullName", value: "id" },
|
||||||
specOptions: [],
|
specOptions: [],
|
||||||
@ -145,9 +149,9 @@ export default {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
handleDetail(id) {
|
handleDetail(id) {
|
||||||
this.formVisible = true;
|
this.detailVisible = true;
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.$refs.JNPFForm.init(id, 'detail');
|
this.$refs.JNPFDetail.init(id);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
handleDelete(id) {
|
handleDelete(id) {
|
||||||
|
|||||||
@ -224,7 +224,7 @@ export default {
|
|||||||
},
|
},
|
||||||
handleClose() {
|
handleClose() {
|
||||||
this.dialogVisible = false;
|
this.dialogVisible = false;
|
||||||
this.$emit('refresh', false)
|
this.$emit('refresh', true)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user