hy-app 0.4.13 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/hy-action-sheet/hy-action-sheet.vue +155 -238
- package/components/hy-action-sheet/props.ts +68 -15
- package/components/hy-action-sheet/typing.d.ts +115 -115
- package/components/hy-address-picker/hy-address-picker.vue +185 -289
- package/components/hy-address-picker/props.ts +97 -21
- package/components/hy-address-picker/typing.d.ts +90 -89
- package/components/hy-avatar/hy-avatar.vue +121 -204
- package/components/hy-avatar/props.ts +76 -18
- package/components/hy-avatar/typing.d.ts +63 -62
- package/components/hy-back-top/hy-back-top.vue +65 -120
- package/components/hy-back-top/props.ts +57 -16
- package/components/hy-back-top/typing.d.ts +43 -42
- package/components/hy-badge/hy-badge.vue +66 -138
- package/components/hy-badge/props.ts +73 -17
- package/components/hy-badge/typing.d.ts +59 -58
- package/components/hy-button/hy-button.vue +226 -375
- package/components/hy-button/props.ts +129 -158
- package/components/hy-calendar/header.vue +48 -64
- package/components/hy-calendar/hy-calendar.vue +274 -438
- package/components/hy-calendar/month.vue +508 -516
- package/components/hy-calendar/props.ts +157 -35
- package/components/hy-calendar/typing.d.ts +129 -128
- package/components/hy-card/hy-card.vue +118 -240
- package/components/hy-card/index.scss +1 -2
- package/components/hy-card/props.ts +122 -27
- package/components/hy-card/typing.d.ts +119 -118
- package/components/hy-cell/hy-cell.vue +176 -258
- package/components/hy-cell/props.ts +71 -17
- package/components/hy-cell/typing.d.ts +87 -86
- package/components/hy-check-button/hy-check-button.vue +69 -139
- package/components/hy-check-button/props.ts +72 -18
- package/components/hy-check-button/typing.d.ts +74 -73
- package/components/hy-checkbox/hy-checkbox.vue +170 -263
- package/components/hy-checkbox/props.ts +94 -24
- package/components/hy-checkbox/typing.d.ts +72 -72
- package/components/hy-checkbox-group/hy-checkbox-group.vue +25 -100
- package/components/hy-checkbox-group/props.ts +80 -0
- package/components/hy-checkbox-group/typing.d.ts +65 -65
- package/components/hy-checkbox-item/hy-checkbox-item.vue +140 -177
- package/components/hy-checkbox-item/props.ts +24 -0
- package/components/hy-checkbox-item/typing.d.ts +4 -3
- package/components/hy-code-input/hy-code-input.vue +179 -262
- package/components/hy-code-input/props.ts +84 -18
- package/components/hy-code-input/typing.d.ts +71 -71
- package/components/hy-config-provider/hy-config-provider.vue +28 -50
- package/components/hy-config-provider/props.ts +26 -11
- package/components/hy-config-provider/typing.d.ts +20 -20
- package/components/hy-count-down/hy-count-down.vue +103 -131
- package/components/hy-count-down/props.ts +30 -8
- package/components/hy-count-down/typing.d.ts +25 -25
- package/components/hy-count-to/hy-count-to.vue +148 -213
- package/components/hy-count-to/props.ts +60 -15
- package/components/hy-count-to/typing.d.ts +46 -46
- package/components/hy-coupon/README.md +133 -0
- package/components/hy-coupon/hy-coupon.vue +180 -0
- package/components/hy-coupon/index.scss +553 -0
- package/components/hy-coupon/props.ts +129 -0
- package/components/hy-coupon/typing.d.ts +146 -0
- package/components/hy-datetime-picker/hy-datetime-picker.vue +415 -580
- package/components/hy-datetime-picker/props.ts +142 -32
- package/components/hy-datetime-picker/typing.d.ts +132 -132
- package/components/hy-divider/hy-divider.vue +90 -169
- package/components/hy-divider/props.ts +78 -19
- package/components/hy-divider/typing.d.ts +60 -60
- package/components/hy-dropdown/hy-dropdown.vue +37 -71
- package/components/hy-dropdown/props.ts +38 -15
- package/components/hy-dropdown/typing.d.ts +44 -44
- package/components/hy-dropdown-item/hy-dropdown-item.vue +141 -173
- package/components/hy-dropdown-item/props.ts +19 -8
- package/components/hy-empty/hy-empty.vue +75 -129
- package/components/hy-empty/props.ts +57 -15
- package/components/hy-empty/typing.d.ts +84 -84
- package/components/hy-flex/hy-flex.vue +33 -88
- package/components/hy-flex/props.ts +58 -0
- package/components/hy-flex/typing.d.ts +14 -16
- package/components/hy-float-button/hy-float-button.vue +289 -406
- package/components/hy-float-button/props.ts +109 -25
- package/components/hy-folding-panel/hy-folding-panel.vue +86 -374
- package/components/hy-folding-panel/props.ts +40 -15
- package/components/hy-folding-panel/typing.d.ts +52 -63
- package/components/hy-folding-panel-item/hy-folding-panel-item.vue +186 -228
- package/components/hy-folding-panel-item/index.scss +87 -0
- package/components/hy-folding-panel-item/props.ts +81 -0
- package/components/hy-folding-panel-item/typing.d.ts +23 -0
- package/components/hy-form/hy-form.vue +172 -212
- package/components/hy-form/props.ts +37 -0
- package/components/hy-form/typing.d.ts +68 -61
- package/components/hy-form-group/typing.d.ts +74 -74
- package/components/hy-form-item/hy-form-item.vue +100 -129
- package/components/hy-form-item/props.ts +25 -0
- package/components/hy-form-item/typing.d.ts +40 -37
- package/components/hy-grid/hy-grid.vue +76 -132
- package/components/hy-grid/props.ts +58 -16
- package/components/hy-grid/typing.d.ts +66 -66
- package/components/hy-icon/hy-icon.vue +84 -161
- package/components/hy-icon/props.ts +76 -22
- package/components/hy-icon/typing.d.ts +83 -82
- package/components/hy-image/hy-image.vue +142 -272
- package/components/hy-image/props.ts +105 -23
- package/components/hy-image/typing.d.ts +84 -87
- package/components/hy-input/hy-input.vue +230 -421
- package/components/hy-input/props.ts +183 -35
- package/components/hy-input/typing.d.ts +169 -169
- package/components/hy-line/hy-line.vue +34 -72
- package/components/hy-line/props.ts +41 -10
- package/components/hy-line/typing.d.ts +29 -29
- package/components/hy-line-progress/hy-line-progress.vue +66 -101
- package/components/hy-line-progress/props.ts +31 -10
- package/components/hy-line-progress/typing.d.ts +29 -29
- package/components/hy-list/hy-list.vue +151 -220
- package/components/hy-list/props.ts +67 -16
- package/components/hy-list/typing.d.ts +52 -52
- package/components/hy-loading/hy-loading.vue +63 -119
- package/components/hy-loading/props.ts +63 -15
- package/components/hy-loading/typing.d.ts +49 -49
- package/components/hy-menu/hy-menu.vue +124 -166
- package/components/hy-menu/props.ts +42 -10
- package/components/hy-menu/typing.d.ts +60 -60
- package/components/hy-modal/hy-modal.vue +127 -218
- package/components/hy-modal/props.ts +89 -24
- package/components/hy-navbar/hy-navbar.vue +104 -177
- package/components/hy-navbar/props.ts +76 -22
- package/components/hy-navbar/typing.d.ts +81 -81
- package/components/hy-notice-bar/hy-notice-bar.vue +67 -144
- package/components/hy-notice-bar/props.ts +80 -19
- package/components/hy-notice-bar/typing.d.ts +62 -62
- package/components/hy-notify/hy-notify.vue +128 -177
- package/components/hy-notify/props.ts +49 -12
- package/components/hy-notify/typing.d.ts +45 -41
- package/components/hy-number-step/hy-number-step.vue +281 -394
- package/components/hy-number-step/props.ts +110 -27
- package/components/hy-number-step/typing.d.ts +120 -120
- package/components/hy-overlay/hy-overlay.vue +39 -66
- package/components/hy-overlay/props.ts +31 -8
- package/components/hy-pagination/hy-pagination.vue +100 -155
- package/components/hy-pagination/props.ts +53 -13
- package/components/hy-picker/hy-picker.vue +309 -430
- package/components/hy-picker/index.scss +8 -12
- package/components/hy-picker/props.ts +110 -26
- package/components/hy-popover/hy-popover.vue +190 -252
- package/components/hy-popover/props.ts +48 -10
- package/components/hy-popup/hy-popup.vue +162 -248
- package/components/hy-popup/props.ts +82 -18
- package/components/hy-price/hy-price.vue +45 -104
- package/components/hy-price/props.ts +52 -12
- package/components/hy-price/typing.d.ts +41 -36
- package/components/hy-qrcode/hy-qrcode.vue +115 -185
- package/components/hy-qrcode/props.ts +68 -18
- package/components/hy-qrcode/typing.d.ts +67 -66
- package/components/hy-radio/hy-radio.vue +161 -259
- package/components/hy-radio/props.ts +95 -25
- package/components/hy-radio/typing.d.ts +85 -84
- package/components/hy-rate/hy-rate.vue +185 -270
- package/components/hy-rate/props.ts +76 -18
- package/components/hy-rate/typing.d.ts +61 -60
- package/components/hy-read-more/hy-read-more.vue +93 -136
- package/components/hy-read-more/props.ts +43 -13
- package/components/hy-scroll-list/hy-scroll-list.vue +81 -102
- package/components/hy-scroll-list/props.ts +22 -11
- package/components/hy-search/hy-search.vue +155 -284
- package/components/hy-search/props.ts +130 -25
- package/components/hy-signature/hy-signature.vue +491 -635
- package/components/hy-signature/props.ts +115 -26
- package/components/hy-signature/typing.d.ts +138 -138
- package/components/hy-slider/hy-slider.vue +388 -477
- package/components/hy-slider/props.ts +75 -19
- package/components/hy-steps/hy-steps.vue +212 -279
- package/components/hy-steps/props.ts +47 -13
- package/components/hy-submit-bar/hy-submit-bar.vue +137 -222
- package/components/hy-submit-bar/props.ts +89 -20
- package/components/hy-submit-bar/typing.d.ts +86 -85
- package/components/hy-subsection/hy-subsection.vue +132 -185
- package/components/hy-subsection/props.ts +50 -17
- package/components/hy-subsection/typing.d.ts +52 -52
- package/components/hy-swipe-action/hy-swipe-action.vue +228 -283
- package/components/hy-swipe-action/props.ts +43 -18
- package/components/hy-swipe-action/typing.d.ts +46 -46
- package/components/hy-swiper/hy-swiper.vue +159 -286
- package/components/hy-swiper/props.ts +126 -28
- package/components/hy-swiper/typing.d.ts +115 -115
- package/components/hy-switch/hy-switch.vue +112 -176
- package/components/hy-switch/props.ts +60 -15
- package/components/hy-switch/typing.d.ts +63 -63
- package/components/hy-tabBar/hy-tabBar.vue +64 -60
- package/components/hy-tabs/hy-tabs.vue +277 -380
- package/components/hy-tabs/props.ts +75 -18
- package/components/hy-tag/hy-tag.vue +111 -204
- package/components/hy-tag/props.ts +81 -19
- package/components/hy-text/hy-text.vue +200 -322
- package/components/hy-text/props.ts +107 -28
- package/components/hy-textarea/hy-textarea.vue +147 -256
- package/components/hy-textarea/props.ts +112 -25
- package/components/hy-textarea/typing.d.ts +42 -42
- package/components/hy-toast/hy-toast.vue +135 -143
- package/components/hy-tooltip/hy-tooltip.vue +220 -306
- package/components/hy-tooltip/props.ts +79 -15
- package/components/hy-transition/hy-transition.vue +111 -138
- package/components/hy-transition/props.ts +30 -8
- package/components/hy-upload/hy-upload.vue +320 -469
- package/components/hy-upload/props.ts +130 -27
- package/components/hy-warn/hy-warn.vue +80 -129
- package/components/hy-warn/props.ts +47 -12
- package/components/hy-waterfall/hy-waterfall.vue +139 -163
- package/components/hy-waterfall/props.ts +19 -7
- package/components/hy-watermark/hy-watermark.vue +762 -870
- package/components/hy-watermark/props.ts +103 -22
- package/global.d.ts +2 -0
- package/libs/css/theme.scss +3 -3
- package/package.json +2 -2
- package/web-types.json +1 -1
- package/components/hy-folding-panel/index.scss +0 -9
|
@@ -1,686 +1,521 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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
|
|
77
|
-
import
|
|
78
|
-
import
|
|
79
|
-
import {
|
|
80
|
-
import
|
|
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
|
|
84
|
-
import HyPicker from
|
|
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
|
-
|
|
93
|
-
const
|
|
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)
|
|
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
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
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
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
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
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
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
|
-
|
|
273
|
-
|
|
274
|
-
|
|
126
|
+
// 获取当前值
|
|
127
|
+
innerValue.value = correctValue(props.modelValue)
|
|
128
|
+
// 更新列表
|
|
129
|
+
updateColumnValue(innerValue.value)
|
|
275
130
|
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
}
|
|
131
|
+
// 初始化hasInput展示
|
|
132
|
+
getInputValue(innerValue.value)
|
|
133
|
+
}
|
|
279
134
|
|
|
280
135
|
watch(
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
136
|
+
() => props.show,
|
|
137
|
+
(newValue) => {
|
|
138
|
+
if (newValue) {
|
|
139
|
+
updateColumnValue(innerValue.value)
|
|
140
|
+
}
|
|
285
141
|
}
|
|
286
|
-
|
|
287
|
-
);
|
|
142
|
+
)
|
|
288
143
|
|
|
289
144
|
watch(
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
)
|
|
145
|
+
() => props.modelValue,
|
|
146
|
+
() => init()
|
|
147
|
+
)
|
|
293
148
|
|
|
294
149
|
const propsChange = computed(() => {
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
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
|
-
|
|
309
|
-
|
|
310
|
-
)
|
|
163
|
+
() => propsChange.value,
|
|
164
|
+
() => init()
|
|
165
|
+
)
|
|
311
166
|
|
|
312
167
|
onMounted(() => {
|
|
313
|
-
|
|
314
|
-
})
|
|
168
|
+
init()
|
|
169
|
+
})
|
|
315
170
|
|
|
316
171
|
const getInputValue = (newValue: string | number) => {
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
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
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
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
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
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
|
-
|
|
370
|
-
|
|
371
|
-
|
|
222
|
+
if (props.closeOnClickOverlay) {
|
|
223
|
+
if (props.hasInput) {
|
|
224
|
+
showByClickInput.value = false
|
|
225
|
+
}
|
|
226
|
+
emit('close')
|
|
372
227
|
}
|
|
373
|
-
|
|
374
|
-
}
|
|
375
|
-
};
|
|
228
|
+
}
|
|
376
229
|
|
|
377
230
|
/**
|
|
378
231
|
* @description 点击工具栏的取消按钮
|
|
379
232
|
* */
|
|
380
233
|
const cancel = () => {
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
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
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
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
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
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
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
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 =
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
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
|
-
|
|
470
|
-
|
|
471
|
-
|
|
322
|
+
let values: string[] = []
|
|
323
|
+
let timeArr: string[] = []
|
|
324
|
+
const formatterFn = props.formatter || innerFormatter
|
|
472
325
|
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
//
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
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
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
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
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
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
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
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
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
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
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
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
|
-
|
|
679
|
-
|
|
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
|
|
520
|
+
@import './index.scss';
|
|
686
521
|
</style>
|