|
@@ -5,8 +5,10 @@ import styles from './index.module.less'
|
|
|
import IconArrow from '../../images/icon_arrow.png'
|
|
|
import IconArrowDefault from '../../images/icon_arrow_default.png'
|
|
|
import isToday from 'dayjs/plugin/isToday'
|
|
|
+import isSameOrBefore from 'dayjs/plugin/isSameOrBefore'
|
|
|
import OHeader from '@/components/o-header'
|
|
|
dayjs.extend(isToday)
|
|
|
+dayjs.extend(isSameOrBefore)
|
|
|
|
|
|
export default defineComponent({
|
|
|
name: 'calendar',
|
|
@@ -60,7 +62,7 @@ export default defineComponent({
|
|
|
return {
|
|
|
minDate: new Date(),
|
|
|
maxDate: new Date(),
|
|
|
- currentDate: dayjs().add(1, 'day').toDate(), // 当前日历日期
|
|
|
+ currentDate: dayjs().toDate(), // 当前日历日期
|
|
|
subtitle: '',
|
|
|
dayList: [],
|
|
|
selectDays: [] as any
|
|
@@ -69,33 +71,20 @@ export default defineComponent({
|
|
|
computed: {
|
|
|
arrowStatus() {
|
|
|
// 上月箭头状态
|
|
|
- return !dayjs().add(1, 'day').isBefore(dayjs(this.currentDate), 'month')
|
|
|
+ return !dayjs().isBefore(dayjs(this.currentDate), 'month')
|
|
|
},
|
|
|
selectDayTitle() {
|
|
|
// 选中日期标题
|
|
|
return dayjs(this.currentDate).format('YYYY-MM-DD')
|
|
|
- },
|
|
|
- isPrevDay() {
|
|
|
- // 是否可以点击上一天
|
|
|
- return dayjs(this.currentDate).subtract(1, 'day').isBefore(dayjs(this.minDate), 'day')
|
|
|
- },
|
|
|
- isNextDay() {
|
|
|
- // 是否可以点击下一天
|
|
|
- return dayjs(this.currentDate).add(1, 'day').isAfter(dayjs(this.maxDate), 'day')
|
|
|
}
|
|
|
},
|
|
|
mounted() {
|
|
|
// 初始化标题和最大显示日期
|
|
|
- this.subtitle = dayjs(this.calendarDate || new Date())
|
|
|
- // .add(1, 'day')
|
|
|
- .format('YYYY年MM月')
|
|
|
+ this.subtitle = dayjs(this.calendarDate || new Date()).format('YYYY年MM月')
|
|
|
this.maxDate = dayjs(this.calendarDate || new Date())
|
|
|
- // .add(1, 'day')
|
|
|
.endOf('month')
|
|
|
.toDate()
|
|
|
- this.minDate = dayjs(this.calendarDate || new Date())
|
|
|
- // .add(1, 'day')
|
|
|
- .toDate()
|
|
|
+ this.minDate = dayjs(this.calendarDate || new Date()).toDate()
|
|
|
|
|
|
console.log(this.list, 'this.list')
|
|
|
console.log(this.calendarDate, 'calendarDate')
|
|
@@ -105,12 +94,14 @@ export default defineComponent({
|
|
|
const dateStr = dayjs(date.date).format('YYYY-MM-DD')
|
|
|
let isActive = false // 是否可选
|
|
|
this.list.forEach((item: any) => {
|
|
|
+ // console.log(dateStr, item.calendarDate)
|
|
|
if (item.calendarDate === dateStr) {
|
|
|
isActive = true
|
|
|
}
|
|
|
})
|
|
|
// 判断是否有课程 并且 时间在当前时间之后
|
|
|
- if (isActive && dayjs().isBefore(dayjs(date.date))) {
|
|
|
+ // console.log(dayjs().isSameOrBefore(dayjs(date.date)), date.date)
|
|
|
+ if (isActive && dayjs(dayjs().format('YYYY-MM-DD')).isSameOrBefore(dayjs(date.date))) {
|
|
|
date.bottomInfo = '可选'
|
|
|
if (dayjs(dateStr).isSame(this.calendarDate)) {
|
|
|
date.type = 'selected'
|