From 6f265250802a23b99268b05024c68ed8b874f40a Mon Sep 17 00:00:00 2001 From: herenshan112 Date: Mon, 15 Jul 2024 08:02:53 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E6=97=A5=E5=8E=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/calendar/Calendar.ts | 9 +- src/api/calendar/DateClass.ts | 21 ++- src/api/calendar/config.ts | 40 ++++ .../app/calendar/calendar1/calendarItem.vue | 175 ++++++++++++++++++ .../app/calendar/calendar1/calendarPage.vue | 86 ++++++++- .../app/calendar/calendar1/dayPage.vue | 24 +++ .../app/calendar/calendar1/monthPage.vue | 122 ++++++++++++ .../app/calendar/calendar1/weekPage.vue | 24 +++ .../DesignForm/app/calendarPage.vue | 2 +- src/components/DesignForm/app/index.vue | 2 +- src/components/DesignForm/app/timeAxis.vue | 2 +- src/types/components.d.ts | 5 +- 12 files changed, 493 insertions(+), 19 deletions(-) create mode 100644 src/components/DesignForm/app/calendar/calendar1/calendarItem.vue create mode 100644 src/components/DesignForm/app/calendar/calendar1/dayPage.vue create mode 100644 src/components/DesignForm/app/calendar/calendar1/monthPage.vue create mode 100644 src/components/DesignForm/app/calendar/calendar1/weekPage.vue diff --git a/src/api/calendar/Calendar.ts b/src/api/calendar/Calendar.ts index 38be445c2..d9328e63d 100644 --- a/src/api/calendar/Calendar.ts +++ b/src/api/calendar/Calendar.ts @@ -7,6 +7,7 @@ export interface dateBase { isCurrent: boolean; title: number; isHolidays: boolean; + isWorks: boolean; date: string; lunars: string; lunarsChina: string; @@ -90,6 +91,7 @@ class Calendar { title: w - i, isCurrent: false, isHolidays: DateClass.getHolidays([y, m, w - i]), + isWorks: DateClass.getWorks([y, m, w - i]), date: `${y}-${clockFactory(m)}-${clockFactory(w - i)}`, lunars: lun, lunarsChinese: @@ -100,7 +102,8 @@ class Calendar { lunarDay: DateClass.getlunarDay(Number(l[0]), Number(l[1]), Number(l[2])), animal: DateClass.getAnimal(Number(l[0])), astro: DateClass.toAstro(y, m, w - i), - term: getTerm(Number(l[0]), m, w - i) + term: getTerm(Number(l[0]), m, w - i), + }); } return arr; @@ -112,7 +115,6 @@ class Calendar { const arr: dateBase[] = []; const y = date[1] === 12 ? date[0] + 1 : date[0]; const m = date[1] === 12 ? 1 : date[1] + 1; - for (let i = 1; i < 42 - day.length + 1; i++) { const lun = DateClass.getLunars(y, m, i); const l = lun.split('-'); @@ -120,6 +122,7 @@ class Calendar { title: i, isCurrent: false, isHolidays: DateClass.getHolidays([y, m, i]), + isWorks: DateClass.getWorks([y, m, i]), date: `${y}-${clockFactory(m)}-${clockFactory(i)}`, lunars: lun, lunarsChinese: @@ -145,6 +148,7 @@ class Calendar { title: i, isCurrent: true, isHolidays: DateClass.getHolidays([date[0], date[1], i]), + isWorks: DateClass.getWorks([date[0], date[1], i]), date: `${date[0]}-${clockFactory(date[1])}-${clockFactory(i)}`, lunars: lun, lunarsChinese: @@ -183,6 +187,7 @@ class Calendar { for (let row = 0; row < 6; row++) { dateArray.push(params.splice(0, 7)); } + console.log("日历数据",dateArray) return dateArray; } } diff --git a/src/api/calendar/DateClass.ts b/src/api/calendar/DateClass.ts index 9d0714507..32daf75c3 100644 --- a/src/api/calendar/DateClass.ts +++ b/src/api/calendar/DateClass.ts @@ -32,6 +32,18 @@ class DateClass { config.Holidays.indexOf(`${date[0]}${clockFactory(date[1])}${clockFactory(date[2])}`) > -1 ); + } + 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 + )) + return ( + config.Works.indexOf(`${date[0]}${clockFactory(date[1])}${clockFactory(date[2])}`) > + -1 + ); } /** * 获取公历月份天数 @@ -306,8 +318,8 @@ class DateClass { 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) + let startWeek = this.getMonday(y,m,d,'s',-1) + let endWeek = this.getMonday(y,m,d,'e',-1) return { start:startWeek, end:endWeek @@ -354,7 +366,7 @@ class DateClass { /** @ 作者: 秦东 @ 时间: 2024-07-12 13:48:55 - @ 功能: 获取周 + @ 功能: 任意日期获取周 */ getMonday = (year: number, month: number, taday: number,type: any, dates: any) => { // let now = new Date(); @@ -396,6 +408,9 @@ class DateClass { let days = y + "-" + m + "-" + d; return [y, m, d]; } + + //获得上周的开始日期 + // getLastWeekStartDate() } export default new DateClass(); diff --git a/src/api/calendar/config.ts b/src/api/calendar/config.ts index 911138f2e..eacc07ee3 100644 --- a/src/api/calendar/config.ts +++ b/src/api/calendar/config.ts @@ -132,6 +132,38 @@ export default { '20230125', '20230126', '20230127', + '20231230', + '20240101', + '20240210', + '20240210', + '20240211', + '20240212', + '20240213', + '20240214', + '20240215', + '20240216', + '20240217', + '20240404', + '20240405', + '20240406', + '20240501', + '20240502', + '20240503', + '20240504', + '20240505', + '20240608', + '20240609', + '20240610', + '20240915', + '20240916', + '20240917', + '20241001', + '20241002', + '20241003', + '20241004', + '20241005', + '20241006', + '20241007', ], /** * 补休日期 @@ -165,5 +197,13 @@ export default { '20220507', '20221008', '20221009', + '20240204', + '20240218', + '20240407', + '20240428', + '20240511', + '20240914', + '20240929', + '20241012', ], }; diff --git a/src/components/DesignForm/app/calendar/calendar1/calendarItem.vue b/src/components/DesignForm/app/calendar/calendar1/calendarItem.vue new file mode 100644 index 000000000..dc6185c40 --- /dev/null +++ b/src/components/DesignForm/app/calendar/calendar1/calendarItem.vue @@ -0,0 +1,175 @@ + + + + + diff --git a/src/components/DesignForm/app/calendar/calendar1/calendarPage.vue b/src/components/DesignForm/app/calendar/calendar1/calendarPage.vue index 1e8d12e56..ac5998962 100644 --- a/src/components/DesignForm/app/calendar/calendar1/calendarPage.vue +++ b/src/components/DesignForm/app/calendar/calendar1/calendarPage.vue @@ -5,6 +5,13 @@ --> @@ -102,7 +168,7 @@ const forwardTime = () =>{ } } .weekNumber{ - + } } diff --git a/src/components/DesignForm/app/calendar/calendar1/dayPage.vue b/src/components/DesignForm/app/calendar/calendar1/dayPage.vue new file mode 100644 index 000000000..b6fcd3707 --- /dev/null +++ b/src/components/DesignForm/app/calendar/calendar1/dayPage.vue @@ -0,0 +1,24 @@ + + + + diff --git a/src/components/DesignForm/app/calendar/calendar1/monthPage.vue b/src/components/DesignForm/app/calendar/calendar1/monthPage.vue new file mode 100644 index 000000000..07cf93f8d --- /dev/null +++ b/src/components/DesignForm/app/calendar/calendar1/monthPage.vue @@ -0,0 +1,122 @@ + + + + diff --git a/src/components/DesignForm/app/calendar/calendar1/weekPage.vue b/src/components/DesignForm/app/calendar/calendar1/weekPage.vue new file mode 100644 index 000000000..ed4b4445c --- /dev/null +++ b/src/components/DesignForm/app/calendar/calendar1/weekPage.vue @@ -0,0 +1,24 @@ + + + + diff --git a/src/components/DesignForm/app/calendarPage.vue b/src/components/DesignForm/app/calendarPage.vue index ab14dd546..2de7a0c0f 100644 --- a/src/components/DesignForm/app/calendarPage.vue +++ b/src/components/DesignForm/app/calendarPage.vue @@ -25,7 +25,7 @@ let timek = new Date() diff --git a/src/types/components.d.ts b/src/types/components.d.ts index ee8dbb95e..471505dc3 100644 --- a/src/types/components.d.ts +++ b/src/types/components.d.ts @@ -38,7 +38,6 @@ declare module '@vue/runtime-core' { ElCard: typeof import('element-plus/es')['ElCard'] ElCarousel: typeof import('element-plus/es')['ElCarousel'] ElCarouselItem: typeof import('element-plus/es')['ElCarouselItem'] - ElCascader: typeof import('element-plus/es')['ElCascader'] ElCheckbox: typeof import('element-plus/es')['ElCheckbox'] ElCheckboxGroup: typeof import('element-plus/es')['ElCheckboxGroup'] ElCol: typeof import('element-plus/es')['ElCol'] @@ -63,7 +62,6 @@ declare module '@vue/runtime-core' { ElImageViewer: typeof import('element-plus/es')['ElImageViewer'] ElInput: typeof import('element-plus/es')['ElInput'] ElInputNumber: typeof import('element-plus/es')['ElInputNumber'] - ElLink: typeof import('element-plus/es')['ElLink'] ElMain: typeof import('element-plus/es')['ElMain'] ElMenu: typeof import('element-plus/es')['ElMenu'] ElMenuItem: typeof import('element-plus/es')['ElMenuItem'] @@ -71,7 +69,6 @@ declare module '@vue/runtime-core' { ElPagination: typeof import('element-plus/es')['ElPagination'] ElPopconfirm: typeof import('element-plus/es')['ElPopconfirm'] ElPopover: typeof import('element-plus/es')['ElPopover'] - ElProgress: typeof import('element-plus/es')['ElProgress'] ElRadio: typeof import('element-plus/es')['ElRadio'] ElRadioButton: typeof import('element-plus/es')['ElRadioButton'] ElRadioGroup: typeof import('element-plus/es')['ElRadioGroup'] @@ -127,16 +124,13 @@ declare module '@vue/runtime-core' { IEpCaretBottom: typeof import('~icons/ep/caret-bottom')['default'] IEpCaretTop: typeof import('~icons/ep/caret-top')['default'] IEpClose: typeof import('~icons/ep/close')['default'] - IEpCollection: typeof import('~icons/ep/collection')['default'] IEpDelete: typeof import('~icons/ep/delete')['default'] IEpEdit: typeof import('~icons/ep/edit')['default'] IEpMessageBox: typeof import('~icons/ep/message-box')['default'] - IEpPicture: typeof import('~icons/ep/picture')['default'] IEpPlus: typeof import('~icons/ep/plus')['default'] IEpRefresh: typeof import('~icons/ep/refresh')['default'] IEpSearch: typeof import('~icons/ep/search')['default'] IEpSetting: typeof import('~icons/ep/setting')['default'] - IEpView: typeof import('~icons/ep/view')['default'] LangSelect: typeof import('./../components/LangSelect/index.vue')['default'] LayoutPage: typeof import('./../components/DesignForm/layoutPage/index.vue')['default'] List: typeof import('./../components/DesignForm/public/form/components/list.vue')['default'] From 0faf0b3b9ac4c2523f85d4815decd71d3cca09be Mon Sep 17 00:00:00 2001 From: herenshan112 Date: Tue, 16 Jul 2024 15:14:42 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E6=97=A5=E5=8E=86=E8=A7=86=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/calendar/Calendar.ts | 78 +++++++++++ src/api/calendar/DateClass.ts | 31 +++-- .../app/calendar/calendar1/calendarItem.vue | 105 ++++++++++---- .../app/calendar/calendar1/calendarPage.vue | 36 ++++- .../app/calendar/calendar1/dayPage.vue | 131 +++++++++++++++++- .../app/calendar/calendar1/monthPage.vue | 3 +- .../app/calendar/calendar1/weekPage.vue | 27 +++- src/components/DesignForm/app/index.vue | 28 ++-- src/components/DesignForm/app/timeAxis.vue | 17 ++- 9 files changed, 385 insertions(+), 71 deletions(-) diff --git a/src/api/calendar/Calendar.ts b/src/api/calendar/Calendar.ts index d9515c08a..553a0baae 100644 --- a/src/api/calendar/Calendar.ts +++ b/src/api/calendar/Calendar.ts @@ -2,6 +2,7 @@ import constValue from '@/api/calendar/const'; import constVal from '@/api/calendar/const'; import DateClass from '@/api/calendar/DateClass'; import { clockFactory } from '@/api/calendar/utils'; +import { formToJSON } from 'axios'; export interface dateBase { isCurrent: boolean; @@ -194,6 +195,83 @@ class Calendar { // console.log("日历数据",dateArray) return dateArray; } + //获取单一日期格式 + gainOneDay(y: number, m: number, d: number){ + let dateStr = y + "-" + m + "-" + d; // 要转换的日期字符串 + let now = new Date(dateStr); //当前日期字符串转换成Date对象 + const lun = DateClass.getLunars(y, m, d); + const l = lun.split('-'); + let currentTime = DateClass.getCurrent() + return { + title: d, + isCurrent: true, + isHolidays: DateClass.getHolidays([y, m, d]), + isWorks: DateClass.getWorks([y, m, d]), + date: `${y}-${clockFactory(m)}-${clockFactory(d)}`, + lunars: lun, + lunarsChinese: + DateClass.toChinaMonth(Number(l[1])) + DateClass.toChinaDay(Number(l[2])), + lunarsChina: DateClass.toChinaDay(Number(l[2])), + isNow: currentTime[2] === d ? true : false, + solarDay: DateClass.getSolarDay(m, d ), + lunarDay: DateClass.getlunarDay(Number(l[0]), Number(l[1]), Number(l[2])), + animal: DateClass.getAnimal(Number(l[0])), + astro: DateClass.toAstro(y, m, d), + term: getTerm(Number(l[0]), m, d), + + } + } + + //获取指定日期所在周的时间 + gainDayOfWeek(year: number, month: number, taday: number){ + let dateStr = year + "-" + month + "-" + taday; // 要转换的日期字符串 + let now = new Date(dateStr); //当前日期字符串转换成Date对象 + let nowTime = now.getTime(); + let nowDayOfWeek = now.getDay()==0?7:now.getDay(); //今天本周的第几天 + let taDay = now.getDate() + let firstTime = now.setDate(taDay - nowDayOfWeek + 1) + let currentTime = DateClass.getCurrent() + const dateArray: dateBase[] = []; + for(let i=1; i<=7;i++){ + let nextWeekFirstDaty = new Date(firstTime + 86400000 * (i - 1)) + let y: any = nextWeekFirstDaty.getFullYear(); + let m: any = nextWeekFirstDaty.getMonth() + 1; + let d: any = nextWeekFirstDaty.getDate(); + const lun = DateClass.getLunars(y, m, d); + const l = lun.split('-'); + dateArray.push({ + title: d, + isCurrent: true, + isHolidays: DateClass.getHolidays([y, m, d]), + isWorks: DateClass.getWorks([y, m, d - i]), + date: `${y}-${clockFactory(m)}-${clockFactory(d)}`, + lunars: lun, + lunarsChinese: + DateClass.toChinaMonth(Number(l[1])) + DateClass.toChinaDay(Number(l[2])), + lunarsChina: DateClass.toChinaDay(Number(l[2])), + isNow: currentTime[2] === d ? true : false, + solarDay: DateClass.getSolarDay(m, d + i), + lunarDay: DateClass.getlunarDay(Number(l[0]), Number(l[1]), Number(l[2])), + animal: DateClass.getAnimal(Number(l[0])), + astro: DateClass.toAstro(y, m, d), + term: getTerm(Number(l[0]), m, d), + + }); + } + + + // console.log("dateStr=========>",dateStr) + // console.log("now=========>",now) + // console.log("nowTime=========>",nowTime) + // console.log("nowDayOfWeek=========>",nowDayOfWeek) + // console.log("taDay=========>",taDay) + // console.log("kjsd=========>",firstTime) + // console.log("dateArray=========>",dateArray) + + return dateArray + } + + //获得一周的所有日期 getWeekNumber(year: number, month: number, taday: number) { let dateStr = year + "-" + month + "-" + taday; // 要转换的日期字符串 diff --git a/src/api/calendar/DateClass.ts b/src/api/calendar/DateClass.ts index e48cbafc9..847ad0521 100644 --- a/src/api/calendar/DateClass.ts +++ b/src/api/calendar/DateClass.ts @@ -333,6 +333,14 @@ class DateClass { } break; case 3: + let dateStr = y + "-" + m + "-" + d; // 要转换的日期字符串 + let now = new Date(dateStr); //当前日期字符串转换成Date对象 + let nowTime = now.getTime(); + let nextWeekFirstDaty = new Date(nowTime + 86400000) + let yy: any = nextWeekFirstDaty.getFullYear(); + let mm: any = nextWeekFirstDaty.getMonth() + 1; + let dd: any = nextWeekFirstDaty.getDate(); + return [yy,mm,dd] break; default: let month = m + 1 @@ -369,21 +377,14 @@ class DateClass { } 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] + let dateStr = y + "-" + m + "-" + d; // 要转换的日期字符串 + let now = new Date(dateStr); //当前日期字符串转换成Date对象 + let nowTime = now.getTime(); + let nextWeekFirstDaty = new Date(nowTime - 86400000) + let yy: any = nextWeekFirstDaty.getFullYear(); + let mm: any = nextWeekFirstDaty.getMonth() + 1; + let dd: any = nextWeekFirstDaty.getDate(); + return [yy,mm,dd] break; default: let month = m - 1 diff --git a/src/components/DesignForm/app/calendar/calendar1/calendarItem.vue b/src/components/DesignForm/app/calendar/calendar1/calendarItem.vue index 3a42ccfc5..545a67743 100644 --- a/src/components/DesignForm/app/calendar/calendar1/calendarItem.vue +++ b/src/components/DesignForm/app/calendar/calendar1/calendarItem.vue @@ -1,28 +1,3 @@ - - + + + diff --git a/src/components/DesignForm/app/calendar/calendar1/monthPage.vue b/src/components/DesignForm/app/calendar/calendar1/monthPage.vue index 251bbce31..15ba9e647 100644 --- a/src/components/DesignForm/app/calendar/calendar1/monthPage.vue +++ b/src/components/DesignForm/app/calendar/calendar1/monthPage.vue @@ -30,7 +30,7 @@ onMounted(()=>{ const selectedTime = ref(props.taDay[0] + "-" + clockFactory(props.taDay[1]) + "-" + clockFactory(props.taDay[2])) const emit = defineEmits(['getDate']); -function changeDate(time: dateBase) { +const changeDate = (time: dateBase) => { selectedTime.value = time.date; emit('getDate', time); } @@ -115,6 +115,7 @@ const TBody = computed(() => padding: 2px; font-size: 16px; transition: all 0.2s; + width: calc(100%/7); } .t-calendar-col:last-child { border-right: 1px solid #ebeef5; diff --git a/src/components/DesignForm/app/calendar/calendar1/weekPage.vue b/src/components/DesignForm/app/calendar/calendar1/weekPage.vue index 2ce942b54..1ab3b7b71 100644 --- a/src/components/DesignForm/app/calendar/calendar1/weekPage.vue +++ b/src/components/DesignForm/app/calendar/calendar1/weekPage.vue @@ -26,11 +26,24 @@ const drawingBoardHeight = computed(()=>{ //周期 const THeader = Calendar.title(); const WeekBody = computed(()=>{ - - console.log("画板高度--->",props.taDay.start[0]); - return Calendar.getWeekNumber(props.taDay.start[0],props.taDay.start[1],props.taDay.start[2]); + Calendar.gainDayOfWeek(props.taDay.start[0],props.taDay.start[1],props.taDay.start[2]); + console.log("画板高度--->",props.taDay.start[0]); + return Calendar.gainDayOfWeek(props.taDay.start[0],props.taDay.start[1],props.taDay.start[2]); }); + +onMounted(()=>{ + nextTick(()=>{ + let ddTime = DateClass.getCurrent() + selectedTime.value = ddTime[0] + "-" + clockFactory(ddTime[1]) + "-" + clockFactory(ddTime[2]) + }) +}) +const selectedTime = ref(props.taDay[0] + "-" + clockFactory(props.taDay[1]) + "-" + clockFactory(props.taDay[2])) +const emit = defineEmits(['getDate']); +const changeDate = (time: dateBase) => { + selectedTime.value = time.date; + emit('getDate', time); +}