KtButton.vue 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <template>
  2. <el-button :size="size" :type="type" :icon="icon"
  3. :class="disabled?'buttonCursor:':''" :loading="loading" :disabled="disabled" @click="handleClick" >
  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: 'mini'
  24. },
  25. type: { // 按钮类型
  26. type: String,
  27. default: null
  28. },
  29. loading: { // 按钮加载标识
  30. type: Boolean,
  31. default: false
  32. },
  33. disabled: { // 按钮是否禁用
  34. type: Boolean,
  35. default: false
  36. },
  37. perms: { // 按钮权限标识,外部使用者传入
  38. type: String,
  39. default: null
  40. }
  41. },
  42. data() {
  43. return {
  44. }
  45. },
  46. methods: {
  47. handleClick: function () {
  48. // 按钮操作处理函数
  49. this.$emit('click', {})
  50. },
  51. hasPerms: function (perms) {
  52. // 根据权限标识和外部指示状态进行权限判断
  53. return hasPermission(perms) & !this.disabled
  54. }
  55. },
  56. mounted() {
  57. }
  58. }
  59. </script>
  60. <style scoped>
  61. buttonCursor{
  62. cursor: pointer;
  63. }
  64. </style>