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
<!-- ******************* 多选框 ******************* -->
<template>
<view class="list">
<view
v-for="(item, index) in settings"
:key="index"
:class="{ txt: true, active: checkStatus(item.key) }"
@click="setValue(item.key)"
>{{ item.label }}
</view>
</view>
</template>
<script>
import arrMixin from './arrMixin'
export default {
name: 'XhRadio',
components: {},
mixins: [arrMixin],
props: {},
filters: {},
data() {
return {}
},
computed: {
settings() {
return this.item.fieldsOptions || []
},
},
watch: {},
mounted() {},
methods: {
checkStatus(item) {
if (!item) {
return false
}
const dataValue = this.dataValue
let flag = Array.isArray(dataValue) && dataValue.indexOf(item) > -1
return flag
},
setValue(txt) {
if (this.disabled) return
const dataValue = this.dataValue || []
let idx = dataValue.indexOf(txt)
if (idx > -1) {
dataValue.splice(idx, 1)
} else {
dataValue.push(txt)
}
this.dataValue = dataValue
this.valueChange(this.dataValue)
},
},
}
</script>
<style lang="scss" scoped>
.list {
display: flex;
flex-wrap: wrap;
.txt {
color: #333;
padding: 10rpx 30rpx;
margin: 10rpx;
background: #f4f5f7;
border-radius: 10rpx;
display: flex;
flex-wrap: wrap;
line-height: 50rpx;
max-width: 46%;
align-items: center;
&.active {
background-color: #2272ff;
color: #fff;
}
}
}
</style>