Compare commits
No commits in common. "e78241c7105a305a033d42568082c1c794ac974d" and "e6b901cbbe3149d6192f35330d340647e87fb00f" have entirely different histories.
e78241c710
...
e6b901cbbe
|
|
@ -1,6 +1,4 @@
|
||||||
//时间转换为String类型
|
//时间转换为String类型
|
||||||
const moment = require("moment");
|
|
||||||
|
|
||||||
function simpleDateFormat(pattern) {
|
function simpleDateFormat(pattern) {
|
||||||
var fmt = new Object();
|
var fmt = new Object();
|
||||||
fmt.pattern = pattern;
|
fmt.pattern = pattern;
|
||||||
|
|
@ -64,9 +62,9 @@ function simpleDateFormatByMoreLine(date) {
|
||||||
/**
|
/**
|
||||||
* @param dateBegin 开始时间
|
* @param dateBegin 开始时间
|
||||||
* @param dateEnd 结束时间
|
* @param dateEnd 结束时间
|
||||||
* @returns {string} 时间差 天 小时 分钟 秒
|
* @returns {string} 时间差
|
||||||
*/
|
*/
|
||||||
function consumingTime(dateBegin, dateEnd) {
|
function consumingTime(dateBegin,dateEnd) {
|
||||||
// //如果时间格式是正确的,那下面这一步转化时间格式就可以不用了
|
// //如果时间格式是正确的,那下面这一步转化时间格式就可以不用了
|
||||||
let submitTime = new Date(dateBegin)
|
let submitTime = new Date(dateBegin)
|
||||||
let endTime = new Date(dateEnd)
|
let endTime = new Date(dateEnd)
|
||||||
|
|
@ -83,36 +81,7 @@ function consumingTime(dateBegin, dateEnd) {
|
||||||
return dayDiff + "天 " + hours + "小时 " + minutes + " 分钟" + seconds + " 秒";
|
return dayDiff + "天 " + hours + "小时 " + minutes + " 分钟" + seconds + " 秒";
|
||||||
}
|
}
|
||||||
|
|
||||||
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 = {
|
module.exports = {
|
||||||
formatToYYYYMMDD: simpleDateFormatByMoreLine,
|
formatToYYYYMMDD: simpleDateFormatByMoreLine,
|
||||||
consumingTime: consumingTime,
|
consumingTime: consumingTime
|
||||||
timeLength: timeLength
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,6 @@
|
||||||
<script>
|
<script>
|
||||||
import componentMinxins from "../ComponentMinxins";
|
import componentMinxins from "../ComponentMinxins";
|
||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
import {timeLength} from '@/utils/date'
|
|
||||||
export default {
|
export default {
|
||||||
mixins: [componentMinxins],
|
mixins: [componentMinxins],
|
||||||
name: "DateTimeRange",
|
name: "DateTimeRange",
|
||||||
|
|
@ -86,12 +85,36 @@ export default {
|
||||||
timeLength() {
|
timeLength() {
|
||||||
//求时长算法
|
//求时长算法
|
||||||
if (Array.isArray(this.value)) {
|
if (Array.isArray(this.value)) {
|
||||||
// let start = moment(this.value[0]).format(this.format.replaceAll("dd", "DD"));
|
let start = moment(this.value[0]).format(this.format.replaceAll("dd", "DD"));
|
||||||
// let end = moment(this.value[1]).format(this.format.replaceAll("dd", "DD"));
|
let end = moment(this.value[1]).format(this.format.replaceAll("dd", "DD"));
|
||||||
if (this.value[0] === this.value[1]) {
|
if (start === end) {
|
||||||
return "0 (时长为0,请确认)";
|
return "0 (时长为0,请确认)";
|
||||||
}
|
}
|
||||||
return timeLength(this.value[0],this.value[1])
|
let mstart = moment(start);
|
||||||
|
let mend = moment(end);
|
||||||
|
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 + "分钟 " : " "}`;
|
||||||
} else {
|
} else {
|
||||||
return "先选择时间哦";
|
return "先选择时间哦";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -88,7 +88,7 @@ import Comment from "@/components/common/Comment";
|
||||||
import FormRenderView from '@/views/common/form/FormRender'
|
import FormRenderView from '@/views/common/form/FormRender'
|
||||||
import ProcessDiagramViewer from "../admin/layout/ProcessDiagramViewer";
|
import ProcessDiagramViewer from "../admin/layout/ProcessDiagramViewer";
|
||||||
import {getInitiatedInstanceList, getInitiatedInstanceInfo} from "@/api/processInstance";
|
import {getInitiatedInstanceList, getInitiatedInstanceInfo} from "@/api/processInstance";
|
||||||
import {timeLength} from '@/utils/date'
|
import {consumingTime} from '@/utils/date'
|
||||||
export default {
|
export default {
|
||||||
name: "InitiatedInstance",
|
name: "InitiatedInstance",
|
||||||
components: {Comment, FormRenderView, ProcessDiagramViewer},
|
components: {Comment, FormRenderView, ProcessDiagramViewer},
|
||||||
|
|
@ -156,7 +156,7 @@ export default {
|
||||||
getTimeConsuming(instance) {
|
getTimeConsuming(instance) {
|
||||||
if (instance.state != 1) {
|
if (instance.state != 1) {
|
||||||
//dateFormat(开始时间,结束时间)
|
//dateFormat(开始时间,结束时间)
|
||||||
return timeLength(instance.submitTime,instance.endTime);
|
return consumingTime(instance.submitTime,instance.endTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue