BOM发料对比

This commit is contained in:
hjq
2026-06-22 18:08:34 +08:00
parent 5641188952
commit a8a6388d85

View File

@@ -289,20 +289,32 @@
if (this.officialSearch || this.officialStatusFilter) { if (this.officialSearch || this.officialStatusFilter) {
const keyword = this.officialSearch ? this.officialSearch.toLowerCase() : ''; const keyword = this.officialSearch ? this.officialSearch.toLowerCase() : '';
const statusFilter = this.officialStatusFilter; const statusFilter = this.officialStatusFilter;
const checkNode = (node) => { const checkNode = (node, parentKeywordMatched = false) => {
let match = true; let matchKeyword = parentKeywordMatched;
if (keyword) { if (!matchKeyword && keyword) {
match = match && ( matchKeyword = (
(node.sfc && node.sfc.toLowerCase().includes(keyword)) || (node.sfc && node.sfc.toLowerCase().includes(keyword)) ||
(node.material_code && node.material_code.toLowerCase().includes(keyword)) || (node.material_code && node.material_code.toLowerCase().includes(keyword)) ||
(node.material_name && node.material_name.toLowerCase().includes(keyword)) (node.material_name && node.material_name.toLowerCase().includes(keyword))
); );
} else if (!keyword) {
matchKeyword = true;
} }
if (statusFilter) { match = match && (node.status === statusFilter); }
if (match) return true; let matchStatus = true;
if (statusFilter) {
matchStatus = (node.status === statusFilter);
}
// 当前节点完全符合条件
if (matchKeyword && matchStatus) return true;
// 否则去检查子节点
// 传递 matchKeyword 给子节点:如果父节点搜索匹配了,子节点就不需要再匹配搜索框,只需匹配状态即可
if (node.children && node.children.length > 0) { if (node.children && node.children.length > 0) {
return node.children.some(child => checkNode(child)); return node.children.some(child => checkNode(child, matchKeyword));
} }
return false; return false;
}; };
result = result.filter(row => checkNode(row)); result = result.filter(row => checkNode(row));
@@ -319,20 +331,32 @@
if (this.inferredSearch || this.inferredStatusFilter) { if (this.inferredSearch || this.inferredStatusFilter) {
const keyword = this.inferredSearch ? this.inferredSearch.toLowerCase() : ''; const keyword = this.inferredSearch ? this.inferredSearch.toLowerCase() : '';
const statusFilter = this.inferredStatusFilter; const statusFilter = this.inferredStatusFilter;
const checkNode = (node) => { const checkNode = (node, parentKeywordMatched = false) => {
let match = true; let matchKeyword = parentKeywordMatched;
if (keyword) { if (!matchKeyword && keyword) {
match = match && ( matchKeyword = (
(node.sfc && node.sfc.toLowerCase().includes(keyword)) || (node.sfc && node.sfc.toLowerCase().includes(keyword)) ||
(node.material_code && node.material_code.toLowerCase().includes(keyword)) || (node.material_code && node.material_code.toLowerCase().includes(keyword)) ||
(node.material_name && node.material_name.toLowerCase().includes(keyword)) (node.material_name && node.material_name.toLowerCase().includes(keyword))
); );
} else if (!keyword) {
matchKeyword = true;
} }
if (statusFilter) { match = match && (node.status === statusFilter); }
if (match) return true; let matchStatus = true;
if (statusFilter) {
matchStatus = (node.status === statusFilter);
}
// 当前节点完全符合条件
if (matchKeyword && matchStatus) return true;
// 否则去检查子节点
// 传递 matchKeyword 给子节点:如果父节点搜索匹配了,子节点就不需要再匹配搜索框,只需匹配状态即可
if (node.children && node.children.length > 0) { if (node.children && node.children.length > 0) {
return node.children.some(child => checkNode(child)); return node.children.some(child => checkNode(child, matchKeyword));
} }
return false; return false;
}; };
result = result.filter(row => checkNode(row)); result = result.filter(row => checkNode(row));