From 58098e654240c7889dfa47c58f5bec213124d823 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=95=E6=9D=B0=E5=88=9A?= <1543758718@qq.com> Date: Tue, 25 Nov 2025 21:00:46 +0800 Subject: [PATCH] commit --- src/common/utils/datetime.ts | 40 +++ src/pages/dashboard/components/Editor.vue | 27 +- .../miningWorkshopDailyreport.vue | 333 ++++++++++++------ 3 files changed, 293 insertions(+), 107 deletions(-) diff --git a/src/common/utils/datetime.ts b/src/common/utils/datetime.ts index 563b95f..049e9a1 100644 --- a/src/common/utils/datetime.ts +++ b/src/common/utils/datetime.ts @@ -23,3 +23,43 @@ export function getSpecificDate(val: Date) { (endD < 10 ? "0" + endD : endD); return enddate; } +// 将时间转为年月日 +export function formatDateToChinese(dateString: any) { + const date = new Date(dateString); + const year = date.getFullYear(); + const month = date.getMonth() + 1; // 月份从0开始,需要+1 + const day = date.getDate(); + + return `${year}年${month}月${day}日`; + +} + +// 中文转英文函数 +export function formatChineseToEnglish(chineseDate: any) { + // 使用正则表达式提取年、月、日 + const match = chineseDate.match(/(\d{4})年(\d{1,2})月(\d{1,2})日/); + console.log(match); + + if (!match) { + throw new Error('日期格式不正确'); + } + + const year = parseInt(match[1]); + const month = parseInt(match[2]) - 1; // 月份从0开始,需要-1 + const day = parseInt(match[3]); + + const date = new Date(year, month, day); + + // 星期名称数组 + const weekdays = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']; + // 月份名称数组 + const months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; + + const weekday = weekdays[date.getDay()]; + const monthName = months[date.getMonth()]; + + // 格式化日期部分,确保日为两位数 + const formattedDay = day < 10 ? '0' + day : day; + + return `${weekday} ${monthName} ${formattedDay} ${year} 00:00:00 GMT+0800`; +} diff --git a/src/pages/dashboard/components/Editor.vue b/src/pages/dashboard/components/Editor.vue index 6f9dae3..50dc5cc 100644 --- a/src/pages/dashboard/components/Editor.vue +++ b/src/pages/dashboard/components/Editor.vue @@ -116,7 +116,7 @@ export default {