refactor(性能测试): 报告显示时间为 x时x分x秒

This commit is contained in:
CaptainB 2022-11-11 15:21:39 +08:00 committed by 刘瑞斌
parent a966eef214
commit 8e7d0b319b
5 changed files with 35 additions and 9 deletions

View File

@ -64,7 +64,7 @@
<el-col :span="8">
<div style="float: right;">
<span class="ms-report-time-desc">
{{ $t('report.test_duration', [this.minutes, this.seconds]) }}
{{ $t('performance_test.report.test_duration_tips', [hours, minutes, seconds]) }}
</span>
<span class="ms-report-time-desc" v-if="startTime !== '0'">
{{ $t('report.test_start_time') }}{{ startTime | datetimeFormat }}
@ -218,6 +218,7 @@ export default {
projectName: '',
startTime: '0',
endTime: '0',
hours: '0',
minutes: '0',
seconds: '0',
title: 'Logging',
@ -290,7 +291,8 @@ export default {
this.startTime = data.startTime;
this.endTime = data.endTime;
let duration = data.duration;
this.minutes = Math.floor(duration / 60);
this.hours = Math.floor(duration / 60 / 60);
this.minutes = Math.floor(duration / 60 % 60);
this.seconds = duration % 60;
}
})

View File

@ -121,8 +121,7 @@
:label="$t('report.test_execute_time')">
<template v-slot:default="scope">
<span v-if="scope.row.status === 'Completed'">
{{ scope.row.minutes }}{{ $t('schedule.cron.minutes') }}
{{ scope.row.seconds }}{{ $t('schedule.cron.seconds') }}
{{ $t('performance_test.report.test_duration', [scope.row.hours, scope.row.minutes, scope.row.seconds]) }}
</span>
</template>
</ms-table-column>
@ -307,8 +306,10 @@ export default {
handleTimeInfo(report) {
if (report.testStartTime) {
let duration = report.testDuration;
let minutes = Math.floor(duration / 60);
let hours = Math.floor(duration / 60 / 60);
let minutes = Math.floor(duration / 60 % 60);
let seconds = duration % 60;
this.$set(report, 'hours', hours);
this.$set(report, 'minutes', minutes);
this.$set(report, 'seconds', seconds);
}
@ -318,10 +319,12 @@ export default {
let data = res.data.data;
if (data) {
let duration = data.duration;
let minutes = Math.floor(duration / 60);
let hours = Math.floor(duration / 60 / 60);
let minutes = Math.floor(duration / 60 % 60);
let seconds = duration % 60;
this.$set(report, 'testStartTime', data.startTime);
this.$set(report, 'testEndTime', data.endTime);
this.$set(report, 'hours', hours);
this.$set(report, 'minutes', minutes);
this.$set(report, 'seconds', seconds);
}

View File

@ -2,7 +2,14 @@ import el from "element-ui/lib/locale/lang/en";
import fu from "fit2cloud-ui/src/locale/lang/en_US"; // 加载fit2cloud的内容
import mf from "metersphere-frontend/src/i18n/lang/en-US"
const message = {}
const message = {
performance_test: {
report: {
test_duration: '{0} hours {1} minutes {2} seconds',
test_duration_tips: 'Execution Time{0} hours {1} minutes {2} seconds',
}
}
}
export default {
...el,
...fu,

View File

@ -2,7 +2,14 @@ import el from "element-ui/lib/locale/lang/zh-CN"; // 加载element的内容
import fu from "fit2cloud-ui/src/locale/lang/zh-CN"; // 加载fit2cloud的内容
import mf from "metersphere-frontend/src/i18n/lang/zh-CN"
const message = {}
const message = {
performance_test: {
report: {
test_duration: '{0}时{1}分{2}秒',
test_duration_tips: '执行时长:{0}时{1}分{2}秒',
}
}
}
export default {
...el,

View File

@ -2,7 +2,14 @@ import el from "element-ui/lib/locale/lang/zh-TW";
import fu from "fit2cloud-ui/src/locale/lang/zh-TW"; // 加载fit2cloud的内容
import mf from "metersphere-frontend/src/i18n/lang/zh-TW"
const message = {}
const message = {
performance_test: {
report: {
test_duration: '{0}時{1}分{2}秒',
test_duration_tips: '執行時長:{0}時{1}分{2}秒',
}
}
}
export default {
...el,