Merge pull request 'master' (#1035) from master into prod

Reviewed-on: http://git.feashow.cn/clay/mosr-web/pulls/1035
This commit is contained in:
2025-06-12 06:07:46 +00:00
3 changed files with 28 additions and 31 deletions

View File

@@ -19,7 +19,6 @@
"highlight.js": "9.18.5",
"jquery": "^3.6.0",
"js-cookie": "^3.0.5",
"moment": "^2.30.1",
"nprogress": "^0.2.0",
"pinia": "^2.0.35",
"sass": "^1.62.1",

View File

@@ -34,7 +34,6 @@
<script setup>
import {defineProps,defineEmits} from 'vue'
// import {timeLength} from '../utils/date'

View File

@@ -1,5 +1,4 @@
//时间转换为String类型
const moment = require("moment");
function simpleDateFormat(pattern) {
var fmt = new Object();
@@ -83,36 +82,36 @@ function consumingTime(dateBegin, dateEnd) {
return dayDiff + "天 " + hours + "小时 " + minutes + " 分钟" + seconds + " 秒";
}
export function timeLength(start, dateEnd) {
// //如果时间格式是正确的,那下面这一步转化时间格式就可以不用了
let mstart = moment(start);
let mend = moment(dateEnd);
let years = mend.diff(start, "years");
let months = mend.diff(start, "months");
let days = mend.diff(start, "days");
let hours = mend.diff(start, "hours");
let minutes = mend.diff(start, "minutes");
minutes = minutes % 60;
hours = hours % 24;
months = months % 12;
//因为每月天不固定,所以天要特殊动态处理
if (mstart.date() < mend.date()) {
days = mend.date() - mstart.date();
if (minutes > 0 || hours > 0) {
days--;
}
}
//处理超过俩月且天超过31
if (days > 31 && mend.month() - mstart.month() >= 2) {
//将日期推至上月求差
days = mend.diff(mstart.add(mend.month() - mstart.month() - 1, "month"), "days");
}
return `${years > 0 ? years + "年 " : " "}` + `${months > 0 ? months + "个月 " : " "}` + `${days > 0 ? days + "天 " : " "}`
+ `${hours > 0 ? hours + "小时 " : " "}` + `${minutes > 0 ? minutes + "分钟 " : " "}`;
}
// export function timeLength(start, dateEnd) {
// // //如果时间格式是正确的,那下面这一步转化时间格式就可以不用了
// let mstart = moment(start);
// let mend = moment(dateEnd);
// let years = mend.diff(start, "years");
// let months = mend.diff(start, "months");
// let days = mend.diff(start, "days");
// let hours = mend.diff(start, "hours");
// let minutes = mend.diff(start, "minutes");
// minutes = minutes % 60;
// hours = hours % 24;
// months = months % 12;
// //因为每月天不固定,所以天要特殊动态处理
// if (mstart.date() < mend.date()) {
// days = mend.date() - mstart.date();
// if (minutes > 0 || hours > 0) {
// days--;
// }
// }
// //处理超过俩月且天超过31
// if (days > 31 && mend.month() - mstart.month() >= 2) {
// //将日期推至上月求差
// days = mend.diff(mstart.add(mend.month() - mstart.month() - 1, "month"), "days");
// }
// return `${years > 0 ? years + "年 " : " "}` + `${months > 0 ? months + "个月 " : " "}` + `${days > 0 ? days + "天 " : " "}`
// + `${hours > 0 ? hours + "小时 " : " "}` + `${minutes > 0 ? minutes + "分钟 " : " "}`;
// }
module.exports = {
formatToYYYYMMDD: simpleDateFormatByMoreLine,
consumingTime: consumingTime,
timeLength: timeLength
// timeLength: timeLength
}