pageWithAttrs

This commit is contained in:
gongjiale 2022-10-22 15:29:21 +08:00
parent a296f5a0d6
commit 1427424073
3 changed files with 45 additions and 3 deletions

View File

@ -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,

View File

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

View File

@ -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)
})
}