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.
Files changed (211) 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/README.md +133 -0
  55. package/components/hy-coupon/hy-coupon.vue +180 -0
  56. package/components/hy-coupon/index.scss +553 -0
  57. package/components/hy-coupon/props.ts +129 -0
  58. package/components/hy-coupon/typing.d.ts +146 -0
  59. package/components/hy-datetime-picker/hy-datetime-picker.vue +415 -580
  60. package/components/hy-datetime-picker/props.ts +142 -32
  61. package/components/hy-datetime-picker/typing.d.ts +132 -132
  62. package/components/hy-divider/hy-divider.vue +90 -169
  63. package/components/hy-divider/props.ts +78 -19
  64. package/components/hy-divider/typing.d.ts +60 -60
  65. package/components/hy-dropdown/hy-dropdown.vue +37 -71
  66. package/components/hy-dropdown/props.ts +38 -15
  67. package/components/hy-dropdown/typing.d.ts +44 -44
  68. package/components/hy-dropdown-item/hy-dropdown-item.vue +141 -173
  69. package/components/hy-dropdown-item/props.ts +19 -8
  70. package/components/hy-empty/hy-empty.vue +75 -129
  71. package/components/hy-empty/props.ts +57 -15
  72. package/components/hy-empty/typing.d.ts +84 -84
  73. package/components/hy-flex/hy-flex.vue +33 -88
  74. package/components/hy-flex/props.ts +58 -0
  75. package/components/hy-flex/typing.d.ts +14 -16
  76. package/components/hy-float-button/hy-float-button.vue +289 -406
  77. package/components/hy-float-button/props.ts +109 -25
  78. package/components/hy-folding-panel/hy-folding-panel.vue +86 -374
  79. package/components/hy-folding-panel/props.ts +40 -15
  80. package/components/hy-folding-panel/typing.d.ts +52 -63
  81. package/components/hy-folding-panel-item/hy-folding-panel-item.vue +186 -228
  82. package/components/hy-folding-panel-item/index.scss +87 -0
  83. package/components/hy-folding-panel-item/props.ts +81 -0
  84. package/components/hy-folding-panel-item/typing.d.ts +23 -0
  85. package/components/hy-form/hy-form.vue +172 -212
  86. package/components/hy-form/props.ts +37 -0
  87. package/components/hy-form/typing.d.ts +68 -61
  88. package/components/hy-form-group/typing.d.ts +74 -74
  89. package/components/hy-form-item/hy-form-item.vue +100 -129
  90. package/components/hy-form-item/props.ts +25 -0
  91. package/components/hy-form-item/typing.d.ts +40 -37
  92. package/components/hy-grid/hy-grid.vue +76 -132
  93. package/components/hy-grid/props.ts +58 -16
  94. package/components/hy-grid/typing.d.ts +66 -66
  95. package/components/hy-icon/hy-icon.vue +84 -161
  96. package/components/hy-icon/props.ts +76 -22
  97. package/components/hy-icon/typing.d.ts +83 -82
  98. package/components/hy-image/hy-image.vue +142 -272
  99. package/components/hy-image/props.ts +105 -23
  100. package/components/hy-image/typing.d.ts +84 -87
  101. package/components/hy-input/hy-input.vue +230 -421
  102. package/components/hy-input/props.ts +183 -35
  103. package/components/hy-input/typing.d.ts +169 -169
  104. package/components/hy-line/hy-line.vue +34 -72
  105. package/components/hy-line/props.ts +41 -10
  106. package/components/hy-line/typing.d.ts +29 -29
  107. package/components/hy-line-progress/hy-line-progress.vue +66 -101
  108. package/components/hy-line-progress/props.ts +31 -10
  109. package/components/hy-line-progress/typing.d.ts +29 -29
  110. package/components/hy-list/hy-list.vue +151 -220
  111. package/components/hy-list/props.ts +67 -16
  112. package/components/hy-list/typing.d.ts +52 -52
  113. package/components/hy-loading/hy-loading.vue +63 -119
  114. package/components/hy-loading/props.ts +63 -15
  115. package/components/hy-loading/typing.d.ts +49 -49
  116. package/components/hy-menu/hy-menu.vue +124 -166
  117. package/components/hy-menu/props.ts +42 -10
  118. package/components/hy-menu/typing.d.ts +60 -60
  119. package/components/hy-modal/hy-modal.vue +127 -218
  120. package/components/hy-modal/props.ts +89 -24
  121. package/components/hy-navbar/hy-navbar.vue +104 -177
  122. package/components/hy-navbar/props.ts +76 -22
  123. package/components/hy-navbar/typing.d.ts +81 -81
  124. package/components/hy-notice-bar/hy-notice-bar.vue +67 -144
  125. package/components/hy-notice-bar/props.ts +80 -19
  126. package/components/hy-notice-bar/typing.d.ts +62 -62
  127. package/components/hy-notify/hy-notify.vue +128 -177
  128. package/components/hy-notify/props.ts +49 -12
  129. package/components/hy-notify/typing.d.ts +45 -41
  130. package/components/hy-number-step/hy-number-step.vue +281 -394
  131. package/components/hy-number-step/props.ts +110 -27
  132. package/components/hy-number-step/typing.d.ts +120 -120
  133. package/components/hy-overlay/hy-overlay.vue +39 -66
  134. package/components/hy-overlay/props.ts +31 -8
  135. package/components/hy-pagination/hy-pagination.vue +100 -155
  136. package/components/hy-pagination/props.ts +53 -13
  137. package/components/hy-picker/hy-picker.vue +309 -430
  138. package/components/hy-picker/index.scss +8 -12
  139. package/components/hy-picker/props.ts +110 -26
  140. package/components/hy-popover/hy-popover.vue +190 -252
  141. package/components/hy-popover/props.ts +48 -10
  142. package/components/hy-popup/hy-popup.vue +162 -248
  143. package/components/hy-popup/props.ts +82 -18
  144. package/components/hy-price/hy-price.vue +45 -104
  145. package/components/hy-price/props.ts +52 -12
  146. package/components/hy-price/typing.d.ts +41 -36
  147. package/components/hy-qrcode/hy-qrcode.vue +115 -185
  148. package/components/hy-qrcode/props.ts +68 -18
  149. package/components/hy-qrcode/typing.d.ts +67 -66
  150. package/components/hy-radio/hy-radio.vue +161 -259
  151. package/components/hy-radio/props.ts +95 -25
  152. package/components/hy-radio/typing.d.ts +85 -84
  153. package/components/hy-rate/hy-rate.vue +185 -270
  154. package/components/hy-rate/props.ts +76 -18
  155. package/components/hy-rate/typing.d.ts +61 -60
  156. package/components/hy-read-more/hy-read-more.vue +93 -136
  157. package/components/hy-read-more/props.ts +43 -13
  158. package/components/hy-scroll-list/hy-scroll-list.vue +81 -102
  159. package/components/hy-scroll-list/props.ts +22 -11
  160. package/components/hy-search/hy-search.vue +155 -284
  161. package/components/hy-search/props.ts +130 -25
  162. package/components/hy-signature/hy-signature.vue +491 -635
  163. package/components/hy-signature/props.ts +115 -26
  164. package/components/hy-signature/typing.d.ts +138 -138
  165. package/components/hy-slider/hy-slider.vue +388 -477
  166. package/components/hy-slider/props.ts +75 -19
  167. package/components/hy-steps/hy-steps.vue +212 -279
  168. package/components/hy-steps/props.ts +47 -13
  169. package/components/hy-submit-bar/hy-submit-bar.vue +137 -222
  170. package/components/hy-submit-bar/props.ts +89 -20
  171. package/components/hy-submit-bar/typing.d.ts +86 -85
  172. package/components/hy-subsection/hy-subsection.vue +132 -185
  173. package/components/hy-subsection/props.ts +50 -17
  174. package/components/hy-subsection/typing.d.ts +52 -52
  175. package/components/hy-swipe-action/hy-swipe-action.vue +228 -283
  176. package/components/hy-swipe-action/props.ts +43 -18
  177. package/components/hy-swipe-action/typing.d.ts +46 -46
  178. package/components/hy-swiper/hy-swiper.vue +159 -286
  179. package/components/hy-swiper/props.ts +126 -28
  180. package/components/hy-swiper/typing.d.ts +115 -115
  181. package/components/hy-switch/hy-switch.vue +112 -176
  182. package/components/hy-switch/props.ts +60 -15
  183. package/components/hy-switch/typing.d.ts +63 -63
  184. package/components/hy-tabBar/hy-tabBar.vue +64 -60
  185. package/components/hy-tabs/hy-tabs.vue +277 -380
  186. package/components/hy-tabs/props.ts +75 -18
  187. package/components/hy-tag/hy-tag.vue +111 -204
  188. package/components/hy-tag/props.ts +81 -19
  189. package/components/hy-text/hy-text.vue +200 -322
  190. package/components/hy-text/props.ts +107 -28
  191. package/components/hy-textarea/hy-textarea.vue +147 -256
  192. package/components/hy-textarea/props.ts +112 -25
  193. package/components/hy-textarea/typing.d.ts +42 -42
  194. package/components/hy-toast/hy-toast.vue +135 -143
  195. package/components/hy-tooltip/hy-tooltip.vue +220 -306
  196. package/components/hy-tooltip/props.ts +79 -15
  197. package/components/hy-transition/hy-transition.vue +111 -138
  198. package/components/hy-transition/props.ts +30 -8
  199. package/components/hy-upload/hy-upload.vue +320 -469
  200. package/components/hy-upload/props.ts +130 -27
  201. package/components/hy-warn/hy-warn.vue +80 -129
  202. package/components/hy-warn/props.ts +47 -12
  203. package/components/hy-waterfall/hy-waterfall.vue +139 -163
  204. package/components/hy-waterfall/props.ts +19 -7
  205. package/components/hy-watermark/hy-watermark.vue +762 -870
  206. package/components/hy-watermark/props.ts +103 -22
  207. package/global.d.ts +2 -0
  208. package/libs/css/theme.scss +3 -3
  209. package/package.json +2 -2
  210. package/web-types.json +1 -1
  211. package/components/hy-folding-panel/index.scss +0 -9
