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>
<div class="ms-header">
<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">
<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>
@ -29,6 +33,11 @@ export default {
props: {
title: String,
historyReportId: String,
historyReportName: String,
},
watch: {
historyReportName() {
}
},
created() {
},
@ -119,4 +128,9 @@ export default {
cursor: pointer;
font-size: 18px;
}
.history-report-name {
margin-left: 20px;
color: var(--primary_color);
}
</style>

View File

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

View File

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

View File

@ -31,7 +31,8 @@
<el-row>
<div class="chart-style">
<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"/>
</div>
</el-row>
@ -40,7 +41,6 @@
</template>
<script>
import echarts from "echarts";
import MsChart from "@/business/components/common/chart/MsChart";
export default {
@ -75,7 +75,10 @@ export default {
{id: 'pie', name: this.$t('commons.report_statistics.pie')}
],
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',
name: this.$t('commons.report_statistics.asc')
}],
@ -120,9 +123,11 @@ export default {
} else {
this.dataOption = this.loadOption;
}
if (this.dataOption.series) {
this.dataOption.series.forEach(item => {
item.type = this.chartType;
});
}
this.reload();
},
setPieOptionAndBarOption(barOption, pieOption) {
@ -236,6 +241,7 @@ export default {
.chart-style {
overflow: auto;
}
.tip {
float: left;
font-size: 14px;

View File

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