Skip to content

Commit

Permalink
releases 4.3.58
Browse files Browse the repository at this point in the history
  • Loading branch information
xuliangzhan committed Jan 3, 2025
1 parent 71b91f6 commit 3d9c5e2
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 14 deletions.
17 changes: 16 additions & 1 deletion examples/views/date-picker/DatePickerTest.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,26 @@
<template>
<div>
<vxe-date-picker v-model="val1" placeholder="可选日期限制" start-date="2000-01-01" end-date="2040-01-01"></vxe-date-picker>
<vxe-date-picker v-model="val1" placeholder="周选择,周天开始" type="week" :start-day="0"></vxe-date-picker>
<vxe-date-picker v-model="val2" placeholder="周选择,周一开始" type="week" :start-day="1"></vxe-date-picker>
<vxe-date-picker v-model="val3" placeholder="周选择,周二开始" type="week" :start-day="2"></vxe-date-picker>
<vxe-date-picker v-model="val4" placeholder="周选择,周三开始" type="week" :start-day="3" clearable></vxe-date-picker>
<vxe-date-picker v-model="val5" placeholder="周选择,周四开始" type="week" :start-day="4" clearable></vxe-date-picker>
<vxe-date-picker v-model="val6" placeholder="周选择,周五开始" type="week" :start-day="5" clearable></vxe-date-picker>
<vxe-date-picker v-model="val7" placeholder="周选择,周六开始" type="week" :start-day="6" clearable></vxe-date-picker>

<vxe-date-picker v-model="val8" placeholder="可选日期限制" start-date="2000-01-01" end-date="2040-01-01"></vxe-date-picker>
</div>
</template>