@@ -1,686 +1,521 @@
1
1
  <template>
2
- <view :class="['hy-datetime-picker', customClass]" :style="customStyle">
3
- <view
4
- v-if="hasInput"
5
- class="hy-datetime-picker__has-input"
6
- @click="onShowByClickInput"
7
- >
8
- <slot name="trigger" :value="inputValue">
9
- <HyInput
10
- v-model="inputValue"
11
- :readonly="true"
12
- :disabled="input?.disabled"
13
- :disabledColor="input?.disabledColor"
14
- :shape="input?.shape"
15
- :border="input?.border"
16
- :prefixIcon="input?.prefixIcon"
17
- :suffixIcon="input?.suffixIcon"
18
- :color="input?.color"
19
- :fontSize="input?.fontSize"
20
- :inputAlign="input?.inputAlign"
21
- :placeholder="input?.placeholder || '请选择时间'"
22
- :placeholderStyle="input?.placeholderStyle"
23
- :placeholderClass="input?.placeholderClass"
24
- :customStyle="
25
- Object.assign({ 'pointer-events': 'none' }, input?.customStyle)
26
- "
27
- ></HyInput>
28
- <view class="input-cover"></view>
29
- </slot>
2
+ <view :class="['hy-datetime-picker', customClass]" :style="customStyle">
3
+ <view v-if="hasInput" class="hy-datetime-picker__has-input" @click="onShowByClickInput">
4
+ <slot name="trigger" :value="inputValue">
5
+ <HyInput
6
+ v-model="inputValue"
7
+ :readonly="true"
8
+ :disabled="input?.disabled"
9
+ :disabledColor="input?.disabledColor"
10
+ :shape="input?.shape"
11
+ :border="input?.border"
12
+ :prefixIcon="input?.prefixIcon"
13
+ :suffixIcon="input?.suffixIcon"
14
+ :color="input?.color"
15
+ :fontSize="input?.fontSize"
16
+ :inputAlign="input?.inputAlign"
17
+ :placeholder="input?.placeholder || '请选择时间'"
18
+ :placeholderStyle="input?.placeholderStyle"
19
+ :placeholderClass="input?.placeholderClass"
20
+ :customStyle="Object.assign({ 'pointer-events': 'none' }, input?.customStyle)"
21
+ ></HyInput>
22
+ <view class="input-cover"></view>
23
+ </slot>
24
+ </view>
25
+ <HyPicker
26
+ ref="picker"
27
+ :show="show || (hasInput && showByClickInput)"
28
+ :popupMode="popupMode"
29
+ :closeOnClickOverlay="closeOnClickOverlay"
30
+ :columns="columns"
31
+ :title="title"
32
+ :itemHeight="itemHeight"
33
+ :loading="loading"
34
+ :showToolbar="showToolbar"
35
+ :visibleItemCount="visibleItemCount"
36
+ :defaultIndex="innerDefaultIndex"
37
+ :cancelText="cancelText"
38
+ :cancelColor="cancelColor"
39
+ :confirmColor="confirmColor"
40
+ :toolbarRightSlot="toolbarRightSlot"
41
+ @close="close"
42
+ @cancel="cancel"
43
+ @confirm="confirm"
44
+ @change="change"
45
+ >
46
+ <template #toolbar-right>
47
+ <slot name="toolbar-right">
48
+ {{ confirmText }}
49
+ </slot>
50
+ </template>
51
+ <template #toolbar-bottom>
52
+ <slot name="toolbar-bottom"></slot>
53
+ </template>
54
+ </HyPicker>
30
55
  </view>
