Compare commits

...

2 Commits

Author SHA1 Message Date
effc1f6f2e Merge branch '0.8.X' of http://49.232.154.205:10100/DeXun/klp-oa into 0.8.X 2026-06-01 16:40:15 +08:00
ca285f78c6 feat(qc): 新增厂家卷号匹配功能,优化卷号录入体验
本次改动在检验任务、化学成分报告、物理性能报告模块中:
1. 支持通过入场卷号和厂家卷号双向搜索匹配
2. 新增多选卷号标签式展示与删除功能
3. 新增批量导入时厂家卷号自动匹配入场卷号的逻辑,包含多匹配结果弹窗选择
4. 在表格中新增厂家卷号展示列,更新导入模板支持厂家卷号字段
2026-06-01 16:40:13 +08:00
4 changed files with 525 additions and 56 deletions

View File

@@ -73,17 +73,56 @@
</el-form-item>
</el-form>
<el-form :model="form" ref="taskForm" label-width="80px" size="small" v-if="form.taskType === '产品检验'">
<el-form-item label="入场卷号" prop="enterCoilNos" :rules="[{ required: true, message: '请输入入场卷号', trigger: 'blur' }]">
<el-autocomplete
v-model="form.enterCoilNos"
:fetch-suggestions="queryCoilNo"
placeholder="请输入入场卷号输入2个字符以上自动搜索"
:loading="coilNoLoading"
:trigger-on-focus="false"
clearable
style="width: 280px;"
/>
</el-form-item>
<div style="background: #f5f7fa; border: 1px solid #e4e7ed; border-radius: 6px; padding: 12px 16px 8px 16px; margin-bottom: 4px;">
<div style="font-size: 12px; color: #909399; margin-bottom: 8px; line-height: 1.6;">
<i class="el-icon-info" style="margin-right: 4px;"></i>
可输入入场卷号或厂家卷号两者互通匹配
</div>
<el-form-item label="入场卷号" prop="enterCoilNos" :rules="[{ required: true, message: '请输入入场卷号', trigger: 'blur' }]">
<div style="display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px;">
<el-tag
v-for="(coilNo, index) in selectedEnterCoilNos"
:key="'enter-' + index"
closable
@close="removeEnterCoilNo(index)"
>
{{ coilNo }}
</el-tag>
</div>
<el-autocomplete
v-model="tempEnterCoilNo"
:fetch-suggestions="queryCoilNo"
placeholder="输入入场卷号搜索添加"
:loading="coilNoLoading"
:trigger-on-focus="false"
clearable
style="width: 280px;"
@select="handleSelectCoilNo"
/>
<div style="display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px;" v-if="selectedSupplierCoilNos.length > 0">
<el-tag
v-for="(coilNo, index) in selectedSupplierCoilNos"
:key="'supplier-' + index"
type="info"
closable
@close="removeSupplierCoilNo(index)"
>
{{ coilNo }}
</el-tag>
</div>
<el-autocomplete
v-model="tempSupplierCoilNo"
:fetch-suggestions="querySupplierCoilNo"
placeholder="或输入厂家卷号自动匹配"
:loading="supplierCoilNoLoading"
:trigger-on-focus="false"
clearable
size="small"
style="width: 280px; margin-top: 6px;"
@select="handleSelectSupplierCoilNo"
/>
</el-form-item>
</div>
</el-form>
<!-- <div style="margin-bottom: 8px;">
<CoilSelector use-trigger multiple @confirm="handleCoilConfirm">
@@ -190,6 +229,11 @@ export default {
},
coilNoOptions: [],
coilNoLoading: false,
selectedEnterCoilNos: [],
tempEnterCoilNo: '',
selectedSupplierCoilNos: [],
tempSupplierCoilNo: '',
supplierCoilNoLoading: false,
};
},
computed: {
@@ -208,6 +252,10 @@ export default {
this.checkItemList = [];
this.form.taskCode = undefined;
this.selectedCoils = [];
this.selectedEnterCoilNos = [];
this.tempEnterCoilNo = '';
this.selectedSupplierCoilNos = [];
this.tempSupplierCoilNo = '';
this.getList();
}
}
@@ -264,7 +312,8 @@ export default {
taskType: this.form.taskType,
belongCompany: this.form.belongCompany || undefined,
coilIds: coilIds || undefined,
enterCoilNos: this.form.enterCoilNos || undefined
enterCoilNos: this.form.enterCoilNos || undefined,
supplierCoilNos: this.form.supplierCoilNos || undefined
});
this.dialogVisible = false;
}
@@ -303,11 +352,59 @@ export default {
const options = (response.rows || []).map(item => ({
value: item.enterCoilNo,
label: item.enterCoilNo
}));
})).filter(opt => !this.selectedEnterCoilNos.includes(opt.value));
cb(options);
}).finally(() => {
this.coilNoLoading = false;
});
},
handleSelectCoilNo(item) {
if (!this.selectedEnterCoilNos.includes(item.value)) {
this.selectedEnterCoilNos.push(item.value);
}
this.tempEnterCoilNo = '';
this.form.enterCoilNos = this.selectedEnterCoilNos.join(',');
},
removeEnterCoilNo(index) {
this.selectedEnterCoilNos.splice(index, 1);
this.form.enterCoilNos = this.selectedEnterCoilNos.join(',');
},
querySupplierCoilNo(queryString, cb) {
if (!queryString || queryString.length < 2) {
cb([]);
return;
}
this.supplierCoilNoLoading = true;
listMaterialCoil({
supplierCoilNo: queryString,
pageNum: 1,
pageSize: 20
}).then(response => {
const options = (response.rows || []).map(item => ({
value: item.supplierCoilNo,
label: item.supplierCoilNo,
enterCoilNo: item.enterCoilNo
})).filter(opt => !this.selectedSupplierCoilNos.includes(opt.value));
cb(options);
}).finally(() => {
this.supplierCoilNoLoading = false;
});
},
handleSelectSupplierCoilNo(item) {
if (!this.selectedSupplierCoilNos.includes(item.value)) {
this.selectedSupplierCoilNos.push(item.value);
}
this.form.supplierCoilNos = this.selectedSupplierCoilNos.join(',');
if (item.enterCoilNo && !this.selectedEnterCoilNos.includes(item.enterCoilNo)) {
this.selectedEnterCoilNos.push(item.enterCoilNo);
this.form.enterCoilNos = this.selectedEnterCoilNos.join(',');
this.$refs["taskForm"].validateField('enterCoilNos');
}
this.tempSupplierCoilNo = '';
},
removeSupplierCoilNo(index) {
this.selectedSupplierCoilNos.splice(index, 1);
this.form.supplierCoilNos = this.selectedSupplierCoilNos.join(',');
}
}
};

