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));