stellar-ui-v2 1.35.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/common/css/common.scss +61 -0
- package/components/ste-animate/README.md +117 -0
- package/components/ste-animate/animate.scss +247 -0
- package/components/ste-animate/ste-animate.vue +200 -0
- package/components/ste-badge/README.md +171 -0
- package/components/ste-badge/ste-badge.vue +238 -0
- package/components/ste-barcode/README.md +36 -0
- package/components/ste-barcode/encode2.js +317 -0
- package/components/ste-barcode/ste-barcode.vue +213 -0
- package/components/ste-button/README.md +129 -0
- package/components/ste-button/ste-button.vue +345 -0
- package/components/ste-calendar/README.md +304 -0
- package/components/ste-calendar/self-date.js +119 -0
- package/components/ste-calendar/ste-calendar.vue +578 -0
- package/components/ste-checkbox/README.md +297 -0
- package/components/ste-checkbox/ste-checkbox.vue +305 -0
- package/components/ste-checkbox-group/ste-checkbox-group.vue +133 -0
- package/components/ste-code-input/README.md +67 -0
- package/components/ste-code-input/ste-code-input.vue +302 -0
- package/components/ste-date-picker/README.md +135 -0
- package/components/ste-date-picker/ste-date-picker.vue +407 -0
- package/components/ste-drag/README.md +103 -0
- package/components/ste-drag/ste-drag.vue +203 -0
- package/components/ste-dropdown-menu/README.md +358 -0
- package/components/ste-dropdown-menu/ste-dropdown-menu.vue +405 -0
- package/components/ste-dropdown-menu-item/ste-dropdown-menu-item.vue +176 -0
- package/components/ste-icon/README.md +90 -0
- package/components/ste-icon/iconfont.css +8 -0
- package/components/ste-icon/ste-icon.vue +147 -0
- package/components/ste-image/README.md +154 -0
- package/components/ste-image/ste-image.vue +218 -0
- package/components/ste-index-item/ste-index-item.vue +96 -0
- package/components/ste-index-list/README.md +153 -0
- package/components/ste-index-list/ste-index-list.vue +128 -0
- package/components/ste-input/README.md +146 -0
- package/components/ste-input/ste-input.vue +480 -0
- package/components/ste-loading/README.md +81 -0
- package/components/ste-loading/ste-loading.vue +166 -0
- package/components/ste-media-preview/README.md +243 -0
- package/components/ste-media-preview/TouchScaleing.js +102 -0
- package/components/ste-media-preview/ste-media-preview.vue +267 -0
- package/components/ste-message-box/README.md +217 -0
- package/components/ste-message-box/ste-message-box.js +72 -0
- package/components/ste-message-box/ste-message-box.vue +380 -0
- package/components/ste-notice-bar/README.md +129 -0
- package/components/ste-notice-bar/ste-notice-bar.vue +331 -0
- package/components/ste-number-keyboard/README.md +246 -0
- package/components/ste-number-keyboard/keyboard.vue +140 -0
- package/components/ste-number-keyboard/ste-number-keyboard.vue +240 -0
- package/components/ste-picker/ste-picker.vue +258 -0
- package/components/ste-popup/README.md +148 -0
- package/components/ste-popup/ste-popup.vue +337 -0
- package/components/ste-price/README.md +129 -0
- package/components/ste-price/ste-price.vue +258 -0
- package/components/ste-progress/README.md +87 -0
- package/components/ste-progress/ste-progress.vue +200 -0
- package/components/ste-qrcode/README.md +50 -0
- package/components/ste-qrcode/ste-qrcode.vue +164 -0
- package/components/ste-qrcode/uqrcode.js +34 -0
- package/components/ste-radio/README.md +286 -0
- package/components/ste-radio/ste-radio.vue +293 -0
- package/components/ste-radio-group/ste-radio-group.vue +128 -0
- package/components/ste-rate/README.md +115 -0
- package/components/ste-rate/ste-rate.vue +202 -0
- package/components/ste-read-more/README.md +111 -0
- package/components/ste-read-more/ste-read-more.vue +133 -0
- package/components/ste-rich-text/README.md +31 -0
- package/components/ste-rich-text/ste-rich-text.vue +70 -0
- package/components/ste-scroll-to/README.md +68 -0
- package/components/ste-scroll-to/mixin.js +173 -0
- package/components/ste-scroll-to/ste-scroll-to.vue +45 -0
- package/components/ste-scroll-to-item/ste-scroll-to-item.vue +25 -0
- package/components/ste-search/README.md +262 -0
- package/components/ste-search/ste-search.vue +547 -0
- package/components/ste-select/README.md +434 -0
- package/components/ste-select/datapager.vue +62 -0
- package/components/ste-select/datetime.vue +106 -0
- package/components/ste-select/defaultDate.js +142 -0
- package/components/ste-select/ste-select.vue +843 -0
- package/components/ste-signature/README.md +105 -0
- package/components/ste-signature/ste-signature.vue +220 -0
- package/components/ste-slider/README.md +165 -0
- package/components/ste-slider/ste-slider.vue +544 -0
- package/components/ste-step/ste-step.vue +264 -0
- package/components/ste-stepper/README.md +170 -0
- package/components/ste-stepper/ste-stepper.vue +373 -0
- package/components/ste-steps/README.md +132 -0
- package/components/ste-steps/ste-steps.vue +65 -0
- package/components/ste-sticky/README.md +52 -0
- package/components/ste-sticky/ste-sticky.vue +127 -0
- package/components/ste-swipe-action/README.md +197 -0
- package/components/ste-swipe-action/ste-swipe-action.vue +303 -0
- package/components/ste-swipe-action-group/ste-swipe-action-group.vue +104 -0
- package/components/ste-swiper/README.md +173 -0
- package/components/ste-swiper/ste-swiper.vue +462 -0
- package/components/ste-swiper-item/ste-swiper-item.vue +41 -0
- package/components/ste-switch/README.md +110 -0
- package/components/ste-switch/ste-switch.vue +144 -0
- package/components/ste-tab/ste-tab.vue +87 -0
- package/components/ste-table/README.md +785 -0
- package/components/ste-table/common.js +8 -0
- package/components/ste-table/ste-table.vue +666 -0
- package/components/ste-table/utils.js +20 -0
- package/components/ste-table-column/checkbox-icon.vue +65 -0
- package/components/ste-table-column/common.scss +65 -0
- package/components/ste-table-column/radio-icon.vue +110 -0
- package/components/ste-table-column/ste-table-column.vue +255 -0
- package/components/ste-table-column/sub-table.vue +116 -0
- package/components/ste-table-column/table-popover.vue +204 -0
- package/components/ste-table-column/var.scss +1 -0
- package/components/ste-tabs/README.md +475 -0
- package/components/ste-tabs/props.js +212 -0
- package/components/ste-tabs/ste-tabs.vue +758 -0
- package/components/ste-text/README.md +66 -0
- package/components/ste-text/ste-text.vue +72 -0
- package/components/ste-toast/README.md +243 -0
- package/components/ste-toast/ste-toast.js +69 -0
- package/components/ste-toast/ste-toast.vue +231 -0
- package/components/ste-touch-swipe/README.md +104 -0
- package/components/ste-touch-swipe/TouchEvent.js +72 -0
- package/components/ste-touch-swipe/ste-touch-swipe.vue +327 -0
- package/components/ste-touch-swipe-item/ste-touch-swipe-item.vue +33 -0
- package/components/ste-tour/README.md +194 -0
- package/components/ste-tour/ste-tour.vue +355 -0
- package/components/ste-tree/README.md +240 -0
- package/components/ste-tree/ste-tree.vue +350 -0
- package/components/ste-upload/README.md +276 -0
- package/components/ste-upload/ReadFile.js +229 -0
- package/components/ste-upload/ste-upload.vue +526 -0
- package/components/ste-video/README.md +60 -0
- package/components/ste-video/props.js +149 -0
- package/components/ste-video/ste-video.vue +647 -0
- package/config/color.js +22 -0
- package/index.js +2 -0
- package/package.json +19 -0
- package/utils/Color.js +66 -0
- package/utils/System.js +110 -0
- package/utils/dayjs.min.js +1 -0
- package/utils/mixin.js +67 -0
- package/utils/store.js +7 -0
- package/utils/utils.js +604 -0
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
# Checkbox 复选框
|
|
2
|
+
|
|
3
|
+
在一组备选项中进行多选。
|
|
4
|
+
|
|
5
|
+
---$
|
|
6
|
+
|
|
7
|
+
### 代码演示
|
|
8
|
+
JavaScript后面的演示代码中涉及到的变量和方法都使用本javasaript代码
|
|
9
|
+
```javascript
|
|
10
|
+
export default {
|
|
11
|
+
data() {
|
|
12
|
+
return {
|
|
13
|
+
value1: false,
|
|
14
|
+
value2: true,
|
|
15
|
+
value3: false,
|
|
16
|
+
value4: true,
|
|
17
|
+
value5: false,
|
|
18
|
+
value6: true,
|
|
19
|
+
value7: true,
|
|
20
|
+
value8: false,
|
|
21
|
+
value9: false,
|
|
22
|
+
value10: false,
|
|
23
|
+
value11: true,
|
|
24
|
+
value12: true,
|
|
25
|
+
value13: false,
|
|
26
|
+
value14: false,
|
|
27
|
+
value15: false,
|
|
28
|
+
value16: false,
|
|
29
|
+
value17: false,
|
|
30
|
+
value18: [],
|
|
31
|
+
value19: [],
|
|
32
|
+
value20: [],
|
|
33
|
+
value21: [],
|
|
34
|
+
value22: [],
|
|
35
|
+
};
|
|
36
|
+
},
|
|
37
|
+
created() {},
|
|
38
|
+
methods: {
|
|
39
|
+
click1(value) {
|
|
40
|
+
this.showToast({
|
|
41
|
+
icon: 'none',
|
|
42
|
+
title: `点击:${value} 复选框的值`,
|
|
43
|
+
});
|
|
44
|
+
},
|
|
45
|
+
click2(value, allowStop, resolve) {
|
|
46
|
+
this.showToast({
|
|
47
|
+
icon: 'none',
|
|
48
|
+
title: `点击:${value} 复选框的值`,
|
|
49
|
+
});
|
|
50
|
+
// 阻止change事件
|
|
51
|
+
allowStop();
|
|
52
|
+
},
|
|
53
|
+
change(value) {
|
|
54
|
+
setTimeout(() => {
|
|
55
|
+
this.showToast({
|
|
56
|
+
icon: 'none',
|
|
57
|
+
title: `改变:${value} 复选框的值`,
|
|
58
|
+
});
|
|
59
|
+
}, 1000);
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
#### 基础用法
|
|
66
|
+
通过`value`属性,双向绑定复选框的勾选状态,单一的checkbox中,默认绑定变量的值会是Boolean,选中为true
|
|
67
|
+
```
|
|
68
|
+
<ste-checkbox v-model="value">复选框</ste-checkbox>
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### 横向排列
|
|
72
|
+
将 `direction` 属性设置为 `row` 后,复选框组会变成横向排列。
|
|
73
|
+
```
|
|
74
|
+
<ste-checkbox-group v-model="value20" direction="row">
|
|
75
|
+
<ste-checkbox name="a">复选框a</ste-checkbox>
|
|
76
|
+
<ste-checkbox name="b">复选框b</ste-checkbox>
|
|
77
|
+
<ste-checkbox name="c">复选框c</ste-checkbox>
|
|
78
|
+
</ste-checkbox-group>
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
#### 禁用
|
|
82
|
+
通过设置 `disabled` 属性可以禁用复选框, 默认`false`。
|
|
83
|
+
```
|
|
84
|
+
<ste-checkbox v-model="value2" disabled>复选框1</ste-checkbox>
|
|
85
|
+
<ste-checkbox v-model="value3" disabled>复选框2</ste-checkbox>
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
#### 只读
|
|
89
|
+
通过设置 `readonly` 属性可以禁用复选框,样式不置灰, 默认`false`。
|
|
90
|
+
```
|
|
91
|
+
<ste-checkbox v-model="value4" readonly>复选框1</ste-checkbox>
|
|
92
|
+
<ste-checkbox v-model="value5" readonly>复选框2</ste-checkbox>
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
#### 自定义形状
|
|
96
|
+
通过设置`shape`为`square`或者`circle`,将复选框设置为方形或者圆形,默认`circle`。
|
|
97
|
+
```
|
|
98
|
+
<ste-checkbox v-model="value6">圆形</ste-checkbox>
|
|
99
|
+
<ste-checkbox v-model="value7" shape="square">方形</ste-checkbox>
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
#### 自定义图标大小
|
|
103
|
+
通过设置 `iconSize` 属性可以自定义图标的大小,单位`rpx`,默认`36`。
|
|
104
|
+
```
|
|
105
|
+
<ste-checkbox v-model="value11" iconSize="60">60rpx</ste-checkbox>
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
#### 自定义图标颜色
|
|
109
|
+
通过设置 `checkedColor` 属性可以自定义图标的颜色(填充色和边框色),默认`#0090FF`。
|
|
110
|
+
```
|
|
111
|
+
<ste-checkbox v-model="value12" checkedColor="#ee0a24">红色</ste-checkbox>
|
|
112
|
+
```
|
|
113
|
+
#### 自定义图标
|
|
114
|
+
通过 `icon` 插槽自定义图标,可以通过 `slotProps`下`checked`判断是否为选中状态,`disabled`判断是否为禁止状态,`readonly`判断是否为只读状态。
|
|
115
|
+
```
|
|
116
|
+
<ste-checkbox-group v-model="value13">
|
|
117
|
+
<ste-checkbox name="a">
|
|
118
|
+
<template #icon="{ slotProps }">
|
|
119
|
+
<ste-icon
|
|
120
|
+
code=""
|
|
121
|
+
size="50"
|
|
122
|
+
:color="slotProps.checked ? '#ee0a24' : '#000000'"
|
|
123
|
+
></ste-icon>
|
|
124
|
+
</template>
|
|
125
|
+
<template #default="{ slotProps }">
|
|
126
|
+
{{ slotProps.checked ? '已选中' : '未选中' }}
|
|
127
|
+
</template>
|
|
128
|
+
</ste-checkbox>
|
|
129
|
+
<ste-checkbox name="b">
|
|
130
|
+
<template #icon="{ slotProps }">
|
|
131
|
+
<ste-icon
|
|
132
|
+
code=""
|
|
133
|
+
size="50"
|
|
134
|
+
:color="slotProps.checked ? '#ee0a24' : '#000000'"
|
|
135
|
+
></ste-icon>
|
|
136
|
+
</template>
|
|
137
|
+
<template #default="{ slotProps }">
|
|
138
|
+
{{ slotProps.checked ? '已选中' : '未选中' }}
|
|
139
|
+
</template>
|
|
140
|
+
</ste-checkbox>
|
|
141
|
+
<ste-checkbox name="c" disabled>
|
|
142
|
+
<template #icon="{ slotProps }">
|
|
143
|
+
<ste-icon
|
|
144
|
+
code=""
|
|
145
|
+
size="50"
|
|
146
|
+
:color="slotProps.disabled ? '#eeeeee' : '#000000'"
|
|
147
|
+
></ste-icon>
|
|
148
|
+
</template>
|
|
149
|
+
<template #default="{ slotProps }">
|
|
150
|
+
{{ slotProps.disabled ? '禁止' : '未禁止' }}
|
|
151
|
+
</template>
|
|
152
|
+
</ste-checkbox>
|
|
153
|
+
<ste-checkbox name="d" readonly>
|
|
154
|
+
<template #icon="{ slotProps }">
|
|
155
|
+
<ste-icon
|
|
156
|
+
code=""
|
|
157
|
+
size="50"
|
|
158
|
+
:color="slotProps.readonly ? 'green' : '#000000'"
|
|
159
|
+
></ste-icon>
|
|
160
|
+
</template>
|
|
161
|
+
<template #default="{ slotProps }">
|
|
162
|
+
{{ slotProps.readonly ? '只读' : '未只读' }}
|
|
163
|
+
</template>
|
|
164
|
+
</ste-checkbox>
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
#### 左侧文本
|
|
168
|
+
将 `textPosition` 属性设置为 `left`,可以将文本位置调整到复选框左侧。
|
|
169
|
+
```
|
|
170
|
+
<ste-checkbox v-model="value6">右边</ste-checkbox>
|
|
171
|
+
<ste-checkbox v-model="value7" textPosition="left">左边</ste-checkbox>
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
#### 自定义文本
|
|
175
|
+
- 通过设置 `textSize` 属性可以自定义文本的大小,单位`rpx`,默认`28`。
|
|
176
|
+
- 通过设置 `textInactiveColor` 属性可以自定义文本未选中颜色,默认`#000000`。
|
|
177
|
+
- 通过设置 `textActiveColor` 属性可以自定义文本选中颜色,默认`#000000`。
|
|
178
|
+
```
|
|
179
|
+
<ste-checkbox v-model="value14" textSize="50" textInactiveColor="green" textActiveColor="#d276a3">
|
|
180
|
+
复选框
|
|
181
|
+
</ste-checkbox>
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
#### 回调事件
|
|
185
|
+
- `click` 点击复选框时触发的事件(可拦截change事件),`value`:改变后的分值,`allowStop`:允许阻止后续的事件触发,:`resolve`:后续的事件执行。
|
|
186
|
+
- `change` 当绑定值变化时触发的事件,`value`:改变后的分值。
|
|
187
|
+
```
|
|
188
|
+
<ste-checkbox v-model="value16" @click="click1" @change="change">复选框</ste-checkbox>
|
|
189
|
+
<text>在click事件后,执行change事件</text>
|
|
190
|
+
<ste-checkbox v-model="value17" @click="click2" @change="change">复选框</ste-checkbox>
|
|
191
|
+
<text>在click事件后,阻止change事件</text>
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
### 复选框组
|
|
195
|
+
需要与`ste-checkbox-group`一起使用,选中值是一个数组,通过`value`绑定在`ste-checkbox-group`上,数组中的项即为选中的`ste-checkbox`的`name`属性设置的值。
|
|
196
|
+
```
|
|
197
|
+
<ste-checkbox-group v-model="value18">
|
|
198
|
+
<ste-checkbox name="a">复选框a</ste-checkbox>
|
|
199
|
+
<ste-checkbox name="b">复选框b</ste-checkbox>
|
|
200
|
+
<ste-checkbox name="c">复选框c</ste-checkbox>
|
|
201
|
+
</ste-checkbox-group>
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
### 复选框组属性和复选框属性
|
|
205
|
+
属性优先级:`ste-checkbox`组件上配置的属性 > `ste-checkbox-group`组件上配置的属性 > `ste-checkbox`组件默认属性
|
|
206
|
+
```
|
|
207
|
+
<ste-checkbox-group v-model="value19" shape="square" textPosition="left">
|
|
208
|
+
<ste-checkbox name="a">复选框a</ste-checkbox>
|
|
209
|
+
<ste-checkbox name="b" disabled>复选框b</ste-checkbox>
|
|
210
|
+
<ste-checkbox name="c" shape="circle">复选框c</ste-checkbox>
|
|
211
|
+
</ste-checkbox-group>
|
|
212
|
+
```
|
|
213
|
+
### 水平排列
|
|
214
|
+
将 `direction` 属性设置为 `row` 后,复选框组会变成水平排列。
|
|
215
|
+
```
|
|
216
|
+
<ste-checkbox-group v-model="value20" direction="row">
|
|
217
|
+
<ste-checkbox name="a">复选框a</ste-checkbox>
|
|
218
|
+
<ste-checkbox name="b">复选框b</ste-checkbox>
|
|
219
|
+
<ste-checkbox name="c">复选框c</ste-checkbox>
|
|
220
|
+
</ste-checkbox-group>
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
### 限制最大可选数
|
|
224
|
+
通过 `max` 属性可以限制复选框组的最大可选数,为`0`则不限制,默认0。
|
|
225
|
+
```
|
|
226
|
+
<ste-checkbox-group v-model="value21" :max="2">
|
|
227
|
+
<ste-checkbox name="a">复选框a</ste-checkbox>
|
|
228
|
+
<ste-checkbox name="b">复选框b</ste-checkbox>
|
|
229
|
+
<ste-checkbox name="c">复选框c</ste-checkbox>
|
|
230
|
+
</ste-checkbox-group>
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
---$
|
|
234
|
+
### API
|
|
235
|
+
#### Checkbox组件属性(Props)
|
|
236
|
+
|
|
237
|
+
| 参数 | 说明 | 类型 | 默认值 | 可选值 | 支持版本 |
|
|
238
|
+
| --- | --- | --- | --- | --- | --- |
|
|
239
|
+
| `value` | 当前选中值(支持v-model双向绑定) | `Boolean` | `false` | - | - |
|
|
240
|
+
| `name` | 选项的值 | `Number/String` | - | - | - |
|
|
241
|
+
| `disabled` | 是否禁用 | `Boolean` | `false` | - | - |
|
|
242
|
+
| `readonly` | 只读 (不置灰) | `Boolean` | `false` | - | - |
|
|
243
|
+
| `shape` | 形状 | `String` | `circle` | `circle`:圆形 <br/>`squar`:方形 | - |
|
|
244
|
+
| `iconSize` | 图标大小,单位rpx | `Number/String` | `36` | - | - |
|
|
245
|
+
| `checkedColor` | 选中状态的图标颜色 | `String` | `#0090FF` | - | - |
|
|
246
|
+
| `textPosition` | 文本的位置 | `String` | `right` | `right`:右 <br/>`left`:左 | - |
|
|
247
|
+
| `textSize` | 文本字体大小,单位rpx | `Number/String` | `25` | - | - |
|
|
248
|
+
| `textlnactiveColor` | 未选中文本颜色 | `String` | `#000000` | - | - |
|
|
249
|
+
| `textActiveColor` | 选中文本颜色 | `String` | `#000000` | - | - |
|
|
250
|
+
| `textDisabled` | 禁用文本点击 | `Boolean` | `false` | - | - |
|
|
251
|
+
| `marginLeft` | 左边距,单位rpx | `Number/String` | `0` | - | `v1.10.0` |
|
|
252
|
+
| `marginRight` | 右边距,单位rpx | `Number/String` | `0` | - | `v1.10.0` |
|
|
253
|
+
| `columnGap` | 复选框和文本间距,单位rpx | `Number/String` | `16` | - | `v1.10.0` |
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
#### CheckboxGroup 组件属性(Props)
|
|
258
|
+
|
|
259
|
+
| 参数 | 说明 | 类型 | 默认值 | 可选值 | 支持版本 |
|
|
260
|
+
| --- | --- | --- | --- | --- | --- |
|
|
261
|
+
| `value` |当前选中值(支持v-model双向绑定) | `Array` | - | - | - |
|
|
262
|
+
| `direction` | 排列方式 | `String` | `row` | `column`:横向 <br/>`row`:纵向 | - |
|
|
263
|
+
| `disabled` | 是否禁用 | `Boolean` | `false` | - | - |
|
|
264
|
+
| `readonly` | 只读 (不置灰) | `Boolean` | `false` | - | - |
|
|
265
|
+
| `shape` | 形状 | `String` | `circle` | `circle`:圆形 <br/>`squar`:方形 | - |
|
|
266
|
+
| `iconSize` | 图标大小,单位rpx | `Number/String` | `36` | - | - |
|
|
267
|
+
| `checkedColor` | 选中状态的图标颜色 | `String` | `#0090FF` | - | - |
|
|
268
|
+
| `textPosition` | 文本的位置 | `String` | `right` | `right`:右 <br/>`left`:左 | - |
|
|
269
|
+
| `textSize` | 文本字体大小,单位rpx | `Number/String` | `25` | - | - |
|
|
270
|
+
| `textlnactiveColor` | 未选中文本颜色 | `String` | `#000000` | - | - |
|
|
271
|
+
| `textActiveColor` | 选中文本颜色 | `String` | `#000000` | - | - |
|
|
272
|
+
| `textDisabled` | 禁用文本点击 | `Boolean` | `false` | - | - |
|
|
273
|
+
| `max` | 最大可选数,0 为无限制 | `Number` | `0` | - | - |
|
|
274
|
+
| `marginLeft` | 左边距,单位rpx | `Number/String` | `0` | - | `v1.10.0` |
|
|
275
|
+
| `marginRight` | 右边距,单位rpx | `Number/String` | `0` | - | `v1.10.0` |
|
|
276
|
+
| `columnGap` | 复选框和文本间距,单位rpx | `Number/String` | `16` | - | `v1.10.0` |
|
|
277
|
+
|
|
278
|
+
#### Checkbox Events
|
|
279
|
+
|事件名 |说明 |事件参数 |支持版本 |
|
|
280
|
+
|--- |--- |--- |--- |
|
|
281
|
+
| `click` |点击复选框时触发的事件(可拦截change事件) |`value`:当前的绑定值,`allowStop`:允许阻止后续的事件触发,:`resolve`:后续的事件执行 | - |
|
|
282
|
+
| `change` |当绑定值变化时触发的事件 |`value`:改变后的绑定值 | - |
|
|
283
|
+
|
|
284
|
+
#### CheckboxGroup Events
|
|
285
|
+
|事件名 |说明 |事件参数 |支持版本 |
|
|
286
|
+
|--- |--- |--- |--- |
|
|
287
|
+
| `change` |当绑定值变化时触发的事件 |`value`:改变后的绑定值 | - |
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
#### Checkbox Slots
|
|
291
|
+
|插槽名 |说明 |插槽参数 |支持版本 |
|
|
292
|
+
| --- | --- | --- | --- |
|
|
293
|
+
| `default` | 复选框文本内容 |`{ checked: boolean, disabled: boolean, readonly: boolean }` | - |
|
|
294
|
+
| `icon` | 复选框图标 |`{ checked: boolean, disabled: boolean, readonly: boolean }` | - |
|
|
295
|
+
|
|
296
|
+
---$
|
|
297
|
+
{{qinpengfei}}
|
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="ste-checkbox--root" :style="[cmpStyle]" @click="click">
|
|
3
|
+
<view class="icon">
|
|
4
|
+
<slot name="icon" :slotProps="cmpSlotProps">
|
|
5
|
+
<view class="input-icon" :style="[cmpInputStyle]">
|
|
6
|
+
<ste-icon
|
|
7
|
+
v-if="cmpChecked && cmpIconSize"
|
|
8
|
+
:size="cmpIconSize * 0.8"
|
|
9
|
+
code=""
|
|
10
|
+
:color="cmpDisabled ? '#bbbbbb' : '#fff'"
|
|
11
|
+
bold
|
|
12
|
+
></ste-icon>
|
|
13
|
+
</view>
|
|
14
|
+
</slot>
|
|
15
|
+
</view>
|
|
16
|
+
<view class="text">
|
|
17
|
+
<slot :slotProps="cmpSlotProps"></slot>
|
|
18
|
+
</view>
|
|
19
|
+
</view>
|
|
20
|
+
</template>
|
|
21
|
+
|
|
22
|
+
<script>
|
|
23
|
+
import utils from '../../utils/utils.js';
|
|
24
|
+
import useColor from '../../config/color.js';
|
|
25
|
+
let color = useColor();
|
|
26
|
+
/**
|
|
27
|
+
* ste-checkbox 复选框
|
|
28
|
+
* @description 复选框组件,在一组备选项中进行多选。
|
|
29
|
+
* @tutorial https://stellar-ui.intecloud.com.cn/pc/index/index?name=ste-checkbox
|
|
30
|
+
* @property {Boolean} value 当前选中值(支持v-model双向绑定) 默认 false
|
|
31
|
+
* @property {Number|String} name 选项的值
|
|
32
|
+
* @property {Boolean} disabled 禁用 默认 false
|
|
33
|
+
* @property {Boolean} readonly 只读(不置灰) 默认 false
|
|
34
|
+
* @property {String} shape 形状 默认 circle
|
|
35
|
+
* @value circle 圆形 默认 {{String}}
|
|
36
|
+
* @value square 方形 {{String}}
|
|
37
|
+
* @property {Number|String} iconSize 图标大小,单位rpx 默认 36
|
|
38
|
+
* @property {String} checkedColor 选中状态的图标颜色 默认 ##0090FF
|
|
39
|
+
* @property {String} textPosition 文本的位置 默认 right
|
|
40
|
+
* @value right 右 默认 {{String}}
|
|
41
|
+
* @value left 左 {{String}}
|
|
42
|
+
* @property {Number|String} textSize 文本字体大小,单位rpx 默认 28
|
|
43
|
+
* @property {String} textInactiveColor 未选中的文本颜色 默认 #000000
|
|
44
|
+
* @property {String} textActiveColor 选中的文本颜色 默认 #000000
|
|
45
|
+
* @property {Boolean} textDisabled 禁用文本点击 默认 false
|
|
46
|
+
* @property {Number|String} marginLeft 左边距,单位rpx 默认 0
|
|
47
|
+
* @property {Number|String} marginRight 右边距,单位rpx 默认 0
|
|
48
|
+
* @property {Number|String} columnGap 复选框和文本间距,单位rpx 默认 16
|
|
49
|
+
* @event {Function} click 点击复选框时触发的事件
|
|
50
|
+
* @event {Function} change 当绑定值变化时触发的事件
|
|
51
|
+
*/
|
|
52
|
+
export default {
|
|
53
|
+
group: '表单组件',
|
|
54
|
+
title: 'Checkbox 复选框',
|
|
55
|
+
name: 'ste-checkbox',
|
|
56
|
+
props: {
|
|
57
|
+
value: {
|
|
58
|
+
type: [Boolean, null],
|
|
59
|
+
default: false,
|
|
60
|
+
},
|
|
61
|
+
name: {
|
|
62
|
+
type: [Number, String, null],
|
|
63
|
+
default: '',
|
|
64
|
+
},
|
|
65
|
+
disabled: {
|
|
66
|
+
type: [Boolean, null],
|
|
67
|
+
default: null,
|
|
68
|
+
},
|
|
69
|
+
readonly: {
|
|
70
|
+
type: [Boolean, null],
|
|
71
|
+
default: null,
|
|
72
|
+
},
|
|
73
|
+
shape: {
|
|
74
|
+
type: [String, null],
|
|
75
|
+
default: null,
|
|
76
|
+
},
|
|
77
|
+
iconSize: {
|
|
78
|
+
type: [Number, String, null],
|
|
79
|
+
default: null,
|
|
80
|
+
},
|
|
81
|
+
checkedColor: {
|
|
82
|
+
type: [String, null],
|
|
83
|
+
default: null,
|
|
84
|
+
},
|
|
85
|
+
textPosition: {
|
|
86
|
+
type: [String, null],
|
|
87
|
+
default: null,
|
|
88
|
+
},
|
|
89
|
+
textSize: {
|
|
90
|
+
type: [Number, String, null],
|
|
91
|
+
default: null,
|
|
92
|
+
},
|
|
93
|
+
textInactiveColor: {
|
|
94
|
+
type: [String, null],
|
|
95
|
+
default: null,
|
|
96
|
+
},
|
|
97
|
+
textActiveColor: {
|
|
98
|
+
type: [String, null],
|
|
99
|
+
default: null,
|
|
100
|
+
},
|
|
101
|
+
textDisabled: {
|
|
102
|
+
type: [Boolean, null],
|
|
103
|
+
default: null,
|
|
104
|
+
},
|
|
105
|
+
marginLeft: {
|
|
106
|
+
type: [Number, String, null],
|
|
107
|
+
default: null,
|
|
108
|
+
},
|
|
109
|
+
marginRight: {
|
|
110
|
+
type: [Number, String, null],
|
|
111
|
+
default: null,
|
|
112
|
+
},
|
|
113
|
+
columnGap: {
|
|
114
|
+
type: [Number, String, null],
|
|
115
|
+
default: null,
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
model: {
|
|
119
|
+
prop: 'value',
|
|
120
|
+
// 派发事件名,更新父组件数据
|
|
121
|
+
event: 'input',
|
|
122
|
+
},
|
|
123
|
+
inject: {
|
|
124
|
+
checkboxGroup: {
|
|
125
|
+
default: '',
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
data() {
|
|
129
|
+
return {
|
|
130
|
+
clickTask: null, // click完成任务和allowStopStatus搭配使用
|
|
131
|
+
allowStopStatus: false, // 允许阻止后续的事件触发
|
|
132
|
+
num: 1, // 解决支付宝小程序checkboxGroup.value更新不触发计算属性的问题
|
|
133
|
+
};
|
|
134
|
+
},
|
|
135
|
+
computed: {
|
|
136
|
+
cmpDisabled() {
|
|
137
|
+
let disabled = this.getDefaultData('disabled', false);
|
|
138
|
+
// 限制最大可选数
|
|
139
|
+
if (this.cmpGroup && this.checkboxGroup.max) {
|
|
140
|
+
if (!this.cmpChecked && this.checkboxGroup.value.length >= this.checkboxGroup.max) {
|
|
141
|
+
disabled = true;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
return disabled;
|
|
145
|
+
},
|
|
146
|
+
cmpReadonly() {
|
|
147
|
+
return this.getDefaultData('readonly', false);
|
|
148
|
+
},
|
|
149
|
+
cmpShape() {
|
|
150
|
+
return this.getDefaultData('shape', 'circle');
|
|
151
|
+
},
|
|
152
|
+
cmpIconSize() {
|
|
153
|
+
return this.getDefaultData('iconSize', 36);
|
|
154
|
+
},
|
|
155
|
+
cmpCheckedColor() {
|
|
156
|
+
return this.getDefaultData('checkedColor', color.getColor().steThemeColor);
|
|
157
|
+
},
|
|
158
|
+
cmpTextPosition() {
|
|
159
|
+
return this.getDefaultData('textPosition', 'right');
|
|
160
|
+
},
|
|
161
|
+
cmpTextSize() {
|
|
162
|
+
return this.getDefaultData('textSize', 28);
|
|
163
|
+
},
|
|
164
|
+
cmpTextInactiveColor() {
|
|
165
|
+
return this.getDefaultData('textInactiveColor', '#000000');
|
|
166
|
+
},
|
|
167
|
+
cmpTextActiveColor() {
|
|
168
|
+
return this.getDefaultData('textActiveColor', '#000000');
|
|
169
|
+
},
|
|
170
|
+
cmpTextDisabled() {
|
|
171
|
+
return this.getDefaultData('textDisabled', false);
|
|
172
|
+
},
|
|
173
|
+
cmpMarginLeft() {
|
|
174
|
+
return this.getDefaultData('marginLeft', '0');
|
|
175
|
+
},
|
|
176
|
+
cmpMarginRight() {
|
|
177
|
+
return this.getDefaultData('marginRight', '0');
|
|
178
|
+
},
|
|
179
|
+
cmpColumnGap() {
|
|
180
|
+
return this.getDefaultData('columnGap', '16');
|
|
181
|
+
},
|
|
182
|
+
cmpSlotProps() {
|
|
183
|
+
return {
|
|
184
|
+
checked: this.cmpChecked,
|
|
185
|
+
disabled: this.cmpDisabled,
|
|
186
|
+
readonly: this.cmpReadonly,
|
|
187
|
+
};
|
|
188
|
+
},
|
|
189
|
+
cmpStyle() {
|
|
190
|
+
let style = {};
|
|
191
|
+
style['fontSize'] = utils.formatPx(this.cmpTextSize);
|
|
192
|
+
style['color'] = this.cmpChecked ? this.cmpTextActiveColor : this.cmpTextInactiveColor;
|
|
193
|
+
style['flexDirection'] = this.cmpTextPosition == 'right' ? 'row' : 'row-reverse';
|
|
194
|
+
style['columnGap'] = utils.formatPx(this.cmpColumnGap);
|
|
195
|
+
style['marginLeft'] = utils.formatPx(this.cmpMarginLeft);
|
|
196
|
+
style['marginRight'] = utils.formatPx(this.cmpMarginRight);
|
|
197
|
+
// #ifdef H5
|
|
198
|
+
if (this.cmpDisabled || this.cmpReadonly) {
|
|
199
|
+
style['cursor'] = 'not-allowed';
|
|
200
|
+
} else if (this.cmpTextDisabled) {
|
|
201
|
+
style['cursor'] = 'default';
|
|
202
|
+
} else {
|
|
203
|
+
style['cursor'] = 'pointer';
|
|
204
|
+
}
|
|
205
|
+
// #endif
|
|
206
|
+
if (this.cmpTextDisabled) {
|
|
207
|
+
style['pointerEvents'] = 'none';
|
|
208
|
+
}
|
|
209
|
+
return style;
|
|
210
|
+
},
|
|
211
|
+
cmpInputStyle() {
|
|
212
|
+
let style = {};
|
|
213
|
+
// 没有icon 则默认样式
|
|
214
|
+
style['borderRadius'] = this.cmpShape == 'circle' ? '50%' : '0';
|
|
215
|
+
style['border'] = `${utils.formatPx(2)} solid ${this.cmpChecked ? this.cmpCheckedColor : '#BBBBBB'}`;
|
|
216
|
+
style['background'] = this.cmpChecked ? this.cmpCheckedColor : '#FFFFFF';
|
|
217
|
+
style['width'] = utils.formatPx(this.cmpIconSize);
|
|
218
|
+
style['height'] = utils.formatPx(this.cmpIconSize);
|
|
219
|
+
style['lineHeight'] = utils.formatPx(this.cmpIconSize);
|
|
220
|
+
// #ifdef H5
|
|
221
|
+
if (this.cmpDisabled || this.cmpReadonly) {
|
|
222
|
+
style['cursor'] = 'not-allowed';
|
|
223
|
+
} else {
|
|
224
|
+
style['cursor'] = 'pointer';
|
|
225
|
+
}
|
|
226
|
+
// #endif
|
|
227
|
+
if (this.cmpDisabled) {
|
|
228
|
+
style['background'] = '#eeeeee';
|
|
229
|
+
style['borderColor'] = '#bbbbbb';
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
// 在没有使用插槽内容时去掉边距
|
|
233
|
+
if (!this.$slots.default) {
|
|
234
|
+
style['columnGap'] = 0;
|
|
235
|
+
}
|
|
236
|
+
return style;
|
|
237
|
+
},
|
|
238
|
+
// 选中状态
|
|
239
|
+
cmpChecked() {
|
|
240
|
+
return this.num && this.cmpGroup ? this.checkboxGroup.value.includes(this.name) : this.value;
|
|
241
|
+
},
|
|
242
|
+
cmpGroup() {
|
|
243
|
+
return !!this.checkboxGroup;
|
|
244
|
+
},
|
|
245
|
+
},
|
|
246
|
+
methods: {
|
|
247
|
+
async click() {
|
|
248
|
+
if (!this.cmpDisabled && !this.cmpReadonly) {
|
|
249
|
+
this.allowStopStatus = false;
|
|
250
|
+
this.clickTask = new Promise((resolve) => {
|
|
251
|
+
this.$emit('click', this.value, this.allowStop, resolve);
|
|
252
|
+
});
|
|
253
|
+
if (this.allowStopStatus) {
|
|
254
|
+
await this.clickTask;
|
|
255
|
+
}
|
|
256
|
+
let value = null;
|
|
257
|
+
if (this.cmpGroup) {
|
|
258
|
+
value = this.checkboxGroup.value;
|
|
259
|
+
if (this.cmpChecked) {
|
|
260
|
+
value = value.filter((value) => value != this.name);
|
|
261
|
+
} else {
|
|
262
|
+
value.push(this.name);
|
|
263
|
+
}
|
|
264
|
+
this.checkboxGroup.$emit('input', value);
|
|
265
|
+
this.checkboxGroup.$emit('change', value);
|
|
266
|
+
this.num++;
|
|
267
|
+
} else {
|
|
268
|
+
value = !this.cmpChecked;
|
|
269
|
+
this.$emit('input', !this.cmpChecked);
|
|
270
|
+
}
|
|
271
|
+
this.$emit('change', value);
|
|
272
|
+
}
|
|
273
|
+
},
|
|
274
|
+
// 允许阻止后续操作
|
|
275
|
+
allowStop() {
|
|
276
|
+
this.allowStopStatus = true;
|
|
277
|
+
},
|
|
278
|
+
getDefaultData(key, value) {
|
|
279
|
+
return this[key] != null ? this[key] : this.checkboxGroup[key] ? this.checkboxGroup[key] : value;
|
|
280
|
+
},
|
|
281
|
+
},
|
|
282
|
+
};
|
|
283
|
+
</script>
|
|
284
|
+
|
|
285
|
+
<style lang="scss" scoped>
|
|
286
|
+
.ste-checkbox--root {
|
|
287
|
+
width: auto;
|
|
288
|
+
height: 100%;
|
|
289
|
+
display: flex;
|
|
290
|
+
align-items: center;
|
|
291
|
+
.input-icon {
|
|
292
|
+
display: flex;
|
|
293
|
+
justify-content: center;
|
|
294
|
+
align-items: flex-end;
|
|
295
|
+
}
|
|
296
|
+
.icon {
|
|
297
|
+
pointer-events: all;
|
|
298
|
+
}
|
|
299
|
+
.text {
|
|
300
|
+
display: flex;
|
|
301
|
+
align-items: center;
|
|
302
|
+
height: 100%;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
</style>
|