Browse Source

feat: 任务进行中状态数字

pull/1/head
wally 4 years ago
parent
commit
27b7326441
  1. 1
      CHANGELOG.md
  2. 35
      src/components/TimeLine/component/TimeStatus.vue
  3. 2
      src/utils/time.js
  4. 1
      src/utils/upload.js

1
CHANGELOG.md

@ -54,6 +54,7 @@
- | 代码格式细节调整 | cb2532b - | 代码格式细节调整 | cb2532b
- | 任务快捷方式图标增加 | 4aba872 - | 任务快捷方式图标增加 | 4aba872
- | 修改角色样式 | 73e268e - | 修改角色样式 | 73e268e
- | 删除calendar中多余的console | e339eec
- | 删除console.log | 5064a38 - | 删除console.log | 5064a38
- | 删除index中没用的alert代码 | 9c9eec7 - | 删除index中没用的alert代码 | 9c9eec7
- | 删除mock,console;upload添加loading | 99d42e2 - | 删除mock,console;upload添加loading | 99d42e2

35
src/components/TimeLine/component/TimeStatus.vue

@ -12,7 +12,7 @@
<view class="u-progress-dot"></view> <view class="u-progress-dot"></view>
<view class="u-progress-info"> <view class="u-progress-info">
<u-icon :name="orderStyle.icon" v-if="orderStyle.icon" size="30"></u-icon> <u-icon :name="orderStyle.icon" v-if="orderStyle.icon" size="30"></u-icon>
<template v-else>{{ time }}</template> <template v-else>{{ computeDurationText() }}</template>
</view> </view>
</view> </view>
</u-circle-progress> </u-circle-progress>
@ -127,6 +127,39 @@ export default {
return `是否要重新开始此任务`; 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
}
},
}, },
}; };
</script> </script>

2
src/utils/time.js

@ -2,9 +2,11 @@ import dayjs from 'dayjs';
const advancedFormat = require('dayjs/plugin/advancedFormat'); const advancedFormat = require('dayjs/plugin/advancedFormat');
const weekOfYear = require('dayjs/plugin/weekOfYear'); const weekOfYear = require('dayjs/plugin/weekOfYear');
const duration = require('dayjs/plugin/duration');
dayjs.extend(advancedFormat); dayjs.extend(advancedFormat);
dayjs.extend(weekOfYear); dayjs.extend(weekOfYear);
dayjs.extend(duration);
/** /**
* 格式化数字 * 格式化数字

1
src/utils/upload.js

@ -42,7 +42,6 @@ export default {
if (code !== 200) { if (code !== 200) {
reject(msg); reject(msg);
} else { } else {
console.log('data.data: ', JSON.parse(data).data);
resolve(JSON.parse(data).data); resolve(JSON.parse(data).data);
} }
} else { } else {

Loading…
Cancel
Save