hy-app 0.3.1 → 0.3.2

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