|
@@ -1,7 +1,7 @@
|
|
|
<!--
|
|
|
* @Author: your name
|
|
|
* @Date: 2021-11-29 09:27:43
|
|
|
- * @LastEditTime: 2022-03-21 03:21:52
|
|
|
+ * @LastEditTime: 2022-03-23 15:59:27
|
|
|
* @LastEditors: your name
|
|
|
* @Description: 权限管理
|
|
|
* @FilePath: \Foshan4A2.0\src\views\authorityManagement\components\home.vue
|
|
@@ -27,7 +27,7 @@
|
|
|
<div class="grid-content">
|
|
|
<div class="title">权限树</div>
|
|
|
<div v-loading="loading" element-loading-text="拼命加载中" element-loading-spinner="el-icon-loading" class="contentTree">
|
|
|
- <el-tree ref="tree" :data="dataListTree" :props="defaultProps" node-key="AuthId" :filter-node-method="filterNode" highlight-current :default-expanded-keys="expandedKeys" :current-node-key="currentKey" @node-expand="handleExpand" @node-collapse="handleCollapse" @node-click="handleNodeClick">
|
|
|
+ <el-tree ref="tree" :data="dataListTree" :props="defaultProps" node-key="AuthId" :filter-node-method="filterNode" highlight-current :default-expanded-keys="expandedKeys" @node-expand="handleExpand" @node-collapse="handleCollapse" @node-click="handleNodeClick">
|
|
|
</el-tree>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -38,7 +38,7 @@
|
|
|
<div class="content">
|
|
|
<template v-if="currDataArr.length">
|
|
|
<el-row>
|
|
|
- <el-col :span="6" v-for="(data,index) in currDataArr" :key="data.AuthId">
|
|
|
+ <el-col :span="6" v-for="data in currDataArr" :key="data.AuthId">
|
|
|
<div class="account-left-content-teams">
|
|
|
<div class="team">
|
|
|
<div class="bg" :class="data.Type == 1 || data.Type == 0 ? 'status1' : 'status2'"></div>
|
|
@@ -66,7 +66,7 @@
|
|
|
<div v-if="data.Type > 0" class="flex details">
|
|
|
<div class="details-msg">状态:<span :class="data.Status === 1 ? 'success' : 'error'">{{data.Status === 1 ? '启用' : '禁用'}}</span></div>
|
|
|
<div v-is="['authtree_btn_state_swatch']" class="details-info">
|
|
|
- <el-switch v-model="data.flag" @change="renderChange(data,index)" active-color="#6F81BC">
|
|
|
+ <el-switch v-model="data.flag" @change="renderChange(data)" active-color="#6F81BC">
|
|
|
</el-switch>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -178,6 +178,7 @@ export default {
|
|
|
title: '', //弹框title
|
|
|
flag: false, //弹框开关
|
|
|
dataId: null, //tree数据id
|
|
|
+ dataUpId: null,
|
|
|
currDataArr: [],
|
|
|
childrenData: [],
|
|
|
dataListTree: [],
|
|
@@ -185,13 +186,14 @@ export default {
|
|
|
children: "children",
|
|
|
label: "AuthName",
|
|
|
},
|
|
|
- currentKey: -1,
|
|
|
- expandedKeys: [-1]
|
|
|
+ currentKey: null,
|
|
|
+ expandedKeys: [-1],
|
|
|
+ initCurrentKeyStep: [false, false]
|
|
|
}
|
|
|
},
|
|
|
created () {
|
|
|
let keyWords = "";
|
|
|
- const treeEx = sessionStorage.getItem('authTreeDatas');
|
|
|
+ const treeEx = sessionStorage.getItem('authExpandedKeys');
|
|
|
if (this.$route.query.keyWords) {
|
|
|
keyWords = this.$route.query.keyWords;
|
|
|
}
|
|
@@ -201,9 +203,7 @@ export default {
|
|
|
this.getAuthTree(keyWords);
|
|
|
},
|
|
|
mounted () {
|
|
|
- setTimeout(() => {
|
|
|
- this.$refs.tree.setCurrentKey(this.expandedKeys[this.expandedKeys.length - 1]);
|
|
|
- }, 500);
|
|
|
+ this.initCurrentKeyStep.splice(1, 1, true)
|
|
|
},
|
|
|
watch: {
|
|
|
dataList: {
|
|
@@ -215,45 +215,58 @@ export default {
|
|
|
},
|
|
|
currentKey: {
|
|
|
handler (val) {
|
|
|
+ if (typeof val !== 'number') {
|
|
|
+ return
|
|
|
+ }
|
|
|
this.$nextTick(() => {
|
|
|
this.$refs.tree.setCurrentKey(val)
|
|
|
+ sessionStorage.setItem('authCurrentKey', val)
|
|
|
+ this.setCards()
|
|
|
})
|
|
|
}
|
|
|
+ },
|
|
|
+ expandedKeys: {
|
|
|
+ handler(arr) {
|
|
|
+ sessionStorage.setItem('authExpandedKeys', JSON.stringify(arr))
|
|
|
+ },
|
|
|
+ deep: true
|
|
|
+ },
|
|
|
+ initCurrentKeyStep: {
|
|
|
+ handler(arr) {
|
|
|
+ if (arr.every(item => item)) {
|
|
|
+ this.currentKey = parseInt(sessionStorage.getItem('authCurrentKey') ?? -1)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ deep: true
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
//树点击
|
|
|
handleNodeClick (data) {
|
|
|
- const dataNew = _.cloneDeep(data)
|
|
|
- this.currentKey = dataNew.AuthId
|
|
|
- this.currDataArr = [];
|
|
|
- this.childrenData = [];
|
|
|
- this.currDataArr = this.decompose(this.dataArr, "AuthId", this.currentKey);
|
|
|
- this.childrenData = this.decompose(this.dataArr, "UpAuthId", this.currentKey);
|
|
|
+ this.currentKey = data.AuthId
|
|
|
},
|
|
|
//下级卡片点击
|
|
|
childrenClick (data) {
|
|
|
- const dataNew = _.cloneDeep(data)
|
|
|
- this.currentKey = dataNew.AuthId
|
|
|
- this.currDataArr = [];
|
|
|
- this.childrenData = [];
|
|
|
- this.currDataArr = this.decompose(this.dataArr, "AuthId", this.currentKey);
|
|
|
- this.childrenData = this.decompose(this.dataArr, "UpAuthId", this.currentKey);
|
|
|
+ this.currentKey = data.AuthId
|
|
|
if (!this.expandedKeys.includes(this.currentKey)) {
|
|
|
this.expandedKeys.push(this.currentKey)
|
|
|
}
|
|
|
+ // this.setCards()
|
|
|
+ },
|
|
|
+ // 根据选中节点获取卡片
|
|
|
+ setCards() {
|
|
|
+ this.currDataArr = this.decompose(this.dataArr, "AuthId", this.currentKey);
|
|
|
+ this.childrenData = this.decompose(this.dataArr, "UpAuthId", this.currentKey);
|
|
|
},
|
|
|
// 节点展开
|
|
|
handleExpand (obj) {
|
|
|
this.expandedKeys.push(obj.AuthId)
|
|
|
- sessionStorage.setItem('authTreeDatas', JSON.stringify(this.expandedKeys))
|
|
|
},
|
|
|
// 节点收起
|
|
|
handleCollapse (obj) {
|
|
|
const { AuthId, children } = obj
|
|
|
children.length && this.collapseChilren(children)
|
|
|
this.expandedKeys = this.expandedKeys.filter(key => key !== AuthId)
|
|
|
- sessionStorage.setItem('authTreeDatas', JSON.stringify(this.expandedKeys))
|
|
|
},
|
|
|
// 收起子节点
|
|
|
collapseChilren (children) {
|
|
@@ -265,7 +278,8 @@ export default {
|
|
|
},
|
|
|
//下级切换状态
|
|
|
childrenRenderChange (data, index) {
|
|
|
- const { AuthId, flag, Type } = data
|
|
|
+ const { AuthId, flag, Type, UpAuthId } = data
|
|
|
+ this.dataUpId = UpAuthId
|
|
|
const isChildren = true
|
|
|
this.handleChange(AuthId, flag, Type, index, isChildren)
|
|
|
},
|
|
@@ -290,9 +304,10 @@ export default {
|
|
|
this.$router.push({ path: '/authority/addPower', query: { AuthId: data.AuthId, Status: data.Status, UpAuthId: data.UpAuthId } })
|
|
|
},
|
|
|
// 关闭开启
|
|
|
- renderChange (data, index) {
|
|
|
- const { AuthId, flag, Type } = data
|
|
|
- this.handleChange(AuthId, flag, Type, index)
|
|
|
+ renderChange (data) {
|
|
|
+ const { AuthId, flag, Type, UpAuthId } = data
|
|
|
+ this.dataUpId = UpAuthId
|
|
|
+ this.handleChange(AuthId, flag, Type)
|
|
|
},
|
|
|
//删除
|
|
|
remove () {
|
|
@@ -321,6 +336,7 @@ export default {
|
|
|
onNodeClick (data) {
|
|
|
this.flag = true
|
|
|
this.dataId = data.AuthId
|
|
|
+ this.dataUpId = data.UpAuthId
|
|
|
this.title = data.AuthName
|
|
|
this.type = data.Type
|
|
|
},
|
|
@@ -379,7 +395,7 @@ export default {
|
|
|
// },
|
|
|
//-----------获取数据------------
|
|
|
//应用状态变更
|
|
|
- async handleChange (id, flag, type, index, isChildren = false) {
|
|
|
+ async handleChange (id, flag, type, index = 0, isChildren = false) {
|
|
|
const Status = flag ? 1 : 0
|
|
|
try {
|
|
|
let res = null
|
|
@@ -396,32 +412,34 @@ export default {
|
|
|
}
|
|
|
if (res.code === 0) {
|
|
|
this.$message.success(res.message)
|
|
|
- if (!isChildren) {
|
|
|
- this.currDataArr[0].Status = Status
|
|
|
- } else {
|
|
|
- this.childrenData[index].Status = Status
|
|
|
- }
|
|
|
- this.dataArr.find(data => {
|
|
|
- if (data.AuthId === id) {
|
|
|
- data.Status = Status
|
|
|
- data.flag = flag
|
|
|
- return true
|
|
|
- }
|
|
|
- })
|
|
|
- if (type !== 1) {
|
|
|
- if (!isChildren) {
|
|
|
- this.childrenData.forEach(data => {
|
|
|
- data.Status = Status
|
|
|
- data.flag = flag
|
|
|
- })
|
|
|
- }
|
|
|
- this.setChildrenStatus(id, flag)
|
|
|
- }
|
|
|
- //this.getAuthTree()
|
|
|
+ // if (!isChildren) {
|
|
|
+ // this.currDataArr[0].Status = Status
|
|
|
+ // } else {
|
|
|
+ // this.childrenData[index].Status = Status
|
|
|
+ // }
|
|
|
+ // this.dataArr.find(data => {
|
|
|
+ // if (data.AuthId === id) {
|
|
|
+ // data.Status = Status
|
|
|
+ // data.flag = flag
|
|
|
+ // return true
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+ // if (type !== 1) {
|
|
|
+ // if (!isChildren) {
|
|
|
+ // this.childrenData.forEach(data => {
|
|
|
+ // data.Status = Status
|
|
|
+ // data.flag = flag
|
|
|
+ // })
|
|
|
+ // }
|
|
|
+ // this.setChildrenStatus(id, flag)
|
|
|
+ // }
|
|
|
+ this.initCurrentKeyStep.splice(0, 1, false)
|
|
|
+ this.currentKey = null
|
|
|
+ this.getAuthTree()
|
|
|
} else {
|
|
|
this.$message.error(res.message)
|
|
|
if (!isChildren) {
|
|
|
- this.currDataArr[0].flag = !flag;
|
|
|
+ this.currDataArr[index].flag = !flag;
|
|
|
} else {
|
|
|
this.childrenData[index].flag = !flag;
|
|
|
}
|
|
@@ -429,14 +447,11 @@ export default {
|
|
|
} catch (error) {
|
|
|
console.log('出错了', error)
|
|
|
if (!isChildren) {
|
|
|
- this.currDataArr[0].flag = !flag;
|
|
|
+ this.currDataArr[index].flag = !flag;
|
|
|
} else {
|
|
|
this.childrenData[index].flag = !flag;
|
|
|
}
|
|
|
}
|
|
|
- this.$nextTick(() => {
|
|
|
- this.$refs.tree.setCurrentKey(this.currentKey)
|
|
|
- })
|
|
|
},
|
|
|
//应用删除
|
|
|
async deleteApp (id) {
|
|
@@ -447,6 +462,12 @@ export default {
|
|
|
if (res.code === 0) {
|
|
|
this.$message.success(res.message)
|
|
|
this.flag = false
|
|
|
+ this.initCurrentKeyStep.splice(0, 1, false)
|
|
|
+ if (this.currentKey === id) {
|
|
|
+ sessionStorage.setItem('authCurrentKey', this.dataUpId)
|
|
|
+ } else {
|
|
|
+ this.currentKey = null
|
|
|
+ }
|
|
|
this.getAuthTree()
|
|
|
} else {
|
|
|
this.flag = false
|
|
@@ -465,6 +486,12 @@ export default {
|
|
|
if (res.code === 0) {
|
|
|
this.$message.success(res.message || '成功')
|
|
|
this.flag = false
|
|
|
+ this.initCurrentKeyStep.splice(0, 1, false)
|
|
|
+ if (this.currentKey === id) {
|
|
|
+ sessionStorage.setItem('authCurrentKey', this.dataUpId)
|
|
|
+ } else {
|
|
|
+ this.currentKey = null
|
|
|
+ }
|
|
|
this.getAuthTree()
|
|
|
} else {
|
|
|
this.flag = false
|