31
- <HyPicker
32
- ref="picker"
33
- :show="show || (hasInput && showByClickInput)"
34
- :popupMode="popupMode"
35
- :closeOnClickOverlay="closeOnClickOverlay"
36
- :columns="columns"
37
- :title="title"
38
- :itemHeight="itemHeight"
39
- :loading="loading"
40
- :showToolbar="showToolbar"
41
- :visibleItemCount="visibleItemCount"
42
- :defaultIndex="innerDefaultIndex"
43
- :cancelText="cancelText"
44
- :cancelColor="cancelColor"
45
- :confirmColor="confirmColor"
46
- :toolbarRightSlot="toolbarRightSlot"
47
- @close="close"
48
- @cancel="cancel"
49
- @confirm="confirm"
50
- @change="change"
51
- >
52
- <template #toolbar-right>
53
- <slot name="toolbar-right">
54
- {{ confirmText }}
55
- </slot>
56
- </template>
57
- <template #toolbar-bottom>
58
- <slot name="toolbar-bottom"></slot>
59
- </template>
60
- </HyPicker>
61
- </view>
62
56
  </template>
63
57
 
64
58
  <script lang="ts">
65
59
  export default {
66
- name: "hy-datetime-picker",
67
- options: {
68
- addGlobalClass: true,
69
- virtualHost: true,
70
- styleIsolation: "shared",
71
- },
72
- };
60
+ name: 'hy-datetime-picker',
61
+ options: {
62
+ addGlobalClass: true,
63
+ virtualHost: true,
64
+ styleIsolation: 'shared'
65
+ }
66
+ }
73
67
  </script>
74
68
 
75
69
  <script setup lang="ts">
76
- import { computed, onMounted, ref, watch } from "vue";
77
- import type { CSSProperties, PropType } from "vue";
78
- import dayjs from "dayjs/esm";
79
- import { error, padZero, DateModeEnum } from "../../libs";
80
- import type HyInputProps from "../hy-input/typing";
81
- import type { IDatetimePickerEmits } from "./typing";
70
+ import { computed, onMounted, ref, watch } from 'vue'
71
+ import dayjs from 'dayjs/esm'
72
+ import { error, padZero, DateModeEnum } from '../../libs'
73
+ import type { IDatetimePickerEmits } from './typing'
74
+ import datetimePickerProps from './props'
82
75
  // 组件
83
- import HyInput from "../hy-input/hy-input.vue";
84
- import HyPicker from "../hy-picker/hy-picker.vue";
76
+ import HyInput from '../hy-input/hy-input.vue'
77
+ import HyPicker from '../hy-picker/hy-picker.vue'
85
78
 
86
79
  /**
87
80
  * 此选择器用于时间日期选择
88
81
  * @displayName hy-datetime-picker
89
82
  */
90
- defineOptions({});
83
+ defineOptions({})
91
84
 
92
- // const props = withDefaults(defineProps<IProps>(), defaultProps)
93
- const props = defineProps({
94
- /** 用于控制选择器的弹出和收起 */
95
- show: {
96
- type: Boolean,
97
- default: false,
98
- },
99
- /**
100
- * 弹出层弹出方向
101
- * @values bottom,top
102
- * */
103
- popupMode: {
104
- type: String,
105
- default: "bottom",
106
- },
107
- /** 是否显示顶部的操作栏 */
108
- showToolbar: {
109
- type: Boolean,
110
- default: true,
111
- },
112
- /** 绑定值 */
113
- modelValue: {
114
- type: [String, Number, Date],
115
- default: "",
116
- },
117
- /** 顶部标题 */
118
- title: String,
119
- /**
120
- * 展示格式 mode=date为日期选择,mode=time为时间选择,mode=year-month为年月选择,mode=datetime为日期时间选择
121
- * @values date,time,year-month,datetime
122
- * */
123
- mode: {
124
- type: String as PropType<DateModeEnum>,
125
- default: DateModeEnum.DATETIME,
126
- },
127
- /** 可选的最大时间 默认值为后10年 */
128
- maxDate: {
129
- type: Number,
130
- default: new Date(new Date().getFullYear() + 10, 0, 1).getTime(),
131
- },
132
- /** 可选的最小时间 默认值为前10年 */
133
- minDate: {
134
- type: Number,
135
- default: new Date(new Date().getFullYear() - 10, 0, 1).getTime(),
136
- },
137
- /** 可选的最小小时,仅mode=time有效 */
138
- minHour: {
139
- type: Number,
140
- default: 0,
141
- },
142
- /** 可选的最大小时,仅mode=time有效 */
143
- maxHour: {
144
- type: Number,
145
- default: 23,
146
- },
147
- /** 可选的最小分钟,仅mode=time有效 */
148
- minMinute: {
149
- type: Number,
150
- default: 0,
151
- },
152
- /** 可选的最大分钟,仅mode=time有效 */
153
- maxMinute: {
154
- type: Number,
155
- default: 59,
156
- },
157
- /** 选项过滤函数 */
158
- filter: Function,
159
- /** 选项格式化函数 */
160
- formatter: Function,
161
- /** 是否显示加载中状态 */
162
- loading: {
163
- type: Boolean,
164
- default: false,
165
- },
166
- /** 各列中,单个选项的高度 */
167
- itemHeight: {
168
- type: Number,
169
- default: 44,
170
- },
171
- /** 取消按钮的文字 */
172
- cancelText: {
173
- type: String,
174
- default: "取消",
175
- },
176
- /** 确认按钮的文字 */
177
- confirmText: {
178
- type: String,
179
- default: "确认",
180
- },
181
- /** 取消按钮的颜色 */
182
- cancelColor: {
183
- type: String,
184
- default: "#909193",
185
- },
186
- /** 确认按钮的颜色 */
187
- confirmColor: {
188
- type: String,
189
- default: "#3c9cff",
190
- },
191
- /** 每列中可见选项的数量 */
192
- visibleItemCount: {
193
- type: Number,
194
- default: 5,
195
- },
196
- /** 是否允许点击遮罩关闭选择器 */
197
- closeOnClickOverlay: {
198
- type: Boolean,
199
- default: false,
200
- },
201
- /** 各列的默认索引 */
202
- defaultIndex: {
203
- type: Array,
204
- default() {
205
- return [];
206
- },
207
- },
208
- /** 输入框是否显示边框 */
209
- hasInput: {
210
- type: Boolean,
211
- default: false,
212
- },
213
- /** 输入框集合属性 */
214
- input: {
215
- type: Object as unknown as PropType<HyInputProps>,
216
- },
217
- /** 自定义时间格式 */
218
- format: String,
219
- /** 右边插槽 */
220
- toolbarRightSlot: {
221
- type: Boolean,
222
- default: false,
223
- },
224
- /** 定义需要用到的外部样式 */
225
- customStyle: {
226
- type: Object as PropType<CSSProperties>,
227
- },
228
- /** 自定义外部类名 */
229
- customClass: String,
230
- });
231
- const emit = defineEmits<IDatetimePickerEmits>();
85
+ const props = defineProps(datetimePickerProps)
86
+ const emit = defineEmits<IDatetimePickerEmits>()
232
87
 
