|
@@ -105,12 +105,38 @@
|
|
|
const treeRef = ref<InstanceType<typeof ElTree>>();
|
|
const treeRef = ref<InstanceType<typeof ElTree>>();
|
|
|
|
|
|
|
|
watch(filterText, (val) => {
|
|
watch(filterText, (val) => {
|
|
|
|
|
+ childrenNodeList.value = [];
|
|
|
treeRef.value!.filter(val);
|
|
treeRef.value!.filter(val);
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
- const filterNode = (value: string, data: Tree) => {
|
|
|
|
|
|
|
+ const childrenNodeList = ref<string[]>([]);
|
|
|
|
|
+
|
|
|
|
|
+ function extractCodes(data: any[], codes: string[] = []) {
|
|
|
|
|
+ data.forEach((item) => {
|
|
|
|
|
+ codes.push(item.data.code);
|
|
|
|
|
+ if (item.childNodes) {
|
|
|
|
|
+ extractCodes(item.childNodes, codes);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ return codes;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ const filterNode = (value: string, data: Tree, node) => {
|
|
|
if (!value) return true;
|
|
if (!value) return true;
|
|
|
- return data.name?.includes(value);
|
|
|
|
|
|
|
+ // 检查当前节点的 label 是否包含关键词
|
|
|
|
|
+ const labelMatch = data.name.includes(value);
|
|
|
|
|
+
|
|
|
|
|
+ if (labelMatch) {
|
|
|
|
|
+ if (node.childNodes && node.childNodes.length > 0) {
|
|
|
|
|
+ childrenNodeList.value = extractCodes(node.childNodes, []);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (childrenNodeList.value.includes(data.code)) {
|
|
|
|
|
+ return true;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ return labelMatch;
|
|
|
|
|
+ }
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
const isInvalid = (data) => {
|
|
const isInvalid = (data) => {
|