|
@@ -1,7 +1,7 @@
|
|
|
<!--
|
|
|
* @Author: zk
|
|
|
* @Date: 2022-02-09 15:47:09
|
|
|
- * @LastEditTime: 2022-03-14 10:48:53
|
|
|
+ * @LastEditTime: 2022-03-14 17:13:37
|
|
|
* @LastEditors: your name
|
|
|
* @Description: 用户组树
|
|
|
* @FilePath: \Foshan4A4.0\src\components\usergrouptree\index.vue
|
|
@@ -13,7 +13,7 @@
|
|
|
</div>
|
|
|
<div :class="type ? 'radioBg':''" class="content">
|
|
|
<el-scrollbar style="height: 100%" wrap-style="overflow-x:hidden;">
|
|
|
- <el-tree ref="tree" :data="data" show-checkbox :default-props="defaultProps" default-expand-all node-key="GroupId" highlight-current @check="currentChange">
|
|
|
+ <el-tree ref="tree" :data="data" show-checkbox :default-props="defaultProps" :default-expanded-keys="defaultExpandedKeys" node-key="GroupId" highlight-current @check="currentChange">
|
|
|
<span slot-scope="{ data }" class="custom-tree-node">
|
|
|
{{ data.GroupName }}
|
|
|
</span>
|
|
@@ -60,7 +60,10 @@ export default {
|
|
|
data: [], // tree数据
|
|
|
checkedList: [], // 已选中数据
|
|
|
pageIndex: 1,
|
|
|
- pageSize: 20
|
|
|
+ pageSize: 20,
|
|
|
+ defaultExpandedKeys: [-1],
|
|
|
+ getExpandedKeysStep: [false, false],
|
|
|
+ userGroupList: [],
|
|
|
}
|
|
|
},
|
|
|
watch: {
|
|
@@ -68,6 +71,24 @@ export default {
|
|
|
handler (val) {
|
|
|
this.checkedList = val
|
|
|
this.$refs.tree.setCheckedKeys(val)
|
|
|
+ this.getExpandedKeysStep.splice(0, 1, true)
|
|
|
+ },
|
|
|
+ deep: true
|
|
|
+ },
|
|
|
+ getExpandedKeysStep: {
|
|
|
+ handler(val) {
|
|
|
+ if (val.every(v => v)) {
|
|
|
+ this.defaultExpandedKeys = [-1]
|
|
|
+ this.checkedKeys.forEach(key => {
|
|
|
+ if (key !== -1) {
|
|
|
+ const group = this.userGroupList.find(item => item.GroupId == key)
|
|
|
+ const GroupUpid = group.GroupUpid
|
|
|
+ if (!this.defaultExpandedKeys.includes(GroupUpid)) {
|
|
|
+ this.defaultExpandedKeys.push(GroupUpid)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
},
|
|
|
deep: true
|
|
|
}
|
|
@@ -97,6 +118,8 @@ export default {
|
|
|
PageSize: this.pageSize
|
|
|
})
|
|
|
const datas = result.returnData
|
|
|
+ this.userGroupList = datas
|
|
|
+ this.getExpandedKeysStep.splice(1, 1, true)
|
|
|
const tree = translateDataToTreeAll(datas, 'GroupUpid', 'GroupId')
|
|
|
const setDisabled = (tree, key) => {
|
|
|
if (key) {
|