doum
2025-09-26 9057e04efad1b7d61c77a72e5c37a504d0aee935
admin/src/components/system/role/MenuConfigWindow.vue
@@ -9,7 +9,7 @@
  >
    <p class="tip" v-if="role != null">为角色 <em>{{role.name}}</em> 配置可访问的菜单</p>
    <el-tree
      ref="menuTree"
      ref="tree"
      :data="menus"
      show-checkbox
      node-key="id"
@@ -43,7 +43,9 @@
  },
  methods: {
    /**
     * @role 角色对象
     * 打开窗口
     *
     * @param role 目标角色
     */
    open (role) {
      fetchMenuList({})
@@ -51,7 +53,7 @@
          this.role = role
          this.menus = records
          // 如果为固定角色,则固定菜单不可更改
          this.__resetDisabled(this.menus, this.role)
          this.__handleFixedMenus(this.menus, this.role)
          // 找出叶节点
          role.menus = role.menus.filter(menu => role.menus.findIndex(m => m.parentId === menu.id) === -1)
          // 初始化选中
@@ -62,9 +64,11 @@
          this.$tip.apiFailed(e)
        })
    },
    // 确认选择菜单
    /**
     * 确认选择菜单
     */
    confirm () {
      const selectedMenus = this.$refs.menuTree.getCheckedNodes(false, true)
      const selectedMenus = this.$refs.tree.getCheckedNodes(false, true)
      this.isWorking = true
      createRoleMenu({
        roleId: this.role.id,
@@ -82,8 +86,14 @@
          this.isWorking = false
        })
    },
    // 重置disabled
    __resetDisabled (menus, role) {
    /**
     * 处理固定菜单
     *
     * @param menus 菜单列表
     * @param role 角色
     * @private
     */
    __handleFixedMenus (menus, role) {
      if (menus == null || menus.length === 0) {
        return
      }
@@ -92,7 +102,7 @@
        if (role.fixed && menu.fixed) {
          menu.disabled = true
        }
        this.__resetDisabled(menu.children, role)
        this.__handleFixedMenus(menu.children, role)
      }
    }
  }
@@ -100,15 +110,15 @@
</script>
<style scoped lang="scss">
  @import "@/assets/style/variables.scss";
  .global-window {
    .tip {
      margin-bottom: 12px;
      em {
        font-style: normal;
        color: $primary-color;
        font-weight: bold;
      }
@import "@/assets/style/variables.scss";
.global-window {
  .tip {
    margin-bottom: 12px;
    em {
      font-style: normal;
      color: $primary-color;
      font-weight: bold;
    }
  }
}
</style>