diff --git a/orion-ops-ui/src/assets/style/global.less b/orion-ops-ui/src/assets/style/global.less index 2b79eb8b..1f8f304b 100644 --- a/orion-ops-ui/src/assets/style/global.less +++ b/orion-ops-ui/src/assets/style/global.less @@ -135,10 +135,10 @@ body { cursor: pointer; border: 1px solid transparent; transition: background-color 0.1s cubic-bezier(0, 0, 1, 1); -} -.click-icon-wrapper:hover { - background: var(--color-fill-3); + &:hover { + background: var(--color-fill-3); + } } // -- element diff --git a/orion-ops-ui/src/components/app/navbar/index.vue b/orion-ops-ui/src/components/app/navbar/index.vue index 4986af5c..aea57833 100644 --- a/orion-ops-ui/src/components/app/navbar/index.vue +++ b/orion-ops-ui/src/components/app/navbar/index.vue @@ -115,6 +115,19 @@ + +
  • + + + + + +
  • @@ -184,24 +197,30 @@ diff --git a/orion-ops-ui/src/components/system/menu/selector/menu-selector-tree.vue b/orion-ops-ui/src/components/system/menu/selector/menu-selector-tree.vue deleted file mode 100644 index 4627166f..00000000 --- a/orion-ops-ui/src/components/system/menu/selector/menu-selector-tree.vue +++ /dev/null @@ -1,148 +0,0 @@ - - - - - - -; diff --git a/orion-ops-ui/src/utils/index.ts b/orion-ops-ui/src/utils/index.ts index c1436d47..e56ba964 100644 --- a/orion-ops-ui/src/utils/index.ts +++ b/orion-ops-ui/src/utils/index.ts @@ -179,6 +179,13 @@ export const objectTruthKeyCount = (obj: any, ignore: string[] = []) => { }, 0); }; +/** + * 休眠 + */ +export const sleep = (ms: number) => { + return new Promise(resolve => setTimeout(resolve, ms)); +}; + /** * 获取当前页面的缩放值 */ diff --git a/orion-ops-ui/src/utils/tree.ts b/orion-ops-ui/src/utils/tree.ts new file mode 100644 index 00000000..aea01f1e --- /dev/null +++ b/orion-ops-ui/src/utils/tree.ts @@ -0,0 +1,116 @@ +import type { NodeData } from '@/types/global'; + +// 寻找当前节点 +export const findNode = (key: any, + nodes: Array, + keyName = 'key'): T => { + if (!nodes || !nodes.length) { + return undefined as unknown as T; + } + for (let node of nodes) { + if (node[keyName] === key) { + return node; + } + } + // 寻找子级 + for (let node of nodes) { + if (node.children?.length) { + const childrenNode = findNode(key, node.children, keyName); + if (childrenNode) { + return childrenNode as T; + } + } + } + return undefined as unknown as T; +}; + +// 寻找父节点 +export const findParentNode = (key: any, + nodes: Array, + keyName = 'key', + parent = (undefined as unknown as T)): T => { + if (!nodes || !nodes.length) { + return undefined as unknown as T; + } + for (let node of nodes) { + if (node[keyName] === key) { + if (parent) { + return parent; + } else { + // 根节点 + return { + root: true + } as unknown as T; + } + } + } + // 寻找子级 + for (let node of nodes) { + if (node.children?.length) { + const parentNode = findParentNode(key, node.children, keyName, node); + if (parentNode) { + return parentNode as T; + } + } + } + return undefined as unknown as T; +}; + +// 级联寻找父节点 +export const findParentNodes = (key: any, + nodes: Array, + result: Array, + keyName = 'key', + parent = ([] as T[])) => { + if (!nodes || !nodes.length) { + return; + } + for (let node of nodes) { + if (node[keyName] === key) { + result.push(...parent); + return; + } + } + // 寻找子级 + for (let node of nodes) { + if (node.children?.length) { + const currentParent = [...parent, node]; + findParentNodes(key, node.children, result, keyName, currentParent); + } + } +}; + +// 检查是否包含子节点 单层 +export const hasChildren = (key: string, + nodes: Array, + keyName = 'key'): boolean => { + if (!nodes || !nodes.length) { + return false; + } + return !!nodes.find(s => s[keyName] === key); +}; + +// 获取所有节点 key +export const flatNodeKeys = (nodes: Array, + result: Array, + keyName = 'key') => { + if (!nodes || !nodes.length) { + return; + } + for (let node of nodes) { + result.push(node[keyName]); + flatNodeKeys(node.children, result, keyName); + } +}; + +// 获取所有节点 +export const flatNodes = (nodes: Array, + result: Array) => { + if (!nodes || !nodes.length) { + return; + } + nodes.forEach(s => { + result.push(s); + flatNodes(s.children, result); + }); +}; diff --git a/orion-ops-ui/src/views/dashboard/workplace/components/categories-percent.vue b/orion-ops-ui/src/views/dashboard/workplace/components/categories-percent.vue index 0d02b636..12eb6c2d 100644 --- a/orion-ops-ui/src/views/dashboard/workplace/components/categories-percent.vue +++ b/orion-ops-ui/src/views/dashboard/workplace/components/categories-percent.vue @@ -10,7 +10,7 @@ - + diff --git a/orion-ops-ui/src/views/dashboard/workplace/components/content-chart.vue b/orion-ops-ui/src/views/dashboard/workplace/components/content-chart.vue index 8edd4c13..ead77d5a 100644 --- a/orion-ops-ui/src/views/dashboard/workplace/components/content-chart.vue +++ b/orion-ops-ui/src/views/dashboard/workplace/components/content-chart.vue @@ -11,7 +11,7 @@ - + diff --git a/orion-ops-ui/src/views/system/menu/components/menu-table.vue b/orion-ops-ui/src/views/system/menu/components/menu-table.vue index 77072b3e..69ed33ce 100644 --- a/orion-ops-ui/src/views/system/menu/components/menu-table.vue +++ b/orion-ops-ui/src/views/system/menu/components/menu-table.vue @@ -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); + } } } } diff --git a/orion-ops-ui/src/views/user/role/components/role-menu-grant-modal.vue b/orion-ops-ui/src/views/user/role/components/role-menu-grant-modal.vue index de467bfe..1a4c9128 100644 --- a/orion-ops-ui/src/views/user/role/components/role-menu-grant-modal.vue +++ b/orion-ops-ui/src/views/user/role/components/role-menu-grant-modal.vue @@ -23,7 +23,7 @@
    @@ -32,7 +32,7 @@
    diff --git a/orion-ops-ui/src/views/user/role/types/const.ts b/orion-ops-ui/src/views/user/role/types/const.ts index 067eda51..8e6d9e61 100644 --- a/orion-ops-ui/src/views/user/role/types/const.ts +++ b/orion-ops-ui/src/views/user/role/types/const.ts @@ -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 = [