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,289 +1,129 @@
|
|
|
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
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
2
|
+
<HyPopup
|
|
3
|
+
:show="show"
|
|
4
|
+
mode="bottom"
|
|
5
|
+
closeable
|
|
6
|
+
@close="close"
|
|
7
|
+
:round="round"
|
|
8
|
+
:closeOnClickOverlay="closeOnClickOverlay"
|
|
9
|
+
>
|
|
10
|
+
<view class="hy-calendar">
|
|
11
|
+
<HyHeader
|
|
12
|
+
:title="title"
|
|
13
|
+
:subtitle="subtitle"
|
|
14
|
+
:showSubtitle="showSubtitle"
|
|
15
|
+
:showTitle="showTitle"
|
|
16
|
+
:weekText="weekText"
|
|
17
|
+
></HyHeader>
|
|
18
|
+
<scroll-view
|
|
19
|
+
:style="{
|
|
20
|
+
height: addUnit(listHeight)
|
|
21
|
+
}"
|
|
22
|
+
scroll-y
|
|
23
|
+
@scroll="onScroll"
|
|
24
|
+
:scroll-top="scrollTop"
|
|
25
|
+
:scrollIntoView="scrollIntoView"
|
|
26
|
+
>
|
|
27
|
+
<HyMount
|
|
28
|
+
:color="color"
|
|
29
|
+
:rowHeight="rowHeight"
|
|
30
|
+
:showMark="showMark"
|
|
31
|
+
:months="months"
|
|
32
|
+
:mode="mode"
|
|
33
|
+
:maxCount="maxCount"
|
|
34
|
+
:startText="startText"
|
|
35
|
+
:endText="endText"
|
|
36
|
+
:defaultDate="defaultDate"
|
|
37
|
+
:minDate="innerMinDate"
|
|
38
|
+
:maxDate="innerMaxDate"
|
|
39
|
+
:maxMonth="monthNum"
|
|
40
|
+
:readonly="readonly"
|
|
41
|
+
:maxRange="maxRange"
|
|
42
|
+
:rangePrompt="rangePrompt"
|
|
43
|
+
:showRangePrompt="showRangePrompt"
|
|
44
|
+
:allowSameDay="allowSameDay"
|
|
45
|
+
:forbidDays="forbidDays"
|
|
46
|
+
:forbidDaysToast="forbidDaysToast"
|
|
47
|
+
ref="month"
|
|
48
|
+
@monthSelected="monthSelected"
|
|
49
|
+
@updateMonthTop="updateMonthTop"
|
|
50
|
+
></HyMount>
|
|
51
|
+
</scroll-view>
|
|
52
|
+
<slot name="footer" v-if="showConfirm">
|
|
53
|
+
<view class="hy-calendar__confirm">
|
|
54
|
+
<HyButton
|
|
55
|
+
shape="circle"
|
|
56
|
+
:text="buttonDisabled ? confirmDisabledText : confirmText"
|
|
57
|
+
:color="color"
|
|
58
|
+
@click="confirm"
|
|
59
|
+
:disabled="buttonDisabled"
|
|
60
|
+
></HyButton>
|
|
61
|
+
</view>
|
|
62
|
+
</slot>
|
|
61
63
|
</view>
|
|
62
|
-
|
|
63
|
-
</view>
|
|
64
|
-
</HyPopup>
|
|
64
|
+
</HyPopup>
|
|
65
65
|
</template>
|
|
66
66
|
|
|
67
67
|
<script lang="ts">
|
|
68
68
|
export default {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
69
|
+
name: 'hy-calendar',
|
|
70
|
+
options: {
|
|
71
|
+
virtualHost: true,
|
|
72
|
+
styleIsolation: 'shared'
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
75
|
</script>
|
|
76
76
|
|
|
77
77
|
<script setup lang="ts">
|
|
78
|
-
import type { ICalendarEmits } from
|
|
79
|
-
import { computed, nextTick, onMounted,
|
|
80
|
-
import {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
isNumericString,
|
|
85
|
-
padZero,
|
|
86
|
-
range,
|
|
87
|
-
} from "../../libs";
|
|
88
|
-
import Calendar from "../../libs/utils/calendar.js";
|
|
89
|
-
import dayjs from "dayjs/esm";
|
|
78
|
+
import type { ICalendarEmits } from './typing'
|
|
79
|
+
import { computed, nextTick, onMounted, ref, watch } from 'vue'
|
|
80
|
+
import { addUnit, error, isArray, isNumericString, padZero, range } from '../../libs'
|
|
81
|
+
import Calendar from '../../libs/utils/calendar.js'
|
|
82
|
+
import calendarProps from './props'
|
|
83
|
+
import dayjs from 'dayjs/esm'
|
|
90
84
|
// 组件
|
|
91
|
-
import HyMount from
|
|
92
|
-
import HyHeader from
|
|
93
|
-
import HyPopup from
|
|
94
|
-
import HyButton from
|
|
85
|
+
import HyMount from './month.vue'
|
|
86
|
+
import HyHeader from './header.vue'
|
|
87
|
+
import HyPopup from '../hy-popup/hy-popup.vue'
|
|
88
|
+
import HyButton from '../hy-button/hy-button.vue'
|
|
95
89
|
|
|
96
90
|
/**
|
|
97
91
|
* 用于单个选择日期,范围选择日期等,日历被包裹在底部弹起的容器中。
|
|
98
92
|
* @displayName hy-calendar
|
|
99
93
|
*/
|
|
100
|
-
defineOptions({})
|
|
94
|
+
defineOptions({})
|
|
101
95
|
|
|
102
|
-
|
|
103
|
-
const
|
|
104
|
-
/** 是否显示日历弹窗 */
|
|
105
|
-
show: {
|
|
106
|
-
type: Boolean,
|
|
107
|
-
default: false,
|
|
108
|
-
required: true,
|
|
109
|
-
},
|
|
110
|
-
/** 标题内容 */
|
|
111
|
-
title: {
|
|
112
|
-
type: String,
|
|
113
|
-
default: "日期选选择",
|
|
114
|
-
},
|
|
115
|
-
/** 是否显示标题 */
|
|
116
|
-
showTitle: {
|
|
117
|
-
type: Boolean,
|
|
118
|
-
default: true,
|
|
119
|
-
},
|
|
120
|
-
/** 是否显示副标题 */
|
|
121
|
-
showSubtitle: {
|
|
122
|
-
type: Boolean,
|
|
123
|
-
default: true,
|
|
124
|
-
},
|
|
125
|
-
/**
|
|
126
|
-
* 日期类型选择
|
|
127
|
-
* @values single,range,multiple
|
|
128
|
-
* */
|
|
129
|
-
mode: {
|
|
130
|
-
type: String,
|
|
131
|
-
default: "single",
|
|
132
|
-
},
|
|
133
|
-
/** mode=range时,第一个日期底部的提示文字 */
|
|
134
|
-
startText: {
|
|
135
|
-
type: String,
|
|
136
|
-
default: "开始",
|
|
137
|
-
},
|
|
138
|
-
/** mode=range时,最后一个日期底部的提示文字 */
|
|
139
|
-
endText: {
|
|
140
|
-
type: String,
|
|
141
|
-
default: "结束",
|
|
142
|
-
},
|
|
143
|
-
/** 自定义列表 */
|
|
144
|
-
customList: {
|
|
145
|
-
type: Array as unknown as PropType<any[]>,
|
|
146
|
-
default: [],
|
|
147
|
-
},
|
|
148
|
-
/** 主题色,对底部按钮和选中日期有效 */
|
|
149
|
-
color: {
|
|
150
|
-
type: String,
|
|
151
|
-
default: "",
|
|
152
|
-
},
|
|
153
|
-
/** 最小的可选日期 */
|
|
154
|
-
minDate: {
|
|
155
|
-
type: [String, Number],
|
|
156
|
-
default: 0,
|
|
157
|
-
},
|
|
158
|
-
/** 最大可选日期 */
|
|
159
|
-
maxDate: {
|
|
160
|
-
type: [String, Number],
|
|
161
|
-
default: 0,
|
|
162
|
-
},
|
|
163
|
-
/** 默认选中的日期,mode为multiple或range是必须为数组格式 */
|
|
164
|
-
defaultDate: [Date, String, Array],
|
|
165
|
-
/** mode=multiple时,最多可选多少个日期 */
|
|
166
|
-
maxCount: {
|
|
167
|
-
type: Number,
|
|
168
|
-
default: Number.MAX_SAFE_INTEGER,
|
|
169
|
-
},
|
|
170
|
-
/** 日期行高 */
|
|
171
|
-
rowHeight: {
|
|
172
|
-
type: Number,
|
|
173
|
-
default: 56,
|
|
174
|
-
},
|
|
175
|
-
/** 日期格式化函数 */
|
|
176
|
-
formatter: {
|
|
177
|
-
type: Function as PropType<(date: Date) => string>,
|
|
178
|
-
},
|
|
179
|
-
/** 是否显示农历 */
|
|
180
|
-
showLunar: {
|
|
181
|
-
type: Boolean,
|
|
182
|
-
default: false,
|
|
183
|
-
},
|
|
184
|
-
/** 是否显示月份背景色 */
|
|
185
|
-
showMark: {
|
|
186
|
-
type: Boolean,
|
|
187
|
-
default: true,
|
|
188
|
-
},
|
|
189
|
-
/** 确定按钮的文字 */
|
|
190
|
-
confirmText: {
|
|
191
|
-
type: String,
|
|
192
|
-
default: "确定",
|
|
193
|
-
},
|
|
194
|
-
/** 确认按钮处于禁用状态时的文字 */
|
|
195
|
-
confirmDisabledText: {
|
|
196
|
-
type: String,
|
|
197
|
-
default: "确定",
|
|
198
|
-
},
|
|
199
|
-
/** 是否允许点击遮罩关闭日历 */
|
|
200
|
-
closeOnClickOverlay: {
|
|
201
|
-
type: Boolean,
|
|
202
|
-
default: false,
|
|
203
|
-
},
|
|
204
|
-
/** 是否为只读状态,只读状态下禁止选择日期 */
|
|
205
|
-
readonly: {
|
|
206
|
-
type: Boolean,
|
|
207
|
-
default: false,
|
|
208
|
-
},
|
|
209
|
-
/** 是否展示确认按钮 */
|
|
210
|
-
showConfirm: {
|
|
211
|
-
type: Boolean,
|
|
212
|
-
default: true,
|
|
213
|
-
},
|
|
214
|
-
/** 日期区间最多可选天数,默认无限制,mode = range时有效 */
|
|
215
|
-
maxRange: {
|
|
216
|
-
type: Number,
|
|
217
|
-
default: Number.MAX_SAFE_INTEGER,
|
|
218
|
-
},
|
|
219
|
-
/** 范围选择超过最多可选天数时的提示文案,mode = range时有效 */
|
|
220
|
-
rangePrompt: String,
|
|
221
|
-
/** 范围选择超过最多可选天数时,是否展示提示文案,mode = range时有效 */
|
|
222
|
-
showRangePrompt: {
|
|
223
|
-
type: Boolean,
|
|
224
|
-
default: true,
|
|
225
|
-
},
|
|
226
|
-
/** 是否允许日期范围的起止时间为同一天,mode = range时有效 */
|
|
227
|
-
allowSameDay: {
|
|
228
|
-
type: Boolean,
|
|
229
|
-
default: false,
|
|
230
|
-
},
|
|
231
|
-
/** 圆角值,默认无圆角 */
|
|
232
|
-
round: {
|
|
233
|
-
type: [String, Number],
|
|
234
|
-
default: 0,
|
|
235
|
-
},
|
|
236
|
-
/** 最多展示的月份数量 */
|
|
237
|
-
monthNum: {
|
|
238
|
-
type: Number,
|
|
239
|
-
default: 3,
|
|
240
|
-
},
|
|
241
|
-
/** 星期文案 */
|
|
242
|
-
weekText: {
|
|
243
|
-
type: Array as unknown as PropType<string[]>,
|
|
244
|
-
default: () => ["一", "二", "三", "四", "五", "六", "日"],
|
|
245
|
-
},
|
|
246
|
-
/** 单选与多选禁止选中的日期列表,mode!=range时有效。 */
|
|
247
|
-
forbidDays: {
|
|
248
|
-
type: Array as unknown as PropType<Date[]>,
|
|
249
|
-
default: () => [],
|
|
250
|
-
},
|
|
251
|
-
/** 单选与多选禁止选中的日期选择时提示 */
|
|
252
|
-
forbidDaysToast: {
|
|
253
|
-
type: String,
|
|
254
|
-
default: "该日期已禁用",
|
|
255
|
-
},
|
|
256
|
-
});
|
|
257
|
-
const emit = defineEmits<ICalendarEmits>();
|
|
96
|
+
const props = defineProps(calendarProps)
|
|
97
|
+
const emit = defineEmits<ICalendarEmits>()
|
|
258
98
|
|
|
259
99
|
// 需要显示的月份的数组
|
|
260
|
-
const months = ref<any[]>([])
|
|
100
|
+
const months = ref<any[]>([])
|
|
261
101
|
// 在月份滚动区域中,当前视图中月份的index索引
|
|
262
|
-
const monthIndex = ref(0)
|
|
102
|
+
const monthIndex = ref(0)
|
|
263
103
|
// 月份滚动区域的高度
|
|
264
|
-
const listHeight = ref(0)
|
|
104
|
+
const listHeight = ref(0)
|
|
265
105
|
// month组件中选择的日期数组
|
|
266
|
-
const selected = ref<string[]>([])
|
|
267
|
-
const scrollIntoView = ref(
|
|
268
|
-
const scrollIntoViewScroll = ref(
|
|
269
|
-
const scrollTop = ref(0)
|
|
106
|
+
const selected = ref<string[]>([])
|
|
107
|
+
const scrollIntoView = ref('')
|
|
108
|
+
const scrollIntoViewScroll = ref('')
|
|
109
|
+
const scrollTop = ref(0)
|
|
270
110
|
// 过滤处理方法
|
|
271
|
-
let innerFormatter = (value: string) => value
|
|
111
|
+
let innerFormatter = (value: string) => value
|
|
272
112
|
|
|
273
113
|
// 由于maxDate和minDate可以为字符串(2021-10-10),或者数值(时间戳),但是dayjs如果接受字符串形式的时间戳会有问题,这里进行处理
|
|
274
114
|
const innerMaxDate = computed(() => {
|
|
275
|
-
|
|
276
|
-
})
|
|
115
|
+
return isNumericString(props.maxDate) ? Number(props.maxDate) : props.maxDate
|
|
116
|
+
})
|
|
277
117
|
const innerMinDate = computed(() => {
|
|
278
|
-
|
|
279
|
-
})
|
|
118
|
+
return isNumericString(props.minDate) ? Number(props.minDate) : props.minDate
|
|
119
|
+
})
|
|
280
120
|
|
|
281
121
|
/**
|
|
282
122
|
* @description 多个条件的变化,会引起选中日期的变化,这里统一管理监听
|
|
283
123
|
* */
|
|
284
124
|
const selectedChange = computed(() => {
|
|
285
|
-
|
|
286
|
-
})
|
|
125
|
+
return [innerMinDate.value, innerMaxDate.value, props.defaultDate]
|
|
126
|
+
})
|
|
287
127
|
|
|
288
128
|
/**
|
|
289
129
|
* @description 获得两个日期之间的月份数
|
|
@@ -291,236 +131,232 @@ const selectedChange = computed(() => {
|
|
|
291
131
|
* @param maxDate 最大日期
|
|
292
132
|
* */
|
|
293
133
|
const getMonths = (minDate: number | string, maxDate: number | string) => {
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
}
|
|
134
|
+
const minYear = dayjs(minDate).year()
|
|
135
|
+
const minMonth = dayjs(minDate).month() + 1
|
|
136
|
+
const maxYear = dayjs(maxDate).year()
|
|
137
|
+
const maxMonth = dayjs(maxDate).month() + 1
|
|
138
|
+
return (maxYear - minYear) * 12 + (maxMonth - minMonth) + 1
|
|
139
|
+
}
|
|
300
140
|
|
|
301
141
|
/**
|
|
302
142
|
* @description 设置月份数据
|
|
303
143
|
* */
|
|
304
144
|
const setMonth = () => {
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
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
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
});
|
|
361
|
-
}
|
|
362
|
-
};
|
|
145
|
+
// 最小日期的毫秒数
|
|
146
|
+
const minDate = innerMinDate.value || dayjs().valueOf()
|
|
147
|
+
// 如果没有指定最大日期,则往后推3个月
|
|
148
|
+
const maxDate =
|
|
149
|
+
innerMaxDate.value ||
|
|
150
|
+
dayjs(minDate)
|
|
151
|
+
.add(props.monthNum - 1, 'month')
|
|
152
|
+
.valueOf()
|
|
153
|
+
// 最大最小月份之间的共有多少个月份,
|
|
154
|
+
const monthList = range(1, props.monthNum, getMonths(minDate, maxDate))
|
|
155
|
+
// 先清空数组
|
|
156
|
+
months.value = []
|
|
157
|
+
for (let i = 0; i < monthList; i++) {
|
|
158
|
+
months.value.push({
|
|
159
|
+
date: new Array(dayjs(minDate).add(i, 'month').daysInMonth())
|
|
160
|
+
.fill(1)
|
|
161
|
+
.map((item, index) => {
|
|
162
|
+
// 日期,取值1-31
|
|
163
|
+
let day = index + 1
|
|
164
|
+
// 星期,0-6,0为周日
|
|
165
|
+
const week = dayjs(minDate).add(i, 'month').date(day).day()
|
|
166
|
+
const date = dayjs(minDate).add(i, 'month').date(day).format('YYYY-MM-DD')
|
|
167
|
+
let bottomInfo = ''
|
|
168
|
+
if (props.showLunar) {
|
|
169
|
+
// 将日期转为农历格式
|
|
170
|
+
const lunar = Calendar.solar2lunar(
|
|
171
|
+
dayjs(date).year(),
|
|
172
|
+
dayjs(date).month() + 1,
|
|
173
|
+
dayjs(date).date()
|
|
174
|
+
)
|
|
175
|
+
bottomInfo = lunar.IDayCn
|
|
176
|
+
}
|
|
177
|
+
let config = {
|
|
178
|
+
day,
|
|
179
|
+
week,
|
|
180
|
+
// 小于最小允许的日期,或者大于最大的日期,则设置为disabled状态
|
|
181
|
+
disabled:
|
|
182
|
+
dayjs(date).isBefore(dayjs(minDate).format('YYYY-MM-DD')) ||
|
|
183
|
+
dayjs(date).isAfter(dayjs(maxDate).format('YYYY-MM-DD')),
|
|
184
|
+
// 返回一个日期对象,供外部的formatter获取当前日期的年月日等信息,进行加工处理
|
|
185
|
+
date: new Date(date),
|
|
186
|
+
bottomInfo,
|
|
187
|
+
dot: false,
|
|
188
|
+
month: dayjs(minDate).add(i, 'month').month() + 1
|
|
189
|
+
}
|
|
190
|
+
const format = props.formatter || innerFormatter
|
|
191
|
+
return format(config as any)
|
|
192
|
+
}),
|
|
193
|
+
// 当前所属的月份
|
|
194
|
+
month: dayjs(minDate).add(i, 'month').month() + 1,
|
|
195
|
+
// 当前年份
|
|
196
|
+
year: dayjs(minDate).add(i, 'month').year()
|
|
197
|
+
})
|
|
198
|
+
}
|
|
199
|
+
}
|
|
363
200
|
|
|
364
201
|
watch(
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
)
|
|
202
|
+
() => selectedChange.value,
|
|
203
|
+
() => setMonth(),
|
|
204
|
+
{ immediate: true }
|
|
205
|
+
)
|
|
369
206
|
|
|
370
207
|
watch(
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
)
|
|
208
|
+
() => props.show,
|
|
209
|
+
(newVal: boolean) => {
|
|
210
|
+
if (newVal) {
|
|
211
|
+
setMonth()
|
|
212
|
+
} else {
|
|
213
|
+
// 关闭时重置scrollIntoView,否则会出现二次打开日历,当前月份数据显示不正确。
|
|
214
|
+
// scrollIntoView需要有一个值变动过程,才会产生作用。
|
|
215
|
+
scrollIntoView.value = ''
|
|
216
|
+
}
|
|
217
|
+
},
|
|
218
|
+
{ immediate: true }
|
|
219
|
+
)
|
|
383
220
|
|
|
384
221
|
const subtitle = computed(() => {
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
})
|
|
222
|
+
// 初始化时,this.months为空数组,所以需要特别判断处理
|
|
223
|
+
if (months.value.length) {
|
|
224
|
+
return `${months.value[monthIndex.value].year}年${months.value[monthIndex.value].month}月`
|
|
225
|
+
} else {
|
|
226
|
+
return ''
|
|
227
|
+
}
|
|
228
|
+
})
|
|
392
229
|
|
|
393
230
|
const buttonDisabled = computed(() => {
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
})
|
|
231
|
+
// 如果为range类型,且选择的日期个数不足1个时,让底部的按钮出于disabled状态
|
|
232
|
+
if (props.mode === 'range') {
|
|
233
|
+
return selected.value.length <= 1
|
|
234
|
+
} else {
|
|
235
|
+
return false
|
|
236
|
+
}
|
|
237
|
+
})
|
|
401
238
|
|
|
402
239
|
onMounted(() => {
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
})
|
|
240
|
+
// start.value = Date.now();
|
|
241
|
+
init()
|
|
242
|
+
})
|
|
406
243
|
|
|
407
244
|
// 在微信小程序中,不支持将函数当做props参数,故只能通过ref形式调用
|
|
408
245
|
const setFormatter = (e: (value: string) => string) => {
|
|
409
|
-
|
|
410
|
-
}
|
|
246
|
+
innerFormatter = e
|
|
247
|
+
}
|
|
411
248
|
|
|
412
249
|
/**
|
|
413
250
|
* @description month组件内部选择日期后,通过事件通知给父组件
|
|
414
251
|
*/
|
|
415
|
-
const monthSelected = (e: string[], scene =
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
252
|
+
const monthSelected = (e: string[], scene = 'init') => {
|
|
253
|
+
selected.value = e
|
|
254
|
+
if (!props.showConfirm) {
|
|
255
|
+
// 在不需要确认按钮的情况下,如果为单选,或者范围多选且已选长度大于2,则直接进行返还
|
|
256
|
+
if (
|
|
257
|
+
props.mode === 'multiple' ||
|
|
258
|
+
props.mode === 'single' ||
|
|
259
|
+
(props.mode === 'range' && selected.value.length >= 2)
|
|
260
|
+
) {
|
|
261
|
+
if (scene === 'init') {
|
|
262
|
+
return
|
|
263
|
+
}
|
|
264
|
+
if (scene === 'tap') {
|
|
265
|
+
emit('confirm', selected.value)
|
|
266
|
+
}
|
|
267
|
+
}
|
|
430
268
|
}
|
|
431
|
-
|
|
432
|
-
};
|
|
269
|
+
}
|
|
433
270
|
|
|
434
271
|
const init = () => {
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
};
|
|
272
|
+
// 校验maxDate,不能小于minDate。
|
|
273
|
+
if (
|
|
274
|
+
innerMaxDate.value &&
|
|
275
|
+
innerMinDate.value &&
|
|
276
|
+
new Date(innerMaxDate.value).getTime() < new Date(innerMinDate.value).getTime()
|
|
277
|
+
) {
|
|
278
|
+
return error('maxDate不能小于minDate时间')
|
|
279
|
+
}
|
|
280
|
+
// 滚动区域的高度
|
|
281
|
+
listHeight.value = props.rowHeight * 5 + 30
|
|
282
|
+
setMonth()
|
|
283
|
+
}
|
|
448
284
|
|
|
449
285
|
const close = () => {
|
|
450
|
-
|
|
451
|
-
}
|
|
286
|
+
emit('close')
|
|
287
|
+
}
|
|
452
288
|
|
|
453
289
|
/**
|
|
454
290
|
* @description 点击确定按钮
|
|
455
291
|
* */
|
|
456
292
|
const confirm = () => {
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
}
|
|
293
|
+
if (!buttonDisabled.value) {
|
|
294
|
+
emit('confirm', selected.value)
|
|
295
|
+
}
|
|
296
|
+
}
|
|
461
297
|
|
|
462
298
|
/**
|
|
463
299
|
* @description 滚动到默认设置的月份
|
|
464
300
|
* @param selected 日期
|
|
465
301
|
* */
|
|
466
302
|
const scrollIntoDefaultMonth = (selected: string) => {
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
}
|
|
303
|
+
// 查询默认日期在可选列表的下标
|
|
304
|
+
const _index = months.value.findIndex(({ year, month }) => {
|
|
305
|
+
month = padZero(month)
|
|
306
|
+
return `${year}-${month}` === selected
|
|
307
|
+
})
|
|
308
|
+
if (_index !== -1) {
|
|
309
|
+
// #ifndef MP-WEIXIN
|
|
310
|
+
nextTick(() => {
|
|
311
|
+
scrollIntoView.value = `month-${_index}`
|
|
312
|
+
scrollIntoViewScroll.value = scrollIntoView.value
|
|
313
|
+
})
|
|
314
|
+
// #endif
|
|
315
|
+
// #ifdef MP-WEIXIN
|
|
316
|
+
scrollTop.value = months.value[_index].top || 0
|
|
317
|
+
// #endif
|
|
318
|
+
}
|
|
319
|
+
}
|
|
484
320
|
// scroll-view滚动监听
|
|
485
321
|
const onScroll = (event: any) => {
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
322
|
+
// 不允许小于0的滚动值,如果scroll-view到顶了,继续下拉,会出现负数值
|
|
323
|
+
const scrollTop = Math.max(0, event.detail.scrollTop)
|
|
324
|
+
// 将当前滚动条数值,除以滚动区域的高度,可以得出当前滚动到了哪一个月份的索引
|
|
325
|
+
for (let i = 0; i < months.value.length; i++) {
|
|
326
|
+
if (scrollTop >= (months.value[i].top || listHeight.value)) {
|
|
327
|
+
monthIndex.value = i
|
|
328
|
+
scrollIntoViewScroll.value = `month-${i}`
|
|
329
|
+
}
|
|
493
330
|
}
|
|
494
|
-
|
|
495
|
-
};
|
|
331
|
+
}
|
|
496
332
|
// 更新月份的top值
|
|
497
333
|
const updateMonthTop = (topArr = []) => {
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
334
|
+
// 设置对应月份的top值,用于onScroll方法更新月份
|
|
335
|
+
topArr.map((item, index) => {
|
|
336
|
+
months.value[index].top = item
|
|
337
|
+
})
|
|
338
|
+
// 如果没有设置默认日期,则将当天日期设置为默认选中的日期
|
|
339
|
+
let selected = dayjs().format('YYYY-MM')
|
|
504
340
|
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
}
|
|
341
|
+
// 获取默认日期的下标
|
|
342
|
+
if (!props.defaultDate) {
|
|
343
|
+
scrollIntoDefaultMonth(selected)
|
|
344
|
+
return
|
|
345
|
+
}
|
|
346
|
+
// 单选模式,可以是字符串或数组,Date对象等
|
|
347
|
+
if (!isArray(props.defaultDate)) {
|
|
348
|
+
selected = dayjs(props.defaultDate).format('YYYY-MM')
|
|
349
|
+
} else {
|
|
350
|
+
selected = dayjs(props.defaultDate[0]).format('YYYY-MM')
|
|
351
|
+
}
|
|
352
|
+
scrollIntoDefaultMonth(selected)
|
|
353
|
+
}
|
|
518
354
|
|
|
519
355
|
defineExpose({
|
|
520
|
-
|
|
521
|
-
})
|
|
356
|
+
setFormatter
|
|
357
|
+
})
|
|
522
358
|
</script>
|
|
523
359
|
|
|
524
360
|
<style scoped lang="scss">
|
|
525
|
-
@import
|
|
361
|
+
@import './index.scss';
|
|
526
362
|
</style>
|