From a8a6388d85ed2b4ede7dd40a0be74625b35b5602 Mon Sep 17 00:00:00 2001 From: hjq <770690987@qq.com> Date: Mon, 22 Jun 2026 18:08:34 +0800 Subject: [PATCH] =?UTF-8?q?BOM=E5=8F=91=E6=96=99=E5=AF=B9=E6=AF=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web_ui/templates/reconciliation.html | 52 ++++++++++++++++++++-------- 1 file changed, 38 insertions(+), 14 deletions(-) diff --git a/web_ui/templates/reconciliation.html b/web_ui/templates/reconciliation.html index 16db9d1..65acf45 100644 --- a/web_ui/templates/reconciliation.html +++ b/web_ui/templates/reconciliation.html @@ -289,20 +289,32 @@ if (this.officialSearch || this.officialStatusFilter) { const keyword = this.officialSearch ? this.officialSearch.toLowerCase() : ''; const statusFilter = this.officialStatusFilter; - const checkNode = (node) => { - let match = true; - if (keyword) { - match = match && ( + const checkNode = (node, parentKeywordMatched = false) => { + let matchKeyword = parentKeywordMatched; + if (!matchKeyword && keyword) { + matchKeyword = ( (node.sfc && node.sfc.toLowerCase().includes(keyword)) || (node.material_code && node.material_code.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) { - return node.children.some(child => checkNode(child)); + return node.children.some(child => checkNode(child, matchKeyword)); } + return false; }; result = result.filter(row => checkNode(row)); @@ -319,20 +331,32 @@ if (this.inferredSearch || this.inferredStatusFilter) { const keyword = this.inferredSearch ? this.inferredSearch.toLowerCase() : ''; const statusFilter = this.inferredStatusFilter; - const checkNode = (node) => { - let match = true; - if (keyword) { - match = match && ( + const checkNode = (node, parentKeywordMatched = false) => { + let matchKeyword = parentKeywordMatched; + if (!matchKeyword && keyword) { + matchKeyword = ( (node.sfc && node.sfc.toLowerCase().includes(keyword)) || (node.material_code && node.material_code.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) { - return node.children.some(child => checkNode(child)); + return node.children.some(child => checkNode(child, matchKeyword)); } + return false; }; result = result.filter(row => checkNode(row));