|
@@ -1,7 +1,7 @@
|
|
|
<!--
|
|
|
* @Author: your name
|
|
|
* @Date: 2021-11-29 09:27:43
|
|
|
- * @LastEditTime: 2022-03-18 16:02:57
|
|
|
+ * @LastEditTime: 2022-03-18 18:18:39
|
|
|
* @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="[currentKey]" @node-click="handleNodeClick">
|
|
|
+ <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>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -100,19 +100,19 @@
|
|
|
<div :title="data.AuthName" class="name">{{data.AuthName}}</div>
|
|
|
<div class="icon">
|
|
|
<el-tooltip effect="dark" content="新增应用" placement="bottom">
|
|
|
- <span v-if="data.Type === 0" @click="renderAdd()" class="cap cap-plus"></span>
|
|
|
+ <span v-if="data.Type === 0" @click.stop="renderAdd()" class="cap cap-plus"></span>
|
|
|
</el-tooltip>
|
|
|
<el-tooltip effect="dark" content="修改应用" placement="bottom">
|
|
|
- <span v-if="data.Type === 1" @click="renderEdit(data)" class="cap cap-edit"></span>
|
|
|
+ <span v-if="data.Type === 1" @click.stop="renderEdit(data)" class="cap cap-edit"></span>
|
|
|
</el-tooltip>
|
|
|
<el-tooltip v-is="['authtree_btn_add_auth']" effect="dark" content="新增权限项" placement="bottom">
|
|
|
- <span v-if="data.Type === 2" @click="renderSub(data)" class="cap cap-sub"></span>
|
|
|
+ <span v-if="data.Type === 2" @click.stop="renderSub(data)" class="cap cap-sub"></span>
|
|
|
</el-tooltip>
|
|
|
<el-tooltip v-is="['authtree_btn_update_auth']" effect="dark" content="编辑权限项" placement="bottom">
|
|
|
- <span v-if="data.Type > 2" @click="renderEdit(data)" class="cap cap-edit"></span>
|
|
|
+ <span v-if="data.Type > 2" @click.stop="renderEdit(data)" class="cap cap-edit"></span>
|
|
|
</el-tooltip>
|
|
|
<el-tooltip v-is="['authtree_btn_add_auth']" effect="dark" content="新增权限项" placement="bottom">
|
|
|
- <span v-if="data.Type > 2" @click="renderSub(data)" class="cap cap-sub"></span>
|
|
|
+ <span v-if="data.Type > 2" @click.stop="renderSub(data)" class="cap cap-sub"></span>
|
|
|
</el-tooltip>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -126,7 +126,7 @@
|
|
|
</div>
|
|
|
</div>
|
|
|
<div v-is="['authtree_btn_del_auth']">
|
|
|
- <div v-if="data.Type !== 0 && data.Type !== 2" @click="onNodeClick(data)" class="info-close">
|
|
|
+ <div v-if="data.Type !== 0 && data.Type !== 2" @click.stop="onNodeClick(data)" class="info-close">
|
|
|
<i class="icon el-icon-close" :class="data.Type === 1 ? 'close1' : data.Type > 2 ? 'close2' : ''"></i>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -179,14 +179,14 @@ export default {
|
|
|
flag: false, //弹框开关
|
|
|
dataId: null, //tree数据id
|
|
|
currDataArr: [],
|
|
|
- currDataArrId: 0,
|
|
|
childrenData: [],
|
|
|
dataListTree: [],
|
|
|
- currentKey: -1,
|
|
|
defaultProps: {
|
|
|
children: "children",
|
|
|
label: "AuthName",
|
|
|
},
|
|
|
+ currentKey: -1,
|
|
|
+ expandedKeys: [-1]
|
|
|
}
|
|
|
},
|
|
|
created: function () {
|
|
@@ -203,28 +203,52 @@ export default {
|
|
|
this.dataListTree.push(_.cloneDeep(val))
|
|
|
},
|
|
|
deep: true
|
|
|
+ },
|
|
|
+ currentKey: {
|
|
|
+ handler(val) {
|
|
|
+ this.$refs.tree.setCurrentKey(val)
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
//树点击
|
|
|
handleNodeClick (data) {
|
|
|
const dataNew = _.cloneDeep(data)
|
|
|
- this.currDataArrId = dataNew.AuthId;
|
|
|
+ this.currentKey = dataNew.AuthId
|
|
|
this.currDataArr = [];
|
|
|
this.childrenData = [];
|
|
|
- this.currDataArr = this.decompose(this.dataArr, "AuthId", dataNew.AuthId);
|
|
|
- this.childrenData = this.decompose(this.dataArr, "UpAuthId", dataNew.AuthId);
|
|
|
+ this.currDataArr = this.decompose(this.dataArr, "AuthId", this.currentKey);
|
|
|
+ this.childrenData = this.decompose(this.dataArr, "UpAuthId", this.currentKey);
|
|
|
},
|
|
|
//下级卡片点击
|
|
|
childrenClick (data) {
|
|
|
const dataNew = _.cloneDeep(data)
|
|
|
- this.currDataArrId = dataNew.AuthId;
|
|
|
+ this.currentKey = dataNew.AuthId
|
|
|
this.currDataArr = [];
|
|
|
this.childrenData = [];
|
|
|
- this.currDataArr = this.decompose(this.dataArr, "AuthId", dataNew.AuthId);
|
|
|
- this.childrenData = this.decompose(this.dataArr, "UpAuthId", dataNew.AuthId);
|
|
|
- // this.$refs.tree.setCurrentKey(dataNew.AuthId);
|
|
|
- this.currentKey = dataNew.AuthId;
|
|
|
+ this.currDataArr = this.decompose(this.dataArr, "AuthId", this.currentKey);
|
|
|
+ this.childrenData = this.decompose(this.dataArr, "UpAuthId", this.currentKey);
|
|
|
+ if (!this.expandedKeys.includes(this.currentKey)) {
|
|
|
+ this.expandedKeys.push(this.currentKey)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 节点展开
|
|
|
+ handleExpand(obj) {
|
|
|
+ this.expandedKeys.push(obj.AuthId)
|
|
|
+ },
|
|
|
+ // 节点收起
|
|
|
+ handleCollapse(obj) {
|
|
|
+ const { AuthId, children } = obj
|
|
|
+ children.length && this.collapseChilren(children)
|
|
|
+ this.expandedKeys = this.expandedKeys.filter(key => key !== AuthId)
|
|
|
+ },
|
|
|
+ // 收起子节点
|
|
|
+ collapseChilren(children) {
|
|
|
+ children.forEach(child => {
|
|
|
+ const { AuthId, children } = child
|
|
|
+ children.length && this.collapseChilren(children)
|
|
|
+ this.expandedKeys = this.expandedKeys.filter(key => key !== AuthId)
|
|
|
+ })
|
|
|
},
|
|
|
//下级切换状态
|
|
|
childrenRenderChange (data, index) {
|
|
@@ -397,6 +421,9 @@ export default {
|
|
|
this.childrenData[index].flag = !flag;
|
|
|
}
|
|
|
}
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.$refs.tree.setCurrentKey(this.currentKey)
|
|
|
+ })
|
|
|
},
|
|
|
//应用删除
|
|
|
async deleteApp (id) {
|
|
@@ -423,7 +450,7 @@ export default {
|
|
|
AuthId: id,
|
|
|
})
|
|
|
if (res.code === 0) {
|
|
|
- this.$message.success(res.message)
|
|
|
+ this.$message.success(res.message || '成功')
|
|
|
this.flag = false
|
|
|
this.getAuthTree()
|
|
|
} else {
|