forked from apache/incubator-weex-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
item.vue
94 lines (89 loc) · 2.3 KB
/
item.vue
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<!-- CopyRight (C) 2017-2022 Alibaba Group Holding Limited. -->
<!-- Created by Tw93 on 17/07/28. -->
<template>
<wxc-cell :has-top-border="hasTopBorder"
:cell-style="{backgroundColor:backgroundColor}"
@wxcCellClicked="wxcCellClicked"
:accessible="true"
:aria-label="`${title},状态为${checked?'已选中':'未选中'},${disabled?'不可更改':''}`">
<text :style="{color:color}"
class="title-text"
slot="title">{{title}}</text>
<image :src="radioIcon"
v-if="radioIcon"
slot="value"
class="radio"></image>
</wxc-cell>
</template>
<style scoped>
.radio {
width: 48px;
height: 48px;
}
.title-text {
font-size: 30px;
}
</style>
<script>
import WxcCell from '../wxc-cell';
import { CHECKED, DISABLED } from './type.js'
export default {
components: { WxcCell },
props: {
hasTopBorder: {
type: Boolean,
default: false
},
title: {
type: String,
require: true
},
value: {
type: [String, Number, Object],
require: true
},
disabled: {
type: Boolean,
default: false
},
checked: {
type: Boolean,
default: false
},
config: {
type: Object,
default: () => ({})
}
},
data: () => ({
icon: [CHECKED, DISABLED]
}),
computed: {
radioIcon () {
const { icon, disabled, checked, config } = this;
const mergeIcon = icon;
config.checkedIcon && (mergeIcon[0] = config.checkedIcon);
config.disabledIcon && (mergeIcon[1] = config.disabledIcon);
return checked ? mergeIcon[disabled ? 1 : 0] : '';
},
backgroundColor () {
const { disabled } = this;
return disabled ? '#F2F3F4' : '#FFFFFF';
},
color () {
const { disabled, checked, config } = this;
let checkedColor = '#EE9900';
config.checkedColor && (checkedColor = config.checkedColor);
return checked && !disabled ? checkedColor : '#3D3D3D';
}
},
methods: {
wxcCellClicked () {
const { disabled, value } = this;
if (!disabled) {
this.$emit('wxcRadioItemChecked', { value, disabled })
}
}
}
}
</script>