按钮级别的新版本,多级别的组织架构
loulijun2021
2023-07-28 e39d4219cfe41c1024c1b9a2575c4314008d30f3
1.递交
已修改2个文件
52 ■■■■ 文件已修改
package.json 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/basicSettings/rolePermission.vue 51 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
package.json
@@ -15,6 +15,7 @@
  },
  "dependencies": {
    "@microsoft/signalr": "^7.0.9",
    "array-to-tree": "^3.3.2",
    "axios": "0.18.1",
    "core-js": "3.6.5",
    "cronstrue": "^2.28.0",
src/views/basicSettings/rolePermission.vue
@@ -70,6 +70,7 @@
      <div
        class="elTableDiv"
      >
        <div style="width: 300px;">
          <el-tree
            ref="treeLeftRef"
@@ -78,7 +79,7 @@
            :data="treeLeft"
            node-key="code"
            highlight-current
            :props="defaultProps"
            :props="defaultPropsLeft"
            :default-expand-all="true"
          />
        </div>
@@ -107,7 +108,7 @@
                    style="padding-top: 10px;width: 199px;"
                    :data="treeCenter"
                    highlight-current
                    :props="defaultProps"
                    :props="defaultPropsCenter"
                    show-checkbox
                    node-key="code"
                    :default-expand-all="true"
@@ -182,6 +183,8 @@
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',
@@ -246,7 +249,11 @@
          }]
        }
      ],
      defaultProps: {
      defaultPropsLeft: {
        children: 'roles',
        label: 'name'
      },
      defaultPropsCenter: {
        children: 'children',
        label: 'label'
      },
@@ -265,15 +272,11 @@
  },
  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) {
@@ -290,6 +293,38 @@
    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) {