hy-app 0.1.1

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