parent
9a43f5eda0
commit
096fc3e935
|
@ -78,6 +78,9 @@ public class ReportStatisticsService {
|
||||||
return blob;
|
return blob;
|
||||||
}
|
}
|
||||||
private TestCaseCountTableDataDTO countShowTable(String groupName, List<String> yaxis, List<TestCaseCountTableDTO> dtos) {
|
private TestCaseCountTableDataDTO countShowTable(String groupName, List<String> yaxis, List<TestCaseCountTableDTO> dtos) {
|
||||||
|
if(yaxis == null){
|
||||||
|
yaxis = new ArrayList<>();
|
||||||
|
}
|
||||||
TestCaseCountTableDataDTO returnDTO = new TestCaseCountTableDataDTO();
|
TestCaseCountTableDataDTO returnDTO = new TestCaseCountTableDataDTO();
|
||||||
String [] headers = new String[]{groupName,"总计","testCase","apiCase","scenarioCase","loadCaseCount"};
|
String [] headers = new String[]{groupName,"总计","testCase","apiCase","scenarioCase","loadCaseCount"};
|
||||||
|
|
||||||
|
@ -86,6 +89,7 @@ public class ReportStatisticsService {
|
||||||
boolean showApi = true;
|
boolean showApi = true;
|
||||||
boolean showScenario = true;
|
boolean showScenario = true;
|
||||||
boolean showLoad = true;
|
boolean showLoad = true;
|
||||||
|
|
||||||
for (String head : headers) {
|
for (String head : headers) {
|
||||||
if(StringUtils.equalsAnyIgnoreCase(head,groupName,"总计") || yaxis.contains(head)){
|
if(StringUtils.equalsAnyIgnoreCase(head,groupName,"总计") || yaxis.contains(head)){
|
||||||
TestCaseCountTableItemDataDTO headData = new TestCaseCountTableItemDataDTO();
|
TestCaseCountTableItemDataDTO headData = new TestCaseCountTableItemDataDTO();
|
||||||
|
|
|
@ -1,33 +1,36 @@
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
|
|
||||||
<el-container v-loading="loading" id="reportAnalysis" :style="{ 'max-height': (h-50) + 'px', 'overflow': 'auto'}" >
|
<el-container v-loading="loading" id="reportAnalysis" :style="{ 'max-height': (h-50) + 'px', 'overflow': 'auto'}">
|
||||||
<el-aside v-if="!isHide" :width="!isHide ?'235px':'0px'" :style="{ 'margin-left': '5px'}" >
|
<el-aside v-if="!isHide" :width="!isHide ?'235px':'0px'" :style="{ 'margin-left': '5px'}">
|
||||||
<history-report-data report-type="TEST_CASE_COUNT"
|
<history-report-data report-type="TEST_CASE_COUNT"
|
||||||
@selectReport="selectReport" @removeHistoryReportId="removeHistoryReportId"
|
@selectReport="selectReport" @removeHistoryReportId="removeHistoryReportId"
|
||||||
ref="historyReport"/>
|
ref="historyReport"/>
|
||||||
</el-aside>
|
</el-aside>
|
||||||
<el-main class="ms-main" style="padding: 0px 5px 0px">
|
<el-main class="ms-main" style="padding: 0px 5px 0px">
|
||||||
<div>
|
<div>
|
||||||
<test-case-count-chart @hidePage="hidePage" @orderCharts="orderCharts" ref="analysisChart"
|
<test-case-count-chart @hidePage="hidePage" @orderCharts="orderCharts"
|
||||||
:chart-width="chartWidth" :load-option="loadOption" :pie-option="pieOption"/>
|
ref="analysisChart" @updateChartType="updateChartType"
|
||||||
</div>
|
:chart-width="chartWidth" :load-option="loadOption" :pie-option="pieOption"/>
|
||||||
<div class="ms-row" v-if="!isHide">
|
</div>
|
||||||
<test-case-count-table :group-name="getGroupNameStr(options.xaxis)" :show-coloums="options.yaxis" :tableData="tableData"/>
|
<div class="ms-row" v-if="!isHide">
|
||||||
</div>
|
<test-case-count-table :group-name="getGroupNameStr(options.xaxis)" :show-coloums="options.yaxis"
|
||||||
</el-main>
|
:tableData="tableData"/>
|
||||||
<el-aside v-if="!isHide" style="height: 100%" :width="!isHide ?'485px':'0px'">
|
</div>
|
||||||
<test-case-count-filter @filterCharts="filterCharts" ref="countFilter"/>
|
</el-main>
|
||||||
</el-aside>
|
<el-aside v-if="!isHide" style="height: 100%" :width="!isHide ?'485px':'0px'">
|
||||||
|
<test-case-count-filter @filterCharts="filterCharts" ref="countFilter"/>
|
||||||
|
</el-aside>
|
||||||
</el-container>
|
</el-container>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import TestCaseCountChart from "./chart/TestCaseCountChart";
|
import TestCaseCountChart from "./chart/TestCaseCountChart";
|
||||||
import TestCaseCountTable from "@/business/components/reportstatistics/projectstatistics/casecount/table/TestCaseCountTable";
|
import TestCaseCountTable
|
||||||
|
from "@/business/components/reportstatistics/projectstatistics/casecount/table/TestCaseCountTable";
|
||||||
import TestCaseCountFilter from "./filter/TestCaseCountFilter";
|
import TestCaseCountFilter from "./filter/TestCaseCountFilter";
|
||||||
import {exportPdf,getCurrentProjectID} from "@/common/js/utils";
|
import {exportPdf, getCurrentProjectID} from "@/common/js/utils";
|
||||||
import html2canvas from 'html2canvas';
|
import html2canvas from 'html2canvas';
|
||||||
import HistoryReportData from "../../base/HistoryReportData";
|
import HistoryReportData from "../../base/HistoryReportData";
|
||||||
|
|
||||||
|
@ -41,6 +44,7 @@ export default {
|
||||||
options: {},
|
options: {},
|
||||||
chartWidth: 0,
|
chartWidth: 0,
|
||||||
tableHeight: 300,
|
tableHeight: 300,
|
||||||
|
chartType: "bar",
|
||||||
loadOption: {
|
loadOption: {
|
||||||
legend: {},
|
legend: {},
|
||||||
xAxis: {},
|
xAxis: {},
|
||||||
|
@ -62,6 +66,9 @@ export default {
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
updateChartType(value) {
|
||||||
|
this.chartType = value;
|
||||||
|
},
|
||||||
handleExport() {
|
handleExport() {
|
||||||
let name = this.$t('commons.report_statistics.test_case_analysis');
|
let name = this.$t('commons.report_statistics.test_case_analysis');
|
||||||
this.$nextTick(function () {
|
this.$nextTick(function () {
|
||||||
|
@ -87,13 +94,12 @@ export default {
|
||||||
let data = response.data.barChartDTO;
|
let data = response.data.barChartDTO;
|
||||||
let pieData = response.data.pieChartDTO;
|
let pieData = response.data.pieChartDTO;
|
||||||
let selectTableData = response.data.tableDTOs;
|
let selectTableData = response.data.tableDTOs;
|
||||||
this.initPic(data,pieData,selectTableData);
|
this.initPic(data, pieData, selectTableData);
|
||||||
|
}, error => {
|
||||||
},error => {
|
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
initPic(barData,pieData,selectTableData){
|
initPic(barData, pieData, selectTableData) {
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
if (barData) {
|
if (barData) {
|
||||||
this.loadOption.legend = barData.legend;
|
this.loadOption.legend = barData.legend;
|
||||||
|
@ -126,7 +132,7 @@ export default {
|
||||||
this.tableData = selectTableData;
|
this.tableData = selectTableData;
|
||||||
}
|
}
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
this.$refs.analysisChart.reload();
|
this.$refs.analysisChart.generateOption(this.chartType);
|
||||||
},
|
},
|
||||||
filterCharts(opt) {
|
filterCharts(opt) {
|
||||||
this.init(opt);
|
this.init(opt);
|
||||||
|
@ -144,6 +150,7 @@ export default {
|
||||||
loadOption: this.loadOption,
|
loadOption: this.loadOption,
|
||||||
pieOption: this.pieOption,
|
pieOption: this.pieOption,
|
||||||
tableData: this.tableData,
|
tableData: this.tableData,
|
||||||
|
chartType: this.chartType,
|
||||||
};
|
};
|
||||||
obj.dataOption = JSON.stringify(dataOptionObj);
|
obj.dataOption = JSON.stringify(dataOptionObj);
|
||||||
obj.reportType = 'TEST_CASE_COUNT';
|
obj.reportType = 'TEST_CASE_COUNT';
|
||||||
|
@ -152,59 +159,63 @@ export default {
|
||||||
this.$refs.historyReport.initReportData();
|
this.$refs.historyReport.initReportData();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
selectReport(selectId){
|
selectReport(selectId) {
|
||||||
if(selectId){
|
if (selectId) {
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
let paramObj = {
|
let paramObj = {
|
||||||
id:selectId
|
id: selectId
|
||||||
}
|
}
|
||||||
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) {
|
||||||
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);
|
if (dataOptionObj.chartType) {
|
||||||
|
this.chartType = dataOptionObj.chartType;
|
||||||
|
}else {
|
||||||
|
this.chartType = "bar";
|
||||||
|
}
|
||||||
|
this.initPic(dataOptionObj.loadOption, dataOptionObj.pieOption, dataOptionObj.tableData);
|
||||||
}
|
}
|
||||||
if(reportData.selectOption){
|
if (reportData.selectOption) {
|
||||||
let selectOptionObj = JSON.parse(reportData.selectOption);
|
let selectOptionObj = JSON.parse(reportData.selectOption);
|
||||||
this.$refs.countFilter.initSelectOption(selectOptionObj);
|
this.$refs.countFilter.initSelectOption(selectOptionObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
}
|
}
|
||||||
}, (error) => {
|
}, (error) => {
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
});
|
});
|
||||||
this.$emit('initHistoryReportId',selectId);
|
this.$emit('initHistoryReportId', selectId);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
removeHistoryReportId(){
|
removeHistoryReportId() {
|
||||||
this.$emit('initHistoryReportId',"");
|
this.$emit('initHistoryReportId', "");
|
||||||
},
|
},
|
||||||
getGroupNameStr(groupName){
|
getGroupNameStr(groupName) {
|
||||||
if(groupName === 'creator') {
|
if (groupName === 'creator') {
|
||||||
return this.$t('commons.report_statistics.report_filter.select_options.creator');
|
return this.$t('commons.report_statistics.report_filter.select_options.creator');
|
||||||
}else if(groupName === 'maintainer'){
|
} else if (groupName === 'maintainer') {
|
||||||
return this.$t('commons.report_statistics.report_filter.select_options.maintainer');
|
return this.$t('commons.report_statistics.report_filter.select_options.maintainer');
|
||||||
}else if(groupName === 'casetype'){
|
} else if (groupName === 'casetype') {
|
||||||
return this.$t('commons.report_statistics.report_filter.select_options.case_type');
|
return this.$t('commons.report_statistics.report_filter.select_options.case_type');
|
||||||
}else if(groupName === 'casestatus'){
|
} else if (groupName === 'casestatus') {
|
||||||
return this.$t('commons.report_statistics.report_filter.select_options.case_status');
|
return this.$t('commons.report_statistics.report_filter.select_options.case_status');
|
||||||
}else if(groupName === 'caselevel'){
|
} else if (groupName === 'caselevel') {
|
||||||
return this.$t('commons.report_statistics.report_filter.select_options.case_level');
|
return this.$t('commons.report_statistics.report_filter.select_options.case_level');
|
||||||
}else {
|
} else {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
selectAndSaveReport(reportName){
|
selectAndSaveReport(reportName) {
|
||||||
let opt = this.$refs.countFilter.getOption();
|
let opt = this.$refs.countFilter.getOption();
|
||||||
this.options = opt;
|
this.options = opt;
|
||||||
this.saveReport(reportName);
|
this.saveReport(reportName);
|
||||||
},
|
},
|
||||||
saveAndSaveAsReport(reportName,saveType){
|
saveAndSaveAsReport(reportName, saveType) {
|
||||||
if(saveType === 'save'){
|
if (saveType === 'save') {
|
||||||
this.saveReport(reportName);
|
this.saveReport(reportName);
|
||||||
}else if(saveType === 'saveAs'){
|
} else if (saveType === 'saveAs') {
|
||||||
this.selectAndSaveReport(reportName);
|
this.selectAndSaveReport(reportName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<div v-loading="loading">
|
<div v-loading="loading">
|
||||||
<el-card class="ms-test-chart" :style="{ width: w+'px', height: h + 'px'}" ref="msDrawer">
|
<el-card class="ms-test-chart" :style="{ width: w+'px', height: h + 'px'}" ref="msDrawer">
|
||||||
<el-row class="ms-row">
|
<el-row class="ms-row">
|
||||||
<p class="tip"><span style="margin-left: 5px"></span> {{$t('commons.report_statistics.chart')}} </p>
|
<p class="tip"><span style="margin-left: 5px"></span> {{ $t('commons.report_statistics.chart') }} </p>
|
||||||
<div class="ms-test-chart-header" v-if="!readOnly">
|
<div class="ms-test-chart-header" v-if="!readOnly">
|
||||||
<el-dropdown @command="exportCommand" :hide-on-click="false">
|
<el-dropdown @command="exportCommand" :hide-on-click="false">
|
||||||
<span class="el-dropdown-link">
|
<span class="el-dropdown-link">
|
||||||
|
@ -22,285 +22,226 @@
|
||||||
<el-option :key="t.id" :value="t.id" :label="t.name" v-for="t in orders"/>
|
<el-option :key="t.id" :value="t.id" :label="t.name" v-for="t in orders"/>
|
||||||
</el-select>
|
</el-select>
|
||||||
<span style="margin: 0px 10px 10px">|</span>
|
<span style="margin: 0px 10px 10px">|</span>
|
||||||
<font-awesome-icon v-if="!isFullScreen && showFullScreen" class="report-alt-ico" :icon="['fa', 'expand-alt']" size="lg" @click="fullScreen"/>
|
<font-awesome-icon v-if="!isFullScreen && showFullScreen" class="report-alt-ico" :icon="['fa', 'expand-alt']"
|
||||||
<font-awesome-icon v-if="isFullScreen && showFullScreen" class="report-alt-ico" :icon="['fa', 'compress-alt']" size="lg" @click="unFullScreen"/>
|
size="lg" @click="fullScreen"/>
|
||||||
|
<font-awesome-icon v-if="isFullScreen && showFullScreen" class="report-alt-ico" :icon="['fa', 'compress-alt']"
|
||||||
|
size="lg" @click="unFullScreen"/>
|
||||||
</div>
|
</div>
|
||||||
</el-row>
|
</el-row>
|
||||||
<el-row style="overflow: auto">
|
<el-row style="overflow: auto">
|
||||||
<ms-chart ref="chart1" v-if="!loading" :options="dataOption" :style="{width: chartWidthNumber+'px', height: (h-50) + 'px'}" class="chart-config" :autoresize="true" id="picChart"/>
|
<ms-chart ref="chart1" v-if="!loading" :options="dataOption"
|
||||||
|
:style="{width: chartWidthNumber+'px', height: (h-50) + 'px'}" class="chart-config" :autoresize="true"
|
||||||
|
id="picChart"/>
|
||||||
</el-row>
|
</el-row>
|
||||||
</el-card>
|
</el-card>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import echarts from "echarts";
|
import echarts from "echarts";
|
||||||
import MsChart from "@/business/components/common/chart/MsChart";
|
import MsChart from "@/business/components/common/chart/MsChart";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "TestCaseCountChart",
|
name: "TestCaseCountChart",
|
||||||
components: {MsChart},
|
components: {MsChart},
|
||||||
props: {
|
props: {
|
||||||
loadOption: {},
|
loadOption: {},
|
||||||
pieOption: {},
|
pieOption: {},
|
||||||
chartWidth:Number,
|
chartWidth: Number,
|
||||||
needFullScreen: Boolean,
|
needFullScreen: Boolean,
|
||||||
readOnly:Boolean,
|
readOnly: Boolean,
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
dataOption: {},
|
||||||
|
x: 0,
|
||||||
|
y: 0,
|
||||||
|
w: document.documentElement.clientWidth - 760,
|
||||||
|
h: document.documentElement.clientHeight * 0.5,
|
||||||
|
chartWidthNumber: document.documentElement.clientWidth - 760,
|
||||||
|
isFullScreen: false,
|
||||||
|
originalW: 100,
|
||||||
|
originalH: 100,
|
||||||
|
showFullScreen: {
|
||||||
|
type: Boolean,
|
||||||
|
default() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
charts: [
|
||||||
|
{id: 'bar', name: this.$t('commons.report_statistics.bar')},
|
||||||
|
{id: 'pie', name: this.$t('commons.report_statistics.pie')}
|
||||||
|
],
|
||||||
|
order: "",
|
||||||
|
orders: [{id: '', name: '默认排序'}, {id: 'desc', name: this.$t('commons.report_statistics.desc')}, {
|
||||||
|
id: 'asc',
|
||||||
|
name: this.$t('commons.report_statistics.asc')
|
||||||
|
}],
|
||||||
|
loading: false,
|
||||||
|
options: {},
|
||||||
|
chartType: "bar",
|
||||||
|
}
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.selectedPicType = this.chartType;
|
||||||
|
this.dataOption = this.loadOption;
|
||||||
|
if (this.needFullScreen) {
|
||||||
|
this.w = document.documentElement.clientWidth;
|
||||||
|
}
|
||||||
|
this.reload();
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
chartWidth() {
|
||||||
|
this.countChartWidth();
|
||||||
},
|
},
|
||||||
data() {
|
chartType() {
|
||||||
return {
|
this.$emit("updateChartType",this.chartType);
|
||||||
dataOption:{},
|
this.countChartWidth();
|
||||||
x: 0,
|
},
|
||||||
y: 0,
|
},
|
||||||
w: document.documentElement.clientWidth - 760,
|
methods: {
|
||||||
h: document.documentElement.clientHeight * 0.5 ,
|
countChartWidth() {
|
||||||
chartWidthNumber:document.documentElement.clientWidth - 760,
|
if (this.chartWidth === 0 || this.chartType === 'bar') {
|
||||||
isFullScreen: false,
|
this.chartWidthNumber = this.w;
|
||||||
originalW: 100,
|
} else {
|
||||||
originalH: 100,
|
this.chartWidthNumber = this.chartWidth;
|
||||||
showFullScreen: {
|
|
||||||
type: Boolean,
|
|
||||||
default() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
// 头部部分
|
|
||||||
chartType: "bar",
|
|
||||||
charts: [
|
|
||||||
{id: 'bar', name: this.$t('commons.report_statistics.bar')},
|
|
||||||
{id: 'pie', name: this.$t('commons.report_statistics.pie')}
|
|
||||||
],
|
|
||||||
order: "",
|
|
||||||
orders: [{id: '', name: '默认排序'},{id: 'desc', name: this.$t('commons.report_statistics.desc')}, {id: 'asc', name: this.$t('commons.report_statistics.asc')}],
|
|
||||||
loading: false,
|
|
||||||
options: {},
|
|
||||||
pieItemOption:{
|
|
||||||
dataset: [{
|
|
||||||
source: [
|
|
||||||
['Product', 'Sales', 'Price', 'Year'],
|
|
||||||
['Cake', 123, 32, 2011],
|
|
||||||
['Cereal', 231, 14, 2011],
|
|
||||||
['Tofu', 235, 5, 2011],
|
|
||||||
['Dumpling', 341, 25, 2011],
|
|
||||||
['Biscuit', 122, 29, 2011],
|
|
||||||
['Cake', 143, 30, 2012],
|
|
||||||
['Cereal', 201, 19, 2012],
|
|
||||||
['Tofu', 255, 7, 2012],
|
|
||||||
['Dumpling', 241, 27, 2012],
|
|
||||||
['Biscuit', 102, 34, 2012],
|
|
||||||
['Cake', 153, 28, 2013],
|
|
||||||
['Cereal', 181, 21, 2013],
|
|
||||||
['Tofu', 395, 4, 2013],
|
|
||||||
['Dumpling', 281, 31, 2013],
|
|
||||||
['Biscuit', 92, 39, 2013],
|
|
||||||
['Cake', 223, 29, 2014],
|
|
||||||
['Cereal', 211, 17, 2014],
|
|
||||||
['Tofu', 345, 3, 2014],
|
|
||||||
['Dumpling', 211, 35, 2014],
|
|
||||||
['Biscuit', 72, 24, 2014],
|
|
||||||
],
|
|
||||||
}, {
|
|
||||||
transform: {
|
|
||||||
type: 'filter',
|
|
||||||
config: { dimension: 'Year', value: 2011 }
|
|
||||||
},
|
|
||||||
}, {
|
|
||||||
transform: {
|
|
||||||
type: 'filter',
|
|
||||||
config: { dimension: 'Year', value: 2012 }
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
transform: {
|
|
||||||
type: 'filter',
|
|
||||||
config: { dimension: 'Year', value: 2013 }
|
|
||||||
}
|
|
||||||
}],
|
|
||||||
series: [{
|
|
||||||
type: 'pie', radius: 50, center: ['50%', '25%'],
|
|
||||||
datasetIndex: 1
|
|
||||||
}, {
|
|
||||||
type: 'pie', radius: 50, center: ['50%', '50%'],
|
|
||||||
datasetIndex: 2
|
|
||||||
}, {
|
|
||||||
type: 'pie', radius: 50, center: ['50%', '75%'],
|
|
||||||
datasetIndex: 3
|
|
||||||
}],
|
|
||||||
media: [{
|
|
||||||
query: { minAspectRatio: 1 },
|
|
||||||
option: {
|
|
||||||
series: [
|
|
||||||
{ center: ['25%', '50%'] },
|
|
||||||
{ center: ['50%', '50%'] },
|
|
||||||
{ center: ['75%', '50%'] }
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
option: {
|
|
||||||
series: [
|
|
||||||
{ center: ['50%', '25%'] },
|
|
||||||
{ center: ['50%', '50%'] },
|
|
||||||
{ center: ['50%', '75%'] }
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}]
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
orderCharts() {
|
||||||
this.dataOption = this.loadOption;
|
this.$emit('orderCharts', this.order);
|
||||||
if(this.needFullScreen){
|
},
|
||||||
this.w = document.documentElement.clientWidth;
|
generateOption(chartTypeParam) {
|
||||||
|
if(chartTypeParam){
|
||||||
|
this.chartType = chartTypeParam;
|
||||||
}
|
}
|
||||||
|
if (this.chartType === 'pie') {
|
||||||
|
this.dataOption = this.pieOption;
|
||||||
|
} else {
|
||||||
|
this.dataOption = this.loadOption;
|
||||||
|
}
|
||||||
|
this.dataOption.series.forEach(item => {
|
||||||
|
item.type = this.chartType;
|
||||||
|
});
|
||||||
this.reload();
|
this.reload();
|
||||||
},
|
},
|
||||||
watch:{
|
reload() {
|
||||||
chartWidth(){
|
this.loading = true
|
||||||
this.countChartWidth();
|
this.$nextTick(() => {
|
||||||
},
|
this.loading = false;
|
||||||
chartType(){
|
})
|
||||||
this.countChartWidth();
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
methods: {
|
fullScreen() {
|
||||||
countChartWidth(){
|
this.originalW = this.w;
|
||||||
if(this.chartWidth === 0 || this.chartType === 'bar'){
|
this.originalH = this.h;
|
||||||
this.chartWidthNumber = this.w;
|
this.w = document.body.clientWidth - 50;
|
||||||
}else {
|
this.h = document.body.clientHeight;
|
||||||
this.chartWidthNumber = this.chartWidth;
|
this.isFullScreen = true;
|
||||||
|
this.$emit('hidePage', true);
|
||||||
|
},
|
||||||
|
unFullScreen() {
|
||||||
|
this.w = this.originalW;
|
||||||
|
this.h = this.originalH;
|
||||||
|
this.isFullScreen = false;
|
||||||
|
this.$emit('hidePage', false);
|
||||||
|
},
|
||||||
|
getImages(command) {
|
||||||
|
let imageType = 'image/png';
|
||||||
|
if (command === 'jpg') {
|
||||||
|
imageType = 'image/jpg';
|
||||||
|
}
|
||||||
|
let returnImageDatas = "";
|
||||||
|
if (document.getElementById('picChart')) {
|
||||||
|
let chartsCanvas = document.getElementById('picChart').querySelectorAll('canvas')[0];
|
||||||
|
if (chartsCanvas) {
|
||||||
|
// toDataURL()是canvas对象的一种方法,用于将canvas对象转换为base64位编码
|
||||||
|
returnImageDatas = chartsCanvas && chartsCanvas.toDataURL(imageType);
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
orderCharts() {
|
this.$emit("getImage", returnImageDatas);
|
||||||
this.$emit('orderCharts', this.order);
|
return returnImageDatas;
|
||||||
},
|
},
|
||||||
generateOption() {
|
exportCommand(command) {
|
||||||
if(this.chartType === 'pie'){
|
let fileName = 'report_pic.' + command;
|
||||||
this.dataOption = this.pieOption;
|
if (document.getElementById('picChart')) {
|
||||||
}else {
|
let chartsCanvas = document.getElementById('picChart').querySelectorAll('canvas')[0]
|
||||||
this.dataOption = this.loadOption;
|
let mime = 'image/png';
|
||||||
|
if (command === 'jpg') {
|
||||||
|
mime = 'image/jpg';
|
||||||
}
|
}
|
||||||
this.dataOption.series.forEach(item => {
|
if (chartsCanvas) {
|
||||||
item.type = this.chartType;
|
// toDataURL()是canvas对象的一种方法,用于将canvas对象转换为base64位编码
|
||||||
});
|
let imageUrl = chartsCanvas && chartsCanvas.toDataURL(mime)
|
||||||
this.reload();
|
if (navigator.userAgent.indexOf('Trident') > -1) {
|
||||||
},
|
// IE11
|
||||||
reload() {
|
let arr = imageUrl.split(',')
|
||||||
this.loading = true
|
// atob() 函数对已经使用base64编码编码的数据字符串进行解码
|
||||||
this.$nextTick(() => {
|
let bstr = atob(arr[1])
|
||||||
this.loading = false;
|
let bstrLen = bstr.length
|
||||||
})
|
// Uint8Array, 开辟 8 位无符号整数值的类型化数组。内容将初始化为 0
|
||||||
},
|
let u8arr = new Uint8Array(bstrLen)
|
||||||
fullScreen() {
|
while (bstrLen--) {
|
||||||
this.originalW = this.w;
|
// charCodeAt() 方法可返回指定位置的字符的 Unicode 编码
|
||||||
this.originalH = this.h;
|
u8arr[bstrLen] = bstr.charCodeAt(bstrLen)
|
||||||
this.w = document.body.clientWidth - 50;
|
|
||||||
this.h = document.body.clientHeight;
|
|
||||||
this.isFullScreen = true;
|
|
||||||
this.$emit('hidePage', true);
|
|
||||||
},
|
|
||||||
unFullScreen() {
|
|
||||||
this.w = this.originalW;
|
|
||||||
this.h = this.originalH;
|
|
||||||
this.isFullScreen = false;
|
|
||||||
this.$emit('hidePage', false);
|
|
||||||
},
|
|
||||||
getImages(command){
|
|
||||||
let imageType = 'image/png';
|
|
||||||
if(command === 'jpg'){
|
|
||||||
imageType = 'image/jpg';
|
|
||||||
}
|
|
||||||
let returnImageDatas = "";
|
|
||||||
if (document.getElementById('picChart')) {
|
|
||||||
let chartsCanvas = document.getElementById('picChart').querySelectorAll('canvas')[0];
|
|
||||||
if (chartsCanvas) {
|
|
||||||
// toDataURL()是canvas对象的一种方法,用于将canvas对象转换为base64位编码
|
|
||||||
returnImageDatas = chartsCanvas && chartsCanvas.toDataURL(imageType);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.$emit("getImage",returnImageDatas);
|
|
||||||
return returnImageDatas;
|
|
||||||
},
|
|
||||||
exportCommand(command){
|
|
||||||
let fileName = 'report_pic.'+command;
|
|
||||||
if (document.getElementById('picChart')) {
|
|
||||||
let chartsCanvas = document.getElementById('picChart').querySelectorAll('canvas')[0]
|
|
||||||
let mime = 'image/png';
|
|
||||||
if(command === 'jpg'){
|
|
||||||
mime = 'image/jpg';
|
|
||||||
}
|
|
||||||
if (chartsCanvas) {
|
|
||||||
// toDataURL()是canvas对象的一种方法,用于将canvas对象转换为base64位编码
|
|
||||||
let imageUrl = chartsCanvas && chartsCanvas.toDataURL(mime)
|
|
||||||
if (navigator.userAgent.indexOf('Trident') > -1) {
|
|
||||||
// IE11
|
|
||||||
let arr = imageUrl.split(',')
|
|
||||||
// atob() 函数对已经使用base64编码编码的数据字符串进行解码
|
|
||||||
let bstr = atob(arr[1])
|
|
||||||
let bstrLen = bstr.length
|
|
||||||
// Uint8Array, 开辟 8 位无符号整数值的类型化数组。内容将初始化为 0
|
|
||||||
let u8arr = new Uint8Array(bstrLen)
|
|
||||||
while (bstrLen--) {
|
|
||||||
// charCodeAt() 方法可返回指定位置的字符的 Unicode 编码
|
|
||||||
u8arr[bstrLen] = bstr.charCodeAt(bstrLen)
|
|
||||||
}
|
|
||||||
// msSaveOrOpenBlob 方法允许用户在客户端上保存文件,方法如同从 Internet 下载文件,这是此类文件保存到“下载”文件夹的原因
|
|
||||||
window.navigator.msSaveOrOpenBlob(new Blob([u8arr], {type: mime}), fileName );
|
|
||||||
} else {
|
|
||||||
// 其他浏览器
|
|
||||||
let $a = document.createElement('a')
|
|
||||||
$a.setAttribute('href', imageUrl)
|
|
||||||
$a.setAttribute('download', fileName)
|
|
||||||
$a.click()
|
|
||||||
}
|
}
|
||||||
|
// msSaveOrOpenBlob 方法允许用户在客户端上保存文件,方法如同从 Internet 下载文件,这是此类文件保存到“下载”文件夹的原因
|
||||||
|
window.navigator.msSaveOrOpenBlob(new Blob([u8arr], {type: mime}), fileName);
|
||||||
|
} else {
|
||||||
|
// 其他浏览器
|
||||||
|
let $a = document.createElement('a')
|
||||||
|
$a.setAttribute('href', imageUrl)
|
||||||
|
$a.setAttribute('download', fileName)
|
||||||
|
$a.click()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
}
|
},
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
|
||||||
.ms-test-chart-header {
|
.ms-test-chart-header {
|
||||||
z-index: 999;
|
z-index: 999;
|
||||||
width: 380px;
|
width: 380px;
|
||||||
float: right;
|
float: right;
|
||||||
margin-right: 10px;
|
margin-right: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.report-alt-ico {
|
.report-alt-ico {
|
||||||
font-size: 15px;
|
font-size: 15px;
|
||||||
margin: 0px 10px 0px;
|
margin: 0px 10px 0px;
|
||||||
color: #8c939d;
|
color: #8c939d;
|
||||||
}
|
}
|
||||||
|
|
||||||
.report-alt-ico:hover {
|
.report-alt-ico:hover {
|
||||||
color: black;
|
color: black;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
font-size: 18px;
|
font-size: 18px;
|
||||||
}
|
}
|
||||||
|
|
||||||
/deep/ .echarts {
|
/deep/ .echarts {
|
||||||
height: calc(100vh / 1.95);
|
height: calc(100vh / 1.95);
|
||||||
}
|
}
|
||||||
|
|
||||||
.tip {
|
.tip {
|
||||||
float: left;
|
float: left;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
border-radius: 2px;
|
border-radius: 2px;
|
||||||
border-left: 2px solid #783887;
|
border-left: 2px solid #783887;
|
||||||
margin: 0px 20px 0px;
|
margin: 0px 20px 0px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.ms-row {
|
.ms-row {
|
||||||
padding-top: 10px;
|
padding-top: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.chart-config {
|
.chart-config {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
/deep/ .el-card__body {
|
/deep/ .el-card__body {
|
||||||
padding: 0px;
|
padding: 0px;
|
||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
Loading…
Reference in New Issue