From a346cfbcb03a303dca252d910d2181f00e7adc20 Mon Sep 17 00:00:00 2001 From: WXL <1785969728@qq.com> Date: 星期二, 03 九月 2024 10:39:10 +0800 Subject: [PATCH] 测试完成 --- src/views/index.vue | 498 ++++++++++++++++++++++++++++++------------------------ 1 files changed, 274 insertions(+), 224 deletions(-) diff --git a/src/views/index.vue b/src/views/index.vue index 17f699a..a98450a 100644 --- a/src/views/index.vue +++ b/src/views/index.vue @@ -110,7 +110,6 @@ <!-- 涓棿echars --> <div class="boxEchars"> <div class="echars1" id="echars"></div> - <div class="echars2" id="echars2"></div> </div> </div> </el-col> @@ -147,27 +146,19 @@ </el-row> <!-- 搴曢儴涓�涓� --> <el-row :gutter="20" style="margin-bottom: 20px"> - <el-col :span="13"> + <el-col :span="15"> <div class="grid-content bg-purple" style="min-height: 300px"> <div class="title"> - 璇婂悗缁熻 + 瀹f暀缁熻 <span class="el-icon-s-unfold moreIcon"></span> </div> <div class="cooperate"> <!-- 鍚堜綔鍖哄煙 --> <div class="pieChart" id="pieCharts"></div> - <div class="Points"> - <p>{{ 122 }}</p> - <span>鍏朵腑闅忚骞查浜烘</span> - <p>{{ 122 }}</p> - <span>闂ㄨ瘖闅忚</span> - <p>{{ 122 }}</p> - <span>鍑洪櫌闅忚</span> - </div> </div> </div> </el-col> - <el-col :span="10"> + <el-col :span="9"> <div class="grid-content bg-purple" style="min-height: 300px"> <div class="title"> 鍚勯」鏈嶅姟缁熻 @@ -176,76 +167,86 @@ <div class="empenty"> <el-row> <el-col :span="4" - ><div class="grid-content bg-purple">璇婄枟棰勭害</div></el-col + ><div class="grid-contents bg-purple">璇婄枟棰勭害</div></el-col > <el-col :span="4" - ><div class="grid-content bg-purple-light">123娆�</div></el-col + ><div class="grid-contents bg-purple-light"> + 123娆� + </div></el-col > <el-col :span="4" - ><div class="grid-content bg-purple">杞瘖鏈嶅姟</div></el-col + ><div class="grid-contents bg-purple">杞瘖鏈嶅姟</div></el-col > <el-col :span="4" - ><div class="grid-content bg-purple-light">231娆�</div></el-col + ><div class="grid-contents bg-purple-light"> + 231娆� + </div></el-col > <el-col :span="4" - ><div class="grid-content bg-purple">淇℃伅鎺ㄩ��</div></el-col + ><div class="grid-contents bg-purple">淇℃伅鎺ㄩ��</div></el-col > <el-col :span="4" - ><div class="grid-content bg-purple-light">900娆�</div></el-col + ><div class="grid-contents bg-purple-light"> + 900娆� + </div></el-col > </el-row ><el-row> <el-col :span="4" - ><div class="grid-content bg-purple">鏍囪瘑涓庡鑸�</div></el-col + ><div class="grid-contents bg-purple">鏍囪瘑涓庡鑸�</div></el-col > <el-col :span="4" - ><div class="grid-content bg-purple-light">23娆�</div></el-col + ><div class="grid-contents bg-purple-light">23娆�</div></el-col > <el-col :span="4" - ><div class="grid-content bg-purple"> + ><div class="grid-contents bg-purple"> 鎮h�呬究鍒╀繚闅滄湇鍔� </div></el-col > <el-col :span="4" - ><div class="grid-content bg-purple-light">13娆�</div></el-col + ><div class="grid-contents bg-purple-light">13娆�</div></el-col > <el-col :span="4" - ><div class="grid-content bg-purple">杩滅▼鍖荤枟</div></el-col + ><div class="grid-contents bg-purple">杩滅▼鍖荤枟</div></el-col > <el-col :span="4" - ><div class="grid-content bg-purple-light">31娆�</div></el-col + ><div class="grid-contents bg-purple-light">31娆�</div></el-col > </el-row ><el-row> <el-col :span="4" - ><div class="grid-content bg-purple">鎮h�呭弽棣�</div></el-col + ><div class="grid-contents bg-purple">鎮h�呭弽棣�</div></el-col > <el-col :span="4" - ><div class="grid-content bg-purple-light">150浜�</div></el-col + ><div class="grid-contents bg-purple-light"> + 150浜� + </div></el-col > <el-col :span="4" - ><div class="grid-content bg-purple">鎮h�呯鐞�</div></el-col + ><div class="grid-contents bg-purple">鎮h�呯鐞�</div></el-col > <el-col :span="4" - ><div class="grid-content bg-purple-light">231浜�</div></el-col + ><div class="grid-contents bg-purple-light"> + 231浜� + </div></el-col > <el-col :span="4" - ><div class="grid-content bg-purple">鍋ュ悍瀹f暀</div></el-col + ><div class="grid-contents bg-purple">鍋ュ悍瀹f暀</div></el-col > <el-col :span="4" - ><div class="grid-content bg-purple-light">400</div></el-col + ><div class="grid-contents bg-purple-light">400</div></el-col > </el-row> <el-row> <el-col :span="4" - ><div class="grid-content bg-purple">鍙嶉鍗犳瘮</div></el-col + ><div class="grid-contents bg-purple">鍙嶉鍗犳瘮</div></el-col > <el-col :span="4" - ><div class="grid-content bg-purple-light">23%</div></el-col + ><div class="grid-contents bg-purple-light">23%</div></el-col > <el-col :span="4" - ><div class="grid-content bg-purple">绠$悊鍗犳瘮</div></el-col + ><div class="grid-contents bg-purple">绠$悊鍗犳瘮</div></el-col > <el-col :span="4" - ><div class="grid-content bg-purple-light">32%</div></el-col + ><div class="grid-contents bg-purple-light">32%</div></el-col > </el-row> </div> @@ -261,12 +262,7 @@ // getUserWork, // getregionCollect, // getregionOrderCount, -// getregionAmountCollect, -// getNodeCount, -// getPrtnerCount, -// getnodeCollect, -// getSkuTop, -// getOrderAmount, + // } from "@/api/home"; import dayjs from "dayjs"; @@ -277,6 +273,10 @@ NodeCount: "", PrtnerCount: "", NodeCount: "", + myChart2: null, + mypPieCharts: null, + lastWidth: window.innerWidth, + lastHeight: window.innerHeight, radio1: "鍛�", ticketStatistics: {}, order: "", @@ -289,6 +289,7 @@ cylinderSeries: [], cylinderXAxis: [], dyat: 30, + intervalId: null, }; }, @@ -317,10 +318,17 @@ this.getPrtnerCount(); this.getnodeCollect(); this.getSkuTop(); - this.getOrderAmount(); }); }, - mounted() {}, + mounted() { + this.setInterval(); + // window.addEventListener("resize", this.handleResize()); + }, + beforeDestroy() { + if (this.intervalId) { + clearInterval(this.intervalId); // 娓呴櫎瀹氭椂鍣� + } + }, methods: { // 鏀瑰彉鏃堕棿浜嬩欢 changes() { @@ -339,26 +347,8 @@ this.getPrtnerCount(); this.getnodeCollect(); this.getSkuTop(); - this.getOrderAmount(); }, - // 鏌辩姸鍥� - async getOrderAmount() { - // const res = await getOrderAmount(this.endatd, this.statd); - // this.cylinderXAxis = res.data.xAxis; - // this.cylinderSeries = res.data.series; - this.cylinderXAxis = [ - "1鏈�", - "2鏈�", - "3鏈�", - "4鏈�", - "5鏈�", - "6鏈�", - "7鏈�", - "8鏈�", - ]; - this.cylinderSeries = [123, 123, 223, 212, 432, 123, 442, 234]; - this.myEcharts(); - }, + // 鑾峰彇鐐逛綅鎬绘暟 async getNodeCount() { // const res = await getNodeCount(); @@ -398,7 +388,6 @@ { amount: 0, count: 88, skuId: "0", skuName: "鍣ㄦ绉�" }, { amount: 0, count: 87, skuId: "0", skuName: "楠ㄧ" }, { amount: 0, count: 67, skuId: "0", skuName: "鏀惧皠绉�" }, - ]; }, // 鑾峰彇宸ュ崟鏁伴噺 @@ -423,80 +412,6 @@ // this.Count = (res.data / 1000000).toFixed(2); }, - // 鏌辩姸鍥� - myEcharts() { - // 鍩轰簬鍑嗗濂界殑dom锛屽垵濮嬪寲echarts瀹炰緥 - var echarts = require("echarts"); - var myChart = echarts.init(document.getElementById("echars2")); - - // 鎸囧畾鍥捐〃鐨勯厤缃」鍜屾暟鎹� - var option = { - title: { - text: "璇婁腑缁熻", - }, - tooltip: { - trigger: "axis", - }, - legend: { - data: ["闄㈠唴鎺ㄩ��", "瀹f暀瀹屾垚"], - }, - toolbox: { - show: true, - feature: { - dataView: { show: true, readOnly: false }, - magicType: { show: true, type: ["line", "bar"] }, - restore: { show: true }, - saveAsImage: { show: true }, - }, - }, - calculable: true, - xAxis: [ - { - type: "category", - // prettier-ignore - data: ["涓�鏈�","浜屾湀","涓夋湀","鍥涙湀","浜旀湀","鍏湀","涓冩湀","鍏湀","涔濇湀","鍗佹湀"], - }, - ], - yAxis: [ - { - type: "value", - }, - ], - series: [ - { - name: "闄㈠唴鎺ㄩ��", - type: "bar", - data: [20, 49, 70, 32, 56, 76, 56, 122, 26, 20, 64, 33], - markPoint: { - data: [ - { type: "max", name: "Max" }, - { type: "min", name: "Min" }, - ], - }, - markLine: { - data: [{ type: "average", name: "Avg" }], - }, - }, - { - name: "瀹f暀瀹屾垚", - type: "bar", - data: [26, 59, 90, 64, 87, 70, 75, 182, 87, 82, 60, 23], - markPoint: { - data: [ - { name: "Max", value: 182, xAxis: 7, yAxis: 183 }, - { name: "Min", value: 2.3, xAxis: 11, yAxis: 3 }, - ], - }, - markLine: { - data: [{ type: "average", name: "Avg" }], - }, - }, - ], - }; - - // 浣跨敤鍒氭寚瀹氱殑閰嶇疆椤瑰拰鏁版嵁鏄剧ず鍥捐〃銆� - myChart.setOption(option); - }, // 鑾峰彇绾跨姸鍥炬椂闂� async getregionAmountCollect() { // const res = await getregionAmountCollect(1, this.endatd, this.statd); @@ -510,66 +425,145 @@ myEcharts2() { var echarts = require("echarts"); var myChart2 = echarts.init(document.getElementById("echars")); + this.myChart2 = myChart2; var option2 = { - title: { - text: "璇婂墠鏁版嵁", - }, tooltip: { trigger: "axis", + axisPointer: { + type: "cross", + crossStyle: { + color: "#999", + }, + }, }, - dataset: { - source: [ - ["product", "2018", "2019", "2020", "2021", "2022", "2023"], - ["澶嶈瘖", 256, 182, 388, 270, 253, 385], - ["浣忛櫌", 351, 451, 355, 353, 373, 468], - ["鎵嬫湳", 440, 362, 569, 436, 445, 332], - ["杞瘖", 525, 237, 541, 518, 433, 249], + toolbox: { + feature: { + dataView: { show: true, readOnly: false }, + magicType: { show: true, type: ["line", "bar"] }, + restore: { show: true }, + saveAsImage: { show: true }, + }, + }, + legend: { + data: [ + "鍑洪櫌闅忚閲�", + "闂ㄨ瘖闅忚閲�", + "鍦ㄩ櫌闅忚閲�", + "闂ㄨ瘖澶嶈瘖閫氱煡", + "鍑洪櫌澶嶈瘖閫氱煡", + "鍦ㄩ櫌璇勪及閲�", ], }, - xAxis: { type: "category" }, - yAxis: { gridIndex: 0 }, - grid: { top: "55%" }, + xAxis: [ + { + type: "category", + data: [ + "涓�鏈�", + "浜屾湀", + "涓夋湀", + "鍥涙湀", + "浜旀湀", + "鍏湀", + "涓冩湀", + "鍏湀", + "涔濇湀", + "鍗佹湀", + ], + axisPointer: { + type: "shadow", + }, + }, + ], + yAxis: [ + { + type: "value", + name: "Precipitation", + min: 0, + max: 250, + interval: 50, + axisLabel: { + formatter: "{value} ml", + }, + }, + { + type: "value", + name: "Temperature", + min: 0, + max: 250, + interval: 50, + axisLabel: { + formatter: "{value} 娆�", + }, + }, + ], + grid: { top: "35%" }, series: [ { - type: "line", - smooth: true, - seriesLayoutBy: "row", - emphasis: { focus: "series" }, - }, - { - type: "line", - smooth: true, - seriesLayoutBy: "row", - emphasis: { focus: "series" }, - }, - { - type: "line", - smooth: true, - seriesLayoutBy: "row", - emphasis: { focus: "series" }, - }, - { - type: "line", - smooth: true, - seriesLayoutBy: "row", - emphasis: { focus: "series" }, - }, - { - type: "pie", - id: "pie", - radius: "30%", - center: ["50%", "25%"], - emphasis: { - focus: "self", + name: "鍑洪櫌闅忚閲�", + type: "bar", + tooltip: { + valueFormatter: function (value) { + return value + " ml"; + }, }, - label: { - formatter: "{b}: {@2018} ({d}%)", + data: [120, 150, 165, 90, 140, 200, 130, 85, 175, 95, 110, 160], + }, + { + name: "闂ㄨ瘖闅忚閲�", + type: "bar", + tooltip: { + valueFormatter: function (value) { + return value + " ml"; + }, }, - encode: { - itemName: "product", - value: "2018", - tooltip: "2018", + data: [102, 190, 135, 88, 175, 160, 83, 145, 200, 110, 97, 180], + }, + { + name: "鍦ㄩ櫌闅忚閲�", + type: "bar", + tooltip: { + valueFormatter: function (value) { + return value + " ml"; + }, }, + data: [145, 92, 178, 134, 167, 85, 199, 112, 156, 88, 120, 145], + }, + + { + name: "鍑洪櫌澶嶈瘖閫氱煡", + type: "line", + smooth: 0.3, + yAxisIndex: 1, + tooltip: { + valueFormatter: function (value) { + return value + " 娆�"; + }, + }, + data: [45, 123, 78, 156, 89, 34, 199, 112, 67, 145, 88, 175], + }, + { + name: "闂ㄨ瘖澶嶈瘖閫氱煡", + type: "line", + smooth: 0.3, + yAxisIndex: 1, + tooltip: { + valueFormatter: function (value) { + return value + " 娆�"; + }, + }, + data: [102, 190, 135, 88, 175, 160, 83, 145, 200, 110, 97, 180], + }, + { + name: "鍦ㄩ櫌璇勪及閲�", + type: "line", + smooth: 0.3, + yAxisIndex: 1, + tooltip: { + valueFormatter: function (value) { + return value + " 娆�"; + }, + }, + data: [120, 150, 165, 90, 140, 200, 130, 85, 175, 95, 110, 160], }, ], }; @@ -581,7 +575,7 @@ series: { id: "pie", label: { - formatter: "{b}: {@[" + dimension + "]} ({d}%)", + formatter: "{b}: {@[" + dimension + "]} ", }, encode: { value: dimension, @@ -598,59 +592,112 @@ // 鍩轰簬鍑嗗濂界殑dom锛屽垵濮嬪寲echarts瀹炰緥 var echarts = require("echarts"); var mypPieCharts = echarts.init(document.getElementById("pieCharts")); - + this.mypPieCharts = mypPieCharts; // 鎸囧畾鍥捐〃鐨勯厤缃」鍜屾暟鎹� var optionPie = { - // title: { - // left: "left", - // }, - + legend: {}, tooltip: { - trigger: "item", - formatter: "{b}<br/>鎬诲崰姣� : {d}% ", + trigger: "axis", + showContent: true, }, - toolbox: { - show: true, - feature: { - mark: { show: true }, - }, + dataset: { + source: [ + ["product", "2012", "2013", "2014", "2015", "2016", "2017"], + ["鍑洪櫌瀹f暀", 56.5, 82.1, 88.7, 70.1, 53.4, 85.1], + ["鍦ㄩ櫌瀹f暀", 51.1, 51.4, 55.1, 53.3, 73.8, 68.7], + ["闂ㄨ瘖瀹f暀", 40.1, 62.2, 69.5, 36.4, 45.2, 32.5], + ], }, - legend: { - top: "5%", - left: "center", - }, + xAxis: { type: "category" }, + yAxis: { gridIndex: 0 }, + grid: { top: "25%", left: "10%", right: "40%", bottom: "10%" }, series: [ { - name: "Access From", + name: "鍑洪櫌瀹f暀", + type: "line", + smooth: true, + seriesLayoutBy: "row", + emphasis: { focus: "series" }, + }, + { + name: "鍦ㄩ櫌瀹f暀", + type: "line", + smooth: true, + seriesLayoutBy: "row", + emphasis: { focus: "series" }, + }, + { + name: "闂ㄨ瘖瀹f暀", + type: "line", + smooth: true, + seriesLayoutBy: "row", + emphasis: { focus: "series" }, + }, + { type: "pie", + id: "pie", radius: ["40%", "70%"], - avoidLabelOverlap: false, + center: ["80%", "50%"], + emphasis: { + focus: "self", + }, itemStyle: { borderRadius: 10, borderColor: "#fff", borderWidth: 2, }, - - emphasis: { - label: { - show: true, - fontSize: 40, - fontWeight: "bold", - }, + label: { + formatter: "{b}: {@2012}", }, - labelLine: { - show: false, + encode: { + itemName: "product", + value: "2012", + tooltip: "2012", }, - data: [ - { value: 580, name: "闂ㄨ瘖闅忚" }, - { value: 484, name: "鍑洪櫌闅忚" }, - ], }, ], }; + mypPieCharts.on("updateAxisPointer", function (event) { + const xAxisInfo = event.axesInfo[0]; + if (xAxisInfo) { + const dimension = xAxisInfo.value + 1; + mypPieCharts.setOption({ + series: { + id: "pie", + label: { + formatter: "{b}: {@[" + dimension + "]} ", + }, + encode: { + value: dimension, + tooltip: dimension, + }, + }, + }); + } + }); // 浣跨敤鍒氭寚瀹氱殑閰嶇疆椤瑰拰鏁版嵁鏄剧ず鍥捐〃銆� mypPieCharts.setOption(optionPie); + }, + // 椤甸潰鍙樺寲璋冩暣澶у皬 + handleResize() { + console.log(111); + // 璋冩暣 ECharts 鍥捐〃澶у皬 + if (this.myChart2) { + this.myChart2.resize(); + } + if (this.mypPieCharts) { + this.mypPieCharts.resize(); + } + }, + setInterval() { + this.intervalId = setInterval(() => { + if (window.innerWidth != this.lastWidth) { + this.lastWidth = window.innerWidth; + console.log("绐楀彛澶у皬鍙兘琚墜鍔ㄨ皟鏁翠簡"); + this.handleResize(); + } + }, 1000); }, }, }; @@ -664,13 +711,10 @@ .boxEchars { width: 100%; - height: 480px; + height: 40vh; margin-top: 45px; display: flex; .echars1 { - flex: 1; - } - .echars2 { flex: 1; } } @@ -757,7 +801,7 @@ .empenty { width: 100%; padding: 20px 0; - height: 280px; + min-height: 280px; } .cooperate { width: 100%; @@ -765,7 +809,7 @@ margin-top: 25px; display: flex; .pieChart { - flex: 3; + flex: 1; } .Points { width: 154px; @@ -919,7 +963,13 @@ .grid-content { min-height: 36px; border-radius: 20px; - padding: 0 20px; + padding: 0 10px; +} +.grid-contents { + min-height: 36px; + border-radius: 20px; + padding: 0 10px; + padding-right: 0; } .row-bg { padding: 10px 0; -- Gitblit v1.9.3