Skip to content

Commit

Permalink
fix: #398
Browse files Browse the repository at this point in the history
  • Loading branch information
todrfu committed Dec 8, 2020
1 parent 41e5a15 commit f2df241
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
10 changes: 5 additions & 5 deletions src/component/v2/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function calculateEmptyGrids(year, month, config) {
* @param {number} month 月份
*/
function calculatePrevMonthGrids(year, month, config) {
let empytGrids = []
let emptyGrids = []
const prevMonthDays = dateUtil.getDatesCountOfMonth(year, month - 1)
let firstDayOfWeek = dateUtil.firstDayOfWeek(year, month)
if (config.firstDayOfWeek === 'Mon') {
Expand All @@ -36,19 +36,19 @@ function calculatePrevMonthGrids(year, month, config) {
const YMInfo = dateUtil.getPrevMonthInfo({ year, month })
for (let i = prevMonthDays; i > len; i--) {
if (onlyShowCurrentMonth) {
empytGrids.push('')
emptyGrids.push('')
} else {
const week = dateUtil.getDayOfWeek(+year, +month, i)
empytGrids.push({
emptyGrids.push({
...YMInfo,
date: i,
week
})
}
}
empytGrids.reverse()
emptyGrids.reverse()
}
return empytGrids
return emptyGrids
}
/**
* 计算下一月日期是否需要多展示的日期
Expand Down
9 changes: 7 additions & 2 deletions src/component/v2/plugins/week.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ function lastWeekInMonth(target = {}, calendarDates = [], calendarConfig = {}) {
const firstDayOfWeekIsMon = firstDayOfWeek === 'Mon'
const { year, month } = target
const lastDay = dateUtil.getDatesCountOfMonth(year, month)
const lastDayWeek = dateUtil.getDayOfWeek(year, month, lastDay)
let lastDayWeek = dateUtil.getDayOfWeek(year, month, lastDay)
if (firstDayOfWeekIsMon && lastDayWeek === 0) {
lastDayWeek = 7
}
const [start, end] = [lastDay - lastDayWeek, lastDay]
return calendarDates.slice(firstDayOfWeekIsMon ? start : start - 1, end)
}
Expand Down Expand Up @@ -244,9 +247,11 @@ export default () => {
return {
name: 'week',
beforeRender(calendarData = {}, calendarConfig = {}, component) {
if (calendarConfig.weekMode && !calendarData.initializedWeekMode) {
const { initializedWeekMode, selectedDates } = calendarData
if (calendarConfig.weekMode && !initializedWeekMode) {
const { defaultDate } = calendarConfig
const target =
(selectedDates && selectedDates[0]) ||
(defaultDate && dateUtil.transformDateRow2Dict(defaultDate)) ||
dateUtil.todayFMD()
const waitRenderData = this.methods(
Expand Down

0 comments on commit f2df241

Please sign in to comment.