233
88
  // 原来的日期选择器不方便,这里增加一个hasInput选项支持类似element的自带输入框的功能。
234
- const inputValue = ref<string | number>(""); // 表单显示值
235
- const innerValue = ref<string | number>(""); // 表单显示值
236
- const showByClickInput = ref<boolean>(false); // 是否在hasInput模式下显示日期选择弹唱
237
- const columns = ref<any[]>([]);
238
- const innerDefaultIndex = ref<number[]>([]);
239
- let innerFormatter = (type: any, value: any) => value;
89
+ const inputValue = ref<string | number>('') // 表单显示值
90
+ const innerValue = ref<string | number>('') // 表单显示值
91
+ const showByClickInput = ref<boolean>(false) // 是否在hasInput模式下显示日期选择弹唱
92
+ const columns = ref<any[]>([])
93
+ const innerDefaultIndex = ref<number[]>([])
94
+ let innerFormatter = (type: any, value: any) => value
240
95
  const validModes = new Set([
241
- DateModeEnum.TIME,
242
- DateModeEnum.MONTH_DAY,
243
- DateModeEnum.HOUR_MINUTE,
244
- DateModeEnum.MINUTE_SECOND,
245
- ]);
96
+ DateModeEnum.TIME,
97
+ DateModeEnum.MONTH_DAY,
98
+ DateModeEnum.HOUR_MINUTE,
99
+ DateModeEnum.MINUTE_SECOND
100
+ ])
246
101
 
247
102
  /**
248
103
  * @description 更新各列的值
249
104
  * */
250
105
  const updateColumns = () => {
251
- const formatterFn = props.formatter || innerFormatter;
252
- // 获取各列的值,并且map后,对各列的具体值进行补0操作
253
- columns.value = getOriginColumns().map((column) =>
254
- column.values.map((value) => formatterFn(column.type, value)),
255
- );
256
- };
106
+ const formatterFn = props.formatter || innerFormatter
107
+ // 获取各列的值,并且map后,对各列的具体值进行补0操作
108
+ columns.value = getOriginColumns().map((column) =>
109
+ column.values.map((value) => formatterFn(column.type, value))
110
+ )
111
+ }
257
112
 
258
113
  /**
259
114
  * @description 更新各列的值,进行补0、格式化等操作
260
115
  * */
261
116
  const updateColumnValue = (value: string | number) => {
262
- innerValue.value = value;
263
- updateColumns();
264
- // 延迟执行,等待u-picker组件列数据更新完后再设置选中值索引
265
- setTimeout(() => {
266
- updateIndexes(value);
267
- }, 100);
268
- };
117
+ innerValue.value = value
118
+ updateColumns()
119
+ // 延迟执行,等待u-picker组件列数据更新完后再设置选中值索引
120
+ setTimeout(() => {
121
+ updateIndexes(value)
122
+ }, 100)
123
+ }
269
124
 
270
125
  const init = () => {
271
- // 获取当前值
272
- innerValue.value = correctValue(props.modelValue);
273
- // 更新列表
274
- updateColumnValue(innerValue.value);
126
+ // 获取当前值
127
+ innerValue.value = correctValue(props.modelValue)
128
+ // 更新列表
129
+ updateColumnValue(innerValue.value)
275
130
 
276
- // 初始化hasInput展示
277
- getInputValue(innerValue.value);
278
- };
131
+ // 初始化hasInput展示
132
+ getInputValue(innerValue.value)
133
+ }
279
134
 
280
135
  watch(
281
- () => props.show,
282
- (newValue) => {
283
- if (newValue) {
284
- updateColumnValue(innerValue.value);
136
+ () => props.show,
137
+ (newValue) => {
138
+ if (newValue) {
139
+ updateColumnValue(innerValue.value)
140
+ }
285
141
  }
286
- },
287
- );
142
+ )
288
143
 
289
144
  watch(
290
- () => props.modelValue,
291
- () => init(),
292
- );
145
+ () => props.modelValue,
146
+ () => init()
147
+ )
293
148
 
294
149
  const propsChange = computed(() => {
295
- return [
296
- props.mode,
297
- props.maxDate,
298
- props.minDate,
299
- props.minHour,
300
- props.maxHour,
301
- props.minMinute,
302
- props.maxMinute,
303
- props.filter,
304
- ];
305
- });
150
+ return [
151
+ props.mode,
152
+ props.maxDate,
153
+ props.minDate,
154
+ props.minHour,
155
+ props.maxHour,
156
+ props.minMinute,
157
+ props.maxMinute,
158
+ props.filter
159
+ ]
160
+ })
306
161
 
307
162
  watch(
308
- () => propsChange.value,
309
- () => init(),
310
- );
163
+ () => propsChange.value,
164
+ () => init()
165
+ )
311
166
 
312
167
  onMounted(() => {
313
- init();
314
- });
168
+ init()
169
+ })
315
170
 
