From 27b7326441be14093b7cf487db8206b91a8f46fd Mon Sep 17 00:00:00 2001 From: wally <18603454788@163.com> Date: Wed, 11 Aug 2021 17:39:59 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BB=BB=E5=8A=A1=E8=BF=9B=E8=A1=8C?= =?UTF-8?q?=E4=B8=AD=E7=8A=B6=E6=80=81=E6=95=B0=E5=AD=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 1 + .../TimeLine/component/TimeStatus.vue | 35 ++++++++++++++++++- src/utils/time.js | 2 ++ src/utils/upload.js | 1 - 4 files changed, 37 insertions(+), 2 deletions(-) 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 {