mirror of
https://github.com/yangzongzhuan/RuoYi-Vue3.git
synced 2025-06-07 02:39:28 +00:00
优化前端树结构性能问题
This commit is contained in:
parent
ca5ae82f9e
commit
537fc97695
@ -1,5 +1,3 @@
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通用js方法封装处理
|
* 通用js方法封装处理
|
||||||
* Copyright (c) 2019 ruoyi
|
* Copyright (c) 2019 ruoyi
|
||||||
@ -86,7 +84,7 @@ export function selectDictLabel(datas, value) {
|
|||||||
return actions.join('');
|
return actions.join('');
|
||||||
}
|
}
|
||||||
|
|
||||||
// 回显数据字典(字符串数组)
|
// 回显数据字典(字符串、数组)
|
||||||
export function selectDictLabels(datas, value, separator) {
|
export function selectDictLabels(datas, value, separator) {
|
||||||
if (value === undefined || value.length ===0) {
|
if (value === undefined || value.length ===0) {
|
||||||
return "";
|
return "";
|
||||||
@ -165,37 +163,19 @@ export function handleTree(data, id, parentId, children) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
var childrenListMap = {};
|
var childrenListMap = {};
|
||||||
var nodeIds = {};
|
|
||||||
var tree = [];
|
var tree = [];
|
||||||
|
|
||||||
for (let d of data) {
|
for (let d of data) {
|
||||||
let parentId = d[config.parentId];
|
let id = d[config.id];
|
||||||
if (childrenListMap[parentId] == null) {
|
childrenListMap[id] = d;
|
||||||
childrenListMap[parentId] = [];
|
|
||||||
}
|
|
||||||
nodeIds[d[config.id]] = d;
|
|
||||||
childrenListMap[parentId].push(d);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let d of data) {
|
for (let d of data) {
|
||||||
let parentId = d[config.parentId];
|
let parentId = d[config.parentId]
|
||||||
if (nodeIds[parentId] == null) {
|
let parentObj = childrenListMap[parentId]
|
||||||
|
if (!parentObj) {
|
||||||
tree.push(d);
|
tree.push(d);
|
||||||
}
|
} else {
|
||||||
}
|
parentObj[config.childrenList].push(d)
|
||||||
|
|
||||||
for (let t of tree) {
|
|
||||||
adaptToChildrenList(t);
|
|
||||||
}
|
|
||||||
|
|
||||||
function adaptToChildrenList(o) {
|
|
||||||
if (childrenListMap[o[config.id]] !== null) {
|
|
||||||
o[config.childrenList] = childrenListMap[o[config.id]];
|
|
||||||
}
|
|
||||||
if (o[config.childrenList]) {
|
|
||||||
for (let c of o[config.childrenList]) {
|
|
||||||
adaptToChildrenList(c);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return tree;
|
return tree;
|
||||||
@ -227,7 +207,6 @@ export function tansParams(params) {
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 返回项目路径
|
// 返回项目路径
|
||||||
export function getNormalPath(p) {
|
export function getNormalPath(p) {
|
||||||
if (p.length === 0 || !p || p == 'undefined') {
|
if (p.length === 0 || !p || p == 'undefined') {
|
||||||
|
Loading…
Reference in New Issue
Block a user