From a547b1dd97d7852ab2045239a13676e421b7f23a Mon Sep 17 00:00:00 2001 From: liwenxuan <1298531568@qq.com> Date: Wed, 15 Oct 2025 15:28:33 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=B6=E9=95=BF=E6=98=BE=E7=A4=BA=E5=88=86?= =?UTF-8?q?=E9=92=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lowCode/assistant/datePicker.vue | 37 ++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/src/components/lowCode/assistant/datePicker.vue b/src/components/lowCode/assistant/datePicker.vue index b2a590b..1c5f867 100644 --- a/src/components/lowCode/assistant/datePicker.vue +++ b/src/components/lowCode/assistant/datePicker.vue @@ -496,7 +496,7 @@ const shichang = computed(() => { let a = calculateTimeDiff(start, end) return a }) -function calculateTimeDiff(startTimestamp: string, endTimestamp: string) { +/* function calculateTimeDiff(startTimestamp: string, endTimestamp: string) { // 解析时间戳为数字 const start = parseInt(startTimestamp, 10); const end = parseInt(endTimestamp, 10); @@ -526,6 +526,41 @@ function calculateTimeDiff(startTimestamp: string, endTimestamp: string) { } return `${days} 天 ${remainingHours} 小时`; } +} */ + +function calculateTimeDiff(startTimestamp: string, endTimestamp: string) { + // 解析时间戳为数字 + const start = parseInt(startTimestamp, 10); + const end = parseInt(endTimestamp, 10); + + // 计算时间差(毫秒)并取绝对值 + const diffMs = Math.abs(end - start); + + // 计算总分钟数并向下取整 + const totalMinutes = Math.floor(diffMs / 60000); + + // 计算天数和剩余小时数 + const days = Math.floor(totalMinutes / 1440); // 1440分钟 = 24小时 + const remainingMinutesAfterDays = totalMinutes % 1440; + const hours = Math.floor(remainingMinutesAfterDays / 60); + const minutes = remainingMinutesAfterDays % 60; + + // 构建返回字符串 + let result = ''; + + if (days > 0) { + result += `${days} 天 `; + } + + if (hours > 0) { + result += `${hours} 小时 `; + } + + if (minutes >= 0) { // 包含0分钟的情况 + result += `${minutes} 分钟`; + } + + return result.trim(); // 去除末尾空格 } const types = props.types; function singleShow() {