lxl
2022-10-27 9ce29c536ba2a636416c618761985e2b9a711ee6
src/views/AuthorizationManagement/roleMenuAuthorization.vue
@@ -20,7 +20,7 @@
            style="width: 300px"
            v-model="selFrom.name"
            placeholder="请选择单位名称..."
            @change="chooseCustom"
            @change="chooseCustom('multiSelect')"
          >
            <el-option
              :value="selectTree"
@@ -36,6 +36,7 @@
                node-key="id"
                ref="treeForm"
                @node-click="addAdminHandleNodeClick"
                :default-expanded-keys="[1]"
              >
              </el-tree>
            </el-option>
@@ -65,10 +66,10 @@
            </template>
          </el-table-column>
          <el-table-column
            prop="id"
            :label="$t('operatManage.UserRoleAuthorizationObj.serialNumber')"
          >
          </el-table-column>
            align="center"
            type="index"
            :label="$t('dataManage.styleObj.index')"
          />
          <el-table-column
            prop="name"
            :label="$t('operatManage.UserRoleAuthorizationObj.name')"
@@ -125,6 +126,7 @@
          node-key="id"
          @check="menuTreeCheck"
          ref="treeForm"
          :default-expanded-keys="[1]"
        >
        </el-tree>
      </div>
@@ -154,6 +156,7 @@
        >
        <div class="btn" style="margin-left: auto">
          <el-button
            v-if="menuStatus.insert"
            type="primary"
            icon="el-icon-circle-plus-outline"
            size="small"
@@ -162,6 +165,7 @@
            >{{ $t('operatManage.UserRoleAuthorizationObj.Added') }}</el-button
          >
          <el-button
            v-if="menuStatus.delete"
            type="danger"
            icon="el-icon-delete"
            size="small"
@@ -185,10 +189,10 @@
      >
        <el-table-column type="selection" width="55"> </el-table-column>
        <el-table-column
          prop="id"
          :label="$t('operatManage.UserRoleAuthorizationObj.serialNumber')"
        >
        </el-table-column>
          align="center"
          type="index"
          :label="$t('dataManage.styleObj.index')"
        />
        <el-table-column
          prop="name"
          :label="$t('operatManage.UserRoleAuthorizationObj.name')"
@@ -220,10 +224,10 @@
      >
        <el-table-column type="selection" width="55"> </el-table-column>
        <el-table-column
          prop="id"
          :label="$t('operatManage.UserRoleAuthorizationObj.serialNumber')"
        >
        </el-table-column>
          align="center"
          type="index"
          :label="$t('dataManage.styleObj.index')"
        />
        <el-table-column
          prop="name"
          :label="$t('operatManage.UserRoleAuthorizationObj.name')"
@@ -309,6 +313,11 @@
      gridData: [],
      addmultipleSelection: [],
      usermultipleSelection: [],
      menuStatus: {
        delete: false,
        insert: false,
        update: false,
      },
    };
  },
  methods: {
@@ -344,6 +353,7 @@
      this.depid = e.id;
      this.selFrom.name = e.name;
      this.selectTree = e.name;
      this.chooseCustom('multiSelect');
      this.getRoleDep();
      this.getMenuTree();
    },
@@ -353,6 +363,10 @@
        this.menuid = node.id;
        this.rolMenuListData.roleid = this.roleid;
        this.getRoleMenu();
        if (list.checkedKeys.length == 2) {
          //单选实现
          this.$refs.treeForm.setCheckedKeys([node.id]);
        }
      } else {
        this.menuid = null;
      }
@@ -392,10 +406,20 @@
      );
    },
    //下拉框选中后自动关闭
    chooseCustom() {
      setTimeout(() => {
        this.$refs.multiSelect.blur();
    chooseCustom(refName) {
      // this.$refs[refName] && this.$refs[refName].blur();
      this.createTimer(this.autoCloseSelect, refName);
    },
    createTimer(callback, refName) {
      const timer = setTimeout(() => {
        callback(refName);
      }, 50);
      this.$once('hook:beforeDestroy', () => {
        clearInterval(timer);
      });
    },
    autoCloseSelect(refName) {
      this.$refs[refName] && this.$refs[refName].blur();
    },
    dephandleSizeChange() {
      this.roleDepListData.pageSize = val;
@@ -473,8 +497,28 @@
        })
        .catch(() => {});
    },
    showPermsMenu(res) {
      switch (res.tag) {
        case '/delete':
          this.menuStatus.delete = true;
          break;
        case '/insert':
          this.menuStatus.insert = true;
          break;
        case '/update':
          this.menuStatus.update = true;
          break;
      }
    },
  },
  created() {
    var val = this.$store.state.currentPerms;
    var permsEntity = this.$store.state.permsEntity;
    for (var i = 0; i < permsEntity.length; i++) {
      if (permsEntity[i].perms == val) {
        this.showPermsMenu(permsEntity[i]);
      }
    }
    this.getDepTree();
    this.getMenuTree();
  },