From d8e5372054200eb1356b26d3490e3481127127e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=95=E9=87=91=E6=B3=BD?= <1098696801@qq.com> Date: Sun, 10 Apr 2022 10:48:49 +0800 Subject: [PATCH] =?UTF-8?q?mb-tree=E5=9B=9E=E6=98=BEbug=EF=BC=8C=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E6=90=9C=E7=B4=A2=EF=BC=8C=E8=8F=9C=E5=8D=95=E5=8F=AA?= =?UTF-8?q?=E6=9C=89=E7=AC=AC=E4=B8=80=E7=BA=A7=E7=9A=84=E6=97=B6=E5=80=99?= =?UTF-8?q?=E5=87=BA=E7=8E=B0bug=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/系统管理/菜单管理/当前用户菜单.ms | 10 +- .../src/components/magic/form/mb-tree.vue | 59 +++--- magic-boot-ui/src/layout/layout.vue | 5 +- magic-boot-ui/src/permission.js | 5 +- magic-boot-ui/src/views/login.vue | 16 -- .../src/views/system/menu/menu-form.vue | 4 +- .../system/role/role-assign-permissions.vue | 4 +- .../src/views/system/role/role-list.vue | 200 +++++++++--------- 8 files changed, 142 insertions(+), 161 deletions(-) diff --git a/data/magic-api/api/系统管理/菜单管理/当前用户菜单.ms b/data/magic-api/api/系统管理/菜单管理/当前用户菜单.ms index 3a9525f..a5ee50b 100644 --- a/data/magic-api/api/系统管理/菜单管理/当前用户菜单.ms +++ b/data/magic-api/api/系统管理/菜单管理/当前用户菜单.ms @@ -5,7 +5,7 @@ "groupId" : "67b2ce258e24491194b74992958c74aa", "name" : "当前用户菜单", "createTime" : null, - "updateTime" : 1648013721548, + "updateTime" : 1649558286068, "lock" : "0", "createBy" : null, "updateBy" : null, @@ -598,6 +598,14 @@ nodes.each((key, node) => { var treeNodes = [] nodes.each((key, node) => { if(node.pid == '0'){ + if(node.component != 'Layout'){ + node = { + isShow: 1, + component: 'Layout', + redirect: node.path, + children: [node] + } + } treeNodes.push(node) } }) diff --git a/magic-boot-ui/src/components/magic/form/mb-tree.vue b/magic-boot-ui/src/components/magic/form/mb-tree.vue index c601cfa..b6caf37 100644 --- a/magic-boot-ui/src/components/magic/form/mb-tree.vue +++ b/magic-boot-ui/src/components/magic/form/mb-tree.vue @@ -2,24 +2,24 @@
展开/折叠 - 全选/全不选 + 全选/全不选
- +
@@ -45,11 +45,11 @@ const props = defineProps({ type: String, default: '' }, - maxHeight: { + style: { type: String, default: '' }, - el: { + props: { type: Object, default: () => {} }, @@ -68,22 +68,19 @@ const props = defineProps({ searchWidth: { type: String, default: '230px' - }, - checkedIds: { - type: Array, - default: () => [] } }) +const checkedIds = ref(props.selectValues.split(',')) + const tree = ref() const treeData = ref([]) -const searchData = ref([]) const defaultProps = reactive({ children: 'children', label: 'name' }) const defaultExpandAll = ref(true) -const refreshTree = ref(true) +const refreshTree = ref(false) const treeAllChecked = ref(false) const searchValue = ref('') @@ -96,20 +93,12 @@ onMounted(() => { }) watch(() => props.selectValues, async () => { - await loadTreeData() - checkedAll(searchData.value, false) - var values = props.selectValues.split(','); - for(var i in values){ - tree.value.setChecked(values[i], true, false) - } + checkedIds.value = props.selectValues.split(',') }) -function searchTree() { - if(searchValue.value){ - searchData.value = proxy.$treeTable.recursionSearch(['name'], proxy.$common.copyNew(treeData.value), searchValue.value, false) - }else{ - searchData.value = treeData.value - } +function searchTree(value, data) { + if (!value) return true + return data.name.includes(value) } function doExpand() { @@ -122,8 +111,8 @@ async function loadTreeData() { if(treeData.value.length == 0){ await proxy.$get(props.url, props.params).then((res) => { treeData.value = res.data.list - searchData.value = treeData.value }) + refreshTree.value = true } } diff --git a/magic-boot-ui/src/layout/layout.vue b/magic-boot-ui/src/layout/layout.vue index aa4126c..2d9986e 100644 --- a/magic-boot-ui/src/layout/layout.vue +++ b/magic-boot-ui/src/layout/layout.vue @@ -8,8 +8,9 @@
- - {{ !$global.user.info.headPortrait ? $global.user.info.name.substring(0,1) : '' }} + + + {{ $global.user.info.name.substring(0,1) }} diff --git a/magic-boot-ui/src/permission.js b/magic-boot-ui/src/permission.js index 660f19d..e3e2e35 100644 --- a/magic-boot-ui/src/permission.js +++ b/magic-boot-ui/src/permission.js @@ -11,7 +11,7 @@ import { generateRoutes } from '@/scripts/routerPermission' NProgress.configure({ showSpinner: false }) // NProgress Configuration const whiteList = ['/login'] // no redirect whitelist - +var loadInfo = false router.beforeEach(async(to, from, next) => { // start progress bar NProgress.start() @@ -26,7 +26,7 @@ router.beforeEach(async(to, from, next) => { NProgress.done() } else { // determine whether the user has obtained his permission roles through getInfo - if (global.user.authorities.length > 0) { + if (loadInfo) { next() } else { try { @@ -42,6 +42,7 @@ router.beforeEach(async(to, from, next) => { router.addRoute(it) }) }) + loadInfo = true // dynamically add accessible routes // hack method to ensure that addRoutes is complete // set the replace: true, so the navigation will not leave a history record diff --git a/magic-boot-ui/src/views/login.vue b/magic-boot-ui/src/views/login.vue index 64d521c..f56e9eb 100644 --- a/magic-boot-ui/src/views/login.vue +++ b/magic-boot-ui/src/views/login.vue @@ -3,7 +3,6 @@