316
171
  const getInputValue = (newValue: string | number) => {
317
- if (newValue == "" || !newValue) {
318
- inputValue.value = "";
319
- return;
320
- }
321
- if (props.mode === "time") {
322
- inputValue.value = newValue;
323
- } else {
324
- if (props.format) {
325
- inputValue.value = dayjs(newValue).format(props.format);
172
+ if (newValue == '' || !newValue) {
173
+ inputValue.value = ''
174
+ return
175
+ }
176
+ if (props.mode === 'time') {
177
+ inputValue.value = newValue
326
178
  } else {
327
- let format = "";
328
- switch (props.mode) {
329
- case DateModeEnum.DATE:
330
- format = "YYYY-MM-DD";
331
- break;
332
- case DateModeEnum.YEAR_MONTH:
333
- format = "YYYY-MM";
334
- break;
335
- case DateModeEnum.DATETIME:
336
- format = "YYYY-MM-DD HH:mm:ss";
337
- break;
338
- case DateModeEnum.MONTH_DAY:
339
- format = "MM-DD";
340
- break;
341
- case DateModeEnum.HOUR_MINUTE:
342
- format = "HH:mm";
343
- break;
344
- case DateModeEnum.MINUTE_SECOND:
345
- format = "mm:ss";
346
- break;
347
- default:
348
- break;
349
- }
350
- inputValue.value = dayjs(newValue).isValid()
351
- ? dayjs(newValue).format(format)
352
- : newValue;
179
+ if (props.format) {
180
+ inputValue.value = dayjs(newValue).format(props.format)
181
+ } else {
182
+ let format = ''
183
+ switch (props.mode) {
184
+ case DateModeEnum.DATE:
185
+ format = 'YYYY-MM-DD'
186
+ break
187
+ case DateModeEnum.YEAR_MONTH:
188
+ format = 'YYYY-MM'
189
+ break
190
+ case DateModeEnum.DATETIME:
191
+ format = 'YYYY-MM-DD HH:mm:ss'
192
+ break
193
+ case DateModeEnum.MONTH_DAY:
194
+ format = 'MM-DD'
195
+ break
196
+ case DateModeEnum.HOUR_MINUTE:
197
+ format = 'HH:mm'
198
+ break
199
+ case DateModeEnum.MINUTE_SECOND:
200
+ format = 'mm:ss'
201
+ break
202
+ default:
203
+ break
204
+ }
205
+ inputValue.value = dayjs(newValue).isValid() ? dayjs(newValue).format(format) : newValue
206
+ }
353
207
  }
354
- }
355
- };
208
+ }
356
209
  const times = (n: number, iteratee: Function) => {
357
- let index = -1;
358
- const result = Array(n < 0 ? 0 : n);
359
- while (++index < n) {
360
- result[index] = iteratee(index);
361
- }
362
- return result;
363
- };
210
+ let index = -1
211
+ const result = Array(n < 0 ? 0 : n)
212
+ while (++index < n) {
213
+ result[index] = iteratee(index)
214
+ }
215
+ return result
216
+ }
364
217
 
365
218
  /**
366
219
  * @description 关闭选择器
367
220
  * */
368
221
  const close = () => {
369
- if (props.closeOnClickOverlay) {
370
- if (props.hasInput) {
371
- showByClickInput.value = false;
222
+ if (props.closeOnClickOverlay) {
223
+ if (props.hasInput) {
224
+ showByClickInput.value = false
225
+ }
226
+ emit('close')
372
227
  }
373
- emit("close");
374
- }
375
- };
228
+ }
376
229
 
377
230
  /**
378
231
  * @description 点击工具栏的取消按钮
379
232
  * */
380
233
  const cancel = () => {
381
- if (props.hasInput) {
382
- showByClickInput.value = false;
383
- }
384
- emit("cancel");
385
- };
234
+ if (props.hasInput) {
235
+ showByClickInput.value = false
236
+ }
237
+ emit('cancel')
238
+ }
386
239
 
387
240
  /**
388
241
  * @description 点击工具栏的确定按钮
389
242
  * */
390
243
  const confirm = () => {
391
- emit("update:modelValue", innerValue.value);
392
- if (props.hasInput) {
393
- getInputValue(innerValue.value);
394
- showByClickInput.value = false;
395
- }
396
- emit("confirm", {
397
- value: innerValue.value,
398
- mode: props.mode,
399
- });
400
- };
244
+ emit('update:modelValue', innerValue.value)
245
+ if (props.hasInput) {
246
+ getInputValue(innerValue.value)
247
+ showByClickInput.value = false
248
+ }
249
+ emit('confirm', {
250
+ value: innerValue.value,
251
+ mode: props.mode
252
+ })
253
+ }
401
254
 
402
255
  /**
403
256
  * @description 用正则截取输出值,当出现多组数字时,抛出错误
404
257
  * */
405
258
  const intercept = (e: any, type?: string) => {
406
- let judge = e.match(/\d+/g);
407
- //判断是否掺杂数字
408
- if (judge.length > 1) {
409
- error("请勿在过滤或格式化函数时添加数字");
410
- return 0;
411
- } else if (type && judge[0].length == 4) {
412
- //判断是否是年份
413
- return judge[0];
414
- } else if (judge[0].length > 2) {
415
- error("请勿在过滤或格式化函数时添加数字");
416
- return 0;
417
- } else {
418
- return judge[0];
419
- }
420
- };
259
+ let judge = e.match(/\d+/g)
260
+ //判断是否掺杂数字
261
+ if (judge.length > 1) {
262
+ error('请勿在过滤或格式化函数时添加数字')
263
+ return 0
264
+ } else if (type && judge[0].length == 4) {
265
+ //判断是否是年份
266
+ return judge[0]
267
+ } else if (judge[0].length > 2) {
268
+ error('请勿在过滤或格式化函数时添加数字')
269
+ return 0
270
+ } else {
271
+ return judge[0]
272
+ }
273
+ }
421
274
 
422
275
  /**
423
276
  * @description 列发生变化时触发
424
277
  * */
