d2-auth-btn.vue 1.07 KB
<template>
  <el-button
    :size="size"
    :type="type"
    :loading="loading"
    v-if="isInRole"
    @click="handleClick"
  >{{label}}</el-button>
</template>

<script>
import { mapGetters } from 'vuex'
export default {
  name: 'AuthButton',
  props: {
    label: {
      type: String,
      default: 'Button'
    },
    size: {
      type: String,
      default: 'mini'
    },
    type: {
      type: String,
      default: 'text'
    },
    loading: {
      type: Boolean,
      default: false
    },
    disabled: {
      type: Boolean,
      default: false
    },
    id: {
      type: String,
      default: null
    }
  },
  computed: {
    ...mapGetters('d2admin/auth', ['curBtns'])
  },
  data () {
    return {
      isInRole: false
    }
  },
  created () {
    //  this.$vrm.setRoles(this.btnIdAll)
    const { action, operation } = this.curBtns
    this.isInRole = [...action, ...operation].find(obj => obj.id === this.id || obj.label === this.label)
  },
  methods: {
    handleClick: function () {
      this.$emit('e-auth-click', {})
    }
  }
}
</script>

<style scoped>
</style>