From 6ef001c79a3d09b716a47e4be8c13f3753c311c1 Mon Sep 17 00:00:00 2001 From: 田源 <lastanimals@163.com> Date: 星期一, 25 十二月 2023 16:21:43 +0800 Subject: [PATCH] 柱状图切换展示形式 --- Source/UBCS-WEB/src/views/statistic/statisticPage.vue | 45 ++++++++++++++++----------------------------- 1 files changed, 16 insertions(+), 29 deletions(-) diff --git a/Source/UBCS-WEB/src/views/statistic/statisticPage.vue b/Source/UBCS-WEB/src/views/statistic/statisticPage.vue index cf657d2..e3f96f3 100644 --- a/Source/UBCS-WEB/src/views/statistic/statisticPage.vue +++ b/Source/UBCS-WEB/src/views/statistic/statisticPage.vue @@ -129,8 +129,6 @@ async getEcharts() { try { const firstResponse = await getBtmAndChart(); - this.ResponseData = await getBtmAndChart(); - this.loading = false; const btmNames = Object.keys(firstResponse.data.data).join(','); const btmValue = Object.values(firstResponse.data.data); if (!btmNames) { @@ -138,36 +136,23 @@ this.pieList = []; this.columnarList = []; this.mixList = []; + this.loading = false; return; } - for (const value of btmValue) { - if (value.includes('0')) { - await this.handleStatisticAnalysis('lineList', btmNames, firstResponse); - } else { - this.lineList = []; - } - if (value.includes('1')) { - await this.handleStatisticAnalysis('pieList', btmNames, firstResponse); - } else { - this.pieList = []; - } - if (value.includes('2')) { - await this.handleStatisticAnalysis('columnarList', btmNames, firstResponse); - } else { - this.columnarList = []; - } - if (value.includes('3')) { - await this.handleStatisticAnalysis('mixList', btmNames, firstResponse); - } else { - this.mixList = []; - } - } + const typeList = { + '0': 'lineList', + '1': 'pieList', + '2': 'columnarList', + '3': 'mixList' + }; + await this.handleStatisticAnalysis(btmNames, firstResponse); + this.loading = false; } catch (error) { this.loading = false; console.error('Error:', error); } }, - async handleStatisticAnalysis(type, btmNames, firstResponse) { + async handleStatisticAnalysis(btmNames, firstResponse) { const secondResponse = await getStatisticAnalysis({btmNames}); const secondData = secondResponse.data.data; const typeList = { @@ -176,6 +161,10 @@ "2": "columnarList", "3": "mixList" }; + this.lineList = []; + this.pieList = []; + this.columnarList = []; + this.mixList = []; const firstData = firstResponse.data.data; //Object.keys瀵艰嚧瀵硅薄椤哄簭涓嶄竴鑷达紝浣跨敤sort鎺掑簭涓庡悗绔繑鍥炴牸寮忎竴鑷� Object.keys(firstData).sort().forEach((key, index) => { @@ -190,7 +179,6 @@ btmname: key }; }); - this[listType] = []; this.$nextTick(() => { list.forEach((i, j) => { if (index === j) { @@ -234,12 +222,12 @@ this.$message.warning('璇疯嚦灏戦�夋嫨涓�鏉℃暟鎹紒'); return; } - let codeStatus = this.selectData.every(key => key.codeType) + let codeStatus = this.selectData.every(key => key.codeType.length > 0); + if (!codeStatus) { this.$message.warning("璇锋鏌ュ凡鍕鹃�夋暟鎹被鍨嬫槸鍚︿负绌猴紒"); return; } - const newArray = this.selectData.map(item => { return { btmname: item.code, @@ -281,7 +269,6 @@ }, //琛ㄦ牸澶氶�� selectChange(selection) { - console.log('selection', selection) this.selectData = selection; }, } -- Gitblit v1.9.3