<!--
  @description: button组件二次封装-权限控制
  @author: 肖文龙
-->
<template>
  <!-- code 01 展示 00或空 不展示 -->
  <el-button
    v-if="codeData[code]==='01'||!code"
    :type="type"
    :icon="icon"
    v-bind="$attrs"
    v-on="$listeners"
  >
    <!-- 插槽 -->
    <slot />
  </el-button>
</template>

<script>
/* Vuex */
import { mapState } from 'vuex'
export default {
  name: 'GXbutton',
  inheritAttrs: false,
  props: {
    // 按钮类型
    type: {
      type: [String, undefined],
      default: undefined
    },
    // icon
    icon: {
      type: [String, undefined],
      default: undefined
    },
    // 按钮编码（控制该按钮显隐）
    code: {
      type: [String, undefined],
      default: undefined

    }
  },
  computed: {
    ...mapState({
      codeData: state => state.user.userButtonAuthority // 用户按钮权限数据
    })
  }
}
</script>

<style scoped>

</style>
