KtButton.vue 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <template>
  2. <el-button :size="size" :type="type" :icon="icon"
  3. :class="disabled?'buttonCursor:':''" :plain="plain" :loading="loading" :disabled="disabled" @click="handleClick" v-if="hasPerms(perms) || !perms">
  4. <!-- :class="hasPerms(perms)?'buttonCursor:':''" :loading="loading" :disabled="!hasPerms(perms)" @click="handleClick"> -->
  5. {{label}}
  6. </el-button>
  7. </template>
  8. <script>
  9. import { hasPermission } from '@/permission/index.js'
  10. export default {
  11. name: 'KtButton',
  12. props: {
  13. label: { // 按钮显示文本
  14. type: String,
  15. default: 'Button'
  16. },
  17. icon: { // 按钮显示图标
  18. type: String,
  19. default: ''
  20. },
  21. size: { // 按钮尺寸
  22. type: String,
  23. default: 'small'
  24. },
  25. type: { // 按钮类型
  26. type: String,
  27. default: null
  28. },
  29. loading: { // 按钮加载标识
  30. type: Boolean,
  31. default: false
  32. },
  33. plain:{
  34. type: Boolean,
  35. default: false
  36. },
  37. disabled: { // 按钮是否禁用
  38. type: Boolean,
  39. default: false
  40. },
  41. perms: { // 按钮权限标识,外部使用者传入
  42. type: String,
  43. default: null
  44. }
  45. },
  46. data() {
  47. return {
  48. }
  49. },
  50. methods: {
  51. handleClick: function () {
  52. // 按钮操作处理函数
  53. this.$emit('click', {})
  54. },
  55. hasPerms: function (perms) {
  56. // 根据权限标识和外部指示状态进行权限判断
  57. if(!hasPermission(perms) ){
  58. return false
  59. }
  60. else{
  61. return true
  62. }
  63. }
  64. },
  65. mounted() {
  66. }
  67. }
  68. </script>
  69. <style scoped>
  70. buttonCursor{
  71. cursor: pointer;
  72. }
  73. </style>