hy-app 0.4.13 → 0.5.0
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/components/hy-action-sheet/hy-action-sheet.vue +155 -238
- package/components/hy-action-sheet/props.ts +68 -15
- package/components/hy-action-sheet/typing.d.ts +115 -115
- package/components/hy-address-picker/hy-address-picker.vue +185 -289
- package/components/hy-address-picker/props.ts +97 -21
- package/components/hy-address-picker/typing.d.ts +90 -89
- package/components/hy-avatar/hy-avatar.vue +121 -204
- package/components/hy-avatar/props.ts +76 -18
- package/components/hy-avatar/typing.d.ts +63 -62
- package/components/hy-back-top/hy-back-top.vue +65 -120
- package/components/hy-back-top/props.ts +57 -16
- package/components/hy-back-top/typing.d.ts +43 -42
- package/components/hy-badge/hy-badge.vue +66 -138
- package/components/hy-badge/props.ts +73 -17
- package/components/hy-badge/typing.d.ts +59 -58
- package/components/hy-button/hy-button.vue +226 -375
- package/components/hy-button/props.ts +129 -158
- package/components/hy-calendar/header.vue +48 -64
- package/components/hy-calendar/hy-calendar.vue +274 -438
- package/components/hy-calendar/month.vue +508 -516
- package/components/hy-calendar/props.ts +157 -35
- package/components/hy-calendar/typing.d.ts +129 -128
- package/components/hy-card/hy-card.vue +118 -240
- package/components/hy-card/index.scss +1 -2
- package/components/hy-card/props.ts +122 -27
- package/components/hy-card/typing.d.ts +119 -118
- package/components/hy-cell/hy-cell.vue +176 -258
- package/components/hy-cell/props.ts +71 -17
- package/components/hy-cell/typing.d.ts +87 -86
- package/components/hy-check-button/hy-check-button.vue +69 -139
- package/components/hy-check-button/props.ts +72 -18
- package/components/hy-check-button/typing.d.ts +74 -73
- package/components/hy-checkbox/hy-checkbox.vue +170 -263
- package/components/hy-checkbox/props.ts +94 -24
- package/components/hy-checkbox/typing.d.ts +72 -72
- package/components/hy-checkbox-group/hy-checkbox-group.vue +25 -100
- package/components/hy-checkbox-group/props.ts +80 -0
- package/components/hy-checkbox-group/typing.d.ts +65 -65
- package/components/hy-checkbox-item/hy-checkbox-item.vue +140 -177
- package/components/hy-checkbox-item/props.ts +24 -0
- package/components/hy-checkbox-item/typing.d.ts +4 -3
- package/components/hy-code-input/hy-code-input.vue +179 -262
- package/components/hy-code-input/props.ts +84 -18
- package/components/hy-code-input/typing.d.ts +71 -71
- package/components/hy-config-provider/hy-config-provider.vue +28 -50
- package/components/hy-config-provider/props.ts +26 -11
- package/components/hy-config-provider/typing.d.ts +20 -20
- package/components/hy-count-down/hy-count-down.vue +103 -131
- package/components/hy-count-down/props.ts +30 -8
- package/components/hy-count-down/typing.d.ts +25 -25
- package/components/hy-count-to/hy-count-to.vue +148 -213
- package/components/hy-count-to/props.ts +60 -15
- package/components/hy-count-to/typing.d.ts +46 -46
- package/components/hy-coupon/README.md +133 -0
- package/components/hy-coupon/hy-coupon.vue +180 -0
- package/components/hy-coupon/index.scss +553 -0
- package/components/hy-coupon/props.ts +129 -0
- package/components/hy-coupon/typing.d.ts +146 -0
- package/components/hy-datetime-picker/hy-datetime-picker.vue +415 -580
- package/components/hy-datetime-picker/props.ts +142 -32
- package/components/hy-datetime-picker/typing.d.ts +132 -132
- package/components/hy-divider/hy-divider.vue +90 -169
- package/components/hy-divider/props.ts +78 -19
- package/components/hy-divider/typing.d.ts +60 -60
- package/components/hy-dropdown/hy-dropdown.vue +37 -71
- package/components/hy-dropdown/props.ts +38 -15
- package/components/hy-dropdown/typing.d.ts +44 -44
- package/components/hy-dropdown-item/hy-dropdown-item.vue +141 -173
- package/components/hy-dropdown-item/props.ts +19 -8
- package/components/hy-empty/hy-empty.vue +75 -129
- package/components/hy-empty/props.ts +57 -15
- package/components/hy-empty/typing.d.ts +84 -84
- package/components/hy-flex/hy-flex.vue +33 -88
- package/components/hy-flex/props.ts +58 -0
- package/components/hy-flex/typing.d.ts +14 -16
- package/components/hy-float-button/hy-float-button.vue +289 -406
- package/components/hy-float-button/props.ts +109 -25
- package/components/hy-folding-panel/hy-folding-panel.vue +86 -374
- package/components/hy-folding-panel/props.ts +40 -15
- package/components/hy-folding-panel/typing.d.ts +52 -63
- package/components/hy-folding-panel-item/hy-folding-panel-item.vue +186 -228
- package/components/hy-folding-panel-item/index.scss +87 -0
- package/components/hy-folding-panel-item/props.ts +81 -0
- package/components/hy-folding-panel-item/typing.d.ts +23 -0
- package/components/hy-form/hy-form.vue +172 -212
- package/components/hy-form/props.ts +37 -0
- package/components/hy-form/typing.d.ts +68 -61
- package/components/hy-form-group/typing.d.ts +74 -74
- package/components/hy-form-item/hy-form-item.vue +100 -129
- package/components/hy-form-item/props.ts +25 -0
- package/components/hy-form-item/typing.d.ts +40 -37
- package/components/hy-grid/hy-grid.vue +76 -132
- package/components/hy-grid/props.ts +58 -16
- package/components/hy-grid/typing.d.ts +66 -66
- package/components/hy-icon/hy-icon.vue +84 -161
- package/components/hy-icon/props.ts +76 -22
- package/components/hy-icon/typing.d.ts +83 -82
- package/components/hy-image/hy-image.vue +142 -272
- package/components/hy-image/props.ts +105 -23
- package/components/hy-image/typing.d.ts +84 -87
- package/components/hy-input/hy-input.vue +230 -421
- package/components/hy-input/props.ts +183 -35
- package/components/hy-input/typing.d.ts +169 -169
- package/components/hy-line/hy-line.vue +34 -72
- package/components/hy-line/props.ts +41 -10
- package/components/hy-line/typing.d.ts +29 -29
- package/components/hy-line-progress/hy-line-progress.vue +66 -101
- package/components/hy-line-progress/props.ts +31 -10
- package/components/hy-line-progress/typing.d.ts +29 -29
- package/components/hy-list/hy-list.vue +151 -220
- package/components/hy-list/props.ts +67 -16
- package/components/hy-list/typing.d.ts +52 -52
- package/components/hy-loading/hy-loading.vue +63 -119
- package/components/hy-loading/props.ts +63 -15
- package/components/hy-loading/typing.d.ts +49 -49
- package/components/hy-menu/hy-menu.vue +124 -166
- package/components/hy-menu/props.ts +42 -10
- package/components/hy-menu/typing.d.ts +60 -60
- package/components/hy-modal/hy-modal.vue +127 -218
- package/components/hy-modal/props.ts +89 -24
- package/components/hy-navbar/hy-navbar.vue +104 -177
- package/components/hy-navbar/props.ts +76 -22
- package/components/hy-navbar/typing.d.ts +81 -81
- package/components/hy-notice-bar/hy-notice-bar.vue +67 -144
- package/components/hy-notice-bar/props.ts +80 -19
- package/components/hy-notice-bar/typing.d.ts +62 -62
- package/components/hy-notify/hy-notify.vue +128 -177
- package/components/hy-notify/props.ts +49 -12
- package/components/hy-notify/typing.d.ts +45 -41
- package/components/hy-number-step/hy-number-step.vue +281 -394
- package/components/hy-number-step/props.ts +110 -27
- package/components/hy-number-step/typing.d.ts +120 -120
- package/components/hy-overlay/hy-overlay.vue +39 -66
- package/components/hy-overlay/props.ts +31 -8
- package/components/hy-pagination/hy-pagination.vue +100 -155
- package/components/hy-pagination/props.ts +53 -13
- package/components/hy-picker/hy-picker.vue +309 -430
- package/components/hy-picker/index.scss +8 -12
- package/components/hy-picker/props.ts +110 -26
- package/components/hy-popover/hy-popover.vue +190 -252
- package/components/hy-popover/props.ts +48 -10
- package/components/hy-popup/hy-popup.vue +162 -248
- package/components/hy-popup/props.ts +82 -18
- package/components/hy-price/hy-price.vue +45 -104
- package/components/hy-price/props.ts +52 -12
- package/components/hy-price/typing.d.ts +41 -36
- package/components/hy-qrcode/hy-qrcode.vue +115 -185
- package/components/hy-qrcode/props.ts +68 -18
- package/components/hy-qrcode/typing.d.ts +67 -66
- package/components/hy-radio/hy-radio.vue +161 -259
- package/components/hy-radio/props.ts +95 -25
- package/components/hy-radio/typing.d.ts +85 -84
- package/components/hy-rate/hy-rate.vue +185 -270
- package/components/hy-rate/props.ts +76 -18
- package/components/hy-rate/typing.d.ts +61 -60
- package/components/hy-read-more/hy-read-more.vue +93 -136
- package/components/hy-read-more/props.ts +43 -13
- package/components/hy-scroll-list/hy-scroll-list.vue +81 -102
- package/components/hy-scroll-list/props.ts +22 -11
- package/components/hy-search/hy-search.vue +155 -284
- package/components/hy-search/props.ts +130 -25
- package/components/hy-signature/hy-signature.vue +491 -635
- package/components/hy-signature/props.ts +115 -26
- package/components/hy-signature/typing.d.ts +138 -138
- package/components/hy-slider/hy-slider.vue +388 -477
- package/components/hy-slider/props.ts +75 -19
- package/components/hy-steps/hy-steps.vue +212 -279
- package/components/hy-steps/props.ts +47 -13
- package/components/hy-submit-bar/hy-submit-bar.vue +137 -222
- package/components/hy-submit-bar/props.ts +89 -20
- package/components/hy-submit-bar/typing.d.ts +86 -85
- package/components/hy-subsection/hy-subsection.vue +132 -185
- package/components/hy-subsection/props.ts +50 -17
- package/components/hy-subsection/typing.d.ts +52 -52
- package/components/hy-swipe-action/hy-swipe-action.vue +228 -283
- package/components/hy-swipe-action/props.ts +43 -18
- package/components/hy-swipe-action/typing.d.ts +46 -46
- package/components/hy-swiper/hy-swiper.vue +159 -286
- package/components/hy-swiper/props.ts +126 -28
- package/components/hy-swiper/typing.d.ts +115 -115
- package/components/hy-switch/hy-switch.vue +112 -176
- package/components/hy-switch/props.ts +60 -15
- package/components/hy-switch/typing.d.ts +63 -63
- package/components/hy-tabBar/hy-tabBar.vue +64 -60
- package/components/hy-tabs/hy-tabs.vue +277 -380
- package/components/hy-tabs/props.ts +75 -18
- package/components/hy-tag/hy-tag.vue +111 -204
- package/components/hy-tag/props.ts +81 -19
- package/components/hy-text/hy-text.vue +200 -322
- package/components/hy-text/props.ts +107 -28
- package/components/hy-textarea/hy-textarea.vue +147 -256
- package/components/hy-textarea/props.ts +112 -25
- package/components/hy-textarea/typing.d.ts +42 -42
- package/components/hy-toast/hy-toast.vue +135 -143
- package/components/hy-tooltip/hy-tooltip.vue +220 -306
- package/components/hy-tooltip/props.ts +79 -15
- package/components/hy-transition/hy-transition.vue +111 -138
- package/components/hy-transition/props.ts +30 -8
- package/components/hy-upload/hy-upload.vue +320 -469
- package/components/hy-upload/props.ts +130 -27
- package/components/hy-warn/hy-warn.vue +80 -129
- package/components/hy-warn/props.ts +47 -12
- package/components/hy-waterfall/hy-waterfall.vue +139 -163
- package/components/hy-waterfall/props.ts +19 -7
- package/components/hy-watermark/hy-watermark.vue +762 -870
- package/components/hy-watermark/props.ts +103 -22
- package/global.d.ts +2 -0
- package/libs/css/theme.scss +3 -3
- package/package.json +2 -2
- package/web-types.json +1 -1
- package/components/hy-folding-panel/index.scss +0 -9
|
@@ -1,550 +1,429 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
Object.assign({ 'pointer-events': 'none' }, input?.customStyle)
|
|
26
|
-
"
|
|
27
|
-
></HyInput>
|
|
28
|
-
<div class="input-cover"></div>
|
|
29
|
-
</slot>
|
|
30
|
-
</view>
|
|
31
|
-
<HyPopup
|
|
32
|
-
:show="show || (hasInput && showByClickInput)"
|
|
33
|
-
:mode="popupMode"
|
|
34
|
-
:zIndex="zIndex"
|
|
35
|
-
@close="closeHandler"
|
|
36
|
-
>
|
|
37
|
-
<view class="hy-picker">
|
|
38
|
-
<!-- 头部内容 -->
|
|
39
|
-
<view class="hy-picker__title" v-if="showToolbar">
|
|
40
|
-
<view
|
|
41
|
-
class="hy-picker__title--left"
|
|
42
|
-
:style="{ color: cancelColor }"
|
|
43
|
-
@tap="cancel"
|
|
44
|
-
>
|
|
45
|
-
{{ cancelText }}
|
|
46
|
-
</view>
|
|
47
|
-
<view class="hy-picker__title--center">
|
|
48
|
-
{{ title }}
|
|
49
|
-
</view>
|
|
50
|
-
<view
|
|
51
|
-
class="hy-picker__title--right"
|
|
52
|
-
:style="{ color: confirmColor }"
|
|
53
|
-
@tap="onConfirm"
|
|
54
|
-
>
|
|
55
|
-
<slot name="toolbar-right">
|
|
56
|
-
{{ confirmText }}
|
|
57
|
-
</slot>
|
|
58
|
-
</view>
|
|
2
|
+
<view class="hy-picker">
|
|
3
|
+
<view v-if="hasInput" class="hy-picker-input cursor-pointer" @click="onShowByClickInput">
|
|
4
|
+
<slot v-if="$slots.default"></slot>
|
|
5
|
+
<template v-else>
|
|
6
|
+
<hy-input
|
|
7
|
+
v-model="inputLabelValue"
|
|
8
|
+
:readonly="true"
|
|
9
|
+
:disabled="input?.disabled"
|
|
10
|
+
:disabledColor="input?.disabledColor"
|
|
11
|
+
:shape="input?.shape"
|
|
12
|
+
:border="input?.border"
|
|
13
|
+
:prefixIcon="input?.prefixIcon"
|
|
14
|
+
:suffixIcon="input?.suffixIcon"
|
|
15
|
+
:color="input?.color"
|
|
16
|
+
:fontSize="input?.fontSize"
|
|
17
|
+
:inputAlign="input?.inputAlign"
|
|
18
|
+
:placeholder="input?.placeholder || '请选择'"
|
|
19
|
+
:placeholderStyle="input?.placeholderStyle"
|
|
20
|
+
:placeholderClass="input?.placeholderClass"
|
|
21
|
+
:customStyle="Object.assign({ 'pointer-events': 'none' }, input?.customStyle)"
|
|
22
|
+
></hy-input>
|
|
23
|
+
<view class="input-cover"></view>
|
|
24
|
+
</template>
|
|
59
25
|
</view>
|
|
60
|
-
|
|
26
|
+
<hy-popup
|
|
27
|
+
:show="show || (hasInput && showByClickInput)"
|
|
28
|
+
:mode="popupMode"
|
|
29
|
+
:zIndex="zIndex"
|
|
30
|
+
@close="closeHandler"
|
|
31
|
+
>
|
|
32
|
+
<view class="hy-picker">
|
|
33
|
+
<!-- 头部内容 -->
|
|
34
|
+
<view class="hy-picker__title" v-if="showToolbar">
|
|
35
|
+
<view
|
|
36
|
+
class="hy-picker__title--left"
|
|
37
|
+
:style="{ color: cancelColor }"
|
|
38
|
+
@tap="cancel"
|
|
39
|
+
>
|
|
40
|
+
{{ cancelText }}
|
|
41
|
+
</view>
|
|
42
|
+
<view class="hy-picker__title--center">
|
|
43
|
+
{{ title }}
|
|
44
|
+
</view>
|
|
45
|
+
<view
|
|
46
|
+
class="hy-picker__title--right"
|
|
47
|
+
:style="{ color: confirmColor }"
|
|
48
|
+
@tap="onConfirm"
|
|
49
|
+
>
|
|
50
|
+
<slot name="toolbar-right">
|
|
51
|
+
{{ confirmText }}
|
|
52
|
+
</slot>
|
|
53
|
+
</view>
|
|
54
|
+
</view>
|
|
55
|
+
<!-- 头部内容 -->
|
|
61
56
|
|
|
62
|
-
|
|
57
|
+
<slot name="toolbar-bottom"></slot>
|
|
63
58
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
maskStyle="backgroundImage: none;"
|
|
75
|
-
@change="changeHandler"
|
|
76
|
-
>
|
|
77
|
-
<picker-view-column
|
|
78
|
-
v-for="(item, index) in innerColumns"
|
|
79
|
-
:key="index"
|
|
80
|
-
class="hy-picker--view__column"
|
|
81
|
-
>
|
|
82
|
-
<view
|
|
83
|
-
v-if="Array.isArray(item)"
|
|
84
|
-
:class="[
|
|
85
|
-
'hy-picker--view__column__item',
|
|
86
|
-
index1 === innerIndex[index] &&
|
|
87
|
-
'hy-picker--view__column__item--selected',
|
|
88
|
-
]"
|
|
89
|
-
v-for="(item1, index1) in item"
|
|
90
|
-
:key="index1"
|
|
91
|
-
:style="{
|
|
92
|
-
height: addUnit(itemHeight),
|
|
93
|
-
lineHeight: addUnit(itemHeight),
|
|
94
|
-
fontWeight: index1 === innerIndex[index] ? 'bold' : 'normal',
|
|
95
|
-
display: 'block',
|
|
96
|
-
}"
|
|
97
|
-
>
|
|
98
|
-
{{ getItemText(item1) }}
|
|
99
|
-
</view>
|
|
100
|
-
</picker-view-column>
|
|
101
|
-
</picker-view>
|
|
102
|
-
<!-- 选择器内容 -->
|
|
59
|
+
<!-- 加载loading -->
|
|
60
|
+
<hy-loading
|
|
61
|
+
v-if="loading"
|
|
62
|
+
mode="circle"
|
|
63
|
+
custom-class="hy-picker__loading"
|
|
64
|
+
:custom-style="{
|
|
65
|
+
height: `${addUnit(visibleItemCount * itemHeight)}`
|
|
66
|
+
}"
|
|
67
|
+
></hy-loading>
|
|
68
|
+
<!-- 加载loading -->
|
|
103
69
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
70
|
+
<!-- 选择器内容 -->
|
|
71
|
+
<picker-view
|
|
72
|
+
v-else
|
|
73
|
+
class="hy-picker--view"
|
|
74
|
+
:indicatorStyle="`height: ${addUnit(itemHeight)}`"
|
|
75
|
+
:value="innerIndex"
|
|
76
|
+
:immediateChange="immediateChange"
|
|
77
|
+
:style="{
|
|
78
|
+
height: `${addUnit(visibleItemCount * itemHeight)}`
|
|
79
|
+
}"
|
|
80
|
+
mask-class="hy-picker--view__mask"
|
|
81
|
+
maskStyle="backgroundImage: none;"
|
|
82
|
+
@change="changeHandler"
|
|
83
|
+
>
|
|
84
|
+
<picker-view-column
|
|
85
|
+
v-for="(item, index) in innerColumns"
|
|
86
|
+
:key="index"
|
|
87
|
+
class="hy-picker--view__column"
|
|
88
|
+
>
|
|
89
|
+
<view
|
|
90
|
+
v-if="Array.isArray(item)"
|
|
91
|
+
:class="[
|
|
92
|
+
'hy-picker--view__column__item',
|
|
93
|
+
index1 === innerIndex[index] &&
|
|
94
|
+
'hy-picker--view__column__item--selected'
|
|
95
|
+
]"
|
|
96
|
+
v-for="(item1, index1) in item"
|
|
97
|
+
:key="index1"
|
|
98
|
+
:style="{
|
|
99
|
+
height: addUnit(itemHeight),
|
|
100
|
+
lineHeight: addUnit(itemHeight),
|
|
101
|
+
fontWeight: index1 === innerIndex[index] ? 'bold' : 'normal',
|
|
102
|
+
display: 'block'
|
|
103
|
+
}"
|
|
104
|
+
>
|
|
105
|
+
{{ getItemText(item1) }}
|
|
106
|
+
</view>
|
|
107
|
+
</picker-view-column>
|
|
108
|
+
</picker-view>
|
|
109
|
+
<!-- 选择器内容 -->
|
|
110
|
+
</view>
|
|
111
|
+
</hy-popup>
|
|
112
|
+
</view>
|
|
112
113
|
</template>
|
|
113
114
|
|
|
114
115
|
<script lang="ts">
|
|
115
116
|
export default {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
}
|
|
117
|
+
name: 'hy-picker',
|
|
118
|
+
options: {
|
|
119
|
+
addGlobalClass: true,
|
|
120
|
+
virtualHost: true,
|
|
121
|
+
styleIsolation: 'shared'
|
|
122
|
+
}
|
|
123
|
+
}
|
|
123
124
|
</script>
|
|
124
125
|
|
|
125
126
|
<script setup lang="ts">
|
|
126
|
-
import { computed, ref, watch } from
|
|
127
|
-
import
|
|
128
|
-
import {
|
|
129
|
-
import
|
|
130
|
-
import type HyInputProps from "../hy-input/typing";
|
|
127
|
+
import { computed, ref, watch } from 'vue'
|
|
128
|
+
import { deepClone, sleep, addUnit, isArray } from '../../libs'
|
|
129
|
+
import type { IPickerEmits } from './typing'
|
|
130
|
+
import pickerProps from './props'
|
|
131
131
|
// 组件
|
|
132
|
-
import HyInput from
|
|
133
|
-
import
|
|
134
|
-
import HyPopup from
|
|
132
|
+
import HyInput from '../hy-input/hy-input.vue'
|
|
133
|
+
import HyLoading from '../hy-loading/hy-loading.vue'
|
|
134
|
+
import HyPopup from '../hy-popup/hy-popup.vue'
|
|
135
135
|
|
|
136
136
|
/**
|
|
137
137
|
* 此选择器用于单列,多列,多列联动的选择场景。
|
|
138
138
|
* @displayName hy-picker
|
|
139
139
|
*/
|
|
140
|
-
defineOptions({})
|
|
140
|
+
defineOptions({})
|
|
141
141
|
|
|
142
|
-
|
|
143
|
-
const
|
|
144
|
-
/** 显示到输入框值 */
|
|
145
|
-
modelValue: {
|
|
146
|
-
type: [String, Array],
|
|
147
|
-
default: "",
|
|
148
|
-
},
|
|
149
|
-
/** 是否显示弹窗 */
|
|
150
|
-
show: {
|
|
151
|
-
type: Boolean,
|
|
152
|
-
default: false,
|
|
153
|
-
},
|
|
154
|
-
/** 弹窗弹出模式 */
|
|
155
|
-
popupMode: {
|
|
156
|
-
type: String,
|
|
157
|
-
default: "bottom",
|
|
158
|
-
},
|
|
159
|
-
/** 分割数组条件 */
|
|
160
|
-
separator: {
|
|
161
|
-
type: String,
|
|
162
|
-
default: "/",
|
|
163
|
-
},
|
|
164
|
-
/** 是否显示顶部的操作栏 */
|
|
165
|
-
showToolbar: {
|
|
166
|
-
type: Boolean,
|
|
167
|
-
default: true,
|
|
168
|
-
},
|
|
169
|
-
/** 顶部标题 */
|
|
170
|
-
title: String,
|
|
171
|
-
/** 二维数组,设置每一列的数据 */
|
|
172
|
-
columns: {
|
|
173
|
-
type: Array as unknown as PropType<(string | PickerColumnVo)[][]>,
|
|
174
|
-
default: [],
|
|
175
|
-
},
|
|
176
|
-
/** 是否显示加载中状态 */
|
|
177
|
-
loading: {
|
|
178
|
-
type: Boolean,
|
|
179
|
-
default: false,
|
|
180
|
-
},
|
|
181
|
-
/** 各列中,单个选项的高度 */
|
|
182
|
-
itemHeight: {
|
|
183
|
-
type: Number,
|
|
184
|
-
default: 44,
|
|
185
|
-
},
|
|
186
|
-
/** 取消按钮的文字 */
|
|
187
|
-
cancelText: {
|
|
188
|
-
type: String,
|
|
189
|
-
default: "取消",
|
|
190
|
-
},
|
|
191
|
-
/** 确认按钮的文字 */
|
|
192
|
-
confirmText: {
|
|
193
|
-
type: String,
|
|
194
|
-
default: "确定",
|
|
195
|
-
},
|
|
196
|
-
/** 取消按钮的颜色 */
|
|
197
|
-
cancelColor: {
|
|
198
|
-
type: String,
|
|
199
|
-
default: "#909193",
|
|
200
|
-
},
|
|
201
|
-
/** 确认按钮的颜色 */
|
|
202
|
-
confirmColor: String,
|
|
203
|
-
/** 每列中可见选项的数量 */
|
|
204
|
-
visibleItemCount: {
|
|
205
|
-
type: Number,
|
|
206
|
-
default: 5,
|
|
207
|
-
},
|
|
208
|
-
/** 显示到选项对象中,需要展示的属性键名 */
|
|
209
|
-
keyName: {
|
|
210
|
-
type: String,
|
|
211
|
-
default: "text",
|
|
212
|
-
},
|
|
213
|
-
/** 是否允许点击遮罩关闭选择器 */
|
|
214
|
-
closeOnClickOverlay: {
|
|
215
|
-
type: Boolean,
|
|
216
|
-
default: false,
|
|
217
|
-
},
|
|
218
|
-
/** 各列的默认索引 */
|
|
219
|
-
defaultIndex: {
|
|
220
|
-
type: Array as PropType<number[]>,
|
|
221
|
-
default: [],
|
|
222
|
-
},
|
|
223
|
-
/** 是否在手指松开时立即触发change事件 */
|
|
224
|
-
immediateChange: {
|
|
225
|
-
type: Boolean,
|
|
226
|
-
default: true,
|
|
227
|
-
},
|
|
228
|
-
/** 最高层级 */
|
|
229
|
-
zIndex: {
|
|
230
|
-
type: Number,
|
|
231
|
-
default: 10076,
|
|
232
|
-
},
|
|
233
|
-
/** 是否显示输入框 */
|
|
234
|
-
hasInput: {
|
|
235
|
-
type: Boolean,
|
|
236
|
-
default: false,
|
|
237
|
-
},
|
|
238
|
-
/** 输入框集合属性 */
|
|
239
|
-
input: {
|
|
240
|
-
type: Object as PropType<HyInputProps>,
|
|
241
|
-
default: () => {},
|
|
242
|
-
},
|
|
243
|
-
/** 是否自定义选择器nav左边内容 */
|
|
244
|
-
toolbarRightSlot: {
|
|
245
|
-
type: Boolean,
|
|
246
|
-
default: false,
|
|
247
|
-
},
|
|
248
|
-
});
|
|
249
|
-
const emit = defineEmits<IPickerEmits>();
|
|
142
|
+
const props = defineProps(pickerProps)
|
|
143
|
+
const emit = defineEmits<IPickerEmits>()
|
|
250
144
|
|
|
251
145
|
// 上一次选择的列索引
|
|
252
|
-
const lastIndex = ref([])
|
|
146
|
+
const lastIndex = ref([])
|
|
253
147
|
// 索引值 ,对应picker-view的value
|
|
254
|
-
const innerIndex = ref<any[]>([])
|
|
148
|
+
const innerIndex = ref<any[]>([])
|
|
255
149
|
// 各列的值
|
|
256
|
-
const innerColumns = ref<any[][]>([])
|
|
150
|
+
const innerColumns = ref<any[][]>([])
|
|
257
151
|
// 上一次的变化列索引
|
|
258
|
-
const columnIndex = ref<number>(0)
|
|
259
|
-
const showByClickInput = ref<boolean>(false)
|
|
260
|
-
const currentActiveValue = ref([])
|
|
152
|
+
const columnIndex = ref<number>(0)
|
|
153
|
+
const showByClickInput = ref<boolean>(false)
|
|
154
|
+
const currentActiveValue = ref([]) //当前用户选中,但是还没确认的值,用户没做change操作时候,点击确认可以默认选中第一个
|
|
261
155
|
|
|
262
156
|
/**
|
|
263
157
|
* @description 设置整体各列的columns的值
|
|
264
158
|
* */
|
|
265
159
|
const setColumns = (columns: any[]) => {
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
}
|
|
160
|
+
innerColumns.value = deepClone(columns)
|
|
161
|
+
// 如果在设置各列数据时,没有被设置默认的各列索引defaultIndex,那么用0去填充它,数组长度为列的数量
|
|
162
|
+
if (innerIndex.value.length === 0) {
|
|
163
|
+
innerIndex.value = new Array(columns.length).fill(0)
|
|
164
|
+
}
|
|
165
|
+
}
|
|
272
166
|
|
|
273
167
|
/**
|
|
274
168
|
* @description 监听默认索引的变化,重新设置对应的值
|
|
275
169
|
* */
|
|
276
170
|
watch(
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
)
|
|
171
|
+
() => props.defaultIndex,
|
|
172
|
+
(newValue) => {
|
|
173
|
+
setIndexs(newValue, true)
|
|
174
|
+
}
|
|
175
|
+
)
|
|
282
176
|
|
|
283
177
|
/**
|
|
284
178
|
* @description 监听columns参数的变化
|
|
285
179
|
* */
|
|
286
180
|
watch(
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
)
|
|
181
|
+
() => props.columns,
|
|
182
|
+
(newValue) => {
|
|
183
|
+
setColumns(newValue)
|
|
184
|
+
},
|
|
185
|
+
{ deep: true, immediate: true }
|
|
186
|
+
)
|
|
293
187
|
|
|
294
188
|
/**
|
|
295
189
|
* @description 已选&&已确认的值显示在input上面的文案
|
|
296
190
|
* */
|
|
297
191
|
const inputLabelValue = computed((): string => {
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
//用户确定的值,才显示到输入框
|
|
318
|
-
if (props.modelValue.length && isArray(props.modelValue)) {
|
|
319
|
-
return props.modelValue.join(props.separator);
|
|
192
|
+
let firstItem = innerColumns.value[0] && innerColumns.value[0][0]
|
|
193
|
+
// //区分是不是对象数组
|
|
194
|
+
if (firstItem && Object.prototype.toString.call(firstItem) === '[object Object]') {
|
|
195
|
+
let res: Record<string, any>[] = []
|
|
196
|
+
innerColumns.value.map((ite, i) => {
|
|
197
|
+
res.push(
|
|
198
|
+
...innerColumns.value[i]?.filter((item) => {
|
|
199
|
+
return isArray(props.modelValue) && props.modelValue.includes(item['id'])
|
|
200
|
+
})
|
|
201
|
+
)
|
|
202
|
+
})
|
|
203
|
+
res = res.map((item) => item[props.keyName])
|
|
204
|
+
return res.join(props.separator)
|
|
205
|
+
} else {
|
|
206
|
+
//用户确定的值,才显示到输入框
|
|
207
|
+
if (props.modelValue.length && isArray(props.modelValue)) {
|
|
208
|
+
return props.modelValue.join(props.separator)
|
|
209
|
+
}
|
|
210
|
+
return props.modelValue as string
|
|
320
211
|
}
|
|
321
|
-
|
|
322
|
-
}
|
|
323
|
-
});
|
|
212
|
+
})
|
|
324
213
|
|
|
325
214
|
/**
|
|
326
215
|
* @description 已选,待确认的值
|
|
327
216
|
* */
|
|
328
217
|
const inputValue = computed(() => {
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
res.push(element);
|
|
346
|
-
});
|
|
347
|
-
}
|
|
348
|
-
return res;
|
|
349
|
-
});
|
|
218
|
+
let items = innerColumns.value.map((item, index) => item[innerIndex.value[index]])
|
|
219
|
+
let res: any[] = []
|
|
220
|
+
//区分是不是对象数组
|
|
221
|
+
if (items[0] && Object.prototype.toString.call(items[0]) === '[object Object]') {
|
|
222
|
+
//对象数组返回id集合
|
|
223
|
+
items.forEach((element) => {
|
|
224
|
+
res.push(element && element['id'])
|
|
225
|
+
})
|
|
226
|
+
} else {
|
|
227
|
+
//非对象数组返回元素集合
|
|
228
|
+
items.forEach((element) => {
|
|
229
|
+
res.push(element)
|
|
230
|
+
})
|
|
231
|
+
}
|
|
232
|
+
return res
|
|
233
|
+
})
|
|
350
234
|
|
|
351
235
|
/**
|
|
352
236
|
* @description 显示
|
|
353
237
|
* */
|
|
354
238
|
const onShowByClickInput = () => {
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
}
|
|
239
|
+
if (!props.input?.disabled) {
|
|
240
|
+
showByClickInput.value = !showByClickInput.value
|
|
241
|
+
}
|
|
242
|
+
}
|
|
359
243
|
|
|
360
244
|
/**
|
|
361
245
|
* @description 获取item需要显示的文字,判别为对象还是文本
|
|
362
246
|
* */
|
|
363
247
|
const getItemText = (item: any) => {
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
return item;
|
|
371
|
-
}
|
|
372
|
-
};
|
|
248
|
+
if (Object.prototype.toString.call(item) === '[object Object]' && props.keyName) {
|
|
249
|
+
return item[props.keyName]
|
|
250
|
+
} else {
|
|
251
|
+
return item
|
|
252
|
+
}
|
|
253
|
+
}
|
|
373
254
|
|
|
374
255
|
/**
|
|
375
256
|
* @description 关闭选择器
|
|
376
257
|
* */
|
|
377
258
|
const closeHandler = () => {
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
259
|
+
if (props.closeOnClickOverlay) {
|
|
260
|
+
if (props.hasInput) {
|
|
261
|
+
showByClickInput.value = false
|
|
262
|
+
}
|
|
263
|
+
emit('update:show', false)
|
|
264
|
+
emit('close')
|
|
381
265
|
}
|
|
382
|
-
|
|
383
|
-
emit("close");
|
|
384
|
-
}
|
|
385
|
-
};
|
|
266
|
+
}
|
|
386
267
|
|
|
387
268
|
/**
|
|
388
269
|
* @description 点击工具栏的取消按钮
|
|
389
270
|
* */
|
|
390
271
|
const cancel = () => {
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
}
|
|
272
|
+
if (props.hasInput) {
|
|
273
|
+
showByClickInput.value = false
|
|
274
|
+
}
|
|
275
|
+
emit('update:show', false)
|
|
276
|
+
emit('cancel')
|
|
277
|
+
}
|
|
397
278
|
|
|
398
279
|
/**
|
|
399
280
|
* @description 点击工具栏的确定按钮
|
|
400
281
|
* */
|
|
401
282
|
const onConfirm = () => {
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
283
|
+
//如果用户有没有触发过change
|
|
284
|
+
if (!currentActiveValue.value.length) {
|
|
285
|
+
let arr = [0]
|
|
286
|
+
//如果有默认值&&默认值的数组长度是正确的,就用默认值
|
|
287
|
+
if (
|
|
288
|
+
Array.isArray(props.defaultIndex) &&
|
|
289
|
+
props.defaultIndex.length == innerColumns.value.length
|
|
290
|
+
) {
|
|
291
|
+
arr = [...props.defaultIndex]
|
|
292
|
+
} else {
|
|
293
|
+
//否则默认都选中第一个
|
|
294
|
+
arr = Array(innerColumns.value.length).fill(0)
|
|
295
|
+
}
|
|
296
|
+
setLastIndex(arr)
|
|
297
|
+
setIndexs(arr)
|
|
298
|
+
}
|
|
299
|
+
emit('update:modelValue', inputValue.value)
|
|
300
|
+
if (props.hasInput) {
|
|
301
|
+
showByClickInput.value = false
|
|
414
302
|
}
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
emit("update:show", false);
|
|
423
|
-
emit("confirm", {
|
|
424
|
-
indexs: innerIndex.value,
|
|
425
|
-
value: innerColumns.value.map(
|
|
426
|
-
(item, index) => item[innerIndex.value[index]],
|
|
427
|
-
),
|
|
428
|
-
values: innerColumns.value,
|
|
429
|
-
});
|
|
430
|
-
};
|
|
303
|
+
emit('update:show', false)
|
|
304
|
+
emit('confirm', {
|
|
305
|
+
indexs: innerIndex.value,
|
|
306
|
+
value: innerColumns.value.map((item, index) => item[innerIndex.value[index]]),
|
|
307
|
+
values: innerColumns.value
|
|
308
|
+
})
|
|
309
|
+
}
|
|
431
310
|
|
|
432
311
|
/**
|
|
433
312
|
* @description 选择器某一列的数据发生变化时触发
|
|
434
313
|
* */
|
|
435
314
|
const changeHandler = (e: any) => {
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
315
|
+
const { value } = e.detail
|
|
316
|
+
let index = 0,
|
|
317
|
+
columnI = 0
|
|
318
|
+
//记录用户选中但是还没确认的值
|
|
319
|
+
currentActiveValue.value = value
|
|
320
|
+
// 通过对比前后两次的列索引,得出当前变化的是哪一列
|
|
321
|
+
for (let i = 0; i < value.length; i++) {
|
|
322
|
+
let item = value[i]
|
|
323
|
+
if (item !== (lastIndex.value[i] || 0)) {
|
|
324
|
+
// 把undefined转为合法假值0
|
|
325
|
+
// 设置columnIndex为当前变化列的索引
|
|
326
|
+
columnI = i
|
|
327
|
+
// index则为变化列中的变化项的索引
|
|
328
|
+
index = item
|
|
329
|
+
break // 终止循环,即使少一次循环,也是性能的提升
|
|
330
|
+
}
|
|
451
331
|
}
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
};
|
|
332
|
+
columnIndex.value = columnI
|
|
333
|
+
const values = innerColumns.value
|
|
334
|
+
const params = {
|
|
335
|
+
value: innerColumns.value.map((item, index) => item[value[index]]),
|
|
336
|
+
index,
|
|
337
|
+
indexs: value,
|
|
338
|
+
// values为当前变化列的数组内容
|
|
339
|
+
values,
|
|
340
|
+
columnIndex: columnI
|
|
341
|
+
}
|
|
342
|
+
// 将当前的各项变化索引,设置为"上一次"的索引变化值
|
|
343
|
+
setLastIndex(value)
|
|
344
|
+
setIndexs(value)
|
|
345
|
+
//如果是非自带输入框才会在change时候触发v-model绑值的变化
|
|
346
|
+
//否则会非常的奇怪,用户未确认,值就变了
|
|
347
|
+
if (!props.hasInput) {
|
|
348
|
+
emit('update:modelValue', inputValue.value)
|
|
349
|
+
}
|
|
350
|
+
emit('change', params)
|
|
351
|
+
}
|
|
473
352
|
|
|
474
353
|
/**
|
|
475
354
|
* @description 设置index索引,此方法可被外部调用设置
|
|
476
355
|
* */
|
|
477
356
|
const setIndexs = (index: number[], isSetLastIndex?: boolean) => {
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
}
|
|
357
|
+
innerIndex.value = deepClone(index)
|
|
358
|
+
if (isSetLastIndex) {
|
|
359
|
+
setLastIndex(index)
|
|
360
|
+
}
|
|
361
|
+
}
|
|
483
362
|
|
|
484
363
|
/**
|
|
485
364
|
* @description 记录上一次的各列索引位置
|
|
486
365
|
* */
|
|
487
366
|
const setLastIndex = (index: number[]) => {
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
}
|
|
367
|
+
// 当能进入此方法,意味着当前设置的各列默认索引,即为“上一次”的选中值,需要记录,是因为changeHandler中
|
|
368
|
+
// 需要拿前后的变化值进行对比,得出当前发生改变的是哪一列
|
|
369
|
+
lastIndex.value = deepClone(index)
|
|
370
|
+
}
|
|
492
371
|
|
|
493
372
|
/**
|
|
494
373
|
* @description 设置对应列选项的所有值
|
|
495
374
|
* */
|
|
496
375
|
const setColumnValues = (columnI: number, values: AnyObject[]) => {
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
376
|
+
// 替换innerColumns数组中columnIndex索引的值为values,使用的是数组的splice方法
|
|
377
|
+
innerColumns.value.splice(columnI, 1, values)
|
|
378
|
+
// 替换完成之后将修改列之后的已选值置空
|
|
379
|
+
setLastIndex(innerIndex.value.slice(0, columnI))
|
|
380
|
+
// 拷贝一份原有的innerIndex做临时变量,将大于当前变化列的所有的列的默认索引设置为0
|
|
381
|
+
let tmpIndex = deepClone(innerIndex.value)
|
|
382
|
+
for (let i = 0; i < innerColumns.value.length; i++) {
|
|
383
|
+
if (i > columnIndex.value) {
|
|
384
|
+
tmpIndex[i] = 0
|
|
385
|
+
}
|
|
506
386
|
}
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
};
|
|
387
|
+
// 一次性赋值,不能单个修改,否则无效
|
|
388
|
+
setIndexs(tmpIndex)
|
|
389
|
+
}
|
|
511
390
|
|
|
512
391
|
/**
|
|
513
392
|
* @description 获取对应列的所有选项
|
|
514
393
|
* */
|
|
515
394
|
const getColumnValues = (columnI: number) => {
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
}
|
|
395
|
+
// 进行同步阻塞,因为外部得到change事件之后,可能需要执行setColumnValues更新列的值
|
|
396
|
+
// 索引如果在外部change的回调中调用getColumnValues的话,可能无法得到变更后的列值,这里进行一定延时,保证值的准确性
|
|
397
|
+
;(async () => {
|
|
398
|
+
await sleep()
|
|
399
|
+
})()
|
|
400
|
+
return innerColumns.value[columnI]
|
|
401
|
+
}
|
|
523
402
|
|
|
524
403
|
/**
|
|
525
404
|
* @description 获取各列选中值对应的索引
|
|
526
405
|
* */
|
|
527
406
|
const getIndexs = () => {
|
|
528
|
-
|
|
529
|
-
}
|
|
407
|
+
return innerIndex.value
|
|
408
|
+
}
|
|
530
409
|
|
|
531
410
|
/**
|
|
532
411
|
* @description 获取各列选中的值
|
|
533
412
|
* */
|
|
534
413
|
const getValues = () => {
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
}
|
|
414
|
+
// 进行同步阻塞,因为外部得到change事件之后,可能需要执行setColumnValues更新列的值
|
|
415
|
+
// 索引如果在外部change的回调中调用getValues的话,可能无法得到变更后的列值,这里进行一定延时,保证值的准确性
|
|
416
|
+
;(async () => {
|
|
417
|
+
await sleep()
|
|
418
|
+
})()
|
|
419
|
+
return innerColumns.value.map((item, index) => item[innerIndex.value[index]])
|
|
420
|
+
}
|
|
542
421
|
|
|
543
422
|
defineExpose({
|
|
544
|
-
|
|
545
|
-
})
|
|
423
|
+
setColumnValues
|
|
424
|
+
})
|
|
546
425
|
</script>
|
|
547
426
|
|
|
548
427
|
<style lang="scss" scoped>
|
|
549
|
-
@import
|
|
428
|
+
@import './index.scss';
|
|
550
429
|
</style>
|