uview-pro 0.2.4 → 0.3.1
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/changelog.md +584 -545
- package/components/common/props.ts +22 -22
- package/components/u-action-sheet/types.ts +37 -35
- package/components/u-action-sheet/u-action-sheet.vue +178 -167
- package/components/u-alert-tips/types.ts +41 -39
- package/components/u-alert-tips/u-alert-tips.vue +238 -223
- package/components/u-avatar/types.ts +36 -34
- package/components/u-avatar/u-avatar.vue +217 -207
- package/components/u-avatar-cropper/types.ts +23 -23
- package/components/u-avatar-cropper/u-avatar-cropper.vue +297 -286
- package/components/u-avatar-cropper/weCropper.d.ts +62 -62
- package/components/u-avatar-cropper/weCropper.js +1281 -1281
- package/components/u-avatar-cropper/weCropper.ts +1276 -1276
- package/components/u-back-top/types.ts +36 -39
- package/components/u-back-top/u-back-top.vue +140 -128
- package/components/u-badge/types.ts +38 -36
- package/components/u-badge/u-badge.vue +183 -165
- package/components/u-button/types.ts +66 -66
- package/components/u-button/u-button.vue +579 -566
- package/components/u-calendar/types.ts +75 -75
- package/components/u-calendar/u-calendar.vue +793 -793
- package/components/u-car-keyboard/types.ts +14 -12
- package/components/u-car-keyboard/u-car-keyboard.vue +262 -253
- package/components/u-card/types.ts +61 -59
- package/components/u-card/u-card.vue +209 -194
- package/components/u-cell-group/types.ts +19 -17
- package/components/u-cell-group/u-cell-group.vue +60 -50
- package/components/u-cell-item/types.ts +56 -54
- package/components/u-cell-item/u-cell-item.vue +226 -213
- package/components/u-checkbox/types.ts +33 -31
- package/components/u-checkbox/u-checkbox.vue +282 -283
- package/components/u-checkbox-group/types.ts +34 -32
- package/components/u-checkbox-group/u-checkbox-group.vue +130 -130
- package/components/u-circle-progress/types.ts +54 -52
- package/components/u-circle-progress/u-circle-progress.vue +206 -191
- package/components/u-city-select/types.ts +22 -20
- package/components/u-city-select/u-city-select.vue +276 -264
- package/components/u-col/types.ts +32 -30
- package/components/u-col/u-col.vue +142 -123
- package/components/u-collapse/types.ts +33 -33
- package/components/u-collapse/u-collapse.vue +190 -186
- package/components/u-collapse-item/types.ts +27 -27
- package/components/u-collapse-item/u-collapse-item.vue +290 -285
- package/components/u-column-notice/types.ts +50 -48
- package/components/u-column-notice/u-column-notice.vue +222 -210
- package/components/u-count-down/types.ts +44 -42
- package/components/u-count-down/u-count-down.vue +286 -274
- package/components/u-count-to/types.ts +34 -32
- package/components/u-count-to/u-count-to.vue +266 -248
- package/components/u-divider/types.ts +33 -31
- package/components/u-divider/u-divider.vue +145 -129
- package/components/u-dropdown/types.ts +34 -32
- package/components/u-dropdown/u-dropdown.vue +330 -302
- package/components/u-dropdown-item/types.ts +29 -27
- package/components/u-dropdown-item/u-dropdown-item.vue +120 -128
- package/components/u-empty/types.ts +38 -36
- package/components/u-empty/u-empty.vue +103 -88
- package/components/u-field/types.ts +71 -69
- package/components/u-field/u-field.vue +388 -373
- package/components/u-form/types.ts +29 -27
- package/components/u-form/u-form.vue +130 -136
- package/components/u-form-item/types.ts +72 -70
- package/components/u-form-item/u-form-item.vue +447 -447
- package/components/u-full-screen/types.ts +16 -14
- package/components/u-full-screen/u-full-screen.vue +103 -89
- package/components/u-gap/types.ts +20 -18
- package/components/u-gap/u-gap.vue +50 -40
- package/components/u-grid/types.ts +21 -19
- package/components/u-grid/u-grid.vue +91 -93
- package/components/u-grid-item/types.ts +16 -16
- package/components/u-grid-item/u-grid-item.vue +130 -134
- package/components/u-icon/types.ts +61 -62
- package/components/u-icon/u-icon.vue +296 -294
- package/components/u-image/types.ts +51 -51
- package/components/u-image/u-image.vue +239 -230
- package/components/u-index-anchor/types.ts +16 -16
- package/components/u-index-anchor/u-index-anchor.vue +94 -86
- package/components/u-index-list/types.ts +43 -43
- package/components/u-index-list/u-index-list.vue +352 -355
- package/components/u-input/types.ts +137 -140
- package/components/u-input/u-input.vue +288 -279
- package/components/u-keyboard/types.ts +40 -40
- package/components/u-keyboard/u-keyboard.vue +178 -169
- package/components/u-lazy-load/types.ts +37 -37
- package/components/u-lazy-load/u-lazy-load.vue +246 -235
- package/components/u-line/types.ts +44 -44
- package/components/u-line/u-line.vue +68 -59
- package/components/u-line-progress/types.ts +58 -58
- package/components/u-line-progress/u-line-progress.vue +126 -117
- package/components/u-link/types.ts +43 -43
- package/components/u-link/u-link.vue +84 -75
- package/components/u-loading/types.ts +35 -35
- package/components/u-loading/u-loading.vue +105 -96
- package/components/u-loading-popup/types.ts +26 -26
- package/components/u-loading-popup/u-loading-popup.vue +253 -239
- package/components/u-loadmore/types.ts +79 -79
- package/components/u-loadmore/u-loadmore.vue +156 -145
- package/components/u-mask/types.ts +40 -43
- package/components/u-mask/u-mask.vue +113 -106
- package/components/u-message-input/types.ts +74 -74
- package/components/u-message-input/u-message-input.vue +281 -270
- package/components/u-modal/types.ts +118 -118
- package/components/u-modal/u-modal.vue +220 -211
- package/components/u-navbar/types.ts +103 -103
- package/components/u-navbar/u-navbar.vue +251 -240
- package/components/u-no-network/image.ts +2 -2
- package/components/u-no-network/types.ts +28 -28
- package/components/u-no-network/u-no-network.vue +303 -292
- package/components/u-notice-bar/types.ts +111 -111
- package/components/u-notice-bar/u-notice-bar.vue +189 -179
- package/components/u-number-box/types.ts +42 -42
- package/components/u-number-box/u-number-box.vue +321 -312
- package/components/u-number-keyboard/types.ts +26 -26
- package/components/u-number-keyboard/u-number-keyboard.vue +188 -179
- package/components/u-picker/types.ts +123 -123
- package/components/u-picker/u-picker.vue +685 -676
- package/components/u-popup/types.ts +59 -59
- package/components/u-popup/u-popup.vue +385 -375
- package/components/u-radio/types.ts +27 -25
- package/components/u-radio/u-radio.vue +279 -272
- package/components/u-radio-group/types.ts +31 -29
- package/components/u-radio-group/u-radio-group.vue +96 -108
- package/components/u-rate/types.ts +42 -40
- package/components/u-rate/u-rate.vue +249 -234
- package/components/u-read-more/types.ts +37 -35
- package/components/u-read-more/u-read-more.vue +172 -156
- package/components/u-root-portal/u-root-portal.vue +56 -54
- package/components/u-row/types.ts +22 -20
- package/components/u-row/u-row.vue +105 -87
- package/components/u-row-notice/types.ts +41 -39
- package/components/u-row-notice/u-row-notice.vue +256 -244
- package/components/u-safe-bottom/u-safe-bottom.vue +57 -46
- package/components/u-search/types.ts +55 -53
- package/components/u-search/u-search.vue +279 -268
- package/components/u-section/types.ts +34 -32
- package/components/u-section/u-section.vue +150 -131
- package/components/u-select/types.ts +45 -43
- package/components/u-select/u-select.vue +388 -378
- package/components/u-skeleton/types.ts +22 -20
- package/components/u-skeleton/u-skeleton.vue +231 -220
- package/components/u-slider/types.ts +34 -32
- package/components/u-slider/u-slider.vue +255 -247
- package/components/u-status-bar/u-status-bar.vue +74 -65
- package/components/u-steps/types.ts +30 -28
- package/components/u-steps/u-steps.vue +181 -169
- package/components/u-sticky/types.ts +24 -22
- package/components/u-sticky/u-sticky.vue +178 -162
- package/components/u-subsection/types.ts +38 -36
- package/components/u-subsection/u-subsection.vue +339 -328
- package/components/u-swipe-action/types.ts +52 -50
- package/components/u-swipe-action/u-swipe-action.vue +276 -260
- package/components/u-swiper/types.ts +49 -47
- package/components/u-swiper/u-swiper.vue +308 -291
- package/components/u-switch/types.ts +30 -28
- package/components/u-switch/u-switch.vue +150 -141
- package/components/u-tabbar/types.ts +38 -36
- package/components/u-tabbar/u-tabbar.vue +315 -298
- package/components/u-table/types.ts +27 -25
- package/components/u-table/u-table.vue +67 -55
- package/components/u-tabs/types.ts +53 -51
- package/components/u-tabs/u-tabs.vue +302 -291
- package/components/u-tabs-swiper/types.ts +55 -53
- package/components/u-tabs-swiper/u-tabs-swiper.vue +409 -397
- package/components/u-tag/types.ts +39 -37
- package/components/u-tag/u-tag.vue +268 -252
- package/components/u-td/types.ts +14 -12
- package/components/u-td/u-td.vue +98 -87
- package/components/u-text/types.ts +72 -72
- package/components/u-text/u-text.vue +343 -341
- package/components/u-th/types.ts +14 -12
- package/components/u-th/u-th.vue +92 -81
- package/components/u-time-line/u-time-line.vue +53 -39
- package/components/u-time-line-item/types.ts +16 -14
- package/components/u-time-line-item/u-time-line-item.vue +90 -78
- package/components/u-toast/types.ts +38 -36
- package/components/u-toast/u-toast.vue +240 -233
- package/components/u-top-tips/types.ts +16 -14
- package/components/u-top-tips/u-top-tips.vue +130 -113
- package/components/u-tr/types.ts +11 -8
- package/components/u-tr/u-tr.vue +39 -24
- package/components/u-upload/types.ts +82 -80
- package/components/u-upload/u-upload.vue +568 -559
- package/components/u-verification-code/types.ts +24 -22
- package/components/u-verification-code/u-verification-code.vue +176 -164
- package/components/u-waterfall/types.ts +18 -16
- package/components/u-waterfall/u-waterfall.vue +187 -175
- package/iconfont.css +913 -913
- package/index.scss +25 -25
- package/index.ts +38 -38
- package/libs/config/config.ts +26 -26
- package/libs/config/zIndex.ts +37 -37
- package/libs/css/color.scss +155 -155
- package/libs/css/common.scss +178 -178
- package/libs/css/style.components.scss +16 -16
- package/libs/css/style.h5.scss +8 -8
- package/libs/css/style.mp.scss +72 -72
- package/libs/css/style.nvue.scss +15 -15
- package/libs/css/style.vue.scss +188 -188
- package/libs/function/$parent.ts +24 -24
- package/libs/function/addUnit.ts +13 -13
- package/libs/function/color.ts +37 -37
- package/libs/function/colorGradient.ts +139 -139
- package/libs/function/debounce.ts +28 -28
- package/libs/function/deepClone.ts +39 -39
- package/libs/function/deepMerge.ts +35 -35
- package/libs/function/getParent.ts +63 -63
- package/libs/function/getRect.ts +26 -26
- package/libs/function/guid.ts +42 -42
- package/libs/function/md5.ts +403 -403
- package/libs/function/parent.ts +21 -21
- package/libs/function/queryParams.ts +64 -64
- package/libs/function/random.ts +16 -16
- package/libs/function/randomArray.ts +11 -11
- package/libs/function/route.ts +118 -118
- package/libs/function/styleUtils.ts +83 -83
- package/libs/function/sys.ts +15 -15
- package/libs/function/test.ts +289 -289
- package/libs/function/throttle.ts +31 -31
- package/libs/function/timeFormat.ts +55 -55
- package/libs/function/timeFrom.ts +48 -48
- package/libs/function/toast.ts +14 -14
- package/libs/function/trim.ts +21 -21
- package/libs/function/type2icon.ts +39 -39
- package/libs/hooks/index.ts +4 -3
- package/libs/hooks/useCompRelation.ts +364 -0
- package/libs/hooks/useComponent.ts +759 -759
- package/libs/hooks/useEmitter.ts +79 -79
- package/libs/hooks/useParent.ts +33 -33
- package/libs/hooks/useRect.ts +33 -33
- package/libs/index.ts +337 -320
- package/libs/request/auto-http.ts +76 -76
- package/libs/request/index.ts +242 -242
- package/libs/store/index.ts +88 -88
- package/libs/util/async-validator.d.ts +75 -75
- package/libs/util/async-validator.js +1 -1
- package/libs/util/calendar.d.ts +57 -57
- package/libs/util/emitter.ts +112 -112
- package/libs/util/eventBus.ts +86 -86
- package/libs/util/logger.ts +364 -364
- package/libs/util/mitt.ts +118 -118
- package/libs/util/parent.ts +20 -20
- package/package.json +4 -4
- package/readme.md +241 -241
- package/theme.scss +38 -38
- package/types/components.d.ts +97 -97
- package/types/global.d.ts +331 -331
- package/types/ignore-errors.d.ts +30 -30
- package/types/index.d.ts +19 -19
- package/types/uni-app.d.ts +63 -63
|
@@ -1,378 +1,388 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<view class="u-select">
|
|
3
|
-
<!-- <view class="u-select__action" :class="{
|
|
4
|
-
'u-select--border': border
|
|
5
|
-
}" @tap.stop="selectHandler">
|
|
6
|
-
<view class="u-select__action__icon" :class="{
|
|
7
|
-
'u-select__action__icon--reverse': value == true
|
|
8
|
-
}">
|
|
9
|
-
<u-icon name="arrow-down-fill" size="26" color="#c0c4cc"></u-icon>
|
|
10
|
-
</view>
|
|
11
|
-
</view> -->
|
|
12
|
-
<u-popup
|
|
13
|
-
:maskCloseAble="maskCloseAble"
|
|
14
|
-
mode="bottom"
|
|
15
|
-
:popup="false"
|
|
16
|
-
v-model="popupValue"
|
|
17
|
-
length="auto"
|
|
18
|
-
:safeAreaInsetBottom="safeAreaInsetBottom"
|
|
19
|
-
@close="close"
|
|
20
|
-
:z-index="uZIndex"
|
|
21
|
-
>
|
|
22
|
-
<view class="u-select">
|
|
23
|
-
<view class="u-select__header" @touchmove.stop.prevent="">
|
|
24
|
-
<view
|
|
25
|
-
class="u-select__header__cancel u-select__header__btn"
|
|
26
|
-
:style="{ color: cancelColor }"
|
|
27
|
-
hover-class="u-hover-class"
|
|
28
|
-
:hover-stay-time="150"
|
|
29
|
-
@tap="getResult('cancel')"
|
|
30
|
-
>
|
|
31
|
-
{{ cancelText }}
|
|
32
|
-
</view>
|
|
33
|
-
<view class="u-select__header__title">
|
|
34
|
-
{{ title }}
|
|
35
|
-
</view>
|
|
36
|
-
<view
|
|
37
|
-
class="u-select__header__confirm u-select__header__btn"
|
|
38
|
-
:style="{ color: moving ? cancelColor : confirmColor }"
|
|
39
|
-
hover-class="u-hover-class"
|
|
40
|
-
:hover-stay-time="150"
|
|
41
|
-
@touchmove.stop=""
|
|
42
|
-
@tap.stop="getResult('confirm')"
|
|
43
|
-
>
|
|
44
|
-
{{ confirmText }}
|
|
45
|
-
</view>
|
|
46
|
-
</view>
|
|
47
|
-
<view class="u-select__body">
|
|
48
|
-
<picker-view
|
|
49
|
-
@change="columnChange"
|
|
50
|
-
class="u-select__body__picker-view"
|
|
51
|
-
:value="defaultSelector"
|
|
52
|
-
@pickstart="pickstart"
|
|
53
|
-
@pickend="pickend"
|
|
54
|
-
v-if="modelValue"
|
|
55
|
-
>
|
|
56
|
-
<picker-view-column v-for="(item, index) in columnData" :key="index">
|
|
57
|
-
<view
|
|
58
|
-
class="u-select__body__picker-view__item"
|
|
59
|
-
v-for="(item1, index1) in item"
|
|
60
|
-
:key="index1"
|
|
61
|
-
>
|
|
62
|
-
<view class="u-line-1">{{ item1[labelName] }}</view>
|
|
63
|
-
</view>
|
|
64
|
-
</picker-view-column>
|
|
65
|
-
</picker-view>
|
|
66
|
-
</view>
|
|
67
|
-
</view>
|
|
68
|
-
</u-popup>
|
|
69
|
-
</view>
|
|
70
|
-
</template>
|
|
71
|
-
|
|
72
|
-
<script
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
*
|
|
93
|
-
* @
|
|
94
|
-
* @
|
|
95
|
-
* @property {String
|
|
96
|
-
* @property {
|
|
97
|
-
* @property {
|
|
98
|
-
* @property {
|
|
99
|
-
* @
|
|
100
|
-
* @
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
const
|
|
118
|
-
//
|
|
119
|
-
const
|
|
120
|
-
|
|
121
|
-
const
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
)
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
//
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
} else if (props.mode == '
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
//
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
1
|
+
<template>
|
|
2
|
+
<view class="u-select" :class="customClass" :style="$u.toStyle(customStyle)">
|
|
3
|
+
<!-- <view class="u-select__action" :class="{
|
|
4
|
+
'u-select--border': border
|
|
5
|
+
}" @tap.stop="selectHandler">
|
|
6
|
+
<view class="u-select__action__icon" :class="{
|
|
7
|
+
'u-select__action__icon--reverse': value == true
|
|
8
|
+
}">
|
|
9
|
+
<u-icon name="arrow-down-fill" size="26" color="#c0c4cc"></u-icon>
|
|
10
|
+
</view>
|
|
11
|
+
</view> -->
|
|
12
|
+
<u-popup
|
|
13
|
+
:maskCloseAble="maskCloseAble"
|
|
14
|
+
mode="bottom"
|
|
15
|
+
:popup="false"
|
|
16
|
+
v-model="popupValue"
|
|
17
|
+
length="auto"
|
|
18
|
+
:safeAreaInsetBottom="safeAreaInsetBottom"
|
|
19
|
+
@close="close"
|
|
20
|
+
:z-index="uZIndex"
|
|
21
|
+
>
|
|
22
|
+
<view class="u-select">
|
|
23
|
+
<view class="u-select__header" @touchmove.stop.prevent="">
|
|
24
|
+
<view
|
|
25
|
+
class="u-select__header__cancel u-select__header__btn"
|
|
26
|
+
:style="{ color: cancelColor }"
|
|
27
|
+
hover-class="u-hover-class"
|
|
28
|
+
:hover-stay-time="150"
|
|
29
|
+
@tap="getResult('cancel')"
|
|
30
|
+
>
|
|
31
|
+
{{ cancelText }}
|
|
32
|
+
</view>
|
|
33
|
+
<view class="u-select__header__title">
|
|
34
|
+
{{ title }}
|
|
35
|
+
</view>
|
|
36
|
+
<view
|
|
37
|
+
class="u-select__header__confirm u-select__header__btn"
|
|
38
|
+
:style="{ color: moving ? cancelColor : confirmColor }"
|
|
39
|
+
hover-class="u-hover-class"
|
|
40
|
+
:hover-stay-time="150"
|
|
41
|
+
@touchmove.stop=""
|
|
42
|
+
@tap.stop="getResult('confirm')"
|
|
43
|
+
>
|
|
44
|
+
{{ confirmText }}
|
|
45
|
+
</view>
|
|
46
|
+
</view>
|
|
47
|
+
<view class="u-select__body">
|
|
48
|
+
<picker-view
|
|
49
|
+
@change="columnChange"
|
|
50
|
+
class="u-select__body__picker-view"
|
|
51
|
+
:value="defaultSelector"
|
|
52
|
+
@pickstart="pickstart"
|
|
53
|
+
@pickend="pickend"
|
|
54
|
+
v-if="modelValue"
|
|
55
|
+
>
|
|
56
|
+
<picker-view-column v-for="(item, index) in columnData" :key="index">
|
|
57
|
+
<view
|
|
58
|
+
class="u-select__body__picker-view__item"
|
|
59
|
+
v-for="(item1, index1) in item"
|
|
60
|
+
:key="index1"
|
|
61
|
+
>
|
|
62
|
+
<view class="u-line-1">{{ item1[labelName] }}</view>
|
|
63
|
+
</view>
|
|
64
|
+
</picker-view-column>
|
|
65
|
+
</picker-view>
|
|
66
|
+
</view>
|
|
67
|
+
</view>
|
|
68
|
+
</u-popup>
|
|
69
|
+
</view>
|
|
70
|
+
</template>
|
|
71
|
+
|
|
72
|
+
<script lang="ts">
|
|
73
|
+
export default {
|
|
74
|
+
name: 'u-select',
|
|
75
|
+
options: {
|
|
76
|
+
addGlobalClass: true,
|
|
77
|
+
// #ifndef MP-TOUTIAO
|
|
78
|
+
virtualHost: true,
|
|
79
|
+
// #endif
|
|
80
|
+
styleIsolation: 'shared'
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
</script>
|
|
84
|
+
|
|
85
|
+
<script setup lang="ts">
|
|
86
|
+
import { ref, computed, watch } from 'vue';
|
|
87
|
+
import { SelectProps } from './types';
|
|
88
|
+
import type { SelectListItem } from '../../types/global';
|
|
89
|
+
import { $u } from '../..';
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* select 列选择器
|
|
93
|
+
* @description 此选择器用于单列,多列,多列联动的选择场景。(从1.3.0版本起,不建议使用Picker组件的单列和多列模式,Select组件是专门为列选择而构造的组件,更简单易用。)
|
|
94
|
+
* @tutorial https://uviewpro.cn/zh/components/select.html
|
|
95
|
+
* @property {String} mode 模式选择,"single-column"-单列模式,"mutil-column"-多列模式,"mutil-column-auto"-多列联动模式
|
|
96
|
+
* @property {Array} list 列数据,数组形式,见官网说明
|
|
97
|
+
* @property {Boolean} v-model 布尔值变量,用于控制选择器的弹出与收起
|
|
98
|
+
* @property {Boolean} safe-area-inset-bottom 是否开启底部安全区适配(默认false)
|
|
99
|
+
* @property {String} cancel-color 取消按钮的颜色(默认#606266)
|
|
100
|
+
* @property {String} confirm-color 确认按钮的颜色(默认#2979ff)
|
|
101
|
+
* @property {String} confirm-text 确认按钮的文字
|
|
102
|
+
* @property {String} cancel-text 取消按钮的文字
|
|
103
|
+
* @property {String} default-value 提供的默认选中的下标,见官网说明
|
|
104
|
+
* @property {Boolean} mask-close-able 是否允许通过点击遮罩关闭Picker(默认true)
|
|
105
|
+
* @property {String Number} z-index 弹出时的z-index值(默认10075)
|
|
106
|
+
* @property {String} value-name 自定义list数据的value属性名 1.3.6
|
|
107
|
+
* @property {String} label-name 自定义list数据的label属性名 1.3.6
|
|
108
|
+
* @property {String} child-name 自定义list数据的children属性名,只对多列联动模式有效 1.3.7
|
|
109
|
+
* @event {Function} confirm 点击确定按钮,返回当前选择的值
|
|
110
|
+
* @example <u-select v-model="show" :list="list"></u-select>
|
|
111
|
+
*/
|
|
112
|
+
|
|
113
|
+
const props = defineProps(SelectProps);
|
|
114
|
+
const emit = defineEmits(['update:modelValue', 'confirm', 'cancel', 'click']);
|
|
115
|
+
// 用于列改变时,保存当前的索引,下一次变化时比较得出是哪一列发生了变化
|
|
116
|
+
|
|
117
|
+
const defaultSelector = ref<number[]>([0]);
|
|
118
|
+
// picker-view的数据
|
|
119
|
+
const columnData = ref<SelectListItem[][]>([]);
|
|
120
|
+
// 每次队列发生变化时,保存选择的结果
|
|
121
|
+
const selectValue = ref<SelectListItem[]>([]);
|
|
122
|
+
// 上一次列变化时的index
|
|
123
|
+
const lastSelectIndex = ref<number[]>([]);
|
|
124
|
+
// 列数
|
|
125
|
+
const columnNum = ref(0);
|
|
126
|
+
// 列是否还在滑动中,微信小程序如果在滑动中就点确定,结果可能不准确
|
|
127
|
+
const moving = ref(false);
|
|
128
|
+
// 如果用户有传递z-index值,优先使用
|
|
129
|
+
const uZIndex = computed(() => (props.zIndex ? props.zIndex : 10075));
|
|
130
|
+
|
|
131
|
+
const popupValue = computed({
|
|
132
|
+
get: () => props.modelValue,
|
|
133
|
+
set: (val: boolean) => emit('update:modelValue', val)
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
watch(
|
|
137
|
+
() => props.modelValue,
|
|
138
|
+
val => {
|
|
139
|
+
if (val) setTimeout(() => init(), 10);
|
|
140
|
+
},
|
|
141
|
+
{ immediate: true }
|
|
142
|
+
);
|
|
143
|
+
// 标识滑动开始,只有微信小程序才有这样的事件
|
|
144
|
+
function pickstart() {
|
|
145
|
+
// #ifdef MP-WEIXIN
|
|
146
|
+
moving.value = true;
|
|
147
|
+
// #endif
|
|
148
|
+
}
|
|
149
|
+
function pickend() {
|
|
150
|
+
// #ifdef MP-WEIXIN
|
|
151
|
+
moving.value = false;
|
|
152
|
+
// #endif
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function init() {
|
|
156
|
+
setColumnNum();
|
|
157
|
+
setDefaultSelector();
|
|
158
|
+
setColumnData();
|
|
159
|
+
setSelectValue();
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// 获取默认选中列下标
|
|
163
|
+
function setDefaultSelector() {
|
|
164
|
+
// 如果没有传入默认选中的值,生成长度为columnNum,用0填充的数组
|
|
165
|
+
defaultSelector.value =
|
|
166
|
+
props.defaultValue.length == columnNum.value ? props.defaultValue : Array(columnNum.value).fill(0);
|
|
167
|
+
lastSelectIndex.value = [...defaultSelector.value];
|
|
168
|
+
}
|
|
169
|
+
// 计算列数
|
|
170
|
+
function setColumnNum() {
|
|
171
|
+
// 单列的列数为1
|
|
172
|
+
if (props.mode == 'single-column') columnNum.value = 1;
|
|
173
|
+
// 多列时,this.list数组长度就是列数
|
|
174
|
+
else if (props.mode == 'mutil-column') columnNum.value = props.list.length;
|
|
175
|
+
// 多列联动时,通过历遍this.list的第一个元素,得出有多少列
|
|
176
|
+
else if (props.mode == 'mutil-column-auto') {
|
|
177
|
+
let num = 1;
|
|
178
|
+
let column: any = props.list;
|
|
179
|
+
// 只要有元素并且第一个元素有children属性,继续遍历
|
|
180
|
+
while (Array.isArray(column) && column[0] && typeof column[0] === 'object' && props.childName in column[0]) {
|
|
181
|
+
column = column[0][props.childName];
|
|
182
|
+
num++;
|
|
183
|
+
}
|
|
184
|
+
columnNum.value = num;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// 获取需要展示在picker中的列数据
|
|
189
|
+
function setColumnData() {
|
|
190
|
+
let data: SelectListItem[][] = [];
|
|
191
|
+
selectValue.value = [];
|
|
192
|
+
if (props.mode == 'mutil-column-auto') {
|
|
193
|
+
// 获得所有数据中的第一个元素
|
|
194
|
+
let column: any = props.list[defaultSelector.value.length ? defaultSelector.value[0] : 0];
|
|
195
|
+
// 通过循环所有的列数,再根据设定列的数组,得出当前需要渲染的整个列数组
|
|
196
|
+
for (let i = 0; i < columnNum.value; i++) {
|
|
197
|
+
// 第一列默认为整个list数组
|
|
198
|
+
if (i == 0) {
|
|
199
|
+
data[i] = is2DList(props.list) ? props.list[i] || [] : (props.list as SelectListItem[]);
|
|
200
|
+
column = column && typeof column === 'object' ? column[props.childName] : [];
|
|
201
|
+
} else {
|
|
202
|
+
// 大于第一列时,判断是否有默认选中的,如果没有就用该列的第一项
|
|
203
|
+
data[i] = Array.isArray(column) ? column : [];
|
|
204
|
+
column =
|
|
205
|
+
Array.isArray(column) &&
|
|
206
|
+
column[defaultSelector.value[i]] &&
|
|
207
|
+
typeof column[defaultSelector.value[i]] === 'object'
|
|
208
|
+
? column[defaultSelector.value[i]][props.childName]
|
|
209
|
+
: [];
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
} else if (props.mode == 'single-column') {
|
|
213
|
+
data[0] = Array.isArray(props.list) && !is2DList(props.list) ? (props.list as SelectListItem[]) : [];
|
|
214
|
+
} else if (props.mode == 'mutil-column') {
|
|
215
|
+
data = is2DList(props.list) ? props.list : [props.list as SelectListItem[]];
|
|
216
|
+
}
|
|
217
|
+
columnData.value = data;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
// 获取默认选中的值,如果没有设置defaultValue,就默认选中每列的第一个
|
|
221
|
+
function setSelectValue() {
|
|
222
|
+
for (let i = 0; i < columnNum.value; i++) {
|
|
223
|
+
const tmp = columnData.value[i][defaultSelector.value[i]];
|
|
224
|
+
let data: any = {
|
|
225
|
+
value: tmp ? tmp[props.valueName] : null,
|
|
226
|
+
label: tmp ? tmp[props.labelName] : null
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
// 判断是否存在额外的参数,如果存在,就返回
|
|
230
|
+
if (tmp && tmp.extra !== undefined) data.extra = tmp.extra;
|
|
231
|
+
selectValue.value.push(data);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// 列选项
|
|
236
|
+
function columnChange(e: any) {
|
|
237
|
+
let index: number = -1;
|
|
238
|
+
const columnIndex = e.detail.value;
|
|
239
|
+
// 由于后面是需要push进数组的,所以需要先清空数组
|
|
240
|
+
selectValue.value = [];
|
|
241
|
+
defaultSelector.value = columnIndex;
|
|
242
|
+
if (props.mode == 'mutil-column-auto') {
|
|
243
|
+
// 对比前后两个数组,寻找变更的是哪一列,如果某一个元素不同,即可判定该列发生了变化
|
|
244
|
+
lastSelectIndex.value.map((val, idx) => {
|
|
245
|
+
if (val != columnIndex[idx]) index = idx;
|
|
246
|
+
});
|
|
247
|
+
for (let i = index + 1; i < columnNum.value; i++) {
|
|
248
|
+
// 当前变化列的下一列的数据,需要获取上一列的数据,同时需要指定是上一列的第几个的children,再往后的
|
|
249
|
+
// 默认是队列的第一个为默认选项
|
|
250
|
+
const prevCol = columnData.value[i - 1];
|
|
251
|
+
const prevIdx = i - 1 == index ? columnIndex[index] : 0;
|
|
252
|
+
columnData.value[i] =
|
|
253
|
+
Array.isArray(prevCol) && prevCol[prevIdx] && typeof prevCol[prevIdx] === 'object'
|
|
254
|
+
? prevCol[prevIdx][props.childName]
|
|
255
|
+
: [];
|
|
256
|
+
// 改变的列之后的所有列,默认选中第一个
|
|
257
|
+
defaultSelector.value[i] = 0;
|
|
258
|
+
}
|
|
259
|
+
// 在历遍的过程中,可能由于上一步修改this.columnData,导致产生连锁反应,程序触发columnChange,会有多次调用
|
|
260
|
+
// 只有在最后一次数据稳定后的结果是正确的,此前的历遍中,可能会产生undefined,故需要判断
|
|
261
|
+
columnIndex.map((item: any, idx: number) => {
|
|
262
|
+
let data = columnData.value[idx][columnIndex[idx]];
|
|
263
|
+
let tmp: any = {
|
|
264
|
+
value: data ? data[props.valueName] : null,
|
|
265
|
+
label: data ? data[props.labelName] : null
|
|
266
|
+
};
|
|
267
|
+
// 判断是否有需要额外携带的参数
|
|
268
|
+
if (data && data.extra !== undefined) tmp.extra = data.extra;
|
|
269
|
+
selectValue.value.push(tmp);
|
|
270
|
+
});
|
|
271
|
+
// 保存这一次的结果,用于下次列发生变化时作比较
|
|
272
|
+
lastSelectIndex.value = [...columnIndex];
|
|
273
|
+
} else if (props.mode == 'single-column') {
|
|
274
|
+
let data = columnData.value[0][columnIndex[0]];
|
|
275
|
+
// 初始默认选中值
|
|
276
|
+
let tmp: any = {
|
|
277
|
+
value: data ? data[props.valueName] : null,
|
|
278
|
+
label: data ? data[props.labelName] : null
|
|
279
|
+
};
|
|
280
|
+
// 判断是否有需要额外携带的参数
|
|
281
|
+
if (data && data.extra !== undefined) tmp.extra = data.extra;
|
|
282
|
+
selectValue.value.push(tmp);
|
|
283
|
+
} else if (props.mode == 'mutil-column') {
|
|
284
|
+
// 初始默认选中值
|
|
285
|
+
columnIndex.map((item: any, idx: number) => {
|
|
286
|
+
let data = columnData.value[idx][columnIndex[idx]];
|
|
287
|
+
// 初始默认选中值
|
|
288
|
+
let tmp: any = {
|
|
289
|
+
value: data ? data[props.valueName] : null,
|
|
290
|
+
label: data ? data[props.labelName] : null
|
|
291
|
+
};
|
|
292
|
+
// 判断是否有需要额外携带的参数
|
|
293
|
+
if (data && data.extra !== undefined) tmp.extra = data.extra;
|
|
294
|
+
selectValue.value.push(tmp);
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
function close() {
|
|
300
|
+
emit('update:modelValue', false);
|
|
301
|
+
// 重置default-value默认值
|
|
302
|
+
defaultSelector.value = [0];
|
|
303
|
+
}
|
|
304
|
+
// 点击确定或者取消
|
|
305
|
+
function getResult(event: 'update:modelValue' | 'confirm' | 'cancel' | 'click' | null = null) {
|
|
306
|
+
// #ifdef MP-WEIXIN
|
|
307
|
+
if (moving.value) return;
|
|
308
|
+
// #endif
|
|
309
|
+
|
|
310
|
+
if (event) emit(event, selectValue.value);
|
|
311
|
+
close();
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
function selectHandler() {
|
|
315
|
+
emit('click');
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
// 类型守卫提前声明
|
|
319
|
+
function is2DList(list: SelectListItem[] | SelectListItem[][]): list is SelectListItem[][] {
|
|
320
|
+
return Array.isArray(list) && list.length > 0 && Array.isArray(list[0]);
|
|
321
|
+
}
|
|
322
|
+
</script>
|
|
323
|
+
|
|
324
|
+
<style scoped lang="scss">
|
|
325
|
+
@import '../../libs/css/style.components.scss';
|
|
326
|
+
|
|
327
|
+
.u-select {
|
|
328
|
+
&__action {
|
|
329
|
+
position: relative;
|
|
330
|
+
line-height: $u-form-item-height;
|
|
331
|
+
height: $u-form-item-height;
|
|
332
|
+
|
|
333
|
+
&__icon {
|
|
334
|
+
position: absolute;
|
|
335
|
+
right: 20rpx;
|
|
336
|
+
top: 50%;
|
|
337
|
+
transition: transform 0.4s;
|
|
338
|
+
transform: translateY(-50%);
|
|
339
|
+
z-index: 1;
|
|
340
|
+
|
|
341
|
+
&--reverse {
|
|
342
|
+
transform: rotate(-180deg) translateY(50%);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
&__hader {
|
|
348
|
+
&__title {
|
|
349
|
+
color: $u-content-color;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
&--border {
|
|
354
|
+
border-radius: 6rpx;
|
|
355
|
+
border-radius: 4px;
|
|
356
|
+
border: 1px solid $u-form-item-border-color;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
&__header {
|
|
360
|
+
@include vue-flex;
|
|
361
|
+
align-items: center;
|
|
362
|
+
justify-content: space-between;
|
|
363
|
+
height: 80rpx;
|
|
364
|
+
padding: 0 40rpx;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
&__body {
|
|
368
|
+
width: 100%;
|
|
369
|
+
height: 500rpx;
|
|
370
|
+
overflow: hidden;
|
|
371
|
+
background-color: #fff;
|
|
372
|
+
|
|
373
|
+
&__picker-view {
|
|
374
|
+
height: 100%;
|
|
375
|
+
box-sizing: border-box;
|
|
376
|
+
|
|
377
|
+
&__item {
|
|
378
|
+
@include vue-flex;
|
|
379
|
+
align-items: center;
|
|
380
|
+
justify-content: center;
|
|
381
|
+
font-size: 32rpx;
|
|
382
|
+
color: $u-main-color;
|
|
383
|
+
padding: 0 8rpx;
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
</style>
|