Commit 8442da0a by 周志凯

[chg]: calc time

1 parent 4ee2ea26
...@@ -924,7 +924,6 @@ ...@@ -924,7 +924,6 @@
<div class="result-header">结果展示</div> <div class="result-header">结果展示</div>
<el-scrollbar ref="scrollbarRef" wrap-class="scrollbar-wrapper"> <el-scrollbar ref="scrollbarRef" wrap-class="scrollbar-wrapper">
<div id="showDiv" class="result-content" v-show="showDiv"> <div id="showDiv" class="result-content" v-show="showDiv">
<div class="result-item">
<!-- /{{ item.totalNum }}条 --> <!-- /{{ item.totalNum }}条 -->
<div class="result-item" v-for="item in results" :key="item.id"> <div class="result-item" v-for="item in results" :key="item.id">
<!-- /{{ item.totalNum }}条 --> <!-- /{{ item.totalNum }}条 -->
...@@ -948,7 +947,7 @@ ...@@ -948,7 +947,7 @@
</div> </div>
</el-scrollbar> </el-scrollbar>
<div class="result-footer"> <div class="result-footer">
<span class="result-intro" v-if="startTiming && endTiming">{{ footerText || '数据重跑' }}完毕! 共计 {{ totalTime }} 秒</span> <span class="result-intro" v-if="startTiming && endTiming">{{ footerText || '数据重跑' }}完毕! 共计 {{ totalTime | formatTime }}</span>
<el-button class="result-clear-btn" @click="onClearClick">清空结果</el-button> <el-button class="result-clear-btn" @click="onClearClick">清空结果</el-button>
</div> </div>
</div> </div>
...@@ -1128,15 +1127,35 @@ ...@@ -1128,15 +1127,35 @@
], ],
socket: null, socket: null,
results: [], results: [],
startTiming: 0, startTiming: 100,
endTiming: 0, endTiming: 100,
footerText: '' footerText: ''
}; };
}, },
filters: {
formatTime(val) {
function autoPrefixZero(num) {
return num > 10 ? num : '0' + num
}
const day = parseInt(val / (24 * 60 * 60 * 1000)) + 1
const hour = parseInt(val % (24 * 60 * 60 * 1000) / (60 * 60 * 1000))
const minutes = parseInt(val % (60 * 60 * 1000) / (60 * 1000))
const seconds = parseInt(val % (60 * 1000) / 1000)
if (val < 1000 || val < 60 * 1000) {
return `${val % (60 * 1000) / 1000} 秒`
} else if (val < 60 * 60 * 1000) {
return `${autoPrefixZero(minutes)} 分钟 ${autoPrefixZero(seconds)} 秒`
} else if (val < 24 * 60 * 60 * 1000) {
return `${autoPrefixZero(hour)} 小时 ${autoPrefixZero(minutes)} 分钟 ${autoPrefixZero(seconds)} 秒`
} else {
return `${autoPrefixZero(day)}${autoPrefixZero(hour)} 小时 ${autoPrefixZero(minutes)} 分钟 ${autoPrefixZero(seconds)} 秒`
}
}
},
computed: { computed: {
totalTime() { totalTime() {
const { startTiming, endTiming } = this const { startTiming, endTiming } = this
return (endTiming - startTiming) / 1000 return endTiming - startTiming
// return this.formatDateToStamp(endTiming) - this.formatDateToStamp(startTiming) // return this.formatDateToStamp(endTiming) - this.formatDateToStamp(startTiming)
} }
}, },
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!