hy-app 0.4.15 → 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.
Files changed (206) hide show
  1. package/components/hy-action-sheet/hy-action-sheet.vue +155 -238
  2. package/components/hy-action-sheet/props.ts +68 -15
  3. package/components/hy-action-sheet/typing.d.ts +115 -115
  4. package/components/hy-address-picker/hy-address-picker.vue +185 -289
  5. package/components/hy-address-picker/props.ts +97 -21
  6. package/components/hy-address-picker/typing.d.ts +90 -89
  7. package/components/hy-avatar/hy-avatar.vue +121 -204
  8. package/components/hy-avatar/props.ts +76 -18
  9. package/components/hy-avatar/typing.d.ts +63 -62
  10. package/components/hy-back-top/hy-back-top.vue +65 -120
  11. package/components/hy-back-top/props.ts +57 -16
  12. package/components/hy-back-top/typing.d.ts +43 -42
  13. package/components/hy-badge/hy-badge.vue +66 -138
  14. package/components/hy-badge/props.ts +73 -17
  15. package/components/hy-badge/typing.d.ts +59 -58
  16. package/components/hy-button/hy-button.vue +226 -375
  17. package/components/hy-button/props.ts +129 -158
  18. package/components/hy-calendar/header.vue +48 -64
  19. package/components/hy-calendar/hy-calendar.vue +274 -438
  20. package/components/hy-calendar/month.vue +508 -516
  21. package/components/hy-calendar/props.ts +157 -35
  22. package/components/hy-calendar/typing.d.ts +129 -128
  23. package/components/hy-card/hy-card.vue +118 -240
  24. package/components/hy-card/index.scss +1 -2
  25. package/components/hy-card/props.ts +122 -27
  26. package/components/hy-card/typing.d.ts +119 -118
  27. package/components/hy-cell/hy-cell.vue +176 -258
  28. package/components/hy-cell/props.ts +71 -17
  29. package/components/hy-cell/typing.d.ts +87 -86
  30. package/components/hy-check-button/hy-check-button.vue +69 -139
  31. package/components/hy-check-button/props.ts +72 -18
  32. package/components/hy-check-button/typing.d.ts +74 -73
  33. package/components/hy-checkbox/hy-checkbox.vue +170 -263
  34. package/components/hy-checkbox/props.ts +94 -24
  35. package/components/hy-checkbox/typing.d.ts +72 -72
  36. package/components/hy-checkbox-group/hy-checkbox-group.vue +25 -100
  37. package/components/hy-checkbox-group/props.ts +80 -0
  38. package/components/hy-checkbox-group/typing.d.ts +65 -65
  39. package/components/hy-checkbox-item/hy-checkbox-item.vue +140 -177
  40. package/components/hy-checkbox-item/props.ts +24 -0
  41. package/components/hy-checkbox-item/typing.d.ts +4 -3
  42. package/components/hy-code-input/hy-code-input.vue +179 -262
  43. package/components/hy-code-input/props.ts +84 -18
  44. package/components/hy-code-input/typing.d.ts +71 -71
  45. package/components/hy-config-provider/hy-config-provider.vue +28 -50
  46. package/components/hy-config-provider/props.ts +26 -11
  47. package/components/hy-config-provider/typing.d.ts +20 -20
  48. package/components/hy-count-down/hy-count-down.vue +103 -131
  49. package/components/hy-count-down/props.ts +30 -8
  50. package/components/hy-count-down/typing.d.ts +25 -25
  51. package/components/hy-count-to/hy-count-to.vue +148 -213
  52. package/components/hy-count-to/props.ts +60 -15
  53. package/components/hy-count-to/typing.d.ts +46 -46
  54. package/components/hy-coupon/hy-coupon.vue +10 -5
  55. package/components/hy-coupon/index.scss +148 -64
  56. package/components/hy-coupon/props.ts +35 -50
  57. package/components/hy-coupon/typing.d.ts +10 -0
  58. package/components/hy-datetime-picker/hy-datetime-picker.vue +415 -580
  59. package/components/hy-datetime-picker/props.ts +142 -32
  60. package/components/hy-datetime-picker/typing.d.ts +132 -132
  61. package/components/hy-divider/hy-divider.vue +90 -169
  62. package/components/hy-divider/props.ts +78 -19
  63. package/components/hy-divider/typing.d.ts +60 -60
  64. package/components/hy-dropdown/hy-dropdown.vue +37 -71
  65. package/components/hy-dropdown/props.ts +38 -15
  66. package/components/hy-dropdown/typing.d.ts +44 -44
  67. package/components/hy-dropdown-item/hy-dropdown-item.vue +141 -173
  68. package/components/hy-dropdown-item/props.ts +19 -8
  69. package/components/hy-empty/hy-empty.vue +75 -129
  70. package/components/hy-empty/props.ts +57 -15
  71. package/components/hy-empty/typing.d.ts +84 -84
  72. package/components/hy-flex/hy-flex.vue +33 -88
  73. package/components/hy-flex/props.ts +58 -0
  74. package/components/hy-flex/typing.d.ts +14 -16
  75. package/components/hy-float-button/hy-float-button.vue +289 -406
  76. package/components/hy-float-button/props.ts +109 -25
  77. package/components/hy-folding-panel/hy-folding-panel.vue +74 -114
  78. package/components/hy-folding-panel/props.ts +42 -0
  79. package/components/hy-folding-panel/typing.d.ts +57 -57
  80. package/components/hy-folding-panel-item/hy-folding-panel-item.vue +139 -231
  81. package/components/hy-folding-panel-item/props.ts +81 -0
  82. package/components/hy-folding-panel-item/typing.d.ts +23 -23
  83. package/components/hy-form/hy-form.vue +172 -212
  84. package/components/hy-form/props.ts +37 -0
  85. package/components/hy-form/typing.d.ts +68 -61
  86. package/components/hy-form-group/typing.d.ts +74 -74
  87. package/components/hy-form-item/hy-form-item.vue +100 -129
  88. package/components/hy-form-item/props.ts +25 -0
  89. package/components/hy-form-item/typing.d.ts +40 -37
  90. package/components/hy-grid/hy-grid.vue +76 -132
  91. package/components/hy-grid/props.ts +58 -16
  92. package/components/hy-grid/typing.d.ts +66 -66
  93. package/components/hy-icon/hy-icon.vue +84 -161
  94. package/components/hy-icon/props.ts +76 -22
  95. package/components/hy-icon/typing.d.ts +83 -82
  96. package/components/hy-image/hy-image.vue +142 -272
  97. package/components/hy-image/props.ts +105 -23
  98. package/components/hy-image/typing.d.ts +84 -87
  99. package/components/hy-input/hy-input.vue +230 -421
  100. package/components/hy-input/props.ts +183 -35
  101. package/components/hy-input/typing.d.ts +169 -169
  102. package/components/hy-line/hy-line.vue +34 -72
  103. package/components/hy-line/props.ts +41 -10
  104. package/components/hy-line/typing.d.ts +29 -29
  105. package/components/hy-line-progress/hy-line-progress.vue +66 -101
  106. package/components/hy-line-progress/props.ts +31 -10
  107. package/components/hy-line-progress/typing.d.ts +29 -29
  108. package/components/hy-list/hy-list.vue +151 -220
  109. package/components/hy-list/props.ts +67 -16
  110. package/components/hy-list/typing.d.ts +52 -52
  111. package/components/hy-loading/hy-loading.vue +63 -119
  112. package/components/hy-loading/props.ts +63 -15
  113. package/components/hy-loading/typing.d.ts +49 -49
  114. package/components/hy-menu/hy-menu.vue +124 -166
  115. package/components/hy-menu/props.ts +42 -10
  116. package/components/hy-menu/typing.d.ts +60 -60
  117. package/components/hy-modal/hy-modal.vue +127 -218
  118. package/components/hy-modal/props.ts +89 -24
  119. package/components/hy-navbar/hy-navbar.vue +104 -177
  120. package/components/hy-navbar/props.ts +76 -22
  121. package/components/hy-navbar/typing.d.ts +81 -81
  122. package/components/hy-notice-bar/hy-notice-bar.vue +67 -144
  123. package/components/hy-notice-bar/props.ts +80 -19
  124. package/components/hy-notice-bar/typing.d.ts +62 -62
  125. package/components/hy-notify/hy-notify.vue +128 -177
  126. package/components/hy-notify/props.ts +49 -12
  127. package/components/hy-notify/typing.d.ts +45 -41
  128. package/components/hy-number-step/hy-number-step.vue +281 -394
  129. package/components/hy-number-step/props.ts +110 -27
  130. package/components/hy-number-step/typing.d.ts +120 -120
  131. package/components/hy-overlay/hy-overlay.vue +39 -66
  132. package/components/hy-overlay/props.ts +31 -8
  133. package/components/hy-pagination/hy-pagination.vue +100 -155
  134. package/components/hy-pagination/props.ts +53 -13
  135. package/components/hy-picker/hy-picker.vue +309 -430
  136. package/components/hy-picker/index.scss +8 -12
  137. package/components/hy-picker/props.ts +110 -26
  138. package/components/hy-popover/hy-popover.vue +190 -252
  139. package/components/hy-popover/props.ts +48 -10
  140. package/components/hy-popup/hy-popup.vue +162 -248
  141. package/components/hy-popup/props.ts +82 -18
  142. package/components/hy-price/hy-price.vue +45 -104
  143. package/components/hy-price/props.ts +52 -12
  144. package/components/hy-price/typing.d.ts +41 -36
  145. package/components/hy-qrcode/hy-qrcode.vue +115 -185
  146. package/components/hy-qrcode/props.ts +68 -18
  147. package/components/hy-qrcode/typing.d.ts +67 -66
  148. package/components/hy-radio/hy-radio.vue +161 -259
  149. package/components/hy-radio/props.ts +95 -25
  150. package/components/hy-radio/typing.d.ts +85 -84
  151. package/components/hy-rate/hy-rate.vue +185 -270
  152. package/components/hy-rate/props.ts +76 -18
  153. package/components/hy-rate/typing.d.ts +61 -60
  154. package/components/hy-read-more/hy-read-more.vue +93 -136
  155. package/components/hy-read-more/props.ts +43 -13
  156. package/components/hy-scroll-list/hy-scroll-list.vue +81 -102
  157. package/components/hy-scroll-list/props.ts +22 -11
  158. package/components/hy-search/hy-search.vue +155 -284
  159. package/components/hy-search/props.ts +130 -25
  160. package/components/hy-signature/hy-signature.vue +491 -635
  161. package/components/hy-signature/props.ts +115 -26
  162. package/components/hy-signature/typing.d.ts +138 -138
  163. package/components/hy-slider/hy-slider.vue +388 -477
  164. package/components/hy-slider/props.ts +75 -19
  165. package/components/hy-steps/hy-steps.vue +212 -279
  166. package/components/hy-steps/props.ts +47 -13
  167. package/components/hy-submit-bar/hy-submit-bar.vue +136 -221
  168. package/components/hy-submit-bar/props.ts +89 -20
  169. package/components/hy-submit-bar/typing.d.ts +87 -87
  170. package/components/hy-subsection/hy-subsection.vue +132 -185
  171. package/components/hy-subsection/props.ts +50 -17
  172. package/components/hy-subsection/typing.d.ts +52 -52
  173. package/components/hy-swipe-action/hy-swipe-action.vue +228 -283
  174. package/components/hy-swipe-action/props.ts +43 -18
  175. package/components/hy-swipe-action/typing.d.ts +46 -46
  176. package/components/hy-swiper/hy-swiper.vue +159 -286
  177. package/components/hy-swiper/props.ts +126 -28
  178. package/components/hy-swiper/typing.d.ts +115 -115
  179. package/components/hy-switch/hy-switch.vue +112 -176
  180. package/components/hy-switch/props.ts +60 -15
  181. package/components/hy-switch/typing.d.ts +63 -63
  182. package/components/hy-tabBar/hy-tabBar.vue +64 -60
  183. package/components/hy-tabs/hy-tabs.vue +277 -380
  184. package/components/hy-tabs/props.ts +75 -18
  185. package/components/hy-tag/hy-tag.vue +111 -204
  186. package/components/hy-tag/props.ts +81 -19
  187. package/components/hy-text/hy-text.vue +200 -322
  188. package/components/hy-text/props.ts +107 -28
  189. package/components/hy-textarea/hy-textarea.vue +147 -256
  190. package/components/hy-textarea/props.ts +112 -25
  191. package/components/hy-textarea/typing.d.ts +42 -42
  192. package/components/hy-toast/hy-toast.vue +135 -143
  193. package/components/hy-tooltip/hy-tooltip.vue +220 -306
  194. package/components/hy-tooltip/props.ts +79 -15
  195. package/components/hy-transition/hy-transition.vue +111 -138
  196. package/components/hy-transition/props.ts +30 -8
  197. package/components/hy-upload/hy-upload.vue +320 -469
  198. package/components/hy-upload/props.ts +130 -27
  199. package/components/hy-warn/hy-warn.vue +80 -129
  200. package/components/hy-warn/props.ts +47 -12
  201. package/components/hy-waterfall/hy-waterfall.vue +139 -163
  202. package/components/hy-waterfall/props.ts +19 -7
  203. package/components/hy-watermark/hy-watermark.vue +762 -870
  204. package/components/hy-watermark/props.ts +103 -22
  205. package/package.json +2 -2
  206. package/web-types.json +1 -1
