MrShi
2024-02-22 8d7bb4ac830444afde480a588e99952105ea8ede
platform/src/components/system/role/MenuConfigWindow.vue
@@ -25,7 +25,8 @@
<script>
import GlobalWindow from '@/components/common/GlobalWindow'
import { createRoleMenu } from '@/api/system/role'
import { fetchTree as fetchMenuList } from '@/api/system/menu'
import { fetchTree as fetchMenuList, fetchTree1 } from '@/api/system/menu'
import { mapState } from 'vuex'
export default {
  name: 'MenuConfigWindow',
  components: { GlobalWindow },
@@ -41,12 +42,16 @@
      selectedIds: []
    }
  },
  computed: {
    ...mapState(['userInfo'])
  },
  methods: {
    /**
     * @role 角色对象
     */
    open (role, type=0) {
      fetchMenuList({}, type)
    open (role) {
      if (this.userInfo.type === 1) {
        fetchTree1({})
        .then(records => {
          this.role = role
          this.menus = records
@@ -61,6 +66,24 @@
        .catch(e => {
          this.$tip.apiFailed(e)
        })
      } else {
        fetchMenuList({})
          .then(records => {
            this.role = role
            this.menus = records
            // 如果为固定角色,则固定菜单不可更改
            this.__resetDisabled(this.menus, this.role)
            // 找出叶节点
            role.menus = role.menus.filter(menu => role.menus.findIndex(m => m.parentId === menu.id) === -1)
            // 初始化选中
            this.selectedIds = role.menus.map(r => r.id)
            this.visible = true
          })
          .catch(e => {
            this.$tip.apiFailed(e)
          })
      }
    },
    // 确认选择菜单
    confirm () {