From 14274240732a9eac21db6a634b5c7f90790d508a Mon Sep 17 00:00:00 2001 From: gongjiale <942894820@qq.com> Date: Sat, 22 Oct 2022 15:29:21 +0800 Subject: [PATCH] pageWithAttrs --- front/src/store/modules/user.js | 8 +++- front/src/vab/plugins/permissions.js | 1 - .../views/home/detailsPageconetentTree.vue | 39 ++++++++++++++++++- 3 files changed, 45 insertions(+), 3 deletions(-) diff --git a/front/src/store/modules/user.js b/front/src/store/modules/user.js index 08e03603..0030845b 100644 --- a/front/src/store/modules/user.js +++ b/front/src/store/modules/user.js @@ -16,6 +16,7 @@ const state = () => ({ username: '', realName: '', deptName: '', + deptId: '', userId: '', avatar: '', role: 0, // 用户管理员权限 @@ -28,6 +29,7 @@ const getters = { role: (state) => state.role, userId: (state) => state.userId, deptName: (state) => state.deptName, + deptId: (state) => state.deptId, } const mutations = { /** @@ -70,6 +72,9 @@ const mutations = { setDeptName(state, name) { state.deptName = name }, + setDeptId(state, name) { + state.deptId = name + }, /** * @author chuzhixin 1204505056@qq.com * @description 设置头像 @@ -143,6 +148,7 @@ const actions = { commit('setRole', res.data.data.roleIdList.length) commit('setUserId', res.data.data.id) commit('setDeptName', res.data.data.deptName) + commit('setDeptId', res.data.data.deptId) // TODO 获取用户信息,后续执行部分操作 // let { username, avatar, roles, ability } = data // if (username && roles && Array.isArray(roles)) { @@ -175,7 +181,7 @@ const actions = { * @param {*} { commit, dispatch } */ async resetAll({ dispatch }) { - debugger + await dispatch('setAccessToken', '') await dispatch('acl/setFull', false, { root: true, diff --git a/front/src/vab/plugins/permissions.js b/front/src/vab/plugins/permissions.js index 1bda7a3c..02acc261 100644 --- a/front/src/vab/plugins/permissions.js +++ b/front/src/vab/plugins/permissions.js @@ -45,7 +45,6 @@ router.beforeEach(async (to, from, next) => { }) console.log('验证白名单', routesWhiteList) if (routesWhiteList.indexOf(to.path) !== -1) { - debugger next() } else { // 这里是一个单点登录的入口 diff --git a/front/src/views/home/detailsPageconetentTree.vue b/front/src/views/home/detailsPageconetentTree.vue index 066d92e9..9401b8a0 100644 --- a/front/src/views/home/detailsPageconetentTree.vue +++ b/front/src/views/home/detailsPageconetentTree.vue @@ -117,6 +117,7 @@ import mybus from '@/myplugins/mybus' import { useRouter } from 'vue-router' import { UpOutlined, DownOutlined } from '@ant-design/icons-vue' + import { useStore } from 'vuex' export default defineComponent({ setup() { const selectedKeys = ref([]) @@ -126,6 +127,12 @@ children: 'children', title: 'name', } + const store = useStore() + // 用户信息 + const user = ref({ + deptName: store.getters['user/deptName'], + deptId: store.getters['user/deptId'], + }) const showKey = ref(0) const treeData = ref([]) const init = () => { @@ -138,7 +145,7 @@ if (select === '123') { select = '' } - // debugger + console.log( '获取url中的select=====================>', router.currentRoute.value.query.select @@ -178,7 +185,33 @@ treeData.value.sort((a, b) => { return sortArr.indexOf(a.key) - sortArr.indexOf(b.key) }) + let deptId=user.value.deptId + treeData.value.forEach((child) => { + let childern=child.children + childern.forEach((childs) => {//第一层:市级 + if(childs.key==deptId ){ + childs.show=true + child.show=true + mybus.emit('paramsGetResources', [childs.key]) + selectId.value =childs.key + } + if(childs.children && childs.children.length>0){//第二层 区级 + let qu=childs.children + qu.forEach((qu) => { + if(qu.key==deptId ){ + qu.show=true + childs.show=true + child.show=true + mybus.emit('paramsGetResources', [qu.key]) + selectId.value = qu.key + } + }) + } + }) + + }) console.log('左侧树结构数据======================>', treeData.value) + showKey.value++ }) } @@ -188,6 +221,7 @@ }) // 生成children const generateChildren = (val, obj) => { + if (val.dataList.length > 0) { val.dataList.forEach((child) => { let children = { @@ -197,12 +231,14 @@ total: child.deptCount, key: child.deptId, } + obj.children.push(children) }) } } // 区级特殊处理 const generateChildren2 = (val, obj) => { + if (val.dataList.length > 0) { val.dataList.forEach((dis) => { let children = { @@ -222,6 +258,7 @@ select: false, key: child.deptId, } + children.children.push(children2) }) }