7fa943eb
梁灏
init
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
<template>
<label :class="wrapClasses">
<span :class="checkboxClasses">
<span :class="innerClasses"></span>
<input
v-if="group"
type="checkbox"
:class="inputClasses"
:disabled="disabled"
:value="value"
v-model="model"
@change="change">
<input
v-if="!group"
type="checkbox"
:class="inputClasses"
:disabled="disabled"
v-model="checked"
@change="change">
</span>
|
4997bd42
梁灏
update Transfer
|
21
|
<slot v-if="showSlot"><span v-el:slot>{{ value }}</span></slot>
|
7fa943eb
梁灏
init
|
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
</label>
</template>
<script>
const prefixCls = 'ivu-checkbox';
export default {
props: {
disabled: {
type: Boolean,
default: false
},
value: {
type: [String, Number, Boolean]
},
checked: {
type: Boolean,
default: false
|
b923c818
梁灏
update Tree
|
39
40
41
42
|
},
indeterminate: {
type: Boolean,
default: false
|
7fa943eb
梁灏
init
|
43
44
45
46
47
48
|
}
},
data () {
return {
model: [],
selected: false,
|
71699f6b
梁灏
optimize Checkbox...
|
49
50
|
group: false,
showSlot: true
|
b0893113
jingsam
add eslint
|
51
|
};
|
7fa943eb
梁灏
init
|
52
53
54
55
56
57
58
59
60
61
|
},
computed: {
wrapClasses () {
return [
`${prefixCls}-wrapper`,
{
[`${prefixCls}-group-item`]: this.group,
[`${prefixCls}-wrapper-checked`]: this.selected,
[`${prefixCls}-wrapper-disabled`]: this.disabled
}
|
b0893113
jingsam
add eslint
|
62
|
];
|
7fa943eb
梁灏
init
|
63
64
65
66
67
68
|
},
checkboxClasses () {
return [
`${prefixCls}`,
{
[`${prefixCls}-checked`]: this.selected,
|
b923c818
梁灏
update Tree
|
69
70
|
[`${prefixCls}-disabled`]: this.disabled,
[`${prefixCls}-indeterminate`]: this.indeterminate
|
7fa943eb
梁灏
init
|
71
|
}
|
b0893113
jingsam
add eslint
|
72
|
];
|
7fa943eb
梁灏
init
|
73
74
75
76
77
78
79
80
81
|
},
innerClasses () {
return `${prefixCls}-inner`;
},
inputClasses () {
return `${prefixCls}-input`;
}
},
ready () {
|
829a2e4c
梁灏
fixed CheckboxGro...
|
82
|
if (this.$parent && this.$parent.$options.name === 'checkboxGroup') this.group = true;
|
7fa943eb
梁灏
init
|
83
84
|
if (!this.group) {
this.updateModel();
|
71699f6b
梁灏
optimize Checkbox...
|
85
86
|
if (this.$els.slot && this.$els.slot.innerHTML === '') {
this.showSlot = false;
|
71699f6b
梁灏
optimize Checkbox...
|
87
|
}
|
7fa943eb
梁灏
init
|
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
}
},
methods: {
change (event) {
if (this.disabled) {
return false;
}
this.selected = event.target.checked;
if (this.group) {
this.$parent.change(this.model);
} else {
this.$emit('on-change', this.checked);
|
f65e9be5
梁灏
update checkboxGroup
|
102
|
this.$dispatch('on-form-change', this.checked);
|
7fa943eb
梁灏
init
|
103
104
105
106
107
108
109
110
111
112
113
|
}
},
updateModel () {
this.selected = this.checked;
}
},
watch: {
checked () {
this.updateModel();
}
}
|
b0893113
jingsam
add eslint
|
114
115
|
};
</script>
|