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
| <template>
| <el-tag
| :round="round"
| :style="cssClass"
| >
| <el-text :style="{ color: cssClass.color }">
| {{ text }}
| </el-text>
| </el-tag>
| </template>
| <script>
| export default {
| data() {
| return {
| list: []
| }
| },
| props: {
| valueKey: [String, Number],
| dictType: String,
| round: {
| type: Boolean,
| default: true
| }
| },
| created() {
| this.initList()
| },
| computed: {
| dictObj: function() {
| return this.list.find(ele => ele.value == this.valueKey) || {}
| },
| text: function() {
| return this.dictObj?.label || ''
| },
| cssClass: function() {
| let str = ''
| try {
| str = JSON.parse(this.dictObj?.cssClass)
| } catch(error) {
| console.log()
| }
| return str
| }
| },
| methods: {
| initList() {
| this.list = this.$getDictData(this.dictType)
| }
| }
| }
| </script>
|
|