From 1452bcf2fe95ffdd1af96f38adb4f8d12c66fbcd Mon Sep 17 00:00:00 2001 From: herenshan112 Date: Mon, 15 Jul 2024 10:28:27 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=A5=E5=8E=86=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/calendar/Calendar.ts | 8 +-- src/api/calendar/DateClass.ts | 64 ++++++++++++++----- src/api/calendar/const.ts | 13 ++++ .../app/calendar/calendar1/calendarItem.vue | 4 +- .../app/calendar/calendar1/calendarPage.vue | 18 +++++- .../app/calendar/calendar1/monthPage.vue | 9 ++- src/components/DesignForm/app/index.vue | 2 +- src/types/components.d.ts | 4 ++ 8 files changed, 96 insertions(+), 26 deletions(-) diff --git a/src/api/calendar/Calendar.ts b/src/api/calendar/Calendar.ts index d9328e63d..bbc0edfbf 100644 --- a/src/api/calendar/Calendar.ts +++ b/src/api/calendar/Calendar.ts @@ -43,7 +43,7 @@ class Calendar { title() { const title: string[] = []; for (let i = 0; i <= 6; i++) { - title.push(constValue.nStr1[i % 7]); + title.push(constValue.nStr5[i % 7]); } return title; } @@ -82,7 +82,7 @@ class Calendar { const y = date[1] === 1 ? date[0] - 1 : date[0]; const m = date[1] === 1 ? 12 : date[1] - 1; let w = DateClass.solarMonth(y, m); - + // console.log("获取当月前面需补齐的数组-->",y,m,w,last) const arr: dateBase[] = []; for (let i = 0; i < last; i++) { const lun = DateClass.getLunars(y, m, w - i); @@ -171,7 +171,7 @@ class Calendar { const result = this.validateDate(date); const currentDay = DateClass.solarWeeks(result[0], result[1]); - + // console.log("获取当月的完整数据",currentDay,result) // 获取当月的完整数据 const beforDays = this.beforDays(date, currentDay).reverse(); @@ -187,7 +187,7 @@ class Calendar { for (let row = 0; row < 6; row++) { dateArray.push(params.splice(0, 7)); } - console.log("日历数据",dateArray) + // console.log("日历数据",dateArray) return dateArray; } } diff --git a/src/api/calendar/DateClass.ts b/src/api/calendar/DateClass.ts index 32daf75c3..b860c411b 100644 --- a/src/api/calendar/DateClass.ts +++ b/src/api/calendar/DateClass.ts @@ -1,7 +1,8 @@ import constValue from '@/api/calendar/const'; import { clockFactory } from '@/api/calendar/utils'; import config from '@/api/calendar/config'; -export const dayArr = ['日', '一', '二', '三', '四', '五', '六']; +export const dayArr = [ '一', '二', '三', '四', '五', '六','日']; +// export const dayArr = ['日', '一', '二', '三', '四', '五', '六']; /** * 日期信息的操作类 @@ -34,12 +35,12 @@ class DateClass { ); } getWorks(date: number[]) { - console.log("日清杀杀杀",`${date[0]}${clockFactory(date[1])}${clockFactory(date[2])}`) - console.log("日清杀杀杀--》",config.Works.indexOf(`${date[0]}${clockFactory(date[1])}${clockFactory(date[2])}`)) - console.log("日清杀杀杀--》",( - config.Works.indexOf(`${date[0]}${clockFactory(date[1])}${clockFactory(date[2])}`) > - -1 - )) + // console.log("日清杀杀杀",`${date[0]}${clockFactory(date[1])}${clockFactory(date[2])}`) + // console.log("日清杀杀杀--》",config.Works.indexOf(`${date[0]}${clockFactory(date[1])}${clockFactory(date[2])}`)) + // console.log("日清杀杀杀--》",( + // config.Works.indexOf(`${date[0]}${clockFactory(date[1])}${clockFactory(date[2])}`) > + // -1 + // )) return ( config.Works.indexOf(`${date[0]}${clockFactory(date[1])}${clockFactory(date[2])}`) > -1 @@ -73,7 +74,11 @@ class DateClass { */ solarWeek(y: number, m: number, d: number) { let date = new Date(y, m - 1, d); - let week = date.getDay(); + let week = date.getDay()-1; + if(week < 0){ + week = 6 + } + // console.log("获取公历某一天是星期几",y, m ,date,week,week < 0) return week; } /** @@ -94,7 +99,7 @@ class DateClass { */ toChinaDay(d: number) { let str = d == 10 ? constValue.nStr2[0] : constValue.nStr2[Math.floor(d / 10)]; - return str + (d % 10 ? constValue.nStr1[d % 10] : constValue.nStr1[10]); + return str + (d % 10 ? constValue.nStr5[d % 10] : constValue.nStr5[10]); } /** * 农历年份转生肖 @@ -310,12 +315,41 @@ class DateClass { } /** @ 作者: 秦东 + @ 时间: 2024-07-15 09:00:20 + @ 功能: 前进时间 + @ 1: 月;2:周;3:天 + */ + moveTime(y: number, m: number, d: number,t?:number){ + switch(t){ + case 2: + break; + case 3: + break; + default: + let month = m + 1 + if(month > 12){ + y = y + 1; + m = 1 + d = this.solarMonth(y,m) + }else{ + m = month + let day = this.solarMonth(y,month) + if(d > day){ + d = day + } + + } + return [y,m,d] + } + } + /** + @ 作者: 秦东 @ 时间: 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) + // console.log("计算时间--0--》",y,m,d,t) switch(t){ case 2: let startWeek = this.getMonday(y,m,d,'s',-1) @@ -385,11 +419,11 @@ class DateClass { - console.log("now--->",now) - console.log("nowTime--->",nowTime) - console.log("day--->",day) - console.log("longTime--->",longTime) - console.log("n--->",n) + // console.log("now--->",now) + // console.log("nowTime--->",nowTime) + // console.log("day--->",day) + // console.log("longTime--->",longTime) + // console.log("n--->",n) diff --git a/src/api/calendar/const.ts b/src/api/calendar/const.ts index fcff549ab..3618f192b 100644 --- a/src/api/calendar/const.ts +++ b/src/api/calendar/const.ts @@ -303,6 +303,19 @@ export default { '\u516b', '\u4e5d', '\u5341' + ], + nStr5: [ + '\u4e00', + '\u4e8c', + '\u4e09', + '\u56db', + '\u4e94', + '\u516d', + '\u65e5', + '\u4e03', + '\u516b', + '\u4e5d', + '\u5341' ], /** * 日期转农历称呼速查表 diff --git a/src/components/DesignForm/app/calendar/calendar1/calendarItem.vue b/src/components/DesignForm/app/calendar/calendar1/calendarItem.vue index dc6185c40..3a42ccfc5 100644 --- a/src/components/DesignForm/app/calendar/calendar1/calendarItem.vue +++ b/src/components/DesignForm/app/calendar/calendar1/calendarItem.vue @@ -17,9 +17,7 @@
{{ col.lunarsChina }} - {{col.date}} - - {{props.time}} + diff --git a/src/components/DesignForm/app/calendar/calendar1/calendarPage.vue b/src/components/DesignForm/app/calendar/calendar1/calendarPage.vue index ac5998962..bdf0267d3 100644 --- a/src/components/DesignForm/app/calendar/calendar1/calendarPage.vue +++ b/src/components/DesignForm/app/calendar/calendar1/calendarPage.vue @@ -5,6 +5,7 @@ -->