View File

@@ -132,11 +132,22 @@
<el-autocomplete
v-model="form.coilNo"
:fetch-suggestions="queryCoilNo"
placeholder="输入入场钢卷号输入2个字符以上自动搜索"
placeholder="输入入场钢卷号搜索"
:loading="coilNoLoading"
:trigger-on-focus="false"
clearable
/>
<el-autocomplete
v-model="tempSupplierCoilNo"
:fetch-suggestions="querySupplierCoilNo"
placeholder="或输入厂家卷号自动匹配"
:loading="supplierCoilNoLoading"
:trigger-on-focus="false"
clearable
size="small"
@select="handleSelectSupplierCoilNo"
style="margin-top: 6px;"
/>
</el-form-item>
<el-form-item label="炉号" prop="heatNo">
<el-input v-model="form.heatNo" placeholder="请输入炉号" />
@@ -248,6 +259,7 @@
:row-class-name="importTableRowClassName">
<el-table-column label="#" width="48" type="index" align="center" />
<el-table-column prop="coilNo" label="入场钢卷号" width="140" />
<el-table-column prop="supplierCoilNo" label="厂家卷号" width="120" />
<el-table-column prop="c" label="C(%)" width="70" align="center" />
<el-table-column prop="si" label="Si(%)" width="70" align="center" />
<el-table-column prop="mn" label="Mn(%)" width="70" align="center" />
@@ -295,6 +307,31 @@
</div>
</el-dialog>
<el-dialog title="选择对应入场卷号" :visible.sync="ambiguousVisible" width="600px" append-to-body :close-on-click-modal="false">
<div style="font-size: 12px; color: #909399; margin-bottom: 12px;">
厂家卷号匹配到多条入场卷号请为每行选择对应记录
</div>
<el-table :data="ambiguousRows" border size="small" max-height="350">
<el-table-column label="厂家卷号" prop="supplierCoilNo" width="140" />
<el-table-column label="选择入场卷号" min-width="280">
<template slot-scope="scope">
<el-select v-model="scope.row.selected" placeholder="请选择入场卷号" size="small" style="width: 100%;">
<el-option
v-for="opt in scope.row.options"
:key="opt"
:label="opt"
:value="opt"
/>
</el-select>
</template>
</el-table-column>
</el-table>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="confirmAmbiguous"> </el-button>
<el-button @click="ambiguousVisible = false"> </el-button>
</div>
</el-dialog>
</div>
</template>
@@ -304,10 +341,11 @@ import { listChemicalItem, getChemicalItem, delChemicalItem, addChemicalItem, up
import CoilSelector from "@/components/CoilSelector";
import { listMaterialCoil } from "@/api/wms/coil";
const CHEMI_TEMPLATE_HEADERS = ['入场钢卷号', 'C(%)', 'Si(%)', 'Mn(%)', 'P(%)', 'S(%)', 'Als(%)', 'Al(%)', 'Ti(%)', 'Cr(%)', 'Ni(%)', 'Cu(%)', 'N(%)', 'Fe(%)', 'B(%)'];
const CHEMI_TEMPLATE_HEADERS = ['入场钢卷号', '厂家卷号', 'C(%)', 'Si(%)', 'Mn(%)', 'P(%)', 'S(%)', 'Als(%)', 'Al(%)', 'Ti(%)', 'Cr(%)', 'Ni(%)', 'Cu(%)', 'N(%)', 'Fe(%)', 'B(%)'];
const CHEMI_HEADER_MAP = {
'入场钢卷号': 'coilNo',
'厂家卷号': 'supplierCoilNo',
'C(%)': 'c',
'Si(%)': 'si',
'Mn(%)': 'mn',
@@ -395,6 +433,10 @@ export default {
importLoading: false,
coilNoOptions: [],
coilNoLoading: false,
tempSupplierCoilNo: '',
supplierCoilNoLoading: false,
ambiguousVisible: false,
ambiguousRows: [],
};
},
created() {
@@ -490,6 +532,34 @@ export default {
this.coilNoLoading = false;
});
},
querySupplierCoilNo(queryString, cb) {
if (!queryString || queryString.length < 2) {
cb([]);
return;
}
this.supplierCoilNoLoading = true;
listMaterialCoil({
supplierCoilNo: queryString,
pageNum: 1,
pageSize: 20
}).then(response => {
const options = (response.rows || []).map(item => ({
value: item.supplierCoilNo,
label: item.supplierCoilNo,
enterCoilNo: item.enterCoilNo
}));
cb(options);
}).finally(() => {
this.supplierCoilNoLoading = false;
});
},
handleSelectSupplierCoilNo(item) {
if (item.enterCoilNo) {
this.form.coilNo = item.enterCoilNo;
this.$refs["form"].validateField('coilNo');
}
this.tempSupplierCoilNo = '';
},
handleBatchAdd(rows) {
this.loading = true;
this.buttonLoading = true;
@@ -559,12 +629,90 @@ export default {
if (!this.importFile || !this.importRawData.length) { this.$message.warning('暂无数据可校验'); return; }
this.importValidateLoading = true;
this.importErrorList = [];
for (let i = 0; i < this.importRawData.length; i++) {
this.ambiguousRows = [];
const dataRows = this.importRawData;
for (let i = 0; i < dataRows.length; i++) {
const rowNum = i + 2;
let coilNo = '';
CHEMI_TEMPLATE_HEADERS.forEach((h, j) => { if (CHEMI_HEADER_MAP[h] === 'coilNo') coilNo = this.importRawData[i][j]; });
if (!coilNo || !String(coilNo).trim()) this.importErrorList.push({ rowNum, errorMsg: '当前钢卷号不能为空' });
let coilNo = '', supplierCoilNo = '';
CHEMI_TEMPLATE_HEADERS.forEach((h, j) => {
if (CHEMI_HEADER_MAP[h] === 'coilNo') coilNo = dataRows[i][j];
if (CHEMI_HEADER_MAP[h] === 'supplierCoilNo') supplierCoilNo = dataRows[i][j];
});
coilNo = String(coilNo || '').trim();
supplierCoilNo = String(supplierCoilNo || '').trim();
if (!coilNo && !supplierCoilNo) {
this.importErrorList.push({ rowNum, errorMsg: '入场钢卷号和厂家卷号不能同时为空' });
}
}
// 处理仅填写厂家卷号的行
if (this.importErrorList.length === 0) {
this.importTableData.forEach((row, idx) => {
const cn = (row.coilNo || '').trim();
const sn = (row.supplierCoilNo || '').trim();
row._sno = sn;
row._idx = idx;
row._fillCoilNo = cn;
// 仅厂家卷号且无入场卷号的行需匹配
if (sn && !cn) row._needMatch = true;
});
const needMatchRows = this.importTableData.filter(r => r._needMatch);
if (needMatchRows.length > 0) {
const uniqueSnos = [...new Set(needMatchRows.map(r => r._sno))];
const multiMap = {}; // supplierCoilNo -> [enterCoilNo, ...]
try {
const results = await Promise.all(
uniqueSnos.map(sno => listMaterialCoil({ supplierCoilNo: sno, pageNum: 1, pageSize: 50 }))
);
uniqueSnos.forEach((sno, idx) => {
const rows = (results[idx] && results[idx].rows) || [];
const enterNos = [...new Set(rows.map(r => r.enterCoilNo).filter(Boolean))];
multiMap[sno] = enterNos;
});
} catch (err) {
this.importValidateLoading = false;
this.importHandleError('厂家卷号匹配失败:' + err.message);
return;
}
const ambiguousList = [];
needMatchRows.forEach(row => {
const candidates = multiMap[row._sno] || [];
if (candidates.length === 0) {
this.importErrorList.push({ rowNum: (row.rowNum || (row._idx + 2)), errorMsg: `厂家卷号"${row._sno}"未匹配到入场卷号` });
} else if (candidates.length === 1) {
row.coilNo = candidates[0];
} else {
ambiguousList.push({
_idx: row._idx,
supplierCoilNo: row._sno,
options: candidates,
selected: null
});
}
});
if (ambiguousList.length > 0) {
this.ambiguousRows = ambiguousList;
this.importValidateLoading = false;
this.ambiguousVisible = true;
return;
}
}
}
this.finishValidation();
},
confirmAmbiguous() {
const unselected = this.ambiguousRows.filter(r => !r.selected);
if (unselected.length > 0) {
this.$message.warning('请为所有行选择入场卷号');
return;
}
this.ambiguousRows.forEach(item => {
this.importTableData[item._idx].coilNo = item.selected;
});
this.ambiguousVisible = false;
this.importValidateLoading = true;
this.finishValidation();
},
finishValidation() {
if (this.importErrorList.length > 0) {
this.$message.error(`数据校验失败,共发现${this.importErrorList.length}条错误`);
} else {
@@ -617,10 +765,10 @@ export default {
this.$refs.importUpload?.clearFiles();
},
importDownloadTemplate() {
const data = [CHEMI_TEMPLATE_HEADERS, ['示例卷号', '0.05', '0.02', '0.30', '0.015', '0.008', '0.040', '0.04', '0.05', '0.03', '0.02', '0.03', '0.005', '98', '0.001']];
const data = [CHEMI_TEMPLATE_HEADERS, ['示例卷号', '示例厂家卷号', '0.05', '0.02', '0.30', '0.015', '0.008', '0.040', '0.04', '0.05', '0.03', '0.02', '0.03', '0.005', '98', '0.001']];
const wb = XLSX.utils.book_new();
const ws = XLSX.utils.aoa_to_sheet(data);
ws['!cols'] = [{ wch: 16 }, { wch: 8 }, { wch: 8 }, { wch: 8 }, { wch: 8 }, { wch: 8 }, { wch: 8 }, { wch: 8 }, { wch: 8 }, { wch: 8 }, { wch: 8 }, { wch: 8 }, { wch: 8 }, { wch: 8 }, { wch: 8 }];
ws['!cols'] = [{ wch: 16 }, { wch: 16 }, { wch: 8 }, { wch: 8 }, { wch: 8 }, { wch: 8 }, { wch: 8 }, { wch: 8 }, { wch: 8 }, { wch: 8 }, { wch: 8 }, { wch: 8 }, { wch: 8 }, { wch: 8 }, { wch: 8 }, { wch: 8 }];
XLSX.utils.book_append_sheet(wb, ws, '导入模板');
XLSX.writeFile(wb, '化学成分导入模板.xlsx');
},

View File

@@ -185,11 +185,22 @@
<el-autocomplete
v-model="form.coilNo"
:fetch-suggestions="queryCoilNo"
placeholder="输入入场钢卷号输入2个字符以上自动搜索"
placeholder="输入入场钢卷号搜索"
:loading="coilNoLoading"
:trigger-on-focus="false"
clearable
/>
<el-autocomplete
v-model="tempSupplierCoilNo"
:fetch-suggestions="querySupplierCoilNo"
placeholder="或输入厂家卷号自动匹配"
:loading="supplierCoilNoLoading"
:trigger-on-focus="false"
clearable
size="small"
@select="handleSelectSupplierCoilNo"
style="margin-top: 6px;"
/>
</el-form-item>
<el-form-item label="屈服强度(MPa)" prop="yieldStrength">
<el-input v-model="form.yieldStrength" placeholder="请输入屈服强度(MPa)" />
@@ -278,14 +289,13 @@
</div>
</div>
<!-- 数据预览表格 -->
<div v-if="importTableData.length > 0" class="data-preview">
<el-table ref="importTable" :data="importTableData" border size="small" max-height="340" stripe
:row-class-name="importTableRowClassName">
<el-table-column label="#" width="48" type="index" align="center" />
<el-table-column prop="coilNo" label="入场钢卷号" width="140" />
<el-table-column prop="supplierCoilNo" label="厂家卷号" width="120" />
<el-table-column prop="yieldStrength" label="屈服强度(MPa)" width="110" align="center" />
<el-table-column prop="tensileStrength" label="抗拉强度(MPa)" width="110" align="center" />
<el-table-column prop="elongation" label="伸长率(%)" width="80" align="center" />
@@ -297,7 +307,6 @@
<el-table-column prop="surfaceStructure" label="表面结构" width="80" align="center" />
<el-table-column prop="coatingSurfaceStructure" label="镀层表面结构" width="90" align="center" />
<el-table-column prop="edgeStatus" label="边缘状态" width="80" align="center" />
</el-table>
</div>
@@ -327,9 +336,31 @@
<div class="result-desc">{{ importErrorMsg }}</div>
</div>
</div>
</div>
</el-dialog>
<el-dialog title="选择对应入场卷号" :visible.sync="ambiguousVisible" width="600px" append-to-body :close-on-click-modal="false">
<div style="font-size: 12px; color: #909399; margin-bottom: 12px;">
厂家卷号匹配到多条入场卷号请为每行选择对应记录
</div>
<el-table :data="ambiguousRows" border size="small" max-height="350">
<el-table-column label="厂家卷号" prop="supplierCoilNo" width="140" />
<el-table-column label="选择入场卷号" min-width="280">
<template slot-scope="scope">
<el-select v-model="scope.row.selected" placeholder="请选择入场卷号" size="small" style="width: 100%;">
<el-option
v-for="opt in scope.row.options"
:key="opt"
:label="opt"
:value="opt"
/>
</el-select>
</template>
</el-table-column>
</el-table>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="confirmAmbiguous"> </el-button>
<el-button @click="ambiguousVisible = false"> </el-button>
</div>
</el-dialog>
@@ -343,12 +374,13 @@ import CoilSelector from "@/components/CoilSelector";
import { listMaterialCoil } from "@/api/wms/coil";
const PHYS_TEMPLATE_HEADERS = [
'当前钢卷号', '屈服强度(MPa)', '抗拉强度(MPa)', '伸长率(%)', '规定塑性延伸强度(MPa)', '硬度(HRB)',
'当前钢卷号', '厂家卷号', '屈服强度(MPa)', '抗拉强度(MPa)', '伸长率(%)', '规定塑性延伸强度(MPa)', '硬度(HRB)',
'镀层重量(g/m²)', '弯曲试验', '表面质量', '表面结构', '镀层表面结构', '边缘状态'
];
const PHYS_HEADER_MAP = {
'当前钢卷号': 'coilNo',
'厂家卷号': 'supplierCoilNo',
'屈服强度(MPa)': 'yieldStrength',
'抗拉强度(MPa)': 'tensileStrength',
'伸长率(%)': 'elongation',
@@ -429,6 +461,10 @@ export default {
importLoading: false,
coilNoOptions: [],
coilNoLoading: false,
tempSupplierCoilNo: '',
supplierCoilNoLoading: false,
ambiguousVisible: false,
ambiguousRows: [],
};
},
created() {
@@ -520,6 +556,34 @@ export default {
this.coilNoLoading = false;
});
},
querySupplierCoilNo(queryString, cb) {
if (!queryString || queryString.length < 2) {
cb([]);
return;
}
this.supplierCoilNoLoading = true;
listMaterialCoil({
supplierCoilNo: queryString,
pageNum: 1,
pageSize: 20
}).then(response => {
const options = (response.rows || []).map(item => ({
value: item.supplierCoilNo,
label: item.supplierCoilNo,
enterCoilNo: item.enterCoilNo
}));
cb(options);
}).finally(() => {
this.supplierCoilNoLoading = false;
});
},
handleSelectSupplierCoilNo(item) {
if (item.enterCoilNo) {
this.form.coilNo = item.enterCoilNo;
this.$refs["form"].validateField('coilNo');
}
this.tempSupplierCoilNo = '';
},
handleBatchAdd(rows) {
this.loading = true;
this.buttonLoading = true;
@@ -589,12 +653,89 @@ export default {
if (!this.importFile || !this.importRawData.length) { this.$message.warning('暂无数据可校验'); return; }
this.importValidateLoading = true;
this.importErrorList = [];
for (let i = 0; i < this.importRawData.length; i++) {
this.ambiguousRows = [];
const dataRows = this.importRawData;
for (let i = 0; i < dataRows.length; i++) {
const rowNum = i + 2;
let coilNo = '';
PHYS_TEMPLATE_HEADERS.forEach((h, j) => { if (PHYS_HEADER_MAP[h] === 'coilNo') coilNo = this.importRawData[i][j]; });
if (!coilNo || !String(coilNo).trim()) this.importErrorList.push({ rowNum, errorMsg: '当前钢卷号不能为空' });
let coilNo = '', supplierCoilNo = '';
PHYS_TEMPLATE_HEADERS.forEach((h, j) => {
if (PHYS_HEADER_MAP[h] === 'coilNo') coilNo = dataRows[i][j];
if (PHYS_HEADER_MAP[h] === 'supplierCoilNo') supplierCoilNo = dataRows[i][j];
});
coilNo = String(coilNo || '').trim();
supplierCoilNo = String(supplierCoilNo || '').trim();
if (!coilNo && !supplierCoilNo) {
this.importErrorList.push({ rowNum, errorMsg: '当前钢卷号和厂家卷号不能同时为空' });
}
}
// 处理仅填写厂家卷号的行
if (this.importErrorList.length === 0) {
this.importTableData.forEach((row, idx) => {
const cn = (row.coilNo || '').trim();
const sn = (row.supplierCoilNo || '').trim();
row._sno = sn;
row._idx = idx;
row._fillCoilNo = cn;
if (sn && !cn) row._needMatch = true;
});
const needMatchRows = this.importTableData.filter(r => r._needMatch);
if (needMatchRows.length > 0) {
const uniqueSnos = [...new Set(needMatchRows.map(r => r._sno))];
const multiMap = {};
try {
const results = await Promise.all(
uniqueSnos.map(sno => listMaterialCoil({ supplierCoilNo: sno, pageNum: 1, pageSize: 50 }))
);
uniqueSnos.forEach((sno, idx) => {
const rows = (results[idx] && results[idx].rows) || [];
const enterNos = [...new Set(rows.map(r => r.enterCoilNo).filter(Boolean))];
multiMap[sno] = enterNos;
});
} catch (err) {
this.importValidateLoading = false;
this.importHandleError('厂家卷号匹配失败:' + err.message);
return;
}
const ambiguousList = [];
needMatchRows.forEach(row => {
const candidates = multiMap[row._sno] || [];
if (candidates.length === 0) {
this.importErrorList.push({ rowNum: (row.rowNum || (row._idx + 2)), errorMsg: `厂家卷号"${row._sno}"未匹配到入场卷号` });
} else if (candidates.length === 1) {
row.coilNo = candidates[0];
} else {
ambiguousList.push({
_idx: row._idx,
supplierCoilNo: row._sno,
options: candidates,
selected: null
});
}
});
if (ambiguousList.length > 0) {
this.ambiguousRows = ambiguousList;
this.importValidateLoading = false;
this.ambiguousVisible = true;
return;
}
}
}
this.finishValidation();
},
confirmAmbiguous() {
const unselected = this.ambiguousRows.filter(r => !r.selected);
if (unselected.length > 0) {
this.$message.warning('请为所有行选择入场卷号');
return;
}
this.ambiguousRows.forEach(item => {
this.importTableData[item._idx].coilNo = item.selected;
});
this.ambiguousVisible = false;
this.importValidateLoading = true;
this.finishValidation();
},
finishValidation() {
if (this.importErrorList.length > 0) {
this.$message.error(`数据校验失败,共发现${this.importErrorList.length}条错误`);
} else {
@@ -647,10 +788,10 @@ export default {
this.$refs.importUpload?.clearFiles();
},
importDownloadTemplate() {
const data = [PHYS_TEMPLATE_HEADERS, ['示例卷号', '300', '420', '35', '260', '85', '275', '合格', '良好', '光面', '无锌花', '良好']];
const data = [PHYS_TEMPLATE_HEADERS, ['示例卷号', '示例厂家卷号', '300', '420', '35', '260', '85', '275', '合格', '良好', '光面', '无锌花', '良好']];
const wb = XLSX.utils.book_new();
const ws = XLSX.utils.aoa_to_sheet(data);
ws['!cols'] = [{ wch: 16 }, { wch: 16 }, { wch: 16 }, { wch: 10 }, { wch: 20 }, { wch: 10 }, { wch: 16 }, { wch: 10 }, { wch: 10 }, { wch: 10 }, { wch: 12 }, { wch: 10 }];
ws['!cols'] = [{ wch: 16 }, { wch: 16 }, { wch: 16 }, { wch: 16 }, { wch: 10 }, { wch: 20 }, { wch: 10 }, { wch: 16 }, { wch: 10 }, { wch: 10 }, { wch: 10 }, { wch: 12 }, { wch: 10 }];
XLSX.utils.book_append_sheet(wb, ws, '导入模板');
XLSX.writeFile(wb, '物理性能导入模板.xlsx');
},

View File

@@ -75,6 +75,7 @@
<el-table-column label="任务编号" align="center" prop="taskCode" />
<el-table-column label="任务类型" align="center" prop="taskType" />
<el-table-column label="入场卷号" align="center" prop="enterCoilNos" />
<el-table-column label="厂家卷号" align="center" prop="supplierCoilNos" />
<el-table-column label="所属单位" align="center" prop="belongCompany" />
<el-table-column label="方案名称" align="center" prop="schemeName" />
<el-table-column label="状态" align="center" prop="status" width="90">
@@ -258,27 +259,57 @@
<el-option label="产品检验" value="产品检验" />
</el-select>
</el-form-item>
<el-form-item label="入场卷号" prop="enterCoilNos" v-if="taskForm.taskType === '产品检验'">
<div style="display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px;">
<el-tag
v-for="(coilNo, index) in selectedEnterCoilNos"
:key="index"
closable
@close="removeEnterCoilNo(index)"
>
{{ coilNo }}
</el-tag>
<template v-if="taskForm.taskType === '产品检验'">
<div style="background: #f5f7fa; border: 1px solid #e4e7ed; border-radius: 6px; padding: 12px 16px 8px 16px; margin-bottom: 18px;">
<div style="font-size: 12px; color: #909399; margin-bottom: 8px; line-height: 1.6;">
<i class="el-icon-info" style="margin-right: 4px;"></i>
可输入入场卷号或厂家卷号两者互通匹配
</div>
<el-form-item label="入场卷号" prop="enterCoilNos">
<div style="display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px;">
<el-tag
v-for="(coilNo, index) in selectedEnterCoilNos"
:key="index"
closable
@close="removeEnterCoilNo(index)"
>
{{ coilNo }}
</el-tag>
</div>
<el-autocomplete
v-model="tempEnterCoilNo"
:fetch-suggestions="queryEnterCoilNo"
placeholder="输入入场卷号搜索添加"
:loading="enterCoilNoLoading"
:trigger-on-focus="false"
clearable
@select="handleSelectEnterCoilNo"
/>
<div style="display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px;" v-if="selectedSupplierCoilNos.length > 0">
<el-tag
v-for="(coilNo, index) in selectedSupplierCoilNos"
:key="'s-' + index"
type="info"
closable
@close="removeSupplierCoilNo(index)"
>
{{ coilNo }}
</el-tag>
</div>
<el-autocomplete
v-model="tempSupplierCoilNo"
:fetch-suggestions="querySupplierCoilNo"
placeholder="或输入厂家卷号自动匹配"
:loading="supplierCoilNoLoading"
:trigger-on-focus="false"
clearable
size="small"
@select="handleSelectSupplierCoilNo"
style="margin-top: 6px;"
/>
</el-form-item>
</div>
<el-autocomplete
v-model="tempEnterCoilNo"
:fetch-suggestions="queryEnterCoilNo"
placeholder="2个字符以上自动搜索"
:loading="enterCoilNoLoading"
:trigger-on-focus="false"
clearable
@select="handleSelectEnterCoilNo"
/>
</el-form-item>
</template>
<el-form-item label="所属单位" prop="belongCompany">
<el-input v-model="taskForm.belongCompany" placeholder="请输入所属单位" />
</el-form-item>
@@ -488,6 +519,9 @@ export default {
enterCoilNoLoading: false,
selectedEnterCoilNos: [],
tempEnterCoilNo: '',
selectedSupplierCoilNos: [],
tempSupplierCoilNo: '',
supplierCoilNoLoading: false,
attachmentOpen: false,
attachmentTitle: '',
attachmentLoading: false,
@@ -558,6 +592,8 @@ export default {
this.resetTaskForm();
this.selectedEnterCoilNos = [];
this.tempEnterCoilNo = '';
this.selectedSupplierCoilNos = [];
this.tempSupplierCoilNo = '';
this.taskOpen = true;
this.taskTitle = "添加检验任务";
},
@@ -581,6 +617,13 @@ export default {
this.selectedEnterCoilNos = [];
}
this.tempEnterCoilNo = '';
// 初始化已选择的厂家卷号
if (response.data.supplierCoilNos) {
this.selectedSupplierCoilNos = response.data.supplierCoilNos.split(',').filter(item => item.trim());
} else {
this.selectedSupplierCoilNos = [];
}
this.tempSupplierCoilNo = '';
this.taskLoading = false;
this.taskOpen = true;
this.taskTitle = "修改检验任务";
@@ -636,7 +679,7 @@ export default {
handleQuickCreate() {
this.schemeVisible = true;
},
handleSchemeConfirm({ template, taskCode, taskType, belongCompany, coilIds, enterCoilNos }) {
handleSchemeConfirm({ template, taskCode, taskType, belongCompany, coilIds, enterCoilNos, supplierCoilNos }) {
this.taskLoading = true;
addInspectionTaskWithItems({
taskCode: taskCode,
@@ -645,7 +688,8 @@ export default {
belongCompany: belongCompany,
taskType: taskType,
coilIds: coilIds || undefined,
enterCoilNos: enterCoilNos || undefined
enterCoilNos: enterCoilNos || undefined,
supplierCoilNos: supplierCoilNos || undefined
}).then(() => {
this.$modal.msgSuccess("快捷创建成功");
this.getTaskList();
@@ -757,6 +801,43 @@ export default {
this.selectedEnterCoilNos.splice(index, 1);
this.taskForm.enterCoilNos = this.selectedEnterCoilNos.join(',');
},
querySupplierCoilNo(queryString, cb) {
if (!queryString || queryString.length < 2) {
cb([]);
return;
}
this.supplierCoilNoLoading = true;
listMaterialCoil({
supplierCoilNo: queryString,
pageNum: 1,
pageSize: 20
}).then(response => {
const options = (response.rows || []).map(item => ({
value: item.supplierCoilNo,
label: item.supplierCoilNo,
enterCoilNo: item.enterCoilNo
})).filter(opt => !this.selectedSupplierCoilNos.includes(opt.value));
cb(options);
}).finally(() => {
this.supplierCoilNoLoading = false;
});
},
handleSelectSupplierCoilNo(item) {
if (!this.selectedSupplierCoilNos.includes(item.value)) {
this.selectedSupplierCoilNos.push(item.value);
}
this.taskForm.supplierCoilNos = this.selectedSupplierCoilNos.join(',');
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 = '';
},
removeSupplierCoilNo(index) {
this.selectedSupplierCoilNos.splice(index, 1);
this.taskForm.supplierCoilNos = this.selectedSupplierCoilNos.join(',');
},
cancelTask() {
this.taskOpen = false;
this.resetTaskForm();
@@ -787,6 +868,8 @@ export default {
this.taskCoilList = [];
this.selectedEnterCoilNos = [];
this.tempEnterCoilNo = '';
this.selectedSupplierCoilNos = [];
this.tempSupplierCoilNo = '';
this.resetForm("taskForm");
},