|
|
@@ -1,4 +1,3 @@
|
|
|
-<!-- 用户编辑弹窗 -->
|
|
|
<template>
|
|
|
<ele-modal
|
|
|
width="1000px"
|
|
|
@@ -20,6 +19,7 @@
|
|
|
placeholder="请选择"
|
|
|
filterable
|
|
|
style="width: 100%"
|
|
|
+ @change="handleStandardChange"
|
|
|
>
|
|
|
<el-option
|
|
|
:label="item.name"
|
|
|
@@ -29,6 +29,15 @@
|
|
|
/>
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
+
|
|
|
+ <el-form-item label="标准代码:">
|
|
|
+ <el-input
|
|
|
+ v-model="form.qualityStandardCode"
|
|
|
+ disabled
|
|
|
+ clearable
|
|
|
+ style="width: 100%"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
</el-col>
|
|
|
|
|
|
<el-col :span="12">
|
|
|
@@ -117,7 +126,6 @@
|
|
|
placeholder="请选择"
|
|
|
class="ele-block"
|
|
|
>
|
|
|
- <!-- style="width: calc(100% - 100px)" -->
|
|
|
<el-option label="TRUE" :value="'TRUE'" />
|
|
|
<el-option label="FALSE" :value="'FALSE'" />
|
|
|
</el-select>
|
|
|
@@ -177,22 +185,6 @@
|
|
|
<el-form-item label="参数单位:" prop=""> h(小时) </el-form-item>
|
|
|
</el-col>
|
|
|
|
|
|
- <!-- <el-col :span="24" v-if="form.textType != 7">
|
|
|
- <el-form-item label="文本描述:" prop="inspectionStandard">
|
|
|
- <el-input v-model="form.inspectionStandard" type="textarea">
|
|
|
- </el-input>
|
|
|
- </el-form-item>
|
|
|
- </el-col> -->
|
|
|
- <!-- <el-col :span="12">
|
|
|
- <el-form-item label="单位:" prop="unit">
|
|
|
- <DictSelection
|
|
|
- clearable
|
|
|
- dictName="质检项标准单位"
|
|
|
- v-model="form.unit"
|
|
|
- ></DictSelection>
|
|
|
- </el-form-item>
|
|
|
- </el-col> -->
|
|
|
-
|
|
|
<el-col :span="12">
|
|
|
<el-form-item label="状态:" prop="status">
|
|
|
<el-select
|
|
|
@@ -358,15 +350,14 @@
|
|
|
},
|
|
|
|
|
|
props: {
|
|
|
- // 弹窗是否打开
|
|
|
visible: Boolean,
|
|
|
- // 修改回显的数据
|
|
|
data: Object
|
|
|
},
|
|
|
data() {
|
|
|
const defaultForm = {
|
|
|
id: null,
|
|
|
qualityStandardId: '',
|
|
|
+ qualityStandardCode: '',
|
|
|
inspectionCode: '',
|
|
|
inspectionName: '',
|
|
|
textType: '1',
|
|
|
@@ -393,11 +384,9 @@
|
|
|
};
|
|
|
return {
|
|
|
defaultForm,
|
|
|
- // 表单数据
|
|
|
form: { ...defaultForm },
|
|
|
|
|
|
qualityStandardList: [],
|
|
|
- // 表单验证规则
|
|
|
rules: {
|
|
|
qualityStandardId: [
|
|
|
{ required: true, message: '请选择质检标准', trigger: 'blur' }
|
|
|
@@ -408,12 +397,9 @@
|
|
|
inspectionCode: [
|
|
|
{ required: true, message: '请输入质检编码', trigger: 'blur' }
|
|
|
],
|
|
|
-
|
|
|
- // unitName:
|
|
|
textType: [
|
|
|
{ required: true, message: '请选择参数类型', trigger: 'blur' }
|
|
|
],
|
|
|
-
|
|
|
inspectionStandard: [
|
|
|
{
|
|
|
required: true,
|
|
|
@@ -423,14 +409,11 @@
|
|
|
]
|
|
|
},
|
|
|
|
|
|
- // 提交状态
|
|
|
loading: false,
|
|
|
- // 是否是修改
|
|
|
isUpdate: false
|
|
|
};
|
|
|
},
|
|
|
computed: {
|
|
|
- // 是否开启响应式布局
|
|
|
styleResponsive() {
|
|
|
return this.$store.state.theme.styleResponsive;
|
|
|
},
|
|
|
@@ -448,39 +431,46 @@
|
|
|
this.getListFn();
|
|
|
},
|
|
|
methods: {
|
|
|
+ handleStandardChange() {
|
|
|
+ if (!this.form.qualityStandardId) {
|
|
|
+ this.form.qualityStandardCode = '';
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ const selectedStandard = this.qualityStandardList.find(
|
|
|
+ item => item.id === this.form.qualityStandardId
|
|
|
+ );
|
|
|
+
|
|
|
+ this.form.qualityStandardCode = selectedStandard ? selectedStandard.standardCode : '';
|
|
|
+ },
|
|
|
+
|
|
|
textTypeChange() {
|
|
|
this.form.maxValue = '';
|
|
|
this.form.minValue = '';
|
|
|
},
|
|
|
+
|
|
|
defaultInput(value) {
|
|
|
console.log(this.form.symbol, '0000 symbol');
|
|
|
if (this.form.textType !== '1') {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- // 1. 过滤非法字符(只保留数字、负号和小数点)
|
|
|
let filteredValue = value.replace(/[^0-9.-]/g, '');
|
|
|
- // 2. 处理负号规则
|
|
|
const minusIndex = filteredValue.indexOf('-');
|
|
|
if (minusIndex > 0) {
|
|
|
- // 负号不在首位则删除所有负号
|
|
|
filteredValue = filteredValue.replace(/-/g, '');
|
|
|
} else if (minusIndex === 0) {
|
|
|
- // 保留首位的负号并移除其他负号
|
|
|
filteredValue = '-' + filteredValue.substring(1).replace(/-/g, '');
|
|
|
}
|
|
|
|
|
|
- // 3. 处理小数点规则
|
|
|
const dotIndex = filteredValue.indexOf('.');
|
|
|
if (dotIndex !== -1) {
|
|
|
- // 只保留第一个小数点,移除后续小数点
|
|
|
const parts = filteredValue.split('.');
|
|
|
filteredValue = parts[0] + '.' + parts.slice(1).join('');
|
|
|
}
|
|
|
- // 4. 更新绑定值
|
|
|
this.form.defaultValue = filteredValue;
|
|
|
},
|
|
|
- /* 保存编辑 */
|
|
|
+
|
|
|
save() {
|
|
|
this.$refs.form.validate((valid) => {
|
|
|
if (!valid) {
|
|
|
@@ -533,7 +523,7 @@
|
|
|
});
|
|
|
});
|
|
|
},
|
|
|
- /* 更新visible */
|
|
|
+
|
|
|
updateVisible(value) {
|
|
|
this.$emit('update:visible', value);
|
|
|
},
|
|
|
@@ -570,6 +560,7 @@
|
|
|
addPostscript() {
|
|
|
this.form.postscriptList.push({ sort: null, content: '' });
|
|
|
},
|
|
|
+
|
|
|
removePostscript(idx, row) {
|
|
|
this.$confirm(`是否删除这个注意事项?`).then(async () => {
|
|
|
this.form.postscriptList.splice(idx, 1);
|
|
|
@@ -585,20 +576,20 @@
|
|
|
if (visible) {
|
|
|
if (this.data) {
|
|
|
const res = await getById(this.data.id);
|
|
|
-
|
|
|
- this.$util.assignObject(this.form, {
|
|
|
- ...res.data
|
|
|
- });
|
|
|
+ this.$util.assignObject(this.form, { ...res.data });
|
|
|
this.isUpdate = true;
|
|
|
+ // 编辑模式下触发标准代码填充
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.handleStandardChange();
|
|
|
+ });
|
|
|
} else {
|
|
|
const code = await getCode('inspection_code');
|
|
|
this.form.inspectionCode = code;
|
|
|
-
|
|
|
+ this.form.qualityStandardCode = '';
|
|
|
this.isUpdate = false;
|
|
|
}
|
|
|
} else {
|
|
|
this.$refs.form.clearValidate();
|
|
|
-
|
|
|
this.form = { ...this.defaultForm };
|
|
|
}
|
|
|
}
|
|
|
@@ -624,4 +615,4 @@
|
|
|
::v-deep .el-form-item__content {
|
|
|
display: flex !important;
|
|
|
}
|
|
|
-</style>
|
|
|
+</style>
|