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