d2-auth-btn.vue
1.07 KB
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
<template>
<el-button
:size="size"
:type="type"
:loading="loading"
v-if="isInRole"
@click="handleClick"
>{{label}}</el-button>
</template>
<script>
import { mapGetters } from 'vuex'
export default {
name: 'AuthButton',
props: {
label: {
type: String,
default: 'Button'
},
size: {
type: String,
default: 'mini'
},
type: {
type: String,
default: 'text'
},
loading: {
type: Boolean,
default: false
},
disabled: {
type: Boolean,
default: false
},
id: {
type: String,
default: null
}
},
computed: {
...mapGetters('d2admin/auth', ['curBtns'])
},
data () {
return {
isInRole: false
}
},
created () {
// this.$vrm.setRoles(this.btnIdAll)
const { action, operation } = this.curBtns
this.isInRole = [...action, ...operation].find(obj => obj.id === this.id || obj.label === this.label)
},
methods: {
handleClick: function () {
this.$emit('e-auth-click', {})
}
}
}
</script>
<style scoped>
</style>