Compare commits

..

2 Commits

3 changed files with 45 additions and 3 deletions

View File

@ -16,6 +16,7 @@ const state = () => ({
username: '', username: '',
realName: '', realName: '',
deptName: '', deptName: '',
deptId: '',
userId: '', userId: '',
avatar: '', avatar: '',
role: 0, // role: 0, //
@ -28,6 +29,7 @@ const getters = {
role: (state) => state.role, role: (state) => state.role,
userId: (state) => state.userId, userId: (state) => state.userId,
deptName: (state) => state.deptName, deptName: (state) => state.deptName,
deptId: (state) => state.deptId,
} }
const mutations = { const mutations = {
/** /**
@ -70,6 +72,9 @@ const mutations = {
setDeptName(state, name) { setDeptName(state, name) {
state.deptName = name state.deptName = name
}, },
setDeptId(state, name) {
state.deptId = name
},
/** /**
* @author chuzhixin 1204505056@qq.com * @author chuzhixin 1204505056@qq.com
* @description 设置头像 * @description 设置头像
@ -143,6 +148,7 @@ const actions = {
commit('setRole', res.data.data.roleIdList.length) commit('setRole', res.data.data.roleIdList.length)
commit('setUserId', res.data.data.id) commit('setUserId', res.data.data.id)
commit('setDeptName', res.data.data.deptName) commit('setDeptName', res.data.data.deptName)
commit('setDeptId', res.data.data.deptId)
// TODO // TODO
// let { username, avatar, roles, ability } = data // let { username, avatar, roles, ability } = data
// if (username && roles && Array.isArray(roles)) { // if (username && roles && Array.isArray(roles)) {
@ -175,7 +181,7 @@ const actions = {
* @param {*} { commit, dispatch } * @param {*} { commit, dispatch }
*/ */
async resetAll({ dispatch }) { async resetAll({ dispatch }) {
debugger
await dispatch('setAccessToken', '') await dispatch('setAccessToken', '')
await dispatch('acl/setFull', false, { await dispatch('acl/setFull', false, {
root: true, root: true,

View File

@ -45,7 +45,6 @@ router.beforeEach(async (to, from, next) => {
}) })
console.log('验证白名单', routesWhiteList) console.log('验证白名单', routesWhiteList)
if (routesWhiteList.indexOf(to.path) !== -1) { if (routesWhiteList.indexOf(to.path) !== -1) {
debugger
next() next()
} else { } else {
// //

View File

@ -117,6 +117,7 @@
import mybus from '@/myplugins/mybus' import mybus from '@/myplugins/mybus'
import { useRouter } from 'vue-router' import { useRouter } from 'vue-router'
import { UpOutlined, DownOutlined } from '@ant-design/icons-vue' import { UpOutlined, DownOutlined } from '@ant-design/icons-vue'
import { useStore } from 'vuex'
export default defineComponent({ export default defineComponent({
setup() { setup() {
const selectedKeys = ref([]) const selectedKeys = ref([])
@ -126,6 +127,12 @@
children: 'children', children: 'children',
title: 'name', title: 'name',
} }
const store = useStore()
//
const user = ref({
deptName: store.getters['user/deptName'],
deptId: store.getters['user/deptId'],
})
const showKey = ref(0) const showKey = ref(0)
const treeData = ref([]) const treeData = ref([])
const init = () => { const init = () => {
@ -138,7 +145,7 @@
if (select === '123') { if (select === '123') {
select = '' select = ''
} }
// debugger
console.log( console.log(
'获取url中的select=====================>', '获取url中的select=====================>',
router.currentRoute.value.query.select router.currentRoute.value.query.select
@ -178,7 +185,33 @@
treeData.value.sort((a, b) => { treeData.value.sort((a, b) => {
return sortArr.indexOf(a.key) - sortArr.indexOf(b.key) 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) console.log('左侧树结构数据======================>', treeData.value)
showKey.value++ showKey.value++
}) })
} }
@ -188,6 +221,7 @@
}) })
// children // children
const generateChildren = (val, obj) => { const generateChildren = (val, obj) => {
if (val.dataList.length > 0) { if (val.dataList.length > 0) {
val.dataList.forEach((child) => { val.dataList.forEach((child) => {
let children = { let children = {
@ -197,12 +231,14 @@
total: child.deptCount, total: child.deptCount,
key: child.deptId, key: child.deptId,
} }
obj.children.push(children) obj.children.push(children)
}) })
} }
} }
// //
const generateChildren2 = (val, obj) => { const generateChildren2 = (val, obj) => {
if (val.dataList.length > 0) { if (val.dataList.length > 0) {
val.dataList.forEach((dis) => { val.dataList.forEach((dis) => {
let children = { let children = {
@ -222,6 +258,7 @@
select: false, select: false,
key: child.deptId, key: child.deptId,
} }
children.children.push(children2) children.children.push(children2)
}) })
} }