按钮级别的新版本,多级别的组织架构
loulijun2021
2023-08-04 f3768ee389adcf28bcbcec234f78b31216d3641b
1.角色权限优化75%
已修改2个文件
72 ■■■■ 文件已修改
src/router/index.js 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/basicSettings/roleList.vue 64 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/router/index.js
@@ -143,7 +143,7 @@
    redirect: '/workOrder/workOrderList',
    name: '工单管理',
    code: '1002',
    meta: { code: '1002', title: '工单管理', icon: 'quality' },
    meta: { code: '1002', title: '工单管理', icon: 'bbgl' },
    alwaysShow: true, // 当children只有一个时,也显示父菜单
    children: [
      {
@@ -156,13 +156,13 @@
      {
        path: 'workOrderSend',
        name: 'workOrderSendCancel',
        code: '1011',
        code: '1021',
        component: () => import('@/views/workOrder/workOrderSend'),
        meta: { code: '1021', title: '工单派发', icon: '', keepAlive: true }
      }, {
        path: 'workOrderClose',
        name: 'workOrderCloseCancel',
        code: '1012',
        code: '1022',
        component: () => import('@/views/workOrder/workOrderClose'),
        meta: { code: '1022', title: '工单关闭', icon: '', keepAlive: true }
      }
@@ -207,7 +207,7 @@
    redirect: '/statistic/reportList',
    name: '统计报表',
    code: '1004',
    meta: { code: '1004', title: '统计报表', icon: 'bbgl' },
    meta: { code: '1004', title: '统计报表', icon: 'quality' },
    alwaysShow: true, // 当children只有一个时,也显示父菜单
    children: [
      {
src/views/basicSettings/roleList.vue
@@ -111,7 +111,7 @@
                <div
                  ref="scrollCenter"
                  style="border-right: 1px solid rgba(0,0,0,0.2);width: 600px;padding-left: 10px;overflow-y: auto"
                  style="border-right: 1px solid rgba(0,0,0,0.2);width: 660px;padding-left: 10px;overflow-y: auto"
                  :style="{height:(tableHeight-40)+'px'}"
                  @scroll="scrollCenterScroll()"
                  @mouseover="isScroll='center'"
@@ -140,7 +140,7 @@
                        v-if="item.expanded"
                        :key="it.menucode"
                        v-model="it.buttonChecked"
                        style="margin-left: 40px;height:26px;display: flex"
                        style="margin-left: 40px;height:26px;display: flex;"
                        @change="val=>handleCheckedButtonChange(val,it.menucode)"
                      >
@@ -148,7 +148,7 @@
                          v-for="i in it.buttoncodelist"
                          :key="i"
                          :label="i"
                          style="display:flex;align-items: center"
                          style="display:flex;align-items: center;"
                        />
                      </el-checkbox-group>
@@ -280,11 +280,12 @@
  },
  created() {
    this.getRolePermissionSearchRole()
  },
  mounted() {
    window.addEventListener('resize', this.getHeight)
    this.getHeight()
    this.getRolePermissionSearchRole()
  },
  methods: {
@@ -347,7 +348,6 @@
              let temp = this.allButtonData.filter(j => j.menucode === it.menucode).length > 0 ? this.allButtonData.filter(j => j.menucode === it.menucode)[0].buttoncode : []
              temp = temp.length > 0 ? temp.split(',') : []
              console.log(temp, 7)
              it.buttonChecked = [] // 数据回显
              it.buttoncodelist.forEach(j => {
@@ -442,10 +442,6 @@
    },
    // 单个按钮改变
    handleCheckedButtonChange(value, code, flag) {
      // console.log(value, code, flag, 1)
      // console.log(JSON.parse(JSON.stringify(this.treeCenter[0])), 2)
      // 判断是否包含在内
      if (!flag) {
        if (!this.menuCheckedCodeArr.includes(code) && value.length === 1) { // 否
@@ -469,7 +465,6 @@
            if (it.buttoncodelist.length) {
              childrenLength++
            }
            console.log(count, childrenLength)
          })
        }
      })
@@ -479,8 +474,6 @@
    },
    // 获取树形节点node
    getLeftTreeNode(data, Node, VueComponent) {
      // console.log(data, Node, VueComponent, 2221)
      // console.log(Node.expanded)
      this.treeCenter[0].children.forEach(item => {
        if (item.menucode === data.menucode) {
          item.expanded = Node.expanded
@@ -510,7 +503,6 @@
    // 处理中间树形选中值改变
    handleTreeCenterCheckChange(obj, selfChecked, selfChildrenTreeCheck) {
      // console.log(obj, selfChecked, selfChildrenTreeCheck, '王老吉')
      obj.flag = selfChecked ? 'Y' : 'N'
      if (!selfChildrenTreeCheck) {
        if (!selfChecked) {
          this.treeCenter[0].children.forEach(item => {
@@ -541,16 +533,17 @@
      this.treeCenter[0].children.forEach(item => {
        if (item.children && item.children.length) {
          item.children.forEach(it => {
            if (it.dataChecked.length > 0) {
            if (it.dataChecked.length > 0 && it.datacodelist.length > 0) {
              count++
            }
            // console.log(it.dataChecked, 234)
            if (it.datacodelist.length > 0) {
              childrenLength++
            }
          })
        }
      })
      // console.log(count, childrenLength, 9)
      // console.log(count, childrenLength, 123)
      this.dataIsChecked = count === childrenLength
      this.$forceUpdate()
    },
@@ -590,31 +583,34 @@
    // 页面勾选好保存事件
    async saveClick() {
      // [{"menucode":"1010","buttoncode":"Add,Update","datacode":"ALL"},]
      const menuKeyArr = this.$refs.treeCenterRef.getCheckedKeys()
      const arr = []
      this.treeCenter[0].children.forEach(item => {
        if (item.children && item.children.length) {
          item.children.forEach(it => {
            if (it.dataChecked && it.dataChecked.toString().length > 0) { // 数据权限已勾选
              it.dataChecked = this.dataKeyValue.find(i => i.dataname === it.dataChecked).datacode
            }
            if (menuKeyArr.includes(it.menucode)) {
              if (it.dataChecked && it.dataChecked.toString().length > 0) { // 数据权限已勾选
                it.dataChecked = this.dataKeyValue.find(i => i.dataname === it.dataChecked).datacode
              }
            if (it.buttonChecked && it.buttonChecked.length > 0) { // 已选菜单
              it.buttonChecked = this.$ButtonData.filter(i =>
                it.buttonChecked.includes(i.buttonname)
              ).map(i => i.buttoncode)
              if (it.buttonChecked && it.buttonChecked.length > 0) { // 已选菜单
                it.buttonChecked = this.$ButtonData.filter(i =>
                  it.buttonChecked.includes(i.buttonname)
                ).map(i => i.buttoncode)
              }
              arr.push({
                menucode: it.menucode,
                datacode: it.dataChecked,
                buttoncode: it.buttonChecked ? it.buttonChecked.join(',') : ''
              })
            }
            arr.push({
              menucode: it.menucode,
              datacode: it.dataChecked,
              buttoncode: it.buttonChecked ? it.buttonChecked.join(',') : ''
            })
          })
        }
      })
      // console.log(this.$refs.treeCenterRef.getCheckedKeys(), 7)
      console.log(arr, 'arr')
      const rolecode = this.$refs.treeLeftRef.getCurrentKey()
      // console.log(JSON.stringify(arr).toString())
      const res = await RolePermissionSava(JSON.stringify(arr), rolecode, this.activeName)
      if (res.code === '200') {
        const rolename = this.treeLeft[0].roles.find(i => i.code === rolecode).name
@@ -622,7 +618,7 @@
        await this.getRolePermissionSearchRoleMenuButton(rolecode)
        await this.getRolePermissionSearchRoleMenu(rolecode)
      }
      this.$forceUpdate()
      // this.$forceUpdate()
    },
    // 获取页面高度
    getHeight() {
@@ -655,4 +651,12 @@
  font-size: 14px;
  padding-right: 8px;
}
::v-deep .el-checkbox__label {
  width: 55px;
}
.el-icon-plus:hover,.el-icon-edit:hover,.el-icon-delete:hover{
  color: #000 !important;
}
</style>