update: 权限管理
This commit is contained in:
parent
37c8110ddc
commit
ece2ba2ff4
|
@ -115,3 +115,33 @@ export const timestampFormat = (time: number) => {
|
||||||
.replace('mm', minute.toString())
|
.replace('mm', minute.toString())
|
||||||
.replace('ss', second.toString());
|
.replace('ss', second.toString());
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const ArrayToTree = (list: any[]): any[] => {
|
||||||
|
const treeList: any[] = [];
|
||||||
|
// 所有项都使用对象存储起来
|
||||||
|
const map = {};
|
||||||
|
|
||||||
|
// 建立一个映射关系:通过id快速找到对应的元素
|
||||||
|
list.forEach((item) => {
|
||||||
|
if (!item.children) {
|
||||||
|
item.children = [];
|
||||||
|
}
|
||||||
|
map[item.id] = item;
|
||||||
|
});
|
||||||
|
|
||||||
|
list.forEach((item) => {
|
||||||
|
// 对于每一个元素来说,先找它的上级
|
||||||
|
// 如果能找到,说明它有上级,则要把它添加到上级的children中去
|
||||||
|
// 如果找不到,说明它没有上级,直接添加到 treeList
|
||||||
|
const parent = map[item.parentId];
|
||||||
|
// 如果存在则表示item不是最顶层的数据
|
||||||
|
if (parent) {
|
||||||
|
parent.children.push(item);
|
||||||
|
} else {
|
||||||
|
// 如果不存在 则是顶层数据
|
||||||
|
treeList.push(item);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// 返回出去
|
||||||
|
return treeList;
|
||||||
|
};
|
|
@ -196,7 +196,7 @@ const form = reactive({
|
||||||
});
|
});
|
||||||
|
|
||||||
const table = reactive({
|
const table = reactive({
|
||||||
columns: [
|
columns: <any>[
|
||||||
{
|
{
|
||||||
title: '-',
|
title: '-',
|
||||||
dataIndex: 'index',
|
dataIndex: 'index',
|
||||||
|
|
Loading…
Reference in New Issue