diff --git a/src/api/calendar/DateClass.ts b/src/api/calendar/DateClass.ts index 5615719cd..9d0714507 100644 --- a/src/api/calendar/DateClass.ts +++ b/src/api/calendar/DateClass.ts @@ -287,6 +287,115 @@ class DateClass { ]; return d[n - 1]; } + /** + @ 作者: 秦东 + @ 时间: 2024-07-12 13:11:32 + @ 功能: 判断公立是不是闰年 + */ + + isLeapYear(year: number): boolean { + return (year % 4 === 0 && year % 100 !== 0) || (year % 400 === 0); + } + /** + @ 作者: 秦东 + @ 时间: 2024-07-12 11:50:37 + @ 功能: 处理年月日回退数据 + @ 1: 月;2:周;3:天 + */ + gobackTime(y: number, m: number, d: number,t?:number){ + console.log("计算时间--0--》",y,m,d,t) + switch(t){ + case 2: + let startWeek = this.getMonday(y,m,d,'s',0) + let endWeek = this.getMonday(y,m,d,'e',0) + return { + start:startWeek, + end:endWeek + } + break; + case 3: + let day = d-1 + if(day <= 0){ + let month = m - 1 + if(month <= 0){ + y = y -1; + m = 12 + d = this.solarMonth(y,m) + }else{ + m = month + d = this.solarMonth(y,month) + } + }else{ + d = day + } + return [y,m,d] + break; + default: + let month = m - 1 + if(month <= 0){ + y = y -1; + m = 12 + d = this.solarMonth(y,m) + console.log("计算时间--1--》",y,m,d) + }else{ + m = month + let day = this.solarMonth(y,month) + if(d > day){ + d = day + } + + } + return [y,m,d] + break; + + } + + } + /** + @ 作者: 秦东 + @ 时间: 2024-07-12 13:48:55 + @ 功能: 获取周 + */ + getMonday = (year: number, month: number, taday: number,type: any, dates: any) => { + // let now = new Date(); + // let nowTime = now.getTime(); + + let dateStr = year + "-" + month + "-" + taday; // 要转换的日期字符串 + // let nowTime = Date.parse(dateStr); + + let now = new Date(dateStr); + let nowTime = now.getTime(); + + let day = now.getDay(); + let longTime = 24 * 60 * 60 * 1000; + let n = longTime * 7 * (dates || 0); + let date: any = '' + + + + console.log("now--->",now) + console.log("nowTime--->",nowTime) + console.log("day--->",day) + console.log("longTime--->",longTime) + console.log("n--->",n) + + + + if (type == "s") { + date = nowTime - (day - 1) * longTime + n; + }; + if (type == "e") { + date = nowTime + (7 - day) * longTime + n; + }; + date = new Date(date); + let y: any = date.getFullYear(); + let m: any = date.getMonth() + 1; + let d: any = date.getDate(); + // m = m < 10 ? "0" + m : m; + // d = d < 10 ? "0" + d : d; + let days = y + "-" + m + "-" + d; + return [y, m, d]; + } } export default new DateClass(); diff --git a/src/components/DesignForm/app/calendar/calendar1/calendarPage.vue b/src/components/DesignForm/app/calendar/calendar1/calendarPage.vue new file mode 100644 index 000000000..1e8d12e56 --- /dev/null +++ b/src/components/DesignForm/app/calendar/calendar1/calendarPage.vue @@ -0,0 +1,108 @@ + + + + diff --git a/src/components/DesignForm/app/calendar/calendar1/type.ts b/src/components/DesignForm/app/calendar/calendar1/type.ts new file mode 100644 index 000000000..e69de29bb diff --git a/src/components/DesignForm/app/calendarPage.vue b/src/components/DesignForm/app/calendarPage.vue index 957ad3272..ab14dd546 100644 --- a/src/components/DesignForm/app/calendarPage.vue +++ b/src/components/DesignForm/app/calendarPage.vue @@ -12,6 +12,11 @@ import { getMonth, getYear } from '@/components/DesignForm/app/calendar/calendar1/handle' + +//引入日历 +import CalendarPage from '@/components/DesignForm/app/calendar/calendar1/calendarPage.vue' + + const value = ref(new Date()) let timek = new Date() @@ -20,8 +25,7 @@ let timek = new Date()