|
@@ -82,6 +82,14 @@ import { weekList, modeList, monthList } from './calendarData';
|
|
|
import { GetMyTaskDailyDistribution } from '@/api/user';
|
|
|
|
|
|
export default {
|
|
|
+ props: {
|
|
|
+ dateStamp: {
|
|
|
+ type: Date,
|
|
|
+ default: () => {
|
|
|
+ return new Date();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
data() {
|
|
|
return {
|
|
|
focusDate: 0,
|
|
@@ -90,8 +98,8 @@ export default {
|
|
|
weekList,
|
|
|
monthList,
|
|
|
date: '',
|
|
|
- curYear: new Date().getFullYear(),
|
|
|
- curMonth: new Date().getMonth() + 1,
|
|
|
+ curYear: this.dateStamp.getFullYear(),
|
|
|
+ curMonth: this.dateStamp.getMonth() + 1,
|
|
|
time_unit: modeList[0].type,
|
|
|
DAY: modeList[0].type,
|
|
|
MONTH: modeList[1].type,
|
|
@@ -133,16 +141,17 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
created() {
|
|
|
- this.date = `${new Date().getFullYear()}-${new Date().getMonth() + 1}`;
|
|
|
+ this.date = `${this.dateStamp.getFullYear()}-${this.dateStamp.getMonth() + 1}`;
|
|
|
this.getDateArr();
|
|
|
- this.focusDate = new Date().getDate();
|
|
|
+ this.focusDate = this.dateStamp.getDate();
|
|
|
},
|
|
|
methods: {
|
|
|
// 返回今天
|
|
|
backToday() {
|
|
|
- this.date = `${new Date().getFullYear()}-${new Date().getMonth() + 1}`;
|
|
|
- this.focusDate = new Date().getDate();
|
|
|
- this.focusMonth = new Date().getMonth();
|
|
|
+ const date = new Date();
|
|
|
+ this.date = `${date.getFullYear()}-${date.getMonth() + 1}`;
|
|
|
+ this.focusDate = date.getDate();
|
|
|
+ this.focusMonth = date.getMonth();
|
|
|
this.$emit('changeDate');
|
|
|
this.getDateArr();
|
|
|
},
|
|
@@ -191,13 +200,15 @@ export default {
|
|
|
|
|
|
// 得到日历所需数组
|
|
|
getDateArr() {
|
|
|
- const curDate = new Date().getDate();
|
|
|
const daysInMonth = dayjs(this.date).daysInMonth();
|
|
|
const dayOfWeek = dayjs(`${this.date}-1`).day();
|
|
|
const curMonth = dayjs(this.date).month();
|
|
|
const curYear = dayjs(this.date).year();
|
|
|
const lastDays = dayjs(curMonth === 0 ? `${curYear - 1}-12` : `${curYear}-${curMonth}`).daysInMonth();
|
|
|
- const isThisMonth = curMonth === new Date().getMonth() && curYear === new Date().getFullYear();
|
|
|
+
|
|
|
+ const date = new Date();
|
|
|
+ const curDate = date.getDate();
|
|
|
+ const isThisMonth = curMonth === date.getMonth() && curYear === date.getFullYear();
|
|
|
|
|
|
const arr = [];
|
|
|
// 是否有上个月
|