Browse Source

时长显示分钟

lwx_v12
liwenxuan 1 month ago
parent
commit
a547b1dd97
  1. 37
      src/components/lowCode/assistant/datePicker.vue

37
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() {

Loading…
Cancel
Save