fix(报表统计): 修复报表统计中数据为0时出现的解析错误

修复报表统计中数据为0时出现的解析错误
This commit is contained in:
song-tianyang 2022-07-12 11:42:43 +08:00 committed by TIanyang
parent 2d92e1ea75
commit 56c9a33ccd
5 changed files with 50 additions and 17 deletions

View File

@ -1,7 +1,11 @@
<template> <template>
<div class="ms-header"> <div class="ms-header">
<el-row> <el-row>
<div class="ms-div">{{ title }}</div> <div class="ms-div">{{ title }}
<span v-if="historyReportName" class="history-report-name">
{{ historyReportName }}
</span>
</div>
<div class="ms-header-right"> <div class="ms-header-right">
<el-button type="primary" v-if="isSaveAsButtonShow" size="mini" @click="handleSaveAs" :disabled="readOnly"> <el-button type="primary" v-if="isSaveAsButtonShow" size="mini" @click="handleSaveAs" :disabled="readOnly">
{{ $t('commons.save_as') }}<i class="el-icon-files el-icon--right"></i></el-button> {{ $t('commons.save_as') }}<i class="el-icon-files el-icon--right"></i></el-button>
@ -29,6 +33,11 @@ export default {
props: { props: {
title: String, title: String,
historyReportId: String, historyReportId: String,
historyReportName: String,
},
watch: {
historyReportName() {
}
}, },
created() { created() {
}, },
@ -119,4 +128,9 @@ export default {
cursor: pointer; cursor: pointer;
font-size: 18px; font-size: 18px;
} }
.history-report-name {
margin-left: 20px;
color: var(--primary_color);
}
</style> </style>

View File

