fix(qc/inspection): 修复产品检验入场卷号校验逻辑
1. 移除表单内置的入场卷号校验规则,改为手动校验 2. 添加失焦校验和实时错误提示 3. 优化两个页面的卷号选择表单结构
This commit is contained in:
@@ -265,7 +265,7 @@
|
||||
<i class="el-icon-info" style="margin-right: 4px;"></i>
|
||||
可输入入场卷号或厂家卷号,两者互通匹配
|
||||
</div>
|
||||
<el-form-item label="入场卷号" prop="enterCoilNos">
|
||||
<el-form-item label="入场卷号">
|
||||
<div style="display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px;">
|
||||
<el-tag
|
||||
v-for="(coilNo, index) in selectedEnterCoilNos"
|
||||
@@ -284,8 +284,12 @@
|
||||
:trigger-on-focus="false"
|
||||
clearable
|
||||
@select="handleSelectEnterCoilNo"
|
||||
@blur="validateEnterCoilNos"
|
||||
/>
|
||||
<div style="display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px;" v-if="selectedSupplierCoilNos.length > 0">
|
||||
<div v-if="enterCoilNoError" class="el-form-item__error" style="position: static; padding-top: 0;">请输入入场卷号</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="厂家卷号">
|
||||
<div style="display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px;" v-if="selectedSupplierCoilNos.length > 0">
|
||||
<el-tag
|
||||
v-for="(coilNo, index) in selectedSupplierCoilNos"
|
||||
:key="'s-' + index"
|
||||
@@ -299,13 +303,12 @@
|
||||
<el-autocomplete
|
||||
v-model="tempSupplierCoilNo"
|
||||
:fetch-suggestions="querySupplierCoilNo"
|
||||
placeholder="或输入厂家卷号自动匹配"
|
||||
placeholder="输入厂家卷号自动匹配"
|
||||
:loading="supplierCoilNoLoading"
|
||||
:trigger-on-focus="false"
|
||||
clearable
|
||||
size="small"
|
||||
@select="handleSelectSupplierCoilNo"
|
||||
style="margin-top: 6px;"
|
||||
/>
|
||||
</el-form-item>
|
||||
</div>
|
||||
@@ -527,14 +530,12 @@ export default {
|
||||
attachmentLoading: false,
|
||||
attachmentTaskRow: null,
|
||||
attachmentFiles: '',
|
||||
enterCoilNoError: false,
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
taskRules() {
|
||||
return {
|
||||
...this.baseTaskRules,
|
||||
enterCoilNos: [{ required: this.taskForm.taskType === '产品检验', message: '请输入入场卷号', trigger: 'blur' }],
|
||||
};
|
||||
return { ...this.baseTaskRules };
|
||||
},
|
||||
itemReadonly() {
|
||||
if (!this.readonly) return false;
|
||||
@@ -629,7 +630,12 @@ export default {
|
||||
this.taskTitle = "修改检验任务";
|
||||
});
|
||||
},
|
||||
validateEnterCoilNos() {
|
||||
this.enterCoilNoError = this.taskForm.taskType === '产品检验' && this.selectedEnterCoilNos.length === 0;
|
||||
},
|
||||
submitTaskForm() {
|
||||
this.validateEnterCoilNos();
|
||||
if (this.enterCoilNoError) return;
|
||||
this.$refs["taskForm"].validate(valid => {
|
||||
if (valid) {
|
||||
this.buttonLoading = true;
|
||||
@@ -794,12 +800,13 @@ export default {
|
||||
if (!this.selectedEnterCoilNos.includes(item.value)) {
|
||||
this.selectedEnterCoilNos.push(item.value);
|
||||
}
|
||||
this.tempEnterCoilNo = '';
|
||||
this.taskForm.enterCoilNos = this.selectedEnterCoilNos.join(',');
|
||||
this.validateEnterCoilNos();
|
||||
},
|
||||
removeEnterCoilNo(index) {
|
||||
this.selectedEnterCoilNos.splice(index, 1);
|
||||
this.taskForm.enterCoilNos = this.selectedEnterCoilNos.join(',');
|
||||
this.validateEnterCoilNos();
|
||||
},
|
||||
querySupplierCoilNo(queryString, cb) {
|
||||
if (!queryString || queryString.length < 2) {
|
||||
@@ -830,9 +837,9 @@ export default {
|
||||
if (item.enterCoilNo && !this.selectedEnterCoilNos.includes(item.enterCoilNo)) {
|
||||
this.selectedEnterCoilNos.push(item.enterCoilNo);
|
||||
this.taskForm.enterCoilNos = this.selectedEnterCoilNos.join(',');
|
||||
this.$refs["taskForm"].validateField('enterCoilNos');
|
||||
}
|
||||
this.tempSupplierCoilNo = '';
|
||||
this.validateEnterCoilNos();
|
||||
},
|
||||
removeSupplierCoilNo(index) {
|
||||
this.selectedSupplierCoilNos.splice(index, 1);
|
||||
@@ -870,6 +877,7 @@ export default {
|
||||
this.tempEnterCoilNo = '';
|
||||
this.selectedSupplierCoilNos = [];
|
||||
this.tempSupplierCoilNo = '';
|
||||
this.enterCoilNoError = false;
|
||||
this.resetForm("taskForm");
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user