425
278
  const change = (e: any) => {
426
- const { indexs, values } = e;
427
- let selectValue: string | number = "";
428
- if (validModes.has(props.mode) && props.mode !== DateModeEnum.MONTH_DAY) {
429
- // 根据value各列索引,从各列数组中,取出当前时间的选中值
430
- selectValue = `${intercept(values[0][indexs[0]])}:${intercept(values[1][indexs[1]])}`;
431
- } else if (props.mode === DateModeEnum.MONTH_DAY) {
432
- // 根据value各列索引,从各列数组中,取出当前时间的选中值
433
- selectValue = `${intercept(values[0][indexs[0]])}-${intercept(values[1][indexs[1]])}`;
434
- } else {
435
- // 将选择的值转为数值,比如'03'转为数值的3,'2019'转为数值的2019
436
- const year = parseInt(intercept(values[0][indexs[0]], "year"));
437
- const month = parseInt(intercept(values[1][indexs[1]]));
438
- let date = parseInt(values[2] ? intercept(values[2][indexs[2]]) : 1);
439
- let hour = 0,
440
- minute = 0,
441
- second = 0;
442
- // 此月份的最大天数
443
- const maxDate = dayjs(`${year}-${month}`).daysInMonth();
444
- // 不允许超过maxDate值
445
- date = Math.min(maxDate, date);
446
- if (props.mode === DateModeEnum.DATETIME) {
447
- hour = parseInt(intercept(values[3][indexs[3]]));
448
- minute = parseInt(intercept(values[4][indexs[4]]));
449
- second = parseInt(intercept(values[5][indexs[5]]));
279
+ const { indexs, values } = e
280
+ let selectValue: string | number = ''
281
+ if (validModes.has(props.mode) && props.mode !== DateModeEnum.MONTH_DAY) {
282
+ // 根据value各列索引,从各列数组中,取出当前时间的选中值
283
+ selectValue = `${intercept(values[0][indexs[0]])}:${intercept(values[1][indexs[1]])}`
284
+ } else if (props.mode === DateModeEnum.MONTH_DAY) {
285
+ // 根据value各列索引,从各列数组中,取出当前时间的选中值
286
+ selectValue = `${intercept(values[0][indexs[0]])}-${intercept(values[1][indexs[1]])}`
287
+ } else {
288
+ // 将选择的值转为数值,比如'03'转为数值的3,'2019'转为数值的2019
289
+ const year = parseInt(intercept(values[0][indexs[0]], 'year'))
290
+ const month = parseInt(intercept(values[1][indexs[1]]))
291
+ let date = parseInt(values[2] ? intercept(values[2][indexs[2]]) : 1)
292
+ let hour = 0,
293
+ minute = 0,
294
+ second = 0
295
+ // 此月份的最大天数
296
+ const maxDate = dayjs(`${year}-${month}`).daysInMonth()
297
+ // 不允许超过maxDate值
298
+ date = Math.min(maxDate, date)
299
+ if (props.mode === DateModeEnum.DATETIME) {
300
+ hour = parseInt(intercept(values[3][indexs[3]]))
301
+ minute = parseInt(intercept(values[4][indexs[4]]))
302
+ second = parseInt(intercept(values[5][indexs[5]]))
303
+ }
304
+ // 转为时间模式
305
+ selectValue = Number(new Date(year, month - 1, date, hour, minute, second))
450
306
  }
451
- // 转为时间模式
452
- selectValue = Number(new Date(year, month - 1, date, hour, minute, second));
453
- }
454
- // 取出准确的合法值,防止超越边界的情况
455
- selectValue = correctValue(selectValue);
456
- innerValue.value = selectValue;
457
- updateColumnValue(selectValue);
458
- // 发出change时间,value为当前选中的时间戳
459
- emit("change", {
460
- value: selectValue,
461
- mode: props.mode,
462
- });
463
- };
307
+ // 取出准确的合法值,防止超越边界的情况
308
+ selectValue = correctValue(selectValue)
309
+ innerValue.value = selectValue
310
+ updateColumnValue(selectValue)
311
+ // 发出change时间,value为当前选中的时间戳
312
+ emit('change', {
313
+ value: selectValue,
314
+ mode: props.mode
315
+ })
316
+ }
464
317
 
465
318
  /**
466
319
  * @description 更新索引
467
320
  * */
