refactor(测试计划): 优化测试计划报告保存方法

优化测试计划报告保存方法
This commit is contained in:
song-tianyang 2023-03-09 14:36:49 +08:00 committed by 建国
parent a84c781bc8
commit 4806d4b6a2
4 changed files with 125 additions and 71 deletions

View File

@ -445,9 +445,11 @@ public class TestPlanReportService {
testPlanReportMapper.insert(testPlanReport);
//更新TestPlan状态改为进行中
testPlan.setStatus(TestPlanStatus.Underway.name());
testPlanMapper.updateByPrimaryKeySelective(testPlan);
if (runInfoDTO != null) {
//runInfoDTO 不为Null时是执行测试计划行为触发的要更新TestPlan状态为进行中
testPlan.setStatus(TestPlanStatus.Underway.name());
testPlanMapper.updateByPrimaryKeySelective(testPlan);
}
TestPlanScheduleReportInfoDTO returnDTO = new TestPlanScheduleReportInfoDTO();
returnDTO.setTestPlanReport(testPlanReport);
@ -709,6 +711,7 @@ public class TestPlanReportService {
testPlanReportContent = parseReportDaoToReportContent(reportDTO, testPlanReportContentList.get(0));
testPlanReportContent.setStartTime(null);
testPlanReportContent.setEndTime(null);
testPlanReportContent.setApiBaseCount(JSON.toJSONString(reportDTO));
testPlanReportContentMapper.updateByPrimaryKeySelective(testPlanReportContent);
}
@ -1042,7 +1045,7 @@ public class TestPlanReportService {
if (ObjectUtils.anyNull(testPlanReport, testPlanReportContent)) {
return testPlanReportDTO;
}
if (this.isDynamicallyGenerateReports(testPlanReportContent)) {
if (this.isDynamicallyGenerateReports(testPlanReportContent) || StringUtils.isNotEmpty(testPlanReportContent.getApiBaseCount())) {
TestPlanWithBLOBs testPlan = testPlanMapper.selectByPrimaryKey(testPlanReport.getTestPlanId());
testPlanReportDTO = this.initTestPlanReportStruct(testPlan, testPlanReport, testPlanReportContent);
}

View File

@ -228,3 +228,4 @@ test_plan_delete_exec_error=The test plan is being executed
test_case_review_status_underway=Underway
test_case_review_status_re_review=ReReview
api_status_fake_error=Fake error
test_case_sync_status_comment=Relevance case %s in test plan [%s] has be executed by result %s。

View File

@ -199,3 +199,4 @@ test_plan_delete_exec_error=測試計劃正在執行中
test_case_review_status_underway=評審中
test_case_review_status_re_review=重新提審
api_status_fake_error=誤報
test_case_sync_status_comment=關聯的case %s 在測試計劃【%s】內的執行結果出現%s。

View File

@ -1,53 +1,88 @@
<template>
<div v-loading="loading" class="head-bar head-right">
<el-row>
<el-popover
placement="right"
width="300">
<el-popover placement="right" width="300">
<p>{{ shareUrl }}</p>
<span style="color: red;float: left;margin-left: 10px;"
v-if="application.typeValue">{{ $t('commons.validity_period') + application.typeValue }}</span>
<span
style="color: red; float: left; margin-left: 10px"
v-if="application.typeValue"
>{{ $t("commons.validity_period") + application.typeValue }}</span
>
<div style="text-align: right; margin: 0">
<el-button type="primary" size="mini" :disabled="!shareUrl"
v-clipboard:copy="shareUrl">{{ $t("commons.copy") }}
<el-button
type="primary"
size="mini"
:disabled="!shareUrl"
v-clipboard:copy="shareUrl"
>{{ $t("commons.copy") }}
</el-button>
</div>
<el-button icon="el-icon-share" slot="reference" :disabled="!isTestManagerOrTestUser"
plain size="mini" @click="handleShare()">
{{ $t('test_track.report.share') }}
<el-button
icon="el-icon-share"
slot="reference"
:disabled="!isTestManagerOrTestUser"
plain
size="mini"
@click="handleShare()"
>
{{ $t("test_track.report.share") }}
</el-button>
</el-popover>
</el-row>
<el-row>
<el-button icon="el-icon-receiving" v-if="!isDb" :disabled="!isTestManagerOrTestUser" plain size="mini"
@click="handleSave()">
{{ $t('commons.save') }}
<el-button
icon="el-icon-receiving"
v-if="!isDb"
:disabled="!isTestManagerOrTestUser"
plain
size="mini"
@click="handleSave()"
>
{{ $t("commons.save") }}
</el-button>
</el-row>
<el-row>
<el-button icon="el-icon-download" :disabled="!isTestManagerOrTestUser"
v-permission="['PROJECT_TRACK_REPORT:READ+EXPORT']" plain size="mini" @click="handleExportHtml()">
{{ $t('commons.export') }}
<el-button
icon="el-icon-download"
:disabled="!isTestManagerOrTestUser"
v-permission="['PROJECT_TRACK_REPORT:READ+EXPORT']"
plain
size="mini"
@click="handleExportHtml()"
>
{{ $t("commons.export") }}
</el-button>
</el-row>
<el-row>
<el-button icon="el-icon-setting" v-if="!isDb" :disabled="!isTestManagerOrTestUser" plain size="mini"
@click="handleEditTemplate()">
{{ $t('test_track.report.configuration') }}
<el-button
icon="el-icon-setting"
v-if="!isDb"
:disabled="!isTestManagerOrTestUser"
plain
size="mini"
@click="handleEditTemplate()"
>
{{ $t("test_track.report.configuration") }}
</el-button>
</el-row>
<test-plan-report-edit :plan-id="planId" :config.sync="report.config" ref="reportEdit"/>
<test-plan-report-edit
:plan-id="planId"
:config.sync="report.config"
ref="reportEdit"
/>
</div>
</template>
<script>
import TestPlanApiReport from "@/business/plan/view/comonents/report/detail/TestPlanApiReport";
import {generateShareInfoWithExpired, getShareRedirectUrl} from "@/api/share";
import { generateShareInfoWithExpired, getShareRedirectUrl } from "@/api/share";
import TestPlanReportEdit from "@/business/plan/view/comonents/report/detail/component/TestPlanReportEdit";
import {editPlanReport, saveTestPlanReport} from "@/api/remote/plan/test-plan";
import {CURRENT_LANGUAGE, getCurrentUser} from "@/business/utils/sdk-utils";
import {getProjectApplicationConfig} from "@/api/project-application";
import {
editPlanReport,
saveTestPlanReport,
} from "@/api/remote/plan/test-plan";
import { CURRENT_LANGUAGE, getCurrentUser } from "@/business/utils/sdk-utils";
import { getProjectApplicationConfig } from "@/api/project-application";
export default {
name: "TestPlanReportButtons",
components: {
@ -58,13 +93,13 @@ export default {
planId: String,
isShare: Boolean,
report: Object,
isDb: Boolean
isDb: Boolean,
},
data() {
return {
loading: false,
isTestManagerOrTestUser: true,
shareUrl: '',
shareUrl: "",
application: {},
};
},
@ -75,49 +110,65 @@ export default {
handleShare() {
let param = {};
param.customData = this.planId;
param.shareType = 'PLAN_REPORT';
param.shareType = "PLAN_REPORT";
if (this.isDb) {
param.customData = this.report.id;
param.shareType = 'PLAN_DB_REPORT';
param.shareType = "PLAN_DB_REPORT";
}
param.lang = localStorage.getItem(CURRENT_LANGUAGE);
generateShareInfoWithExpired(param)
.then((response) => {
this.shareUrl = getShareRedirectUrl(response.data);
});
generateShareInfoWithExpired(param).then((response) => {
this.shareUrl = getShareRedirectUrl(response.data);
});
this.getProjectApplication();
},
getProjectApplication() {
getProjectApplicationConfig('TRACK_SHARE_REPORT_TIME')
.then(res => {
if (res.data) {
let quantity = res.data.typeValue ? res.data.typeValue.substring(0, res.data.typeValue.length - 1) : null;
let unit = res.data.typeValue ? res.data.typeValue.substring(res.data.typeValue.length - 1) : null;
if (unit === 'H') {
res.data.typeValue = quantity + this.$t('commons.date_unit.hour');
} else if (unit === 'D') {
res.data.typeValue = quantity + this.$t('commons.date_unit.day');
} else if (unit === 'M') {
res.data.typeValue = quantity + this.$t('commons.workspace_unit') + this.$t('commons.date_unit.month');
} else if (unit === 'Y') {
res.data.typeValue = quantity + this.$t('commons.date_unit.year');
}
if (quantity == null && unit == null) {
res.data.typeValue = '24' + this.$t('commons.date_unit.hour');
}
this.application = res.data;
getProjectApplicationConfig("TRACK_SHARE_REPORT_TIME").then((res) => {
if (res.data) {
let quantity = res.data.typeValue
? res.data.typeValue.substring(0, res.data.typeValue.length - 1)
: null;
let unit = res.data.typeValue
? res.data.typeValue.substring(res.data.typeValue.length - 1)
: null;
if (unit === "H") {
res.data.typeValue = quantity + this.$t("commons.date_unit.hour");
} else if (unit === "D") {
res.data.typeValue = quantity + this.$t("commons.date_unit.day");
} else if (unit === "M") {
res.data.typeValue =
quantity +
this.$t("commons.workspace_unit") +
this.$t("commons.date_unit.month");
} else if (unit === "Y") {
res.data.typeValue = quantity + this.$t("commons.date_unit.year");
}
});
if (quantity == null && unit == null) {
res.data.typeValue = "24" + this.$t("commons.date_unit.hour");
}
this.application = res.data;
}
});
},
handleSave() {
let param = {};
this.buildParam(param);
editPlanReport({id: this.planId, reportSummary: this.report.summary ? this.report.summary : ''})
this.loading = true;
editPlanReport({
id: this.planId,
reportSummary: this.report.summary ? this.report.summary : "",
})
.then(() => {
saveTestPlanReport(this.planId)
.then(() => {
this.$success(this.$t('commons.save_success'));
this.$success(this.$t("commons.save_success"));
this.loading = false;
})
.catch(() => {
this.loading = false;
});
})
.catch(() => {
this.loading = false;
});
},
buildParam(param) {
@ -126,32 +177,30 @@ export default {
param.isNew = true;
},
handleExportHtml() {
let url = '/test/plan/report/export/' + this.planId;
let url = "/test/plan/report/export/" + this.planId;
if (this.isDb) {
url = '/test/plan/report/db/export/' + this.report.id;
url = "/test/plan/report/db/export/" + this.report.id;
}
if (this.isShare) {
url = '/share' + url;
url = "/share" + url;
}
let lang = 'zh_CN';
let lang = "zh_CN";
let user = getCurrentUser();
if (user && user.language) {
lang = user.language;
}
url = url + '/' + lang;
url = url + "/" + lang;
this.loading = true;
this.$fileDownload(url, this.report.name + '.html')
.then(() => {
this.loading = false;
this.$success(this.$t("organization.integration.successful_operation"));
});
this.$fileDownload(url, this.report.name + ".html").then(() => {
this.loading = false;
this.$success(this.$t("organization.integration.successful_operation"));
});
},
}
}
},
};
</script>
<style scoped>
.head-right {
text-align: right;
float: right;