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,351 +1,247 @@
|
|
|
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
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
2
|
+
<view class="hy-address-picker">
|
|
3
|
+
<view v-if="hasInput" class="hy-address-picker__has-input" @tap="onShowByClickInput">
|
|
4
|
+
<!-- @slot 自定义输入框 -->
|
|
5
|
+
<slot name="trigger" :value="inputValue">
|
|
6
|
+
<HyInput
|
|
7
|
+
v-model="inputValue"
|
|
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
|
+
></HyInput>
|
|
23
|
+
<view class="input-cover"></view>
|
|
24
|
+
</slot>
|
|
25
|
+
</view>
|
|
26
|
+
<HyPicker
|
|
27
|
+
ref="uPickerRef"
|
|
28
|
+
:show="show || (hasInput && showByClickInput)"
|
|
29
|
+
:popupMode="popupMode"
|
|
30
|
+
:closeOnClickOverlay="closeOnClickOverlay"
|
|
31
|
+
:columns="columns"
|
|
32
|
+
:defaultIndex="defaultIndex"
|
|
33
|
+
:title="title"
|
|
34
|
+
keyName="name"
|
|
35
|
+
:itemHeight="itemHeight"
|
|
36
|
+
:loading="loading"
|
|
37
|
+
:showToolbar="showToolbar"
|
|
38
|
+
:visibleItemCount="visibleItemCount"
|
|
39
|
+
:cancelText="cancelText"
|
|
40
|
+
:cancelColor="cancelColor"
|
|
41
|
+
:confirmColor="confirmColor"
|
|
42
|
+
:toolbarRightSlot="toolbarRightSlot"
|
|
43
|
+
@close="close"
|
|
44
|
+
@cancel="cancel"
|
|
45
|
+
@confirm="confirm"
|
|
46
|
+
@change="change"
|
|
47
|
+
>
|
|
48
|
+
<template #toolbar-right>
|
|
49
|
+
<!-- @slot 工具栏右侧内容,自定义右侧内容,因为微信小程序限制,需要同时设置:toolbarRightSlot="true"生效。 -->
|
|
50
|
+
<slot name="toolbar-right">
|
|
51
|
+
{{ confirmText }}
|
|
52
|
+
</slot>
|
|
53
|
+
</template>
|
|
54
|
+
<template #toolbar-bottom>
|
|
55
|
+
<!-- @slot 工具栏下面内容,自定义底部内容 -->
|
|
56
|
+
<slot name="toolbar-bottom"></slot>
|
|
57
|
+
</template>
|
|
58
|
+
</HyPicker>
|
|
31
59
|
</view>
|
|
32
|
-
<HyPicker
|
|
33
|
-
ref="uPickerRef"
|
|
34
|
-
:show="show || (hasInput && showByClickInput)"
|
|
35
|
-
:popupMode="popupMode"
|
|
36
|
-
:closeOnClickOverlay="closeOnClickOverlay"
|
|
37
|
-
:columns="columns"
|
|
38
|
-
:defaultIndex="defaultIndex"
|
|
39
|
-
:title="title"
|
|
40
|
-
keyName="name"
|
|
41
|
-
:itemHeight="itemHeight"
|
|
42
|
-
:loading="loading"
|
|
43
|
-
:showToolbar="showToolbar"
|
|
44
|
-
:visibleItemCount="visibleItemCount"
|
|
45
|
-
:cancelText="cancelText"
|
|
46
|
-
:cancelColor="cancelColor"
|
|
47
|
-
:confirmColor="confirmColor"
|
|
48
|
-
:toolbarRightSlot="toolbarRightSlot"
|
|
49
|
-
@close="close"
|
|
50
|
-
@cancel="cancel"
|
|
51
|
-
@confirm="confirm"
|
|
52
|
-
@change="change"
|
|
53
|
-
>
|
|
54
|
-
<template #toolbar-right>
|
|
55
|
-
<!-- @slot 工具栏右侧内容,自定义右侧内容,因为微信小程序限制,需要同时设置:toolbarRightSlot="true"生效。 -->
|
|
56
|
-
<slot name="toolbar-right">
|
|
57
|
-
{{ confirmText }}
|
|
58
|
-
</slot>
|
|
59
|
-
</template>
|
|
60
|
-
<template #toolbar-bottom>
|
|
61
|
-
<!-- @slot 工具栏下面内容,自定义底部内容 -->
|
|
62
|
-
<slot name="toolbar-bottom"></slot>
|
|
63
|
-
</template>
|
|
64
|
-
</HyPicker>
|
|
65
|
-
</view>
|
|
66
60
|
</template>
|
|
67
61
|
|
|
68
62
|
<script lang="ts">
|
|
69
63
|
export default {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
}
|
|
64
|
+
name: 'hy-address-picker',
|
|
65
|
+
options: {
|
|
66
|
+
addGlobalClass: true,
|
|
67
|
+
virtualHost: true,
|
|
68
|
+
styleIsolation: 'shared'
|
|
69
|
+
}
|
|
70
|
+
}
|
|
77
71
|
</script>
|
|
78
72
|
|
|
79
73
|
<script setup lang="ts">
|
|
80
|
-
import { onMounted, ref, toRefs } from
|
|
81
|
-
import type {
|
|
82
|
-
import
|
|
83
|
-
import
|
|
84
|
-
import type HyInputProps from "../hy-input/typing";
|
|
74
|
+
import { onMounted, ref, toRefs } from 'vue'
|
|
75
|
+
import type { IAddressPickerEmits } from './typing'
|
|
76
|
+
import address from '../../libs/utils/address.json'
|
|
77
|
+
import addressPickerProps from './props'
|
|
85
78
|
// 组件
|
|
86
|
-
import HyInput from
|
|
87
|
-
import HyPicker from
|
|
79
|
+
import HyInput from '../hy-input/hy-input.vue'
|
|
80
|
+
import HyPicker from '../hy-picker/hy-picker.vue'
|
|
88
81
|
|
|
89
82
|
/**
|
|
90
83
|
* 此选择器用于选择地址
|
|
91
84
|
* @displayName hy-address-picker
|
|
92
85
|
*/
|
|
93
|
-
defineOptions({})
|
|
86
|
+
defineOptions({})
|
|
94
87
|
|
|
95
|
-
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
show: {
|
|
99
|
-
type: Boolean,
|
|
100
|
-
default: false,
|
|
101
|
-
},
|
|
102
|
-
/**
|
|
103
|
-
* 弹出层弹出方向
|
|
104
|
-
* @values top,bottom
|
|
105
|
-
* */
|
|
106
|
-
popupMode: {
|
|
107
|
-
type: String,
|
|
108
|
-
default: "bottom",
|
|
109
|
-
},
|
|
110
|
-
/** 是否显示顶部的操作栏 */
|
|
111
|
-
showToolbar: {
|
|
112
|
-
type: Boolean,
|
|
113
|
-
default: true,
|
|
114
|
-
},
|
|
115
|
-
/** 绑定值 */
|
|
116
|
-
modelValue: {
|
|
117
|
-
type: String,
|
|
118
|
-
required: true,
|
|
119
|
-
},
|
|
120
|
-
/** 顶部标题 */
|
|
121
|
-
title: String,
|
|
122
|
-
/** 字符串截取数组条件 */
|
|
123
|
-
separator: {
|
|
124
|
-
type: String,
|
|
125
|
-
default: " ",
|
|
126
|
-
},
|
|
127
|
-
/** 是否显示加载中状态 */
|
|
128
|
-
loading: {
|
|
129
|
-
type: Boolean,
|
|
130
|
-
default: false,
|
|
131
|
-
},
|
|
132
|
-
/** 各列中,单个选项的高度 */
|
|
133
|
-
itemHeight: {
|
|
134
|
-
type: Number,
|
|
135
|
-
default: 44,
|
|
136
|
-
},
|
|
137
|
-
/** 取消按钮的文字 */
|
|
138
|
-
cancelText: {
|
|
139
|
-
type: String,
|
|
140
|
-
default: "取消",
|
|
141
|
-
},
|
|
142
|
-
/** 确认按钮的文字 */
|
|
143
|
-
confirmText: {
|
|
144
|
-
type: String,
|
|
145
|
-
default: "确认",
|
|
146
|
-
},
|
|
147
|
-
/** 取消按钮的颜色 */
|
|
148
|
-
cancelColor: {
|
|
149
|
-
type: String,
|
|
150
|
-
default: "#909193",
|
|
151
|
-
},
|
|
152
|
-
/** 确认按钮的颜色 */
|
|
153
|
-
confirmColor: {
|
|
154
|
-
type: String,
|
|
155
|
-
default: "#3c9cff",
|
|
156
|
-
},
|
|
157
|
-
/** 每列中可见选项的数量 */
|
|
158
|
-
visibleItemCount: {
|
|
159
|
-
type: Number,
|
|
160
|
-
default: 5,
|
|
161
|
-
},
|
|
162
|
-
/** 是否允许点击遮罩关闭选择器 */
|
|
163
|
-
closeOnClickOverlay: {
|
|
164
|
-
type: Boolean,
|
|
165
|
-
default: false,
|
|
166
|
-
},
|
|
167
|
-
/** 各列的默认索引 */
|
|
168
|
-
defaultIndex: {
|
|
169
|
-
type: Array as PropType<Array<any>>,
|
|
170
|
-
},
|
|
171
|
-
/** 是否显示输入框 */
|
|
172
|
-
hasInput: {
|
|
173
|
-
type: Boolean,
|
|
174
|
-
default: false,
|
|
175
|
-
},
|
|
176
|
-
/** 输入框集合属性 */
|
|
177
|
-
input: {
|
|
178
|
-
type: Object as PropType<HyInputProps>,
|
|
179
|
-
},
|
|
180
|
-
/** 右边插槽 */
|
|
181
|
-
toolbarRightSlot: {
|
|
182
|
-
type: Boolean,
|
|
183
|
-
default: false,
|
|
184
|
-
},
|
|
185
|
-
/** 自定义输入框外部样式 */
|
|
186
|
-
customStyle: {
|
|
187
|
-
type: Object as PropType<CSSProperties>,
|
|
188
|
-
},
|
|
189
|
-
});
|
|
190
|
-
const { show, modelValue, hasInput, input, separator, closeOnClickOverlay } =
|
|
191
|
-
toRefs(props);
|
|
192
|
-
const emit = defineEmits<IAddressPickerEmits>();
|
|
88
|
+
const props = defineProps(addressPickerProps)
|
|
89
|
+
const { show, modelValue, hasInput, input, separator, closeOnClickOverlay } = toRefs(props)
|
|
90
|
+
const emit = defineEmits<IAddressPickerEmits>()
|
|
193
91
|
|
|
194
92
|
// 原来的日期选择器不方便,这里增加一个hasInput选项支持类似element的自带输入框的功能。
|
|
195
|
-
const inputValue = ref<string>(
|
|
196
|
-
const showByClickInput = ref<boolean>(false)
|
|
197
|
-
const columns = ref<any[]>([])
|
|
198
|
-
const uPickerRef = ref<InstanceType<typeof HyPicker> | null>()
|
|
199
|
-
const defaultIndex = ref<number[]>([])
|
|
93
|
+
const inputValue = ref<string>('') // 表单显示值
|
|
94
|
+
const showByClickInput = ref<boolean>(false) // 是否在hasInput模式下显示日期选择
|
|
95
|
+
const columns = ref<any[]>([])
|
|
96
|
+
const uPickerRef = ref<InstanceType<typeof HyPicker> | null>()
|
|
97
|
+
const defaultIndex = ref<number[]>([])
|
|
200
98
|
|
|
201
99
|
function normalizeCityName(city: string) {
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
100
|
+
// 定义常见的后缀
|
|
101
|
+
const suffixes = ['市', '省', '自治区', '特别行政区', '县', '区']
|
|
102
|
+
suffixes.forEach((suffix) => {
|
|
103
|
+
if (city.endsWith(suffix)) {
|
|
104
|
+
city = city.slice(0, -suffix.length)
|
|
105
|
+
}
|
|
106
|
+
})
|
|
107
|
+
return city
|
|
210
108
|
}
|
|
211
109
|
/**
|
|
212
110
|
* @description 判断城市是否相等
|
|
213
111
|
* */
|
|
214
112
|
const areCitiesEqual = (city1: string, city2: string) => {
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
}
|
|
113
|
+
const normalizedCity1 = normalizeCityName(city1)
|
|
114
|
+
const normalizedCity2 = normalizeCityName(city2)
|
|
115
|
+
return normalizedCity1 === normalizedCity2
|
|
116
|
+
}
|
|
219
117
|
/**
|
|
220
118
|
* @description 更新各列的值
|
|
221
119
|
* */
|
|
222
120
|
const updateColumnValue = (value: string) => {
|
|
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
|
-
columns.value = [provinceData, cityData, areaData];
|
|
262
|
-
};
|
|
121
|
+
let provinceIndex, cityIndex, countyIndex
|
|
122
|
+
// 判断是初始化有数据就找到对应索引,无数据默认索引为0
|
|
123
|
+
if (value) {
|
|
124
|
+
const addressArr = value.split(separator.value)
|
|
125
|
+
// 查出省索引
|
|
126
|
+
provinceIndex = address.findIndex((item) => areCitiesEqual(item.name, addressArr[0]))
|
|
127
|
+
// 查出市索引
|
|
128
|
+
cityIndex = address[provinceIndex].areas.findIndex((item) =>
|
|
129
|
+
areCitiesEqual(item.name, addressArr[1])
|
|
130
|
+
)
|
|
131
|
+
|
|
132
|
+
// 查出县/区索引
|
|
133
|
+
countyIndex = address[provinceIndex].areas[cityIndex].areas.findIndex((item) =>
|
|
134
|
+
areCitiesEqual(item.name, addressArr[2])
|
|
135
|
+
)
|
|
136
|
+
} else {
|
|
137
|
+
provinceIndex = 0
|
|
138
|
+
cityIndex = 0
|
|
139
|
+
countyIndex = 0
|
|
140
|
+
}
|
|
141
|
+
// 省级数组
|
|
142
|
+
const provinceData = address.map((item) => ({
|
|
143
|
+
name: item.name,
|
|
144
|
+
code: item.code
|
|
145
|
+
}))
|
|
146
|
+
// 市级数组
|
|
147
|
+
const cityData = address[provinceIndex].areas.map((item) => ({
|
|
148
|
+
name: item.name,
|
|
149
|
+
code: item.code
|
|
150
|
+
}))
|
|
151
|
+
// 县/区级数组
|
|
152
|
+
const areaData = address[provinceIndex].areas[cityIndex].areas
|
|
153
|
+
|
|
154
|
+
// 默认索引
|
|
155
|
+
defaultIndex.value = [provinceIndex, cityIndex, countyIndex]
|
|
156
|
+
// 列表
|
|
157
|
+
columns.value = [provinceData, cityData, areaData]
|
|
158
|
+
}
|
|
263
159
|
|
|
264
160
|
const init = () => {
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
}
|
|
161
|
+
// 获取当前值
|
|
162
|
+
inputValue.value = modelValue.value
|
|
163
|
+
// 更新列表
|
|
164
|
+
updateColumnValue(modelValue.value)
|
|
165
|
+
}
|
|
270
166
|
|
|
271
167
|
onMounted(() => {
|
|
272
|
-
|
|
273
|
-
})
|
|
168
|
+
init()
|
|
169
|
+
})
|
|
274
170
|
|
|
275
171
|
/**
|
|
276
172
|
* @description 关闭选择器
|
|
277
173
|
* */
|
|
278
174
|
const close = () => {
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
175
|
+
if (closeOnClickOverlay.value) {
|
|
176
|
+
if (hasInput.value) {
|
|
177
|
+
showByClickInput.value = false
|
|
178
|
+
}
|
|
179
|
+
emit('close')
|
|
282
180
|
}
|
|
283
|
-
|
|
284
|
-
}
|
|
285
|
-
};
|
|
181
|
+
}
|
|
286
182
|
|
|
287
183
|
/**
|
|
288
184
|
* @description 点击工具栏的取消按钮
|
|
289
185
|
* */
|
|
290
186
|
const cancel = () => {
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
}
|
|
187
|
+
if (hasInput.value) {
|
|
188
|
+
showByClickInput.value = false
|
|
189
|
+
}
|
|
190
|
+
emit('cancel')
|
|
191
|
+
}
|
|
296
192
|
|
|
297
193
|
/**
|
|
298
194
|
* @description 点击工具栏的确定按钮
|
|
299
195
|
* */
|
|
300
196
|
const confirm = ({ value }: { value: Record<string, any>[] }) => {
|
|
301
|
-
|
|
197
|
+
inputValue.value = value.map((item) => item.name).join(separator.value)
|
|
302
198
|
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
}
|
|
199
|
+
showByClickInput.value = false
|
|
200
|
+
emit('update:modelValue', inputValue.value)
|
|
201
|
+
emit('confirm', {
|
|
202
|
+
value: inputValue.value
|
|
203
|
+
})
|
|
204
|
+
}
|
|
309
205
|
|
|
310
206
|
/**
|
|
311
207
|
* @description 列发生变化时触发
|
|
312
208
|
* */
|
|
313
209
|
const change = (e: any) => {
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
210
|
+
const { columnIndex, index, indexs } = e
|
|
211
|
+
//如果改变的是第一列
|
|
212
|
+
if (columnIndex === 0) {
|
|
213
|
+
const children1 = address[index].areas.map((item) => {
|
|
214
|
+
return { name: item.name, code: item.code }
|
|
215
|
+
})
|
|
216
|
+
uPickerRef.value?.setColumnValues(1, children1)
|
|
217
|
+
//更换 第二列数据
|
|
218
|
+
const children2 = address[index].areas[indexs[1]].areas.map((item) => ({
|
|
219
|
+
...item
|
|
220
|
+
}))
|
|
221
|
+
uPickerRef.value?.setColumnValues(2, children2)
|
|
222
|
+
//更换 第三列数据
|
|
223
|
+
}
|
|
224
|
+
if (columnIndex === 1) {
|
|
225
|
+
//如果改变的是第二列
|
|
226
|
+
const children3 = address[indexs[0]].areas[indexs[1]].areas.map((item) => ({
|
|
227
|
+
...item
|
|
228
|
+
}))
|
|
229
|
+
uPickerRef.value?.setColumnValues(2, children3)
|
|
230
|
+
}
|
|
335
231
|
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
}
|
|
232
|
+
// 发出change时间,value为当前选中的时间戳
|
|
233
|
+
emit('change', {
|
|
234
|
+
...e
|
|
235
|
+
})
|
|
236
|
+
}
|
|
341
237
|
|
|
342
238
|
const onShowByClickInput = () => {
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
}
|
|
239
|
+
if (!props.input?.disabled) {
|
|
240
|
+
showByClickInput.value = !showByClickInput.value
|
|
241
|
+
}
|
|
242
|
+
}
|
|
347
243
|
</script>
|
|
348
244
|
|
|
349
245
|
<style lang="scss" scoped>
|
|
350
|
-
@import
|
|
246
|
+
@import './index.scss';
|
|
351
247
|
</style>
|
|
@@ -1,24 +1,100 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type { CSSProperties, PropType } from "vue";
|
|
2
|
+
import type HyInputProps from "../hy-input/typing";
|
|
2
3
|
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
4
|
+
const addressPickerProps = {
|
|
5
|
+
/** 用于控制选择器的弹出和收起 */
|
|
6
|
+
show: {
|
|
7
|
+
type: Boolean,
|
|
8
|
+
default: false,
|
|
9
|
+
},
|
|
10
|
+
/**
|
|
11
|
+
* 弹出层弹出方向
|
|
12
|
+
* @values top,bottom
|
|
13
|
+
* */
|
|
14
|
+
popupMode: {
|
|
15
|
+
type: String,
|
|
16
|
+
default: "bottom",
|
|
17
|
+
},
|
|
18
|
+
/** 是否显示顶部的操作栏 */
|
|
19
|
+
showToolbar: {
|
|
20
|
+
type: Boolean,
|
|
21
|
+
default: true,
|
|
22
|
+
},
|
|
23
|
+
/** 绑定值 */
|
|
24
|
+
modelValue: {
|
|
25
|
+
type: String,
|
|
26
|
+
default: "",
|
|
27
|
+
required: true,
|
|
28
|
+
},
|
|
29
|
+
/** 顶部标题 */
|
|
30
|
+
title: String,
|
|
31
|
+
/** 字符串截取数组条件 */
|
|
32
|
+
separator: {
|
|
33
|
+
type: String,
|
|
34
|
+
default: " ",
|
|
35
|
+
},
|
|
36
|
+
/** 是否显示加载中状态 */
|
|
37
|
+
loading: {
|
|
38
|
+
type: Boolean,
|
|
39
|
+
default: false,
|
|
40
|
+
},
|
|
41
|
+
/** 各列中,单个选项的高度 */
|
|
42
|
+
itemHeight: {
|
|
43
|
+
type: Number,
|
|
44
|
+
default: 44,
|
|
45
|
+
},
|
|
46
|
+
/** 取消按钮的文字 */
|
|
47
|
+
cancelText: {
|
|
48
|
+
type: String,
|
|
49
|
+
default: "取消",
|
|
50
|
+
},
|
|
51
|
+
/** 确认按钮的文字 */
|
|
52
|
+
confirmText: {
|
|
53
|
+
type: String,
|
|
54
|
+
default: "确认",
|
|
55
|
+
},
|
|
56
|
+
/** 取消按钮的颜色 */
|
|
57
|
+
cancelColor: {
|
|
58
|
+
type: String,
|
|
59
|
+
default: "#909193",
|
|
60
|
+
},
|
|
61
|
+
/** 确认按钮的颜色 */
|
|
62
|
+
confirmColor: {
|
|
63
|
+
type: String,
|
|
64
|
+
default: "#3c9cff",
|
|
65
|
+
},
|
|
66
|
+
/** 每列中可见选项的数量 */
|
|
67
|
+
visibleItemCount: {
|
|
68
|
+
type: Number,
|
|
69
|
+
default: 5,
|
|
70
|
+
},
|
|
71
|
+
/** 是否允许点击遮罩关闭选择器 */
|
|
72
|
+
closeOnClickOverlay: {
|
|
73
|
+
type: Boolean,
|
|
74
|
+
default: false,
|
|
75
|
+
},
|
|
76
|
+
/** 各列的默认索引 */
|
|
77
|
+
defaultIndex: {
|
|
78
|
+
type: Array as PropType<Array<any>>,
|
|
79
|
+
},
|
|
80
|
+
/** 是否显示输入框 */
|
|
81
|
+
hasInput: {
|
|
82
|
+
type: Boolean,
|
|
83
|
+
default: false,
|
|
84
|
+
},
|
|
85
|
+
/** 输入框集合属性 */
|
|
86
|
+
input: {
|
|
87
|
+
type: Object as PropType<HyInputProps>,
|
|
88
|
+
},
|
|
89
|
+
/** 右边插槽 */
|
|
90
|
+
toolbarRightSlot: {
|
|
91
|
+
type: Boolean,
|
|
92
|
+
default: false,
|
|
93
|
+
},
|
|
94
|
+
/** 自定义输入框外部样式 */
|
|
95
|
+
customStyle: {
|
|
96
|
+
type: Object as PropType<CSSProperties>,
|
|
97
|
+
},
|
|
22
98
|
};
|
|
23
99
|
|
|
24
|
-
export default
|
|
100
|
+
export default addressPickerProps;
|