jinlin
2024-02-26 6f0714843341b168573ad0272069f7af2d3d2b87
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<template>
  <el-button class="zt-button" :type="buttonType" :icon="buttonIcon" @click="onClick" v-if="$hasPermission(perm)">
    {{ text }}
    <slot></slot>
    </el-button>
</template>
<script>
  export default {
    name: 'ZtButton',
    props: {
      type: String,
      icon2: String,
      perm: {// 权限
        type: String,
        default: ''
      }
    },
    computed: {
      buttonType() {
        if (this.type === 'query') {
          return 'primary'
        } else if (this.type === 'add' || this.type === 'update') {
          return 'primary'
        } else if (this.type === 'delete') {
          return 'danger'
        } else if (this.type === 'export') {
          return 'info'
        } else if (this.type === 'import') {
          return 'primary'
        } else if (this.type === 'warning') {
          return 'warning'
        } else {
          return 'primary'
        }
        return this.type
      },
      buttonIcon() {
        if (this.type === 'query') {
          return 'el-icon-search'
        } else if (this.type === 'add' || this.type === 'update') {
          return 'el-icon-edit'
        } else if (this.type === 'delete') {
          return 'el-icon-delete'
        } else if (this.type === 'export') {
          return 'el-icon-download'
        } else if (this.type === 'import') {
          return 'el-icon-upload2'
        }
        return this.icon2
      },
      text() {
        if (this.type === 'query') {
          return this.$t('query')
        } else if (this.type === 'add') {
          return this.$t('add')
        } else if (this.type === 'update') {
          return this.$t('update')
        } else if (this.type === 'delete') {
          return this.$t('deleteBatch')
        } else if (this.type === 'export') {
          return this.$t('export')
        }else if (this.type === 'import') {
          return this.$t('import')
        }
        // return this.icon2
      }
    },
    methods: {
      onClick() {
        this.$emit('click')
      }
    }
  }
</script>
<style>
  .zt-button {
    padding: 9px 18px !important;
  }
</style>