feat: 新增测试树表

This commit is contained in:
xlsea
2025-05-10 19:32:20 +08:00
parent 4a4febeeab
commit fd0783a50f
18 changed files with 601 additions and 38 deletions

View File

@ -57,7 +57,9 @@ export function useTreeTable<A extends NaiveUI.TreeTableApiFn>(
});
// if defaultExpandAll is true, expand all nodes
expandedRowKeys.value = defaultExpandAll ? records.map(item => item[idField]) : [records[0][idField]];
expandedRowKeys.value = defaultExpandAll
? records.map(item => item[idField])
: records.filter(item => item[parentIdField] === 0).map(item => item[idField]) || [];
return { data: treeData };
},
@ -138,7 +140,7 @@ export function useTreeTable<A extends NaiveUI.TreeTableApiFn>(
/** collapse all nodes */
function collapseAll() {
toggleCollapse();
expandedRowKeys.value = data.value.length ? [data.value[0][idField]] : [];
expandedRowKeys.value = [];
}
scope.run(() => {