From d88a3e7e25d846c8292ff267bf130956b91f9231 Mon Sep 17 00:00:00 2001 From: TsMask <340112800@qq.com> Date: Wed, 26 Feb 2025 17:48:42 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=B3=BB=E7=BB=9F=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E6=9B=B4=E6=8D=A2=E4=B8=BB=E9=A1=B5=E9=A1=B5=E9=9D=A2=E9=80=89?= =?UTF-8?q?=E6=8B=A9=E6=AD=BB=E5=BE=AA=E7=8E=AF=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../setting/components/change-home-index.vue | 67 ++++++++++--------- 1 file changed, 36 insertions(+), 31 deletions(-) diff --git a/src/views/system/setting/components/change-home-index.vue b/src/views/system/setting/components/change-home-index.vue index f4ec03d7..27ef5eaf 100644 --- a/src/views/system/setting/components/change-home-index.vue +++ b/src/views/system/setting/components/change-home-index.vue @@ -6,14 +6,15 @@ import { listMenu } from '@/api/system/menu'; import { RESULT_CODE_SUCCESS } from '@/constants/result-constants'; import { getConfigKey, changeValue } from '@/api/system/config'; import { parseDataToTree } from '@/utils/parse-tree-utils'; +import { MENU_TYPE_BUTTON } from '@/constants/menu-constants'; const { t } = useI18n(); type StateType = { edite: boolean; loading: boolean; open: boolean; - default: any; - options: any; + default: string; + options: any[]; }; let state: StateType = reactive({ @@ -57,22 +58,42 @@ function fnEdit(v: boolean) { } onMounted(() => { - listMenu(toRaw({ status: 1 })).then(res => { - if (res.code === RESULT_CODE_SUCCESS) { - state.options = parseDataToTree(res.data, 'menuId'); - const setDisabledAndComponent = (item:any) => { - if (!item.component) { - item.disabled = true; - item.component = 'Null' + item.menuId; + listMenu(toRaw({ statusFlag: '1', visibleFlag: '0' })).then(res => { + if (res.code === RESULT_CODE_SUCCESS) { + const data: any[] = []; + const randD = (item: any) => { + if (item.menuType == MENU_TYPE_BUTTON) { + return undefined; } - }; + const tmp: any = { + label: item.menuName, + value: item.component || item.menuPath, + disabled: !item.component, + }; - state.options.forEach((item:any) => { - setDisabledAndComponent(item); // 处理父菜单 - if (item.children && Array.isArray(item.children)) { - item.children.forEach(setDisabledAndComponent); // 处理子菜单 + const children: any = []; + if (Array.isArray(item.children) && item.children.length > 0) { + for (const child of item.children) { + const v = randD(child); + if (v) { + children.push(v); + } + } } - }); + if (children.length > 0) { + tmp.children = children; + } + + return tmp; + }; + const arr = parseDataToTree(res.data, 'menuId'); + for (const v of arr) { + const item = randD(v); + if (item) { + data.push(item); + } + } + Object.assign(state.options, data); } }); @@ -95,14 +116,7 @@ onMounted(() => { show-search style="width: 240px" :tree-data="state.options" - :field-names="{ - children: 'children', - label: 'menuName', - value: 'component', - }" tree-default-expand-all - tree-node-label-prop="menuName" - tree-node-filter-prop="menuName" :dropdown-style="{ maxHeight: '400px', overflow: 'auto' }" :placeholder="t('common.selectPlease')" > @@ -120,17 +134,8 @@ onMounted(() => {