@@ -1,351 +1,247 @@
1
1
  <template>
2
- <view class="hy-address-picker">
3
- <view
4
- v-if="hasInput"
5
- class="hy-address-picker__has-input"
6
- @tap="onShowByClickInput"
7
- >
8
- <!-- @slot 自定义输入框 -->
9
- <slot name="trigger" :value="inputValue">
10
- <HyInput
11
- v-model="inputValue"
12
- :readonly="true"
13
- :disabled="input?.disabled"
14
- :disabledColor="input?.disabledColor"
15
- :shape="input?.shape"
16
- :border="input?.border"
17
- :prefixIcon="input?.prefixIcon"
18
- :suffixIcon="input?.suffixIcon"
19
- :color="input?.color"
20
- :fontSize="input?.fontSize"
21
- :inputAlign="input?.inputAlign"
22
- :placeholder="input?.placeholder || '请选择地址'"
23
- :placeholderStyle="input?.placeholderStyle"
24
- :placeholderClass="input?.placeholderClass"
25
- :customStyle="
26
- Object.assign({ 'pointer-events': 'none' }, input?.customStyle)
27
- "
28
- ></HyInput>
29
- <view class="input-cover"></view>
30
- </slot>
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
- name: "hy-address-picker",
71
- options: {
72
- addGlobalClass: true,
73
- virtualHost: true,
74
- styleIsolation: "shared",
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 "vue";
81
- import type { PropType, CSSProperties } from "vue";
82
- import type { IAddressPickerEmits } from "./typing";
83
- import address from "../../libs/utils/address.json";
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 "../hy-input/hy-input.vue";
87
- import HyPicker from "../hy-picker/hy-picker.vue";
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
- // const props = withDefaults(defineProps<IProps>(), defaultProps)
96
- const props = defineProps({
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); // 是否在hasInput模式下显示日期选择
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
- const suffixes = ["", "", "自治区", "特别行政区", "", ""];
204
- suffixes.forEach((suffix) => {
205
- if (city.endsWith(suffix)) {
206
- city = city.slice(0, -suffix.length);
207
- }
208
- });
209
- return city;
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
- const normalizedCity1 = normalizeCityName(city1);
216
- const normalizedCity2 = normalizeCityName(city2);
217
- return normalizedCity1 === normalizedCity2;
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
- let provinceIndex, cityIndex, countyIndex;
224
- // 判断是初始化有数据就找到对应索引,无数据默认索引为0
225
- if (value) {
226
- const addressArr = value.split(separator.value);
227
- // 查出省索引
228
- provinceIndex = address.findIndex((item) =>
229
- areCitiesEqual(item.name, addressArr[0]),
230
- );
231
- // 查出市索引
232
- cityIndex = address[provinceIndex].areas.findIndex((item) =>
233
- areCitiesEqual(item.name, addressArr[1]),
234
- );
235
-
236
- // 查出县/区索引
237
- countyIndex = address[provinceIndex].areas[cityIndex].areas.findIndex(
238
- (item) => areCitiesEqual(item.name, addressArr[2]),
239
- );
240
- } else {
241
- provinceIndex = 0;
242
- cityIndex = 0;
243
- countyIndex = 0;
244
- }
245
- // 省级数组
246
- const provinceData = address.map((item) => ({
247
- name: item.name,
248
- code: item.code,
249
- }));
250
- // 市级数组
251
- const cityData = address[provinceIndex].areas.map((item) => ({
252
- name: item.name,
253
- code: item.code,
254
- }));
255
- // 县/区级数组
256
- const areaData = address[provinceIndex].areas[cityIndex].areas;
257
-
258
- // 默认索引
259
- defaultIndex.value = [provinceIndex, cityIndex, countyIndex];
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
- inputValue.value = modelValue.value;
267
- // 更新列表
268
- updateColumnValue(modelValue.value);
269
- };
161
+ // 获取当前值
162
+ inputValue.value = modelValue.value
163
+ // 更新列表
164
+ updateColumnValue(modelValue.value)
165
+ }
270
166
 
