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

View File

@ -121,8 +121,7 @@
:label="$t('report.test_execute_time')"> :label="$t('report.test_execute_time')">
<template v-slot:default="scope"> <template v-slot:default="scope">
<span v-if="scope.row.status === 'Completed'"> <span v-if="scope.row.status === 'Completed'">
{{ scope.row.minutes }}{{ $t('schedule.cron.minutes') }} {{ $t('performance_test.report.test_duration', [scope.row.hours, scope.row.minutes, scope.row.seconds]) }}
{{ scope.row.seconds }}{{ $t('schedule.cron.seconds') }}
</span> </span>
</template> </template>
</ms-table-column> </ms-table-column>
@ -307,8 +306,10 @@ export default {
handleTimeInfo(report) { handleTimeInfo(report) {
if (report.testStartTime) { if (report.testStartTime) {
let duration = report.testDuration; 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; let seconds = duration % 60;
this.$set(report, 'hours', hours);
this.$set(report, 'minutes', minutes); this.$set(report, 'minutes', minutes);
this.$set(report, 'seconds', seconds); this.$set(report, 'seconds', seconds);
} }
@ -318,10 +319,12 @@ export default {
let data = res.data.data; let data = res.data.data;
if (data) { if (data) {
let duration = data.duration; 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; let seconds = duration % 60;
this.$set(report, 'testStartTime', data.startTime); this.$set(report, 'testStartTime', data.startTime);
this.$set(report, 'testEndTime', data.endTime); this.$set(report, 'testEndTime', data.endTime);
this.$set(report, 'hours', hours);
this.$set(report, 'minutes', minutes); this.$set(report, 'minutes', minutes);
this.$set(report, 'seconds', seconds); 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 fu from "fit2cloud-ui/src/locale/lang/en_US"; // 加载fit2cloud的内容
import mf from "metersphere-frontend/src/i18n/lang/en-US" 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 { export default {
...el, ...el,
...fu, ...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 fu from "fit2cloud-ui/src/locale/lang/zh-CN"; // 加载fit2cloud的内容
import mf from "metersphere-frontend/src/i18n/lang/zh-CN" 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 { export default {
...el, ...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 fu from "fit2cloud-ui/src/locale/lang/zh-TW"; // 加载fit2cloud的内容
import mf from "metersphere-frontend/src/i18n/lang/zh-TW" 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 { export default {
...el, ...el,