refact: 提取 tree 工具.
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
<template #title>
|
||||
{{ $t('workplace.categoriesPercent') }}
|
||||
</template>
|
||||
<Chart height="310px" :option="chartOption" />
|
||||
<chart height="310px" :option="chartOption" />
|
||||
</a-card>
|
||||
</a-spin>
|
||||
</template>
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
<template #extra>
|
||||
<a-link>{{ $t('workplace.viewMore') }}</a-link>
|
||||
</template>
|
||||
<Chart height="289px" :option="chartOption" />
|
||||
<chart height="289px" :option="chartOption" />
|
||||
</a-card>
|
||||
</a-spin>
|
||||
</template>
|
||||
|
||||
@@ -190,6 +190,7 @@
|
||||
import { Message } from '@arco-design/web-vue';
|
||||
import { useCacheStore, useDictStore } from '@/store';
|
||||
import usePermission from '@/hooks/permission';
|
||||
import { findParentNode } from '@/utils/tree';
|
||||
|
||||
const { toOptions, getDictValue, toggleDictValue } = useDictStore();
|
||||
const cacheStore = useCacheStore();
|
||||
@@ -215,36 +216,22 @@
|
||||
setFetchLoading(true);
|
||||
// 调用删除接口
|
||||
await deleteMenu(id);
|
||||
|
||||
// 获取父菜单
|
||||
const findParentMenu = (arr: any, id: number): any => {
|
||||
if (!arr || !arr.length) {
|
||||
return null;
|
||||
}
|
||||
// 当前级
|
||||
for (let e of arr) {
|
||||
if (e.id === id) {
|
||||
return arr;
|
||||
}
|
||||
}
|
||||
// 子级
|
||||
for (let e of arr) {
|
||||
if (e.children && e.children.length) {
|
||||
if (findParentMenu(e.children, id)) {
|
||||
return e.children;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
// 获取父级容器
|
||||
const parent = findParentMenu(tableRenderData.value, id) as unknown as MenuQueryResponse[];
|
||||
const parent = findParentNode(id, tableRenderData.value, 'id');
|
||||
if (parent) {
|
||||
// 删除
|
||||
for (let i = 0; i < parent.length; i++) {
|
||||
if (parent[i].id === id) {
|
||||
parent.splice(i, 1);
|
||||
// 页面删除 不重新调用接口
|
||||
let children;
|
||||
if (parent.root) {
|
||||
children = tableRenderData.value;
|
||||
} else {
|
||||
children = parent.children;
|
||||
}
|
||||
if (children) {
|
||||
// 删除
|
||||
for (let i = 0; i < children.length; i++) {
|
||||
if (children[i].id === id) {
|
||||
children.splice(i, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
<div class="usn mb8">
|
||||
<a-space>
|
||||
<template v-for="opt of quickGrantMenuOperator" :key="opt.name">
|
||||
<a-button size="mini" type="text" @click="() => { table.checked(opt.rule) }">
|
||||
<a-button size="mini" type="text" @click="() => { table.checkOrUncheckByRule(opt.rule, true) }">
|
||||
{{ '全选' + opt.name }}
|
||||
</a-button>
|
||||
</template>
|
||||
@@ -32,7 +32,7 @@
|
||||
<div class="usn mb8">
|
||||
<a-space>
|
||||
<template v-for="opt of quickGrantMenuOperator" :key="opt.name">
|
||||
<a-button size="mini" type="text" @click="() => { table.unchecked(opt.rule) }">
|
||||
<a-button size="mini" type="text" @click="() => { table.checkOrUncheckByRule(opt.rule, false) }">
|
||||
{{ '反选' + opt.name }}
|
||||
</a-button>
|
||||
</template>
|
||||
|
||||
@@ -12,7 +12,7 @@ const addType = ['add', 'create'];
|
||||
const updateType = ['update', 'modify'];
|
||||
const deleteType = ['delete', 'remove'];
|
||||
const standardRead = [...queryType];
|
||||
const standardWrite = [...addType, ...updateType, ...deleteType];
|
||||
const standardWrite = [...addType, ...updateType];
|
||||
|
||||
// 快速分配菜单操作
|
||||
export const quickGrantMenuOperator = [
|
||||
|
||||
Reference in New Issue
Block a user