<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>
|