| | |
| | | <div |
| | | class="elTableDiv" |
| | | > |
| | | |
| | | <div style="width: 300px;"> |
| | | <el-tree |
| | | ref="treeLeftRef" |
| | |
| | | :data="treeLeft" |
| | | node-key="code" |
| | | highlight-current |
| | | :props="defaultProps" |
| | | :props="defaultPropsLeft" |
| | | :default-expand-all="true" |
| | | /> |
| | | </div> |
| | |
| | | style="padding-top: 10px;width: 199px;" |
| | | :data="treeCenter" |
| | | highlight-current |
| | | :props="defaultProps" |
| | | :props="defaultPropsCenter" |
| | | show-checkbox |
| | | node-key="code" |
| | | :default-expand-all="true" |
| | |
| | | import ImportPicker from '@/components/ImportPicker' |
| | | import elDragDialog from '@/directive/el-drag-dialog' |
| | | import waves from '@/directive/waves' |
| | | import { RolePermissionSearchRole, RolePermissionSearchRoleMenu } from '@/api/basicSettings' |
| | | import arrayToTree from 'array-to-tree' |
| | | |
| | | export default { |
| | | name: 'Zzjg', |
| | |
| | | }] |
| | | } |
| | | ], |
| | | defaultProps: { |
| | | defaultPropsLeft: { |
| | | children: 'roles', |
| | | label: 'name' |
| | | }, |
| | | defaultPropsCenter: { |
| | | children: 'children', |
| | | label: 'label' |
| | | }, |
| | |
| | | }, |
| | | |
| | | created() { |
| | | |
| | | this.getRolePermissionSearchRole() |
| | | }, |
| | | mounted() { |
| | | window.addEventListener('resize', this.getHeight) |
| | | this.getHeight() |
| | | |
| | | this.$nextTick(() => { |
| | | this.$refs.treeLeftRef.setCurrentKey('2001') // 默认选中节点第一个 |
| | | }) |
| | | |
| | | this.treeCenter[0].children.forEach(item => { |
| | | if (item.children && item.children.length) { |
| | |
| | | console.log(JSON.parse(JSON.stringify(this.treeCenter))) |
| | | }, |
| | | methods: { |
| | | |
| | | // 获取角色权限查询角色 |
| | | async getRolePermissionSearchRole() { |
| | | const { data: res } = await RolePermissionSearchRole() |
| | | this.treeLeft = res |
| | | if (res.length > 0) { |
| | | this.$nextTick(() => { // 默认选中第一个 |
| | | this.$refs.treeLeftRef.setCurrentKey(res[0].roles[0].code) // 默认选中节点第一个 |
| | | }) |
| | | await this.getRolePermissionSearchRoleMenu(res[0].roles[0].code) |
| | | } else { |
| | | this.$notify.error('请先建相对应的角色!') |
| | | } |
| | | }, |
| | | async getRolePermissionSearchRoleMenu(rolecode) { |
| | | const { data: res } = await RolePermissionSearchRoleMenu({ rolecode, type: 'PC' }) |
| | | |
| | | // 拿到数组list转换成树形tree |
| | | const result = arrayToTree(res, { |
| | | parentProperty: 'parentid', |
| | | customID: 'code', |
| | | childrenProperty: 'children' |
| | | }) |
| | | |
| | | const aaa = [ |
| | | { code: '-1', name: '全部', flag: result.every(i => i.flag === 'Y') ? 'Y' : 'N', children: result } |
| | | ] |
| | | |
| | | console.log(JSON.parse(JSON.stringify(aaa))) |
| | | // aaa数组给菜单树形 然后再做按钮类的 |
| | | }, |
| | | |
| | | // 左边滚动条滑动时 |
| | | scrollLeftScroll() { |
| | | if (!this.isScroll) { |