@ -19,6 +19,7 @@
:is-show-close="false" style="overflow: hidden"> :is-show-close="false" style="overflow: hidden">
<template v-slot:header> <template v-slot:header>
<report-header :title="$t('commons.report_statistics.test_case_analysis')" :history-report-id="historyReportId" <report-header :title="$t('commons.report_statistics.test_case_analysis')" :history-report-id="historyReportId"
:history-report-name="historyReportName"
@closePage="close" @updateReport="updateReport" @closePage="close" @updateReport="updateReport"
@selectAndSaveReport="openSaveReportDialog('saveAs')"/> @selectAndSaveReport="openSaveReportDialog('saveAs')"/>
</template> </template>
@ -31,6 +32,7 @@
<template v-slot:header> <template v-slot:header>
<report-header :title="$t('commons.report_statistics.test_case_count')" :history-report-id="historyReportId" <report-header :title="$t('commons.report_statistics.test_case_count')" :history-report-id="historyReportId"
@closePage="close" @closePage="close"
:history-report-name="historyReportName"
@updateReport="updateReport" @updateReport="updateReport"
@selectAndSaveReport="openSaveReportDialog('saveAs')"/> @selectAndSaveReport="openSaveReportDialog('saveAs')"/>
</template> </template>
@ -74,6 +76,7 @@ export default {
testCaseTrendDrawer: false, testCaseTrendDrawer: false,
testCaseCountDrawer: false, testCaseCountDrawer: false,
historyReportId: "", historyReportId: "",
historyReportName: "",
reportTypes: [{id: 'track', name: this.$t('test_track.test_track')}], reportTypes: [{id: 'track', name: this.$t('test_track.test_track')}],
dialogFormVisible: false, dialogFormVisible: false,
form: { form: {
@ -129,8 +132,9 @@ export default {
} }
}); });
}, },
initHistoryReportId(reportId) { initHistoryReportId(reportId, reportName) {
this.historyReportId = reportId; this.historyReportId = reportId;
this.historyReportName = reportName;
}, },
handleCloseSaveReportDialog() { handleCloseSaveReportDialog() {
this.form.reportName = ""; this.form.reportName = "";

View File

@ -125,10 +125,12 @@ export default {
this.pieOption.width = pieData.width; this.pieOption.width = pieData.width;
this.chartWidth = pieData.width; this.chartWidth = pieData.width;
} }
if (this.pieOption.series) {
this.pieOption.series.forEach(item => { this.pieOption.series.forEach(item => {
item.type = this.$refs.analysisChart.chartType; item.type = this.$refs.analysisChart.chartType;
}); });
} }
}
if (selectTableData) { if (selectTableData) {
this.tableData = selectTableData; this.tableData = selectTableData;
} }
@ -180,6 +182,7 @@ export default {
}); });
}, },
selectReport(selectId) { selectReport(selectId) {
let selectName = "";
if (selectId) { if (selectId) {
this.loading = true; this.loading = true;
let paramObj = { let paramObj = {
@ -188,6 +191,7 @@ export default {
this.$post('/history/report/selectById', paramObj, response => { this.$post('/history/report/selectById', paramObj, response => {
let reportData = response.data; let reportData = response.data;
if (reportData) { if (reportData) {
selectName = reportData.name;
if (reportData.dataOption) { if (reportData.dataOption) {
let dataOptionObj = JSON.parse(reportData.dataOption); let dataOptionObj = JSON.parse(reportData.dataOption);
if (dataOptionObj.chartType) { if (dataOptionObj.chartType) {
@ -203,14 +207,15 @@ export default {
} }
this.loading = false; this.loading = false;
} }
this.$emit('initHistoryReportId', selectId, selectName);
}, (error) => { }, (error) => {
this.loading = false; this.loading = false;
this.removeHistoryReportId();
}); });
this.$emit('initHistoryReportId', selectId);
} }
}, },
removeHistoryReportId() { removeHistoryReportId() {
this.$emit('initHistoryReportId', ""); this.$emit('initHistoryReportId', "", "");
}, },
getGroupNameStr(groupName) { getGroupNameStr(groupName) {
if (groupName === 'creator') { if (groupName === 'creator') {

View File

@ -31,7 +31,8 @@
<el-row> <el-row>
<div class="chart-style"> <div class="chart-style">
<ms-chart ref="chart1" v-if="!loading" :options="dataOption" <ms-chart ref="chart1" v-if="!loading" :options="dataOption"
:style="{width: chartWidthNumber+'px', height: (h-70) + 'px'}" class="chart-config" :autoresize="true" :style="{width: chartWidthNumber+'px', height: (h-70) + 'px'}" class="chart-config"
:autoresize="true"
id="picChart"/> id="picChart"/>
</div> </div>
</el-row> </el-row>
@ -40,7 +41,6 @@
</template> </template>
<script> <script>
import echarts from "echarts";
import MsChart from "@/business/components/common/chart/MsChart"; import MsChart from "@/business/components/common/chart/MsChart";
export default { export default {
@ -75,7 +75,10 @@ export default {
{id: 'pie', name: this.$t('commons.report_statistics.pie')} {id: 'pie', name: this.$t('commons.report_statistics.pie')}
], ],
order: "", order: "",
orders: [{id: '', name: this.$t('commons.sort_default')}, {id: 'desc', name: this.$t('commons.report_statistics.desc')}, { orders: [{id: '', name: this.$t('commons.sort_default')}, {
id: 'desc',
name: this.$t('commons.report_statistics.desc')
}, {
id: 'asc', id: 'asc',
name: this.$t('commons.report_statistics.asc') name: this.$t('commons.report_statistics.asc')
}], }],
@ -120,9 +123,11 @@ export default {
} else { } else {
this.dataOption = this.loadOption; this.dataOption = this.loadOption;
} }
if (this.dataOption.series) {
this.dataOption.series.forEach(item => { this.dataOption.series.forEach(item => {
item.type = this.chartType; item.type = this.chartType;
}); });
}
this.reload(); this.reload();
}, },
setPieOptionAndBarOption(barOption, pieOption) { setPieOptionAndBarOption(barOption, pieOption) {
@ -236,6 +241,7 @@ export default {
.chart-style { .chart-style {
overflow: auto; overflow: auto;
} }
.tip { .tip {
float: left; float: left;
font-size: 14px; font-size: 14px;

View File

@ -140,6 +140,7 @@ export default {
this.loading = false; this.loading = false;
}, },
selectReport(selectId) { selectReport(selectId) {
let selectName = "";
if (selectId) { if (selectId) {
this.loading = true; this.loading = true;
let paramObj = { let paramObj = {
@ -148,6 +149,7 @@ export default {
this.$post('/history/report/selectById', paramObj, response => { this.$post('/history/report/selectById', paramObj, response => {
let reportData = response.data; let reportData = response.data;
if (reportData) { if (reportData) {
selectName = reportData.name;
if (reportData.dataOption) { if (reportData.dataOption) {
let dataOptionObj = JSON.parse(reportData.dataOption); let dataOptionObj = JSON.parse(reportData.dataOption);
this.initPic(dataOptionObj.loadOption, dataOptionObj.pieOption, dataOptionObj.tableData); this.initPic(dataOptionObj.loadOption, dataOptionObj.pieOption, dataOptionObj.tableData);
@ -157,15 +159,17 @@ export default {
this.$refs.analysisFilter.initSelectOption(selectOptionObj); this.$refs.analysisFilter.initSelectOption(selectOptionObj);
} }
} }
this.$emit('initHistoryReportId', selectId, selectName);
this.loading = false; this.loading = false;
}, (error) => { }, (error) => {
this.loading = false; this.loading = false;
this.removeHistoryReportId();
}); });
this.$emit('initHistoryReportId', selectId);
} }
}, },
removeHistoryReportId() { removeHistoryReportId() {
this.$emit('initHistoryReportId', ""); this.$emit('initHistoryReportId', "", "");
}, },
selectAndSaveReport(reportName) { selectAndSaveReport(reportName) {
let opt = this.$refs.analysisFilter.getOption(); let opt = this.$refs.analysisFilter.getOption();