From 22025ff80da15e9cc71c1bbf16f8ded1de48770d Mon Sep 17 00:00:00 2001 From: hyx Date: Thu, 30 Apr 2020 11:25:22 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E4=BF=AE=E6=94=B9=E9=97=AE?= =?UTF-8?q?=E9=A2=98=201=20panel=E6=9F=A5=E8=AF=A2=E5=9B=BE=E8=A1=A8?= =?UTF-8?q?=EF=BC=8C=E5=9B=BE=E8=A1=A8=E6=95=B0=E6=8D=AE=E4=B8=8D=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E5=90=8E=E5=8F=B0=EF=BC=8C=E6=9F=A5=E8=AF=A2=E5=89=8D?= =?UTF-8?q?=E5=8F=B0=E7=BC=93=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/charts/chart-list.vue | 72 +++++++++++++++---- .../components/charts/line-chart-block.vue | 4 +- 2 files changed, 61 insertions(+), 15 deletions(-) diff --git a/nezha-fronted/src/components/charts/chart-list.vue b/nezha-fronted/src/components/charts/chart-list.vue index e09fa0395..0da16f530 100644 --- a/nezha-fronted/src/components/charts/chart-list.vue +++ b/nezha-fronted/src/components/charts/chart-list.vue @@ -155,7 +155,8 @@ export default { currentRecordNum:0,//懒加载:本次取记录的index,第一次从0开始取,每次取3行 lineNum:3,//每页加载的行数 pagePanelId:'',//当前分页的panelId - dragging: null + dragging: null, + chartDataCacheGroup:new Map,//图表数据缓存,用于查询:id:{} }; }, computed: {}, @@ -546,27 +547,21 @@ export default { this.dataTotalList = [...chartListTmp]; if(this.isPage){ - this.pageDataList(); + this.pageDataList(null,null,true); }else { this.dataList = [...this.dataTotalList]; } this.$nextTick(() => { - /* - if (this.dataList.length > 0 && this.$refs.editChart) { - this.$refs.editChart.forEach((item, i) => { - item.showLoad(this.dataList[i]);//之后要实现 - }); - }*/ if (this.dataList.length > 0 ) { this.dataList.forEach((item) => { this.$refs['editChart'+item.id][0].showLoad(item);//之后要实现 }); } - this.dataSetFirst(this.dataList); + this.dataSetFirst(this.dataList,null,true); }); }, - pageDataList(isAdd,panelId){ + pageDataList(isAdd,panelId,isSearch){ if(panelId!==this.pagePanelId){ this.currentRecordNum = 0; } @@ -609,7 +604,7 @@ export default { let dataListTmp = [...this.dataList]; this.dataList = [...dataListTmp.concat(dataTmpList)]; this.$nextTick(() => { - this.dataSetFirst(dataTmpList,oldDataListLen); + this.dataSetFirst(dataTmpList,oldDataListLen,isSearch); }); }else { this.dataList = [...dataTmpList]; @@ -673,7 +668,7 @@ export default { }); }, // arr: 该panel下图表list,生成该看板下所有图表 - dataSetFirst(arr,oldDataListLen) { + dataSetFirst(arr,oldDataListLen,isSearch) { if (arr.length) { arr.forEach((item, index) => { let realIndex = index; @@ -682,14 +677,52 @@ export default { } let chartType = item.type; if(chartType!=='url'){ - this.getChartData(item, realIndex); + if(isSearch){ + this.getChartDataForSearch(item,realIndex);///??? + //this.getChartData(item, realIndex); + }else { + this.getChartData(item, realIndex); + } }else { this.setSize(item.span, realIndex); // 设置该图表宽度 } }); } }, - + getChartDataForSearch(chartItem,realIndex){ + let chartData = this.chartDataCacheGroup.get(chartItem.id); + if(chartData){ + this.setSize(chartItem.span, realIndex); // 设置该图表宽度 + let filterType = chartData.filterType; + let errorMsg = chartData.errorMsg; + let tableData = chartData.tableData; + let panelId = chartData.panelId; + let filter = chartData.filter; + let legend = chartData.legend; + let series = chartData.series; + if(this.$refs['editChart'+chartItem.id] && this.$refs['editChart'+chartItem.id].length>0) { + if (chartItem.type === 'table') {//表格 + if (filterType === 'showFullScreen') {//全屏查询 + this.$refs['editChart'+chartItem.id][0].setData(chartItem, tableData, + panelId, filter, filterType,errorMsg); + } else { + this.$refs['editChart'+chartItem.id][0].setData(chartItem, tableData, + panelId, filter,'',errorMsg); + } + } else if (chartItem.type === 'line' || chartItem.type === 'bar' || chartItem.type === 'stackArea' || chartItem.type === 4) { + if (filterType === 'showFullScreen') {//全屏查询 + this.$refs['editChart'+chartItem.id][0].setData(chartItem, series, + panelId, filter, legend, filterType,errorMsg); + } else { + this.$refs['editChart'+chartItem.id][0].setData(chartItem, series, + panelId, filter, legend,'',errorMsg); + } + } + } + }else { + this.getChartData(chartItem, realIndex); + } + }, // 获取一个图表具体数据,图表信息,图表位置index getChartData(chartInfo, pos, filterType) { const chartItem = chartInfo; @@ -867,6 +900,17 @@ export default { }); if(this.$refs['editChart'+chartItem.id] && this.$refs['editChart'+chartItem.id].length>0) { + const chartData = { + chartItem:chartItem, + series:series, + legend:legend, + tableData:tableData, + panelId:this.filter.panelId, + filter:this.filter, + filterType:filterType, + errorMsg:errorMsg, + } + this.chartDataCacheGroup.set(chartInfo.id,chartData); if (chartItem.type === 'table') {//表格 if (filterType === 'showFullScreen') {//全屏查询 this.$refs['editChart'+chartItem.id][0].setData(chartItem, tableData, diff --git a/nezha-fronted/src/components/charts/line-chart-block.vue b/nezha-fronted/src/components/charts/line-chart-block.vue index 4e970c66e..5f6812f0a 100644 --- a/nezha-fronted/src/components/charts/line-chart-block.vue +++ b/nezha-fronted/src/components/charts/line-chart-block.vue @@ -921,7 +921,9 @@ // boundaryGap: false,//line-false; bar-true; //data: ['20190101', '20190102', '周三', '周四', '周五', '周六', '周日'] axisLabel: { - intervale: 0, + interval: '0', + //showMinLabel:false, + showMaxLabel:false, rotate: 0, formatter: function (value) { value = bus.computeTimezone(value);