k94314517
2025-07-15 9d7979a2933632bc2083c7f0b3e4a793b0dc3f3e
admin/src/components/base/BaseOpera.vue
@@ -1,4 +1,6 @@
<script>
import {mapState} from "vuex";
export default {
  name: 'BaseOpera',
  data () {
@@ -13,6 +15,9 @@
        'field.id': 'id'
      }
    }
  },
  computed: {
    ...mapState(['userInfo']),
  },
  methods: {
    /**
@@ -125,6 +130,29 @@
            this.isWorking = false
          })
      })
    },
    /**
     * 是否包含指定权限
     *
     * @param permissions 目标权限数组
     * @returns {boolean}
     */
    containPermissions (permissions) {
      if (permissions == null) {
        return true
      }
      if (this.userInfo == null) {
        return false
      }
      if (this.userInfo.permissions == null || this.userInfo.permissions.length === 0) {
        return false
      }
      for (const code of permissions) {
        if (this.userInfo.permissions.findIndex(p => p === code) > -1) {
          return true
        }
      }
      return false
    }
  }
}