<script lang="ts" setup>
import { ref } from 'vue'
const val1 = ref('')
const val2 = ref('')
const val3 = ref('')
const val4 = ref('')
const val5 = ref('')
const val6 = ref('')
const val7 = ref('')
const val8 = ref('')
</script>
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vxe-pc-ui",
"version": "4.3.57",
"version": "4.3.58",
"description": "A vue based PC component library",
"scripts": {
"update": "npm install --legacy-peer-deps",
Expand Down
23 changes: 17 additions & 6 deletions packages/date-picker/src/date-picker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -738,15 +738,19 @@ export default defineComponent({
}
if (XEUtils.isValidDate(dValue)) {
dLabel = XEUtils.toDateString(dValue, dateLabelFormat, { firstDay: firstDayOfWeek })
// 由于年份和第几周是冲突的行为,所以需要特殊处理,判断是否跨年
// 周选择器,由于年份和第几周是冲突的行为,所以需要特殊处理,判断是否跨年,例如
// '2024-12-31' 'yyyy-MM-dd W' >> '2024-12-31 1'
// '2025-01-01' 'yyyy-MM-dd W' >> '2025-01-01 1'
if (dateLabelFormat && type === 'week') {
const firstWeekDate = XEUtils.getWhatWeek(dValue, 0, firstDayOfWeek, firstDayOfWeek)
if (firstWeekDate.getFullYear() < dValue.getFullYear()) {
const weekNum = XEUtils.getYearWeek(dValue, firstDayOfWeek)
const weekDate = XEUtils.getWhatWeek(dValue, 0, weekNum === 1 ? ((6 + firstDayOfWeek) % 7) as VxeDatePickerPropTypes.StartDay : firstDayOfWeek, firstDayOfWeek)
const weekFullYear = weekDate.getFullYear()
if (weekFullYear !== dValue.getFullYear()) {
const yyIndex = dateLabelFormat.indexOf('yyyy')
if (yyIndex > -1) {
const yyNum = Number(dLabel.substring(yyIndex, yyIndex + 4))
if (yyNum && !isNaN(yyNum)) {
dLabel = dLabel.replace(`${yyNum}`, `${yyNum - 1}`)
dLabel = dLabel.replace(`${yyNum}`, `${weekFullYear}`)
}
}
}
Expand Down Expand Up @@ -786,7 +790,10 @@ export default defineComponent({
}

const dateCheckMonth = (date: Date) => {
const month = XEUtils.getWhatMonth(date, 0, 'first')
const firstDayOfWeek = computeFirstDayOfWeek.value
const weekNum = XEUtils.getYearWeek(date, firstDayOfWeek)
const weekStartDate = XEUtils.getWhatWeek(date, 0, firstDayOfWeek, firstDayOfWeek)
const month = XEUtils.getWhatMonth(weekNum === 1 ? XEUtils.getWhatDay(weekStartDate, 6) : date, 0, 'first')
if (!XEUtils.isEqual(month, reactData.selectMonth)) {
reactData.selectMonth = month
}
Expand Down Expand Up @@ -930,7 +937,11 @@ export default defineComponent({

// 日期
const dateMonthHandle = (date: Date, offsetMonth: number) => {
reactData.selectMonth = XEUtils.getWhatMonth(date, offsetMonth, 'first')
const firstDayOfWeek = computeFirstDayOfWeek.value
const weekNum = XEUtils.getYearWeek(date, firstDayOfWeek)
const weekStartDate = XEUtils.getWhatWeek(date, 0, firstDayOfWeek, firstDayOfWeek)
const month = XEUtils.getWhatMonth(weekNum === 1 ? XEUtils.getWhatDay(weekStartDate, 6) : date, offsetMonth, 'first')
reactData.selectMonth = month
}

const dateNowHandle = () => {
Expand Down
23 changes: 17 additions & 6 deletions packages/input/src/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -918,15 +918,19 @@ export default defineComponent({
}
if (XEUtils.isValidDate(dValue)) {
dLabel = XEUtils.toDateString(dValue, dateLabelFormat, { firstDay: firstDayOfWeek })
// 由于年份和第几周是冲突的行为,所以需要特殊处理,判断是否跨年
// 周选择器,由于年份和第几周是冲突的行为,所以需要特殊处理,判断是否跨年,例如
// '2024-12-31' 'yyyy-MM-dd W' >> '2024-12-31 1'
// '2025-01-01' 'yyyy-MM-dd W' >> '2025-01-01 1'
if (dateLabelFormat && type === 'week') {
const firstWeekDate = XEUtils.getWhatWeek(dValue, 0, firstDayOfWeek, firstDayOfWeek)
if (firstWeekDate.getFullYear() < dValue.getFullYear()) {
const weekNum = XEUtils.getYearWeek(dValue, firstDayOfWeek)
const weekDate = XEUtils.getWhatWeek(dValue, 0, weekNum === 1 ? ((6 + firstDayOfWeek) % 7) as VxeInputPropTypes.StartDay : firstDayOfWeek, firstDayOfWeek)
const weekFullYear = weekDate.getFullYear()
if (weekFullYear !== dValue.getFullYear()) {
const yyIndex = dateLabelFormat.indexOf('yyyy')
if (yyIndex > -1) {
const yyNum = Number(dLabel.substring(yyIndex, yyIndex + 4))
if (yyNum && !isNaN(yyNum)) {
dLabel = dLabel.replace(`${yyNum}`, `${yyNum - 1}`)
dLabel = dLabel.replace(`${yyNum}`, `${weekFullYear}`)
}
}
}
Expand Down Expand Up @@ -983,7 +987,10 @@ export default defineComponent({
}

const dateCheckMonth = (date: Date) => {
const month = XEUtils.getWhatMonth(date, 0, 'first')
const firstDayOfWeek = computeFirstDayOfWeek.value
const weekNum = XEUtils.getYearWeek(date, firstDayOfWeek)
const weekStartDate = XEUtils.getWhatWeek(date, 0, firstDayOfWeek, firstDayOfWeek)
const month = XEUtils.getWhatMonth(weekNum === 1 ? XEUtils.getWhatDay(weekStartDate, 6) : date, 0, 'first')
if (!XEUtils.isEqual(month, reactData.selectMonth)) {
reactData.selectMonth = month
}
Expand Down Expand Up @@ -1270,7 +1277,11 @@ export default defineComponent({

// 日期
const dateMonthHandle = (date: Date, offsetMonth: number) => {
reactData.selectMonth = XEUtils.getWhatMonth(date, offsetMonth, 'first')
const firstDayOfWeek = computeFirstDayOfWeek.value
const weekNum = XEUtils.getYearWeek(date, firstDayOfWeek)
const weekStartDate = XEUtils.getWhatWeek(date, 0, firstDayOfWeek, firstDayOfWeek)
const month = XEUtils.getWhatMonth(weekNum === 1 ? XEUtils.getWhatDay(weekStartDate, 6) : date, offsetMonth, 'first')
reactData.selectMonth = month
}

const dateNowHandle = () => {
Expand Down

0 comments on commit 3d9c5e2

Please sign in to comment.