271
167
  onMounted(() => {
272
- init();
273
- });
168
+ init()
169
+ })
274
170
 
275
171
  /**
276
172
  * @description 关闭选择器
277
173
  * */
278
174
  const close = () => {
279
- if (closeOnClickOverlay.value) {
280
- if (hasInput.value) {
281
- showByClickInput.value = false;
175
+ if (closeOnClickOverlay.value) {
176
+ if (hasInput.value) {
177
+ showByClickInput.value = false
178
+ }
179
+ emit('close')
282
180
  }
283
- emit("close");
284
- }
285
- };
181
+ }
286
182
 
287
183
  /**
288
184
  * @description 点击工具栏的取消按钮
289
185
  * */
290
186
  const cancel = () => {
291
- if (hasInput.value) {
292
- showByClickInput.value = false;
293
- }
294
- emit("cancel");
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
- inputValue.value = value.map((item) => item.name).join(separator.value);
197
+ inputValue.value = value.map((item) => item.name).join(separator.value)
302
198
 
303
- showByClickInput.value = false;
304
- emit("update:modelValue", inputValue.value);
305
- emit("confirm", {
306
- value: inputValue.value,
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
- const { columnIndex, index, indexs } = e;
315
- //如果改变的是第一列
316
- if (columnIndex === 0) {
317
- const children1 = address[index].areas.map((item) => {
318
- return { name: item.name, code: item.code };
319
- });
320
- uPickerRef.value?.setColumnValues(1, children1);
321
- //更换 第二列数据
322
- const children2 = address[index].areas[indexs[1]].areas.map((item) => ({
323
- ...item,
324
- }));
325
- uPickerRef.value?.setColumnValues(2, children2);
326
- //更换 第三列数据
327
- }
328
- if (columnIndex === 1) {
329
- //如果改变的是第二列
330
- const children3 = address[indexs[0]].areas[indexs[1]].areas.map((item) => ({
331
- ...item,
332
- }));
333
- uPickerRef.value?.setColumnValues(2, children3);
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
- // 发出change时间,value为当前选中的时间戳
337
- emit("change", {
338
- ...e,
339
- });
340
- };
232
+ // 发出change时间,value为当前选中的时间戳
233
+ emit('change', {
234
+ ...e
235
+ })
236
+ }
341
237
 
342
238
  const onShowByClickInput = () => {
343
- if (!props.input?.disabled) {
344
- showByClickInput.value = !showByClickInput.value;
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 "./index.scss";
246
+ @import './index.scss';
351
247
  </style>
@@ -1,24 +1,100 @@
1
- import type IProps from "./typing";
1
+ import type { CSSProperties, PropType } from "vue";
2
+ import type HyInputProps from "../hy-input/typing";
2
3
 
3
- const defaultProps: IProps = {
4
- show: false,
5
- popupMode: "bottom",
6
- showToolbar: true,
7
- modelValue: "",
8
- title: "",
9
- separator: " ",
10
- loading: false,
11
- itemHeight: 44,
12
- cancelText: "取消",
13
- confirmText: "确认",
14
- cancelColor: "#909193",
15
- confirmColor: "#3c9cff",
16
- visibleItemCount: 5,
17
- closeOnClickOverlay: false,
18
- defaultIndex: [],
19
- hasInput: false,
20
- input: {},
21
- toolbarRightSlot: false,
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 defaultProps;
100
+ export default addressPickerProps;