diff --git a/CHANGELOG.md b/CHANGELOG.md index af1de9a..ab4d6a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -54,6 +54,7 @@ - | 代码格式细节调整 | cb2532b - | 任务快捷方式图标增加 | 4aba872 - | 修改角色样式 | 73e268e + - | 删除calendar中多余的console | e339eec - | 删除console.log | 5064a38 - | 删除index中没用的alert代码 | 9c9eec7 - | 删除mock,console;upload添加loading | 99d42e2 diff --git a/src/components/TimeLine/component/TimeStatus.vue b/src/components/TimeLine/component/TimeStatus.vue index 53f06b2..62bb82c 100644 --- a/src/components/TimeLine/component/TimeStatus.vue +++ b/src/components/TimeLine/component/TimeStatus.vue @@ -12,7 +12,7 @@ - + @@ -127,6 +127,39 @@ export default { return `是否要重新开始此任务`; } }, + + // 计算进行中状态剩余时间 + // 预计结束时间 = realStart(实际开始) + planDuration(计划时长) + // 剩余时间 = 预计结束时间 - 当前时间 + // 剩余时间 = realStart + planDuration - Date.now() + computeDurationText() { + try { + const { realStart, planDuration } = this.task; + const leftTime = +realStart + +planDuration - Date.now(); // 剩余时间 + console.log('leftTime: ', leftTime, this.$moment.duration(leftTime)); + if (leftTime < 0) return '0'; + const { years, months, days, hours, minutes, seconds, milliseconds } = this.$moment.duration(leftTime); + let num = 0; + let time = 'seconds'; + if (years > 0) { + num = years; + } else if (months > 0) { + num = months; + } else if (days > 0) { + num = days; + } else if (hours > 0) { + num = hours; + } else if (minutes > 0) { + num = minutes; + } else if (seconds > 0) { + num = seconds; + } else if (milliseconds > 0) { + num = milliseconds; + } + } catch (e) { + //TODO handle the exception + } + }, }, }; diff --git a/src/utils/time.js b/src/utils/time.js index 00b8567..46fa0df 100644 --- a/src/utils/time.js +++ b/src/utils/time.js @@ -2,9 +2,11 @@ import dayjs from 'dayjs'; const advancedFormat = require('dayjs/plugin/advancedFormat'); const weekOfYear = require('dayjs/plugin/weekOfYear'); +const duration = require('dayjs/plugin/duration'); dayjs.extend(advancedFormat); dayjs.extend(weekOfYear); +dayjs.extend(duration); /** * 格式化数字 diff --git a/src/utils/upload.js b/src/utils/upload.js index 88b2550..537a82a 100644 --- a/src/utils/upload.js +++ b/src/utils/upload.js @@ -42,7 +42,6 @@ export default { if (code !== 200) { reject(msg); } else { - console.log('data.data: ', JSON.parse(data).data); resolve(JSON.parse(data).data); } } else {