468
321
  const updateIndexes = (value: number | string) => {
469
- let values: string[] = [];
470
- let timeArr: string[] = [];
471
- const formatterFn = props.formatter || innerFormatter;
322
+ let values: string[] = []
323
+ let timeArr: string[] = []
324
+ const formatterFn = props.formatter || innerFormatter
472
325
 
473
- switch (props.mode) {
474
- case DateModeEnum.TIME:
475
- timeArr = value.toString().split(":");
476
- // 使用formatter格式化方法进行管道处理
477
- values = [
478
- formatterFn("hour", timeArr[0]),
479
- formatterFn("minute", timeArr[1]),
480
- ];
481
- break;
482
- case DateModeEnum.MONTH_DAY:
483
- timeArr = value.toString().split("-");
484
- // 使用formatter格式化方法进行管道处理
485
- values = [
486
- formatterFn("month", timeArr[0]),
487
- formatterFn("day", timeArr[1]),
488
- ];
489
- break;
490
- case DateModeEnum.HOUR_MINUTE:
491
- timeArr = value.toString().split(":");
492
- // 使用formatter格式化方法进行管道处理
493
- values = [
494
- formatterFn("hour", timeArr[0]),
495
- formatterFn("minute", timeArr[1]),
496
- ];
497
- break;
498
- case DateModeEnum.MINUTE_SECOND:
499
- timeArr = value.toString().split(":");
500
- // 使用formatter格式化方法进行管道处理
501
- values = [
502
- formatterFn("minute", timeArr[0]),
503
- formatterFn("second", timeArr[1]),
504
- ];
505
- break;
506
- default:
507
- values = [
508
- formatterFn("year", `${dayjs(value).year()}`),
509
- // 月份补0
510
- formatterFn("month", padZero(dayjs(value).month() + 1)),
511
- ];
512
- if (props.mode === DateModeEnum.DATE) {
513
- // date模式,需要添加天列
514
- values.push(formatterFn("day", padZero(dayjs(value).date())));
515
- }
516
- if (props.mode === DateModeEnum.DATETIME) {
517
- // 数组的push方法,可以写入多个参数
518
- values.push(
519
- formatterFn("day", padZero(dayjs(value).date())),
520
- formatterFn("hour", padZero(dayjs(value).hour())),
521
- formatterFn("minute", padZero(dayjs(value).minute())),
522
- formatterFn("second", padZero(dayjs(value).second())),
523
- );
524
- }
525
- break;
526
- }
527
- // 根据当前各列的所有值,从各列默认值中找到默认值在各列中的索引
528
- innerDefaultIndex.value = columns.value.map((column, index) => {
529
- // 通过取大值,可以保证不会出现找不到索引的"-1"情况
530
- return Math.max(
531
- 0,
532
- column.findIndex((item: string) => item === values[index]),
533
- );
534
- });
535
- };
326
+ switch (props.mode) {
327
+ case DateModeEnum.TIME:
328
+ timeArr = value.toString().split(':')
329
+ // 使用formatter格式化方法进行管道处理
330
+ values = [formatterFn('hour', timeArr[0]), formatterFn('minute', timeArr[1])]
331
+ break
332
+ case DateModeEnum.MONTH_DAY:
333
+ timeArr = value.toString().split('-')
334
+ // 使用formatter格式化方法进行管道处理
335
+ values = [formatterFn('month', timeArr[0]), formatterFn('day', timeArr[1])]
336
+ break
337
+ case DateModeEnum.HOUR_MINUTE:
338
+ timeArr = value.toString().split(':')
339
+ // 使用formatter格式化方法进行管道处理
340
+ values = [formatterFn('hour', timeArr[0]), formatterFn('minute', timeArr[1])]
341
+ break
342
+ case DateModeEnum.MINUTE_SECOND:
343
+ timeArr = value.toString().split(':')
344
+ // 使用formatter格式化方法进行管道处理
345
+ values = [formatterFn('minute', timeArr[0]), formatterFn('second', timeArr[1])]
346
+ break
347
+ default:
348
+ values = [
349
+ formatterFn('year', `${dayjs(value).year()}`),
350
+ // 月份补0
351
+ formatterFn('month', padZero(dayjs(value).month() + 1))
352
+ ]
353
+ if (props.mode === DateModeEnum.DATE) {
354
+ // date模式,需要添加天列
355
+ values.push(formatterFn('day', padZero(dayjs(value).date())))
356
+ }
357
+ if (props.mode === DateModeEnum.DATETIME) {
358
+ // 数组的push方法,可以写入多个参数
359
+ values.push(
360
+ formatterFn('day', padZero(dayjs(value).date())),
361
+ formatterFn('hour', padZero(dayjs(value).hour())),
362
+ formatterFn('minute', padZero(dayjs(value).minute())),
363
+ formatterFn('second', padZero(dayjs(value).second()))
364
+ )
365
+ }
366
+ break
367
+ }
368
+ // 根据当前各列的所有值,从各列默认值中找到默认值在各列中的索引
369
+ innerDefaultIndex.value = columns.value.map((column, index) => {
370
+ // 通过取大值,可以保证不会出现找不到索引的"-1"情况
371
+ return Math.max(
372
+ 0,
373
+ column.findIndex((item: string) => item === values[index])
374
+ )
375
+ })
376
+ }
536
377
 
537
378
  /**
538
379
  * @description 获取每列数据
539
380
  * */
540
381
  const getOriginColumns = () => {
541
- // 生成各列的值
542
- return getRanges().map(({ type, range }) => {
543
- let values = times(range[1] - range[0] + 1, (index: number) => {
544
- let value: string | number = range[0] + index;
545
- value = type === "year" ? `${value}` : padZero(value);
546
- return value;
547
- });
548
- // 进行过滤
549
- if (props.filter) {
550
- values = props.filter(type, values);
551
- if (!values || (values && values.length == 0)) {
552
- error("日期filter结果不能为空");
553
- }
554
- }
555
- return { type, values };
556
- });
557
- };
382
+ // 生成各列的值
383
+ return getRanges().map(({ type, range }) => {
384
+ let values = times(range[1] - range[0] + 1, (index: number) => {
385
+ let value: string | number = range[0] + index
386
+ value = type === 'year' ? `${value}` : padZero(value)
387
+ return value
388
+ })
389
+ // 进行过滤
390
+ if (props.filter) {
391
+ values = props.filter(type, values)
392
+ if (!values || (values && values.length == 0)) {
393
+ error('日期filter结果不能为空')
394
+ }
395
+ }
396
+ return { type, values }
397
+ })
398
+ }
558
399
 
559
400
  /**
560
401
  * @description 得出合法的时间
561
402
  * */
562
403
  const correctValue = (value: number | string | Date): string | number => {
563
- const isDateMode = props.mode !== DateModeEnum.TIME;
564
- // if (isDateMode && !test.date(value)) {
565
- if (!isDateMode && !value) {
566
- // 如果是时间类型,而又没有默认值的话,就用最小时间
567
- value = `${padZero(props.minHour)}:${padZero(props.minMinute)}`;
568
- }
569
- // 时间类型
570
- if (validModes.has(props.mode)) {
571
- return value as string;
572
- } else {
573
- // 如果是日期格式,控制在最小日期和最大日期之间
574
- value = dayjs(value).isBefore(dayjs(props.minDate)) ? props.minDate : value;
575
- value = dayjs(value).isAfter(dayjs(props.maxDate)) ? props.maxDate : value;
576
- return value as string | number;
577
- }
578
- };
404
+ const isDateMode = props.mode !== DateModeEnum.TIME
405
+ // if (isDateMode && !test.date(value)) {
406
+ if (!isDateMode && !value) {
407
+ // 如果是时间类型,而又没有默认值的话,就用最小时间
408
+ value = `${padZero(props.minHour)}:${padZero(props.minMinute)}`
409
+ }
410
+ // 时间类型
411
+ if (validModes.has(props.mode)) {
412
+ return value as string
413
+ } else {
414
+ // 如果是日期格式,控制在最小日期和最大日期之间
415
+ value = dayjs(value).isBefore(dayjs(props.minDate)) ? props.minDate : value
416
+ value = dayjs(value).isAfter(dayjs(props.maxDate)) ? props.maxDate : value
417
+ return value as string | number
418
+ }
419
+ }
579
420
  /**
580
421
  * @description 获取每列的最大和最小值
581
422
  * */
582
423
  const getRanges = () => {
583
- if (props.mode === DateModeEnum.TIME) {
584
- return [
585
- {
586
- type: "hour",
587
- range: [props.minHour, props.maxHour],
588
- },
589
- {
590
- type: "minute",
591
- range: [props.minMinute, props.maxMinute],
592
- },
593
- ];
594
- }
595
- const { maxYear, maxDate, maxMonth, maxHour, maxMinute } = getBoundary(
596
- "max",
597
- innerValue.value,
598
- );
599
- const { minYear, minDate, minMonth, minHour, minMinute } = getBoundary(
600
- "min",
601
- innerValue.value,
602
- );
603
- const result = [
604
- {
605
- type: "year",
606
- range: [minYear, maxYear],
607
- },
608
- {
609
- type: "month",
610
- range: [minMonth, maxMonth],
611
- },
612
- {
613
- type: "day",
614
- range: [minDate, maxDate],
615
- },
616
- {
617
- type: "hour",
618
- range: [minHour, maxHour],
619
- },
620
- {
621
- type: "minute",
622
- range: [minMinute, maxMinute],
623
- },
624
- {
625
- type: "second",
626
- range: [minMinute, maxMinute],
627
- },
628
- ];
629
- let arr = result;
630
- // 截取对应的列数
631
- if (props.mode === DateModeEnum.DATE) arr = result.splice(0, 3);
632
- if (props.mode === DateModeEnum.YEAR_MONTH) arr = result.splice(0, 2);
633
- if (props.mode === DateModeEnum.MONTH_DAY) arr = result.splice(1, 2);
634
- if (props.mode === DateModeEnum.HOUR_MINUTE) arr = result.splice(3, 2);
635
- if (props.mode === DateModeEnum.MINUTE_SECOND) arr = result.splice(4, 2);
636
- return arr;
637
- };
424
+ if (props.mode === DateModeEnum.TIME) {
425
+ return [
426
+ {
427
+ type: 'hour',
428
+ range: [props.minHour, props.maxHour]
429
+ },
430
+ {
431
+ type: 'minute',
432
+ range: [props.minMinute, props.maxMinute]
433
+ }
434
+ ]
435
+ }
436
+ const { maxYear, maxDate, maxMonth, maxHour, maxMinute } = getBoundary('max', innerValue.value)
437
+ const { minYear, minDate, minMonth, minHour, minMinute } = getBoundary('min', innerValue.value)
438
+ const result = [
439
+ {
440
+ type: 'year',
441
+ range: [minYear, maxYear]
442
+ },
443
+ {
444
+ type: 'month',
445
+ range: [minMonth, maxMonth]
446
+ },
447
+ {
448
+ type: 'day',
449
+ range: [minDate, maxDate]
450
+ },
451
+ {
452
+ type: 'hour',
453
+ range: [minHour, maxHour]
454
+ },
455
+ {
456
+ type: 'minute',
457
+ range: [minMinute, maxMinute]
458
+ },
459
+ {
460
+ type: 'second',
461
+ range: [minMinute, maxMinute]
462
+ }
463
+ ]
464
+ let arr = result
465
+ // 截取对应的列数
466
+ if (props.mode === DateModeEnum.DATE) arr = result.splice(0, 3)
467
+ if (props.mode === DateModeEnum.YEAR_MONTH) arr = result.splice(0, 2)
468
+ if (props.mode === DateModeEnum.MONTH_DAY) arr = result.splice(1, 2)
469
+ if (props.mode === DateModeEnum.HOUR_MINUTE) arr = result.splice(3, 2)
470
+ if (props.mode === DateModeEnum.MINUTE_SECOND) arr = result.splice(4, 2)
471
+ return arr
472
+ }
638
473
  /**
639
474
  * @description 根据minDate、maxDate、minHour、maxHour等边界值,判断各列的开始和结束边界值
640
475
  * */
641
476
  const getBoundary = (type: string, innerVal: string | number) => {
642
- const value = new Date(innerVal);
643
- const boundary = new Date((props as any)[`${type}Date`]);
644
- const year = dayjs(boundary).year();
645
- let month = 1;
646
- let date = 1;
647
- let hour = 0;
648
- let minute = 0;
649
- if (type === "max") {
650
- month = 12;
651
- // 月份的天数
652
- date = dayjs(value).daysInMonth() || 31;
653
- hour = 23;
654
- minute = 59;
655
- }
656
- // 获取边界值,逻辑是:当年达到了边界值(最大或最小年),就检查月允许的最大和最小值,以此类推
657
- if (dayjs(value).year() === year) {
658
- month = dayjs(boundary).month() + 1;
659
- if (dayjs(value).month() + 1 === month) {
660
- date = dayjs(boundary).date();
661
- if (dayjs(value).date() === date) {
662
- hour = dayjs(boundary).hour();
663
- if (dayjs(value).hour() === hour) {
664
- minute = dayjs(boundary).minute();
477
+ const value = new Date(innerVal)
478
+ const boundary = new Date((props as any)[`${type}Date`])
479
+ const year = dayjs(boundary).year()
480
+ let month = 1
481
+ let date = 1
482
+ let hour = 0
483
+ let minute = 0
484
+ if (type === 'max') {
485
+ month = 12
486
+ // 月份的天数
487
+ date = dayjs(value).daysInMonth() || 31
488
+ hour = 23
489
+ minute = 59
490
+ }
491
+ // 获取边界值,逻辑是:当年达到了边界值(最大或最小年),就检查月允许的最大和最小值,以此类推
492
+ if (dayjs(value).year() === year) {
493
+ month = dayjs(boundary).month() + 1
494
+ if (dayjs(value).month() + 1 === month) {
495
+ date = dayjs(boundary).date()
496
+ if (dayjs(value).date() === date) {
497
+ hour = dayjs(boundary).hour()
498
+ if (dayjs(value).hour() === hour) {
499
+ minute = dayjs(boundary).minute()
500
+ }
501
+ }
665
502
  }
666
- }
667
503
  }
668
- }
669
- return {
670
- [`${type}Year`]: year,
671
- [`${type}Month`]: month,
672
- [`${type}Date`]: date,
673
- [`${type}Hour`]: hour,
674
- [`${type}Minute`]: minute,
675
- };
676
- };
504
+ return {
505
+ [`${type}Year`]: year,
506
+ [`${type}Month`]: month,
507
+ [`${type}Date`]: date,
508
+ [`${type}Hour`]: hour,
509
+ [`${type}Minute`]: minute
510
+ }
511
+ }
677
512
  const onShowByClickInput = () => {
678
- if (!props.input?.disabled) {
679
- showByClickInput.value = !showByClickInput.value;
680
- }
681
- };
513
+ if (!props.input?.disabled) {
514
+ showByClickInput.value = !showByClickInput.value
515
+ }
516
+ }
682
517
  </script>
683
518
 
684
519
  <style lang="scss" scoped>
685
- @import "./index.scss";
520
+ @import './index.scss';
686
521
  </style>