@tplc/wot 1.0.12 → 1.0.13
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/CHANGELOG.md +2 -0
- package/components/wd-calendar/index.scss +145 -58
- package/components/wd-calendar/types.ts +41 -23
- package/components/wd-calendar/wd-calendar.vue +130 -123
- package/components/wd-calendar-view/month/index.scss +65 -33
- package/components/wd-calendar-view/month/month.vue +113 -80
- package/components/wd-calendar-view/month/types.ts +1 -2
- package/components/wd-calendar-view/monthPanel/index.scss +15 -15
- package/components/wd-calendar-view/monthPanel/month-panel.vue +78 -64
- package/components/wd-calendar-view/monthPanel/types.ts +10 -58
- package/components/wd-calendar-view/types.ts +36 -12
- package/components/wd-calendar-view/utils.ts +36 -14
- package/components/wd-calendar-view/wd-calendar-view.vue +7 -7
- package/components/wd-calendar-view/year/index.scss +13 -18
- package/components/wd-calendar-view/year/types.ts +1 -2
- package/components/wd-calendar-view/year/year.vue +43 -25
- package/components/wd-calendar-view/yearPanel/index.scss +4 -4
- package/components/wd-calendar-view/yearPanel/types.ts +2 -2
- package/components/wd-calendar-view/yearPanel/year-panel.vue +41 -36
- package/components/wd-drop-menu/index.scss +45 -17
- package/components/wd-drop-menu/types.ts +3 -3
- package/components/wd-drop-menu/wd-drop-menu.vue +25 -61
- package/components/wd-drop-menu-item/index.scss +15 -15
- package/components/wd-drop-menu-item/types.ts +15 -18
- package/components/wd-drop-menu-item/wd-drop-menu-item.vue +54 -33
- package/package.json +1 -1
- package/types/components/common/dayjs.d.ts +26 -0
- package/types/components/wd-calendar/types.d.ts +18 -24
- package/types/components/wd-calendar/wd-calendar.vue.d.ts +24 -40
- package/types/components/wd-calendar-view/month/month.vue.d.ts +3 -11
- package/types/components/wd-calendar-view/month/types.d.ts +0 -4
- package/types/components/wd-calendar-view/monthPanel/month-panel.vue.d.ts +12 -18
- package/types/components/wd-calendar-view/monthPanel/types.d.ts +6 -48
- package/types/components/wd-calendar-view/types.d.ts +4 -11
- package/types/components/wd-calendar-view/utils.d.ts +12 -3
- package/types/components/wd-calendar-view/year/types.d.ts +0 -4
- package/types/components/wd-calendar-view/year/year.vue.d.ts +3 -11
- package/types/components/wd-cell/wd-cell.vue.d.ts +5 -5
- package/types/components/wd-col-picker/wd-col-picker.vue.d.ts +9 -9
- package/types/components/wd-datetime-picker/wd-datetime-picker.vue.d.ts +10 -10
- package/types/components/wd-datetime-picker-view/wd-datetime-picker-view.vue.d.ts +1 -1
- package/types/components/wd-drop-menu/types.d.ts +3 -3
- package/types/components/wd-drop-menu/wd-drop-menu.vue.d.ts +5 -5
- package/types/components/wd-drop-menu-item/types.d.ts +15 -27
- package/types/components/wd-drop-menu-item/wd-drop-menu-item.vue.d.ts +35 -46
- package/types/components/wd-floating-panel/wd-floating-panel.vue.d.ts +1 -1
- package/types/components/wd-form/wd-form.vue.d.ts +1 -1
- package/types/components/wd-form-item/wd-form-item.vue.d.ts +1 -1
- package/types/components/wd-grid-item/wd-grid-item.vue.d.ts +1 -1
- package/types/components/wd-input/wd-input.vue.d.ts +4 -4
- package/types/components/wd-keyboard/wd-keyboard.vue.d.ts +1 -1
- package/types/components/wd-notify/wd-notify.vue.d.ts +1 -1
- package/types/components/wd-number-keyboard/wd-number-keyboard.vue.d.ts +1 -1
- package/types/components/wd-picker/wd-picker.vue.d.ts +12 -12
- package/types/components/wd-picker-view/wd-picker-view.vue.d.ts +2 -2
- package/types/components/wd-select-picker/wd-select-picker.vue.d.ts +12 -12
- package/types/components/wd-signature/wd-signature.vue.d.ts +2 -2
- package/types/components/wd-steps/wd-steps.vue.d.ts +1 -1
- package/types/components/wd-swiper/wd-swiper.vue.d.ts +1 -1
- package/types/components/wd-tabs/wd-tabs.vue.d.ts +1 -1
- package/types/components/wd-textarea/wd-textarea.vue.d.ts +3 -3
- /package/components/wd-input/{placeholder.scss → placeholder.css} +0 -0
|
@@ -1,53 +1,50 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<view :class="`wd-calendar ${customClass}`">
|
|
3
|
-
<
|
|
4
|
-
<
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
:
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
:title-width="labelWidth"
|
|
11
|
-
:prop="prop"
|
|
12
|
-
:rules="rules"
|
|
13
|
-
:clickable="!disabled && !readonly"
|
|
14
|
-
:value-align="alignRight ? 'right' : 'left'"
|
|
15
|
-
:center="center"
|
|
16
|
-
:custom-class="cellClass"
|
|
17
|
-
:custom-style="customStyle"
|
|
18
|
-
:custom-title-class="customLabelClass"
|
|
19
|
-
:custom-value-class="customValueClass"
|
|
20
|
-
:ellipsis="ellipsis"
|
|
21
|
-
:use-title-slot="!!$slots.label"
|
|
22
|
-
:marker-side="markerSide"
|
|
23
|
-
@click="open"
|
|
2
|
+
<view :class="`wd-calendar ${cell.border.value ? 'is-border' : ''} ${customClass}`">
|
|
3
|
+
<view class="wd-calendar__field" @click="open" v-if="withCell">
|
|
4
|
+
<slot v-if="useDefaultSlot"></slot>
|
|
5
|
+
<view
|
|
6
|
+
v-else
|
|
7
|
+
:class="`wd-calendar__cell ${disabled ? 'is-disabled' : ''} ${readonly ? 'is-readonly' : ''} ${alignRight ? 'is-align-right' : ''} ${
|
|
8
|
+
error ? 'is-error' : ''
|
|
9
|
+
} ${size ? 'is-' + size : ''} ${center ? 'is-center' : ''}`"
|
|
24
10
|
>
|
|
25
|
-
<
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
<
|
|
31
|
-
<
|
|
32
|
-
|
|
11
|
+
<view
|
|
12
|
+
v-if="label || useLabelSlot"
|
|
13
|
+
:class="`wd-calendar__label ${isRequired ? 'is-required' : ''} ${customLabelClass}`"
|
|
14
|
+
:style="labelWidth ? 'min-width:' + labelWidth + ';max-width:' + labelWidth + ';' : ''"
|
|
15
|
+
>
|
|
16
|
+
<text v-if="label" class="wd-calendar__label-inner">{{ label }}</text>
|
|
17
|
+
<slot v-else name="label"></slot>
|
|
18
|
+
</view>
|
|
19
|
+
<view class="wd-calendar__body">
|
|
20
|
+
<view class="wd-calendar__value-wraper">
|
|
21
|
+
<view
|
|
22
|
+
:class="`wd-calendar__value ${ellipsis ? 'is-ellipsis' : ''} ${customValueClass} ${showValue ? '' : 'wd-calendar__value--placeholder'}`"
|
|
23
|
+
>
|
|
24
|
+
{{ showValue || placeholder || translate('placeholder') }}
|
|
25
|
+
</view>
|
|
26
|
+
<wd-icon
|
|
27
|
+
v-if="!disabled && !readonly"
|
|
28
|
+
custom-class="wd-calendar__arrow"
|
|
29
|
+
name="arrow-right"
|
|
30
|
+
/>
|
|
33
31
|
</view>
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
<view v-else @click="open">
|
|
37
|
-
<slot></slot>
|
|
32
|
+
<view v-if="errorMessage" class="wd-calendar__error-message">{{ errorMessage }}</view>
|
|
33
|
+
</view>
|
|
38
34
|
</view>
|
|
39
|
-
</
|
|
35
|
+
</view>
|
|
40
36
|
<wd-action-sheet
|
|
41
37
|
v-model="pickerShow"
|
|
42
38
|
:duration="250"
|
|
43
39
|
:close-on-click-modal="closeOnClickModal"
|
|
44
40
|
:safe-area-inset-bottom="safeAreaInsetBottom"
|
|
45
41
|
:z-index="zIndex"
|
|
46
|
-
:root-portal="rootPortal"
|
|
47
42
|
@close="close"
|
|
48
43
|
>
|
|
49
44
|
<view class="wd-calendar__header">
|
|
50
|
-
<view v-if="!showTypeSwitch && shortcuts.length === 0" class="wd-calendar__title">
|
|
45
|
+
<view v-if="!showTypeSwitch && shortcuts.length === 0" class="wd-calendar__title">
|
|
46
|
+
{{ title || translate('title') }}
|
|
47
|
+
</view>
|
|
51
48
|
<view v-if="showTypeSwitch" class="wd-calendar__tabs">
|
|
52
49
|
<wd-tabs ref="calendarTabs" v-model="currentTab" @change="handleTypeChange">
|
|
53
50
|
<wd-tab :title="translate('day')" :name="translate('day')" />
|
|
@@ -74,7 +71,10 @@
|
|
|
74
71
|
v-if="inited"
|
|
75
72
|
:class="`wd-calendar__view ${currentType.indexOf('range') > -1 ? 'is-range' : ''} ${showConfirm ? 'is-show-confirm' : ''}`"
|
|
76
73
|
>
|
|
77
|
-
<view
|
|
74
|
+
<view
|
|
75
|
+
v-if="range(type)"
|
|
76
|
+
:class="`wd-calendar__range-label ${type === 'monthrange' ? 'is-monthrange' : ''}`"
|
|
77
|
+
>
|
|
78
78
|
<view
|
|
79
79
|
:class="`wd-calendar__range-label-item ${!calendarValue || !isArray(calendarValue) || !calendarValue[0] ? 'is-placeholder' : ''}`"
|
|
80
80
|
style="text-align: right"
|
|
@@ -82,7 +82,9 @@
|
|
|
82
82
|
{{ rangeLabel[0] }}
|
|
83
83
|
</view>
|
|
84
84
|
<view class="wd-calendar__range-sperator">/</view>
|
|
85
|
-
<view
|
|
85
|
+
<view
|
|
86
|
+
:class="`wd-calendar__range-label-item ${!calendarValue || !isArray(calendarValue) || !calendarValue[1] ? 'is-placeholder' : ''}`"
|
|
87
|
+
>
|
|
86
88
|
{{ rangeLabel[1] }}
|
|
87
89
|
</view>
|
|
88
90
|
</view>
|
|
@@ -107,7 +109,9 @@
|
|
|
107
109
|
/>
|
|
108
110
|
</view>
|
|
109
111
|
<view v-if="showConfirm" class="wd-calendar__confirm">
|
|
110
|
-
<wd-button block :disabled="confirmBtnDisabled" @click="handleConfirm">
|
|
112
|
+
<wd-button block :disabled="confirmBtnDisabled" @click="handleConfirm">
|
|
113
|
+
{{ confirmText || translate('confirm') }}
|
|
114
|
+
</wd-button>
|
|
111
115
|
</view>
|
|
112
116
|
</wd-action-sheet>
|
|
113
117
|
</view>
|
|
@@ -119,21 +123,17 @@ export default {
|
|
|
119
123
|
options: {
|
|
120
124
|
addGlobalClass: true,
|
|
121
125
|
virtualHost: true,
|
|
122
|
-
styleIsolation: 'shared'
|
|
123
|
-
}
|
|
126
|
+
styleIsolation: 'shared',
|
|
127
|
+
},
|
|
124
128
|
}
|
|
125
129
|
</script>
|
|
126
130
|
|
|
127
131
|
<script lang="ts" setup>
|
|
128
|
-
import wdIcon from '../wd-icon/wd-icon.vue'
|
|
129
|
-
import wdCalendarView from '../wd-calendar-view/wd-calendar-view.vue'
|
|
130
|
-
import wdActionSheet from '../wd-action-sheet/wd-action-sheet.vue'
|
|
131
|
-
import wdButton from '../wd-button/wd-button.vue'
|
|
132
|
-
import wdCell from '../wd-cell/wd-cell.vue'
|
|
133
132
|
import { ref, computed, watch } from 'vue'
|
|
134
|
-
import dayjs from '
|
|
135
|
-
import { deepClone, isArray, isEqual, padZero,
|
|
133
|
+
import { dayjs } from '../common/dayjs'
|
|
134
|
+
import { deepClone, isArray, isEqual, padZero, requestAnimationFrame } from '../common/util'
|
|
136
135
|
import { getWeekNumber, isRange } from '../wd-calendar-view/utils'
|
|
136
|
+
import { useCell } from '../composables/useCell'
|
|
137
137
|
import { FORM_KEY, type FormItemRule } from '../wd-form/types'
|
|
138
138
|
import { useParent } from '../composables/useParent'
|
|
139
139
|
import { useTranslate } from '../composables/useTranslate'
|
|
@@ -153,51 +153,39 @@ const defaultDisplayFormat = (value: number | number[], type: CalendarType): str
|
|
|
153
153
|
.join(', ')
|
|
154
154
|
case 'daterange':
|
|
155
155
|
return `${(value as number[])[0] ? dayjs((value as number[])[0]).format('YYYY-MM-DD') : translate('startTime')} ${translate('to')} ${
|
|
156
|
-
(value as number[])[1]
|
|
156
|
+
(value as number[])[1]
|
|
157
|
+
? dayjs((value as number[])[1]).format('YYYY-MM-DD')
|
|
158
|
+
: translate('endTime')
|
|
157
159
|
}`
|
|
158
160
|
case 'datetime':
|
|
159
161
|
return dayjs(value as number).format('YYYY-MM-DD HH:mm:ss')
|
|
160
162
|
case 'datetimerange':
|
|
161
163
|
return `${(value as number[])[0] ? dayjs((value as number[])[0]).format(translate('timeFormat')) : translate('startTime')} ${translate(
|
|
162
|
-
'to'
|
|
164
|
+
'to',
|
|
163
165
|
)}\n${(value as number[])[1] ? dayjs((value as number[])[1]).format(translate('timeFormat')) : translate('endTime')}`
|
|
164
166
|
case 'week': {
|
|
165
|
-
const
|
|
166
|
-
const year = date.getFullYear()
|
|
167
|
+
const year = new Date(value as number).getFullYear()
|
|
167
168
|
const week = getWeekNumber(value as number)
|
|
168
|
-
|
|
169
|
-
weekStart.setDate(date.getDate() - date.getDay() + 1)
|
|
170
|
-
const weekEnd = new Date(date)
|
|
171
|
-
weekEnd.setDate(date.getDate() + (7 - date.getDay()))
|
|
172
|
-
const adjustedYear = weekEnd.getFullYear() > year ? weekEnd.getFullYear() : year
|
|
173
|
-
return translate('weekFormat', adjustedYear, padZero(week))
|
|
169
|
+
return translate('weekFormat', year, padZero(week))
|
|
174
170
|
}
|
|
175
171
|
case 'weekrange': {
|
|
176
|
-
const
|
|
177
|
-
const date2 = new Date((value as number[])[1])
|
|
178
|
-
const year1 = date1.getFullYear()
|
|
179
|
-
const year2 = date2.getFullYear()
|
|
172
|
+
const year1 = new Date((value as number[])[0]).getFullYear()
|
|
180
173
|
const week1 = getWeekNumber((value as number[])[0])
|
|
174
|
+
const year2 = new Date((value as number[])[1]).getFullYear()
|
|
181
175
|
const week2 = getWeekNumber((value as number[])[1])
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
const weekStart2 = new Date(date2)
|
|
187
|
-
weekStart2.setDate(date2.getDate() - date2.getDay() + 1)
|
|
188
|
-
const weekEnd2 = new Date(date2)
|
|
189
|
-
weekEnd2.setDate(date2.getDate() + (7 - date2.getDay()))
|
|
190
|
-
const adjustedYear1 = weekEnd1.getFullYear() > year1 ? weekEnd1.getFullYear() : year1
|
|
191
|
-
const adjustedYear2 = weekEnd2.getFullYear() > year2 ? weekEnd2.getFullYear() : year2
|
|
192
|
-
return `${(value as number[])[0] ? translate('weekFormat', adjustedYear1, padZero(week1)) : translate('startWeek')} - ${
|
|
193
|
-
(value as number[])[1] ? translate('weekFormat', adjustedYear2, padZero(week2)) : translate('endWeek')
|
|
176
|
+
return `${(value as number[])[0] ? translate('weekFormat', year1, padZero(week1)) : translate('startWeek')} - ${
|
|
177
|
+
(value as number[])[1]
|
|
178
|
+
? translate('weekFormat', year2, padZero(week2))
|
|
179
|
+
: translate('endWeek')
|
|
194
180
|
}`
|
|
195
181
|
}
|
|
196
182
|
case 'month':
|
|
197
183
|
return dayjs(value as number).format('YYYY / MM')
|
|
198
184
|
case 'monthrange':
|
|
199
185
|
return `${(value as number[])[0] ? dayjs((value as number[])[0]).format('YYYY / MM') : translate('startMonth')} ${translate('to')} ${
|
|
200
|
-
(value as number[])[1]
|
|
186
|
+
(value as number[])[1]
|
|
187
|
+
? dayjs((value as number[])[1]).format('YYYY / MM')
|
|
188
|
+
: translate('endMonth')
|
|
201
189
|
}`
|
|
202
190
|
}
|
|
203
191
|
}
|
|
@@ -232,45 +220,47 @@ const formatRange = (value: number, rangeType: 'start' | 'end', type: CalendarTy
|
|
|
232
220
|
}
|
|
233
221
|
|
|
234
222
|
const props = defineProps(calendarProps)
|
|
235
|
-
const emit = defineEmits(['cancel', 'change', 'update:modelValue', 'confirm', 'open'
|
|
223
|
+
const emit = defineEmits(['cancel', 'change', 'update:modelValue', 'confirm', 'open'])
|
|
236
224
|
|
|
237
225
|
const pickerShow = ref<boolean>(false)
|
|
238
226
|
const calendarValue = ref<null | number | number[]>(null)
|
|
239
227
|
const lastCalendarValue = ref<null | number | number[]>(null)
|
|
240
|
-
const panelHeight = ref<number>(
|
|
228
|
+
const panelHeight = ref<number>(438)
|
|
241
229
|
const confirmBtnDisabled = ref<boolean>(true)
|
|
242
230
|
const currentTab = ref<number>(0)
|
|
243
231
|
const lastTab = ref<number>(0)
|
|
244
232
|
const currentType = ref<CalendarType>('date')
|
|
245
233
|
const lastCurrentType = ref<CalendarType>()
|
|
246
234
|
const inited = ref<boolean>(false)
|
|
235
|
+
const cell = useCell()
|
|
247
236
|
const calendarView = ref()
|
|
248
237
|
const calendarTabs = ref()
|
|
249
238
|
|
|
250
239
|
const rangeLabel = computed(() => {
|
|
251
240
|
const [start, end] = deepClone(isArray(calendarValue.value) ? calendarValue.value : [])
|
|
252
241
|
return [start, end].map((item, index) => {
|
|
253
|
-
return (props.innerDisplayFormat || formatRange)(
|
|
242
|
+
return (props.innerDisplayFormat || formatRange)(
|
|
243
|
+
item,
|
|
244
|
+
index === 0 ? 'start' : 'end',
|
|
245
|
+
currentType.value,
|
|
246
|
+
)
|
|
254
247
|
})
|
|
255
248
|
})
|
|
256
249
|
|
|
257
250
|
const showValue = computed(() => {
|
|
258
|
-
if (
|
|
259
|
-
|
|
251
|
+
if (
|
|
252
|
+
(!isArray(props.modelValue) && props.modelValue) ||
|
|
253
|
+
(isArray(props.modelValue) && props.modelValue.length)
|
|
254
|
+
) {
|
|
255
|
+
return (props.displayFormat || defaultDisplayFormat)(
|
|
256
|
+
props.modelValue,
|
|
257
|
+
lastCurrentType.value || currentType.value,
|
|
258
|
+
)
|
|
260
259
|
} else {
|
|
261
260
|
return ''
|
|
262
261
|
}
|
|
263
262
|
})
|
|
264
263
|
|
|
265
|
-
const cellClass = computed(() => {
|
|
266
|
-
const classes = ['wd-calendar__cell']
|
|
267
|
-
if (props.disabled) classes.push('is-disabled')
|
|
268
|
-
if (props.readonly) classes.push('is-readonly')
|
|
269
|
-
if (props.error) classes.push('is-error')
|
|
270
|
-
if (!showValue.value) classes.push('wd-calendar__cell--placeholder')
|
|
271
|
-
return classes.join(' ')
|
|
272
|
-
})
|
|
273
|
-
|
|
274
264
|
watch(
|
|
275
265
|
() => props.modelValue,
|
|
276
266
|
(val, oldVal) => {
|
|
@@ -279,8 +269,8 @@ watch(
|
|
|
279
269
|
confirmBtnDisabled.value = getConfirmBtnStatus(val)
|
|
280
270
|
},
|
|
281
271
|
{
|
|
282
|
-
immediate: true
|
|
283
|
-
}
|
|
272
|
+
immediate: true,
|
|
273
|
+
},
|
|
284
274
|
)
|
|
285
275
|
|
|
286
276
|
watch(
|
|
@@ -290,55 +280,71 @@ watch(
|
|
|
290
280
|
const tabs = ['date', 'week', 'month']
|
|
291
281
|
const rangeTabs = ['daterange', 'weekrange', 'monthrange']
|
|
292
282
|
|
|
293
|
-
const index =
|
|
283
|
+
const index =
|
|
284
|
+
newValue.indexOf('range') > -1 ? rangeTabs.indexOf(newValue) || 0 : tabs.indexOf(newValue)
|
|
294
285
|
currentTab.value = index
|
|
295
286
|
}
|
|
296
|
-
panelHeight.value = props.showConfirm ?
|
|
287
|
+
panelHeight.value = props.showConfirm ? 488 : 550
|
|
297
288
|
currentType.value = deepClone(newValue)
|
|
298
289
|
},
|
|
299
290
|
{
|
|
300
291
|
deep: true,
|
|
301
|
-
immediate: true
|
|
302
|
-
}
|
|
292
|
+
immediate: true,
|
|
293
|
+
},
|
|
303
294
|
)
|
|
304
295
|
|
|
305
296
|
watch(
|
|
306
297
|
() => props.showConfirm,
|
|
307
298
|
(val) => {
|
|
308
|
-
panelHeight.value = val ?
|
|
299
|
+
panelHeight.value = val ? 488 : 550
|
|
309
300
|
},
|
|
310
301
|
{
|
|
311
302
|
deep: true,
|
|
312
|
-
immediate: true
|
|
313
|
-
}
|
|
303
|
+
immediate: true,
|
|
304
|
+
},
|
|
314
305
|
)
|
|
315
306
|
|
|
316
|
-
const
|
|
317
|
-
|
|
318
|
-
|
|
307
|
+
const { parent: form } = useParent(FORM_KEY)
|
|
308
|
+
|
|
309
|
+
// 表单校验错误信息
|
|
310
|
+
const errorMessage = computed(() => {
|
|
311
|
+
if (form && props.prop && form.errorMessages && form.errorMessages[props.prop]) {
|
|
312
|
+
return form.errorMessages[props.prop]
|
|
313
|
+
} else {
|
|
314
|
+
return ''
|
|
319
315
|
}
|
|
320
316
|
})
|
|
321
317
|
|
|
322
|
-
//
|
|
323
|
-
const
|
|
324
|
-
|
|
318
|
+
// 是否展示必填
|
|
319
|
+
const isRequired = computed(() => {
|
|
320
|
+
let formRequired = false
|
|
321
|
+
if (form && form.props.rules) {
|
|
322
|
+
const rules = form.props.rules
|
|
323
|
+
for (const key in rules) {
|
|
324
|
+
if (
|
|
325
|
+
Object.prototype.hasOwnProperty.call(rules, key) &&
|
|
326
|
+
key === props.prop &&
|
|
327
|
+
Array.isArray(rules[key])
|
|
328
|
+
) {
|
|
329
|
+
formRequired = rules[key].some((rule: FormItemRule) => rule.required)
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
return props.required || props.rules.some((rule) => rule.required) || formRequired
|
|
325
334
|
})
|
|
326
335
|
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
336
|
+
const range = computed(() => {
|
|
337
|
+
return (type: CalendarType) => {
|
|
338
|
+
return isRange(type)
|
|
339
|
+
}
|
|
330
340
|
})
|
|
331
341
|
|
|
332
|
-
function handleClear() {
|
|
333
|
-
emit('clear')
|
|
334
|
-
emit('update:modelValue', null)
|
|
335
|
-
}
|
|
336
|
-
|
|
337
342
|
function scrollIntoView() {
|
|
338
343
|
calendarView.value && calendarView.value && calendarView.value.$.exposed.scrollIntoView()
|
|
339
344
|
}
|
|
340
345
|
// 对外暴露方法
|
|
341
346
|
async function open() {
|
|
347
|
+
await props.initFun?.()
|
|
342
348
|
const { disabled, readonly } = props
|
|
343
349
|
|
|
344
350
|
if (disabled || readonly) return
|
|
@@ -348,9 +354,10 @@ async function open() {
|
|
|
348
354
|
lastCalendarValue.value = deepClone(calendarValue.value)
|
|
349
355
|
lastTab.value = currentTab.value
|
|
350
356
|
lastCurrentType.value = currentType.value
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
357
|
+
requestAnimationFrame(() => {
|
|
358
|
+
scrollIntoView()
|
|
359
|
+
})
|
|
360
|
+
|
|
354
361
|
setTimeout(() => {
|
|
355
362
|
if (props.showTypeSwitch) {
|
|
356
363
|
calendarTabs.value.scrollIntoView()
|
|
@@ -374,6 +381,7 @@ function handleTypeChange({ index }: { index: number }) {
|
|
|
374
381
|
const tabs = ['date', 'week', 'month']
|
|
375
382
|
const rangeTabs = ['daterange', 'weekrange', 'monthrange']
|
|
376
383
|
const type = props.type.indexOf('range') > -1 ? rangeTabs[index] : tabs[index]
|
|
384
|
+
|
|
377
385
|
currentTab.value = index
|
|
378
386
|
currentType.value = type as CalendarType
|
|
379
387
|
}
|
|
@@ -395,7 +403,7 @@ function handleChange({ value }: { value: number | number[] | null }) {
|
|
|
395
403
|
confirmBtnDisabled.value = getConfirmBtnStatus(value)
|
|
396
404
|
|
|
397
405
|
emit('change', {
|
|
398
|
-
value
|
|
406
|
+
value,
|
|
399
407
|
})
|
|
400
408
|
|
|
401
409
|
if (!props.showConfirm && !confirmBtnDisabled.value) {
|
|
@@ -408,7 +416,7 @@ function handleConfirm() {
|
|
|
408
416
|
value: calendarValue.value,
|
|
409
417
|
resolve: (isPass: boolean) => {
|
|
410
418
|
isPass && onConfirm()
|
|
411
|
-
}
|
|
419
|
+
},
|
|
412
420
|
})
|
|
413
421
|
} else {
|
|
414
422
|
onConfirm()
|
|
@@ -420,7 +428,6 @@ function onConfirm() {
|
|
|
420
428
|
emit('update:modelValue', calendarValue.value)
|
|
421
429
|
emit('confirm', {
|
|
422
430
|
value: calendarValue.value,
|
|
423
|
-
type: currentType.value
|
|
424
431
|
})
|
|
425
432
|
}
|
|
426
433
|
|
|
@@ -429,8 +436,8 @@ function handleShortcutClick(index: number) {
|
|
|
429
436
|
calendarValue.value = deepClone(
|
|
430
437
|
props.onShortcutsClick({
|
|
431
438
|
item: props.shortcuts[index],
|
|
432
|
-
index
|
|
433
|
-
})
|
|
439
|
+
index,
|
|
440
|
+
}),
|
|
434
441
|
)
|
|
435
442
|
confirmBtnDisabled.value = getConfirmBtnStatus(calendarValue.value)
|
|
436
443
|
}
|
|
@@ -442,10 +449,10 @@ function handleShortcutClick(index: number) {
|
|
|
442
449
|
|
|
443
450
|
defineExpose<CalendarExpose>({
|
|
444
451
|
close,
|
|
445
|
-
open
|
|
452
|
+
open,
|
|
446
453
|
})
|
|
447
454
|
</script>
|
|
448
455
|
|
|
449
456
|
<style lang="scss" scoped>
|
|
450
|
-
@import './index
|
|
457
|
+
@import './index';
|
|
451
458
|
</style>
|
|
@@ -44,8 +44,7 @@
|
|
|
44
44
|
height: $-calendar-day-height;
|
|
45
45
|
line-height: $-calendar-day-height;
|
|
46
46
|
text-align: center;
|
|
47
|
-
margin-bottom:
|
|
48
|
-
|
|
47
|
+
margin-bottom: 6rpx;
|
|
49
48
|
@include when(disabled) {
|
|
50
49
|
.wd-month__day-text {
|
|
51
50
|
color: $-calendar-disabled-color;
|
|
@@ -56,11 +55,20 @@
|
|
|
56
55
|
color: $-calendar-active-color;
|
|
57
56
|
}
|
|
58
57
|
|
|
59
|
-
@include when(selected
|
|
58
|
+
@include when(selected) {
|
|
60
59
|
.wd-month__day-container {
|
|
61
|
-
|
|
60
|
+
color: #fff;
|
|
62
61
|
background: $-calendar-active-color;
|
|
63
|
-
|
|
62
|
+
border-radius: $-calendar-active-border;
|
|
63
|
+
.text-price {
|
|
64
|
+
color: #fff;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
.wd-month__day-bottom,
|
|
68
|
+
.wd-month__day-top,
|
|
69
|
+
.wd-month__day-floor,
|
|
70
|
+
.wd-month__day-text {
|
|
71
|
+
color: #fff !important;
|
|
64
72
|
}
|
|
65
73
|
}
|
|
66
74
|
|
|
@@ -69,23 +77,17 @@
|
|
|
69
77
|
background: $-calendar-range-color;
|
|
70
78
|
}
|
|
71
79
|
}
|
|
72
|
-
@include when(multiple-middle) {
|
|
73
|
-
.wd-month__day-container {
|
|
74
|
-
background: $-calendar-active-color;
|
|
75
|
-
color: $-calendar-selected-color;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
80
|
|
|
79
81
|
@include when(start) {
|
|
80
82
|
&::after {
|
|
81
83
|
position: absolute;
|
|
82
|
-
content: '';
|
|
83
|
-
height: $-calendar-day-height;
|
|
84
84
|
top: 0;
|
|
85
85
|
right: 0;
|
|
86
86
|
left: 50%;
|
|
87
|
-
background: $-calendar-range-color;
|
|
88
87
|
z-index: 1;
|
|
88
|
+
height: $-calendar-day-height;
|
|
89
|
+
content: '';
|
|
90
|
+
background: $-calendar-range-color;
|
|
89
91
|
}
|
|
90
92
|
|
|
91
93
|
&.is-without-end::after {
|
|
@@ -93,70 +95,100 @@
|
|
|
93
95
|
}
|
|
94
96
|
|
|
95
97
|
.wd-month__day-container {
|
|
98
|
+
color: #fff;
|
|
96
99
|
background: $-calendar-active-color;
|
|
97
|
-
|
|
98
|
-
|
|
100
|
+
border-radius: $-calendar-active-border;
|
|
101
|
+
}
|
|
102
|
+
.wd-month__day-text-custom {
|
|
103
|
+
color: #fff;
|
|
104
|
+
}
|
|
105
|
+
.wd-month__day-bottom,
|
|
106
|
+
.wd-month__day-top,
|
|
107
|
+
.wd-month__day-floor,
|
|
108
|
+
.wd-month__day-text {
|
|
109
|
+
color: #fff !important;
|
|
99
110
|
}
|
|
100
111
|
}
|
|
101
112
|
|
|
102
113
|
@include when(end) {
|
|
103
114
|
&::after {
|
|
104
115
|
position: absolute;
|
|
105
|
-
content: '';
|
|
106
|
-
height: $-calendar-day-height;
|
|
107
116
|
top: 0;
|
|
108
|
-
left: 0;
|
|
109
117
|
right: 50%;
|
|
110
|
-
|
|
118
|
+
left: 0;
|
|
111
119
|
z-index: 1;
|
|
120
|
+
height: $-calendar-day-height;
|
|
121
|
+
content: '';
|
|
122
|
+
background: $-calendar-range-color;
|
|
112
123
|
}
|
|
113
124
|
|
|
114
125
|
.wd-month__day-container {
|
|
126
|
+
color: #fff;
|
|
115
127
|
background: $-calendar-active-color;
|
|
116
|
-
|
|
117
|
-
|
|
128
|
+
border-radius: $-calendar-active-border;
|
|
129
|
+
}
|
|
130
|
+
.wd-month__day-text-custom {
|
|
131
|
+
color: #fff;
|
|
132
|
+
}
|
|
133
|
+
.wd-month__day-bottom,
|
|
134
|
+
.wd-month__day-top,
|
|
135
|
+
.wd-month__day-floor,
|
|
136
|
+
.wd-month__day-text {
|
|
137
|
+
color: #fff !important;
|
|
118
138
|
}
|
|
119
139
|
}
|
|
120
140
|
|
|
121
141
|
@include when(same) {
|
|
122
142
|
.wd-month__day-container {
|
|
143
|
+
color: #fff;
|
|
123
144
|
background: $-calendar-active-color;
|
|
124
|
-
color: $-calendar-selected-color;
|
|
125
145
|
border-radius: $-calendar-active-border;
|
|
126
146
|
}
|
|
127
147
|
}
|
|
128
|
-
|
|
129
|
-
@include when(last-row){
|
|
130
|
-
margin-bottom: 0;
|
|
131
|
-
}
|
|
132
148
|
}
|
|
133
149
|
|
|
134
150
|
@include e(day-container) {
|
|
135
151
|
position: relative;
|
|
136
152
|
z-index: 2;
|
|
153
|
+
height: 100%;
|
|
154
|
+
padding: 0 2px;
|
|
137
155
|
}
|
|
138
156
|
|
|
139
157
|
@include e(day-text) {
|
|
140
158
|
font-weight: $-calendar-day-fw;
|
|
159
|
+
&-custom {
|
|
160
|
+
font-size: 14px;
|
|
161
|
+
color: $-calendar-active-color;
|
|
162
|
+
}
|
|
141
163
|
}
|
|
142
164
|
|
|
143
165
|
@include e(day-top) {
|
|
144
166
|
position: absolute;
|
|
145
|
-
top:
|
|
146
|
-
left: 0;
|
|
167
|
+
top: 6px;
|
|
147
168
|
right: 0;
|
|
148
|
-
|
|
169
|
+
left: 0;
|
|
149
170
|
font-size: $-calendar-info-fs;
|
|
171
|
+
line-height: 1.1;
|
|
150
172
|
text-align: center;
|
|
151
173
|
}
|
|
152
174
|
|
|
153
175
|
@include e(day-bottom) {
|
|
154
176
|
position: absolute;
|
|
155
|
-
bottom: 10px;
|
|
156
|
-
left: 0;
|
|
157
177
|
right: 0;
|
|
178
|
+
bottom: 6px;
|
|
179
|
+
left: 0;
|
|
180
|
+
font-size: $-calendar-info-fs;
|
|
158
181
|
line-height: 1.1;
|
|
182
|
+
text-align: center;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
@include e(day-floor) {
|
|
186
|
+
position: absolute;
|
|
187
|
+
right: 0;
|
|
188
|
+
bottom: 2px;
|
|
189
|
+
left: 0;
|
|
159
190
|
font-size: $-calendar-info-fs;
|
|
191
|
+
line-height: 1.1;
|
|
160
192
|
text-align: center;
|
|
161
193
|
}
|
|
162
|
-
}
|
|
194
|
+
}
|