| | |
| | | <!-- |
| | | * @Author: daidai |
| | | * @Date: 2022-02-28 16:16:42 |
| | | * @LastEditors: Please set LastEditors |
| | | * @LastEditTime: 2022-07-20 17:57:11 |
| | | * @FilePath: \web-pc\src\pages\big-screen\view\indexs\left-center.vue |
| | | --> |
| | | <template> |
| | | <div id="name" style="width: 100%; height: 100%"> |
| | | <Echart :options="options" style="width: 100%; height: 100%"></Echart> |
| | | <Echart |
| | | :options="options" |
| | | style="width: 100%; height: 100%" |
| | | v-if="!loading" |
| | | /> |
| | | <div v-else style="color: white; text-align: center; padding-top: 50px"> |
| | | æ°æ®å è½½ä¸... |
| | | </div> |
| | | <div v-if="error" style="color: red; text-align: center; padding-top: 50px"> |
| | | æ°æ®å 载失败: {{ error }} |
| | | </div> |
| | | </div> |
| | | </template> |
| | | |
| | | <script> |
| | | import { currentGET } from "api/modules"; |
| | | import { ProLocationStatistics } from "@/api/http.js"; |
| | | import { GetProWeekTasks } from "@/api/http.js"; |
| | | import * as echarts from 'echarts'; |
| | | let style = { |
| | | fontSize: 24, |
| | | }; |
| | | |
| | | export default { |
| | | data() { |
| | | return { |
| | | pageflag: true, |
| | | myChart: {}, |
| | | options: {}, |
| | | loading: false, |
| | | error: null, |
| | | timer: null |
| | | }; |
| | | }, |
| | | filters: { |
| | | numsFilter(msg) { |
| | | return msg || 0; |
| | | }, |
| | | }, |
| | | created() { |
| | | this.getData(); |
| | | }, |
| | | mounted() { |
| | | this.init(); |
| | | this.fetchData(); |
| | | this.startAutoRefresh(); |
| | | }, |
| | | beforeDestroy() { |
| | | this.clearData(); |
| | | this.stopAutoRefresh(); |
| | | }, |
| | | methods: { |
| | | init() { |
| | | initEmptyChart() { |
| | | this.options = { |
| | | //æµ®å¨æ¡ |
| | | tooltip: {}, |
| | | //å¾ä¾ |
| | | legend: { |
| | | right: '12%', |
| | | bottom: '4%', |
| | | textStyle: { |
| | | color: '#fff', |
| | | fontSize: '13' |
| | | }, |
| | | itemGap: 20, |
| | | itemWidth: 10, |
| | | itemHeight: 10, |
| | | icon: 'circle', |
| | | data: ['PM2.5', 'CO2', 'SO'] |
| | | }, |
| | | grid: { |
| | | left: '8%', |
| | | top: '15%', |
| | | bottom: '14%', |
| | | width: '86%', |
| | | }, |
| | | visualMap: [{ |
| | | type: 'piecewise', |
| | | show: false, |
| | | pieces: [{ |
| | | gt: 0, |
| | | lte: 60, |
| | | color: '#69dbf7' |
| | | }, { |
| | | gte: 60, |
| | | color: '#e5421b' |
| | | }], |
| | | seriesName: 'SO', |
| | | seriesIndex: 2 |
| | | }, { |
| | | type: 'piecewise', |
| | | show: false, |
| | | pieces: [{ |
| | | gt: 0, |
| | | lte: 60, |
| | | color: '#1be57a' |
| | | }, { |
| | | gte: 60, |
| | | color: '#e5421b' |
| | | }], |
| | | seriesName: 'CO2', |
| | | seriesIndex: 1 |
| | | }, { |
| | | type: 'piecewise', |
| | | show: false, |
| | | pieces: [{ |
| | | gt: 0, |
| | | lte: 60, |
| | | color: '#feb01e' |
| | | }, { |
| | | gte: 60, |
| | | color: '#e5421b' |
| | | }], |
| | | seriesName: 'PM2.5', |
| | | seriesIndex: 0 |
| | | }, { |
| | | type: 'piecewise', |
| | | show: false, |
| | | pieces: [{ |
| | | gt: 0, |
| | | lte: 60, |
| | | color: '#69dbf7' |
| | | }, { |
| | | gte: 60, |
| | | color: '#e5421b' |
| | | }], |
| | | seriesName: 'SO', |
| | | seriesIndex: 5 |
| | | }, { |
| | | type: 'piecewise', |
| | | show: false, |
| | | pieces: [{ |
| | | gt: 0, |
| | | lte: 60, |
| | | color: '#1be57a' |
| | | }, { |
| | | gte: 60, |
| | | color: '#e5421b' |
| | | }], |
| | | seriesName: 'CO2', |
| | | seriesIndex: 4 |
| | | }, { |
| | | type: 'piecewise', |
| | | show: false, |
| | | pieces: [{ |
| | | gt: 0, |
| | | lte: 60, |
| | | color: '#feb01e' |
| | | }, { |
| | | gte: 60, |
| | | color: '#e5421b' |
| | | }], |
| | | seriesName: 'PM2.5', |
| | | seriesIndex: 3 |
| | | }], |
| | | //xè½´ |
| | | xAxis: { |
| | | axisLine: { |
| | | lineStyle: { |
| | | color: '#132987' |
| | | } |
| | | }, |
| | | axisLabel: { |
| | | textStyle: { |
| | | color: '#FFF', |
| | | fontSize: 12 |
| | | }, |
| | | }, |
| | | //å»åº¦çº¿ |
| | | axisTick: { |
| | | show: false |
| | | }, |
| | | //åæ è½´æ¾ç¤ºå¼ |
| | | data: ["1æ¶", "2æ¶", "3æ¶", "4æ¶", "5æ¶", "6æ¶", "7æ¶", "8æ¶"] |
| | | }, |
| | | //yè½´ |
| | | yAxis: { |
| | | min: 0, |
| | | max: 100, |
| | | axisLabel: { // æ¹åyè½´åä½é¢è²åå¤§å° |
| | | //formatter: '{value} m³ ', // ç»yè½´æ·»å åä½ |
| | | textStyle: { |
| | | color: '#fff', |
| | | fontSize: 12, |
| | | }, |
| | | }, |
| | | //åæ è½´çº¿ |
| | | axisLine: { |
| | | show: false, |
| | | }, |
| | | //å»åº¦çº¿ |
| | | axisTick: { |
| | | show: false |
| | | }, |
| | | //å¨gridåºåä¸çåé线 |
| | | splitLine: { |
| | | show: true, |
| | | lineStyle: { |
| | | color: '#132987', |
| | | } |
| | | }, |
| | | }, |
| | | |
| | | // |
| | | series: [{ |
| | | name: 'PM2.5', |
| | | type: 'line', |
| | | symbolSize: [0, 0], |
| | | itemStyle: { |
| | | color: '#feb01e' |
| | | }, |
| | | data: [43, 50, 41, 18, 28, 25, 26, 40], |
| | | }, { |
| | | name: 'CO2', |
| | | type: 'line', |
| | | symbolSize: [0, 0], |
| | | itemStyle: { |
| | | color: '#1be57a' |
| | | }, |
| | | data: [21, 30, 37, 39, 23, 37, 5, 50] |
| | | }, { |
| | | name: 'SO', |
| | | type: 'line', |
| | | symbolSize: [0, 0], |
| | | itemStyle: { |
| | | color: '#69dbf7' |
| | | }, |
| | | data: [76, 58, 60, 38, 49, 59, 78, 60] |
| | | }, { //æ°´æ³¢çº¹ç¹ |
| | | name: 'PM2.5', |
| | | type: 'effectScatter', |
| | | symbolSize: [5, 5], |
| | | rippleEffect: { |
| | | period: 1, |
| | | scale: 4, |
| | | brushType: 'fill' |
| | | }, |
| | | itemStyle: { |
| | | color: new echarts.graphic.RadialGradient(0.4, 0.3, 1, [{ |
| | | offset: 0, |
| | | color: '#feb01e' |
| | | }, { |
| | | offset: 1, |
| | | color: 'rgba(254,176,30,.3)' |
| | | }]) |
| | | }, |
| | | data: [43, 50, 41, 18, 28, 25, 26, 40] |
| | | |
| | | }, { //æ°´æ³¢çº¹ç¹ |
| | | name: 'CO2', |
| | | type: 'effectScatter', |
| | | symbolSize: [5, 5], |
| | | rippleEffect: { |
| | | period: 1, |
| | | scale: 4, |
| | | brushType: 'fill' |
| | | }, |
| | | itemStyle: { |
| | | color: new echarts.graphic.RadialGradient(0.4, 0.3, 1, [{ |
| | | offset: 0, |
| | | color: '#1be57a' |
| | | }, { |
| | | offset: 1, |
| | | color: 'rgba(27,229,122,.3)' |
| | | }]) |
| | | }, |
| | | data: [21, 30, 37, 39, 23, 37, 5, 50] |
| | | |
| | | }, { //æ°´æ³¢çº¹ç¹ |
| | | name: 'SO', |
| | | type: 'effectScatter', |
| | | symbolSize: [5, 5], |
| | | rippleEffect: { |
| | | period: 1, |
| | | scale: 4, |
| | | brushType: 'fill' |
| | | }, |
| | | itemStyle: { |
| | | color: new echarts.graphic.RadialGradient(0.4, 0.3, 1, [{ |
| | | offset: 0, |
| | | color: '#69dbf7' |
| | | }, { |
| | | offset: 1, |
| | | color: '#aefbc3' |
| | | }]) |
| | | }, |
| | | markLine: { |
| | | symbol: "none", |
| | | label: { |
| | | normal: { |
| | | show: false, |
| | | } |
| | | }, |
| | | lineStyle: { |
| | | type: "solid", |
| | | color: 'rgba(210,56,56,.6)', |
| | | width: 2 |
| | | }, |
| | | data: [{ |
| | | yAxis: 60 |
| | | }] |
| | | }, |
| | | data: [76, 58, 60, 38, 49, 59, 78, 60] |
| | | |
| | | }] |
| | | }; |
| | | }, |
| | | clearData() { |
| | | if (this.timer) { |
| | | clearInterval(this.timer); |
| | | this.timer = null; |
| | | } |
| | | }, |
| | | async getData() { |
| | | this.pageflag = true; |
| | | // currentGET("big2").then((res) => { |
| | | // if (!this.timer) { |
| | | // console.log("è®¾å¤æ»è§2", res); |
| | | // } |
| | | // if (res.success) { |
| | | // this.userOverview = res.data; |
| | | // this.onlineconfig = { |
| | | // ...this.onlineconfig, |
| | | // number: [1] |
| | | // } |
| | | // this.config = { |
| | | // ...this.config, |
| | | // number: [7] |
| | | // } |
| | | // this.offlineconfig = { |
| | | // ...this.offlineconfig, |
| | | // number: [4] |
| | | // } |
| | | // this.laramnumconfig = { |
| | | // ...this.laramnumconfig, |
| | | // number: [10] |
| | | // } |
| | | // this.switper(); |
| | | // } else { |
| | | // this.pageflag = false; |
| | | // this.$Message.warning(res.msg); |
| | | // } |
| | | // }); |
| | | var rep = await ProLocationStatistics(); |
| | | this.options = { |
| | | //æµ®å¨æ¡ |
| | | tooltip: {}, |
| | | //å¾ä¾ |
| | | legend: { |
| | | right: '12%', |
| | | bottom: '4%', |
| | | textStyle: { |
| | | color: '#fff', |
| | | fontSize: '13' |
| | | }, |
| | | itemGap: 20, |
| | | itemWidth: 10, |
| | | itemHeight: 10, |
| | | icon: 'circle', |
| | | data: ['æåå
¥åº', 'æååºåº', 'æååæ¡'] |
| | | }, |
| | | grid: { |
| | | left: '8%', |
| | | top: '15%', |
| | | bottom: '14%', |
| | | width: '86%', |
| | | }, |
| | | visualMap: [{ |
| | | type: 'piecewise', |
| | | show: false, |
| | | pieces: [{ |
| | | gt: 0, |
| | | lte: 60, |
| | | color: '#69dbf7' |
| | | }, { |
| | | gte: 60, |
| | | color: '#e5421b' |
| | | }], |
| | | seriesName: 'æåå
¥åº', |
| | | seriesIndex: 2 |
| | | }, { |
| | | type: 'piecewise', |
| | | show: false, |
| | | pieces: [{ |
| | | gt: 0, |
| | | lte: 60, |
| | | color: '#1be57a' |
| | | }, { |
| | | gte: 60, |
| | | color: '#e5421b' |
| | | }], |
| | | seriesName: 'æååºåº', |
| | | seriesIndex: 1 |
| | | }, { |
| | | type: 'piecewise', |
| | | show: false, |
| | | pieces: [{ |
| | | gt: 0, |
| | | lte: 60, |
| | | color: '#feb01e' |
| | | }, { |
| | | gte: 60, |
| | | color: '#e5421b' |
| | | }], |
| | | seriesName: 'æååæ¡', |
| | | seriesIndex: 0 |
| | | }], |
| | | //xè½´ |
| | | xAxis: { |
| | | axisLine: { |
| | | lineStyle: { |
| | | color: '#132987' |
| | | } |
| | | }, |
| | | axisLabel: { |
| | | textStyle: { |
| | | color: '#FFF', |
| | | fontSize: 12 |
| | | }, |
| | | }, |
| | | //å»åº¦çº¿ |
| | | axisTick: { |
| | | show: false |
| | | }, |
| | | //åæ è½´æ¾ç¤ºå¼ |
| | | data: ["04/19", "04/20", "04/21", "04/22", "04/23", "04/24", "04/25"] |
| | | }, |
| | | //yè½´ |
| | | yAxis: { |
| | | axisLabel: { // æ¹åyè½´åä½é¢è²åå¤§å° |
| | | //formatter: '{value} m³ ', // ç»yè½´æ·»å åä½ |
| | | textStyle: { |
| | | color: '#fff', |
| | | fontSize: 12, |
| | | }, |
| | | }, |
| | | //åæ è½´çº¿ |
| | | axisLine: { |
| | | show: false, |
| | | }, |
| | | //å»åº¦çº¿ |
| | | axisTick: { |
| | | show: false |
| | | }, |
| | | //å¨gridåºåä¸çåé线 |
| | | splitLine: { |
| | | show: true, |
| | | lineStyle: { |
| | | color: '#132987', |
| | | } |
| | | }, |
| | | }, |
| | | |
| | | // |
| | | series: [{ |
| | | name: 'æåå
¥åº', |
| | | type: 'line', |
| | | symbolSize: [0, 0], |
| | | itemStyle: { |
| | | color: '#feb01e' |
| | | }, |
| | | data: [160, 156, 150, 180, 170, 200, 20], |
| | | }, { |
| | | name: 'æååºåº', |
| | | type: 'line', |
| | | symbolSize: [0, 0], |
| | | itemStyle: { |
| | | color: '#1be57a' |
| | | }, |
| | | data: [80, 115, 120, 130, 91, 99, 20] |
| | | }, { |
| | | name: 'æååæ¡', |
| | | type: 'line', |
| | | symbolSize: [0, 0], |
| | | itemStyle: { |
| | | color: '#69dbf7' |
| | | }, |
| | | data: [70, 113, 118, 111, 89, 99, 32] |
| | | }, { //æ°´æ³¢çº¹ç¹ |
| | | name: 'æåå
¥åº', |
| | | type: 'effectScatter', |
| | | symbolSize: [5, 5], |
| | | rippleEffect: { |
| | | period: 1, |
| | | scale: 4, |
| | | brushType: 'fill' |
| | | }, |
| | | itemStyle: { |
| | | color: new echarts.graphic.RadialGradient(0.4, 0.3, 1, [{ |
| | | offset: 0, |
| | | color: '#feb01e' |
| | | }, { |
| | | offset: 1, |
| | | color: 'rgba(254,176,30,.3)' |
| | | }]) |
| | | }, |
| | | data: [160, 156, 150, 180, 170, 200, 20] |
| | | |
| | | }, { //æ°´æ³¢çº¹ç¹ |
| | | name: 'æååºåº', |
| | | type: 'effectScatter', |
| | | symbolSize: [5, 5], |
| | | rippleEffect: { |
| | | period: 1, |
| | | scale: 4, |
| | | brushType: 'fill' |
| | | }, |
| | | itemStyle: { |
| | | color: new echarts.graphic.RadialGradient(0.4, 0.3, 1, [{ |
| | | offset: 0, |
| | | color: '#1be57a' |
| | | }, { |
| | | offset: 1, |
| | | color: 'rgba(27,229,122,.3)' |
| | | }]) |
| | | }, |
| | | data: [80, 115, 120, 130, 91, 99, 20] |
| | | |
| | | }, { //æ°´æ³¢çº¹ç¹ |
| | | name: 'æååæ¡', |
| | | type: 'effectScatter', |
| | | symbolSize: [5, 5], |
| | | rippleEffect: { |
| | | period: 1, |
| | | scale: 4, |
| | | brushType: 'fill' |
| | | }, |
| | | itemStyle: { |
| | | color: new echarts.graphic.RadialGradient(0.4, 0.3, 1, [{ |
| | | offset: 0, |
| | | color: '#69dbf7' |
| | | }, { |
| | | offset: 1, |
| | | color: '#aefbc3' |
| | | }]) |
| | | }, |
| | | markLine: { |
| | | symbol: "none", |
| | | label: { |
| | | normal: { |
| | | show: false, |
| | | } |
| | | }, |
| | | lineStyle: { |
| | | type: "solid", |
| | | color: 'rgba(210,56,56,.6)', |
| | | width: 2 |
| | | }, |
| | | data: [{ |
| | | yAxis: 60 |
| | | }] |
| | | }, |
| | | data: [70, 113, 118, 111, 89, 99, 32] |
| | | |
| | | }] |
| | | }; |
| | | this.switper(); |
| | | }, |
| | | //轮询 |
| | | switper() { |
| | | if (this.timer) { |
| | | return; |
| | | } |
| | | let looper = (a) => { |
| | | this.getData(); |
| | | tooltip: { |
| | | trigger: 'axis', |
| | | formatter: params => { |
| | | let result = `${params[0].axisValue}<br>`; |
| | | params.forEach(item => { |
| | | result += `${item.marker} ${item.seriesName}: ${item.value}<br>`; |
| | | }); |
| | | return result; |
| | | } |
| | | }, |
| | | legend: { |
| | | right: '12%', |
| | | bottom: '4%', |
| | | textStyle: { |
| | | color: '#fff', |
| | | fontSize: '13' |
| | | }, |
| | | itemGap: 20, |
| | | itemWidth: 10, |
| | | itemHeight: 10, |
| | | icon: 'circle', |
| | | data: ['æåå
¥åº', 'æååºåº', '空æ¡åæµ', 'æåååº'] |
| | | }, |
| | | grid: { |
| | | left: '8%', |
| | | top: '15%', |
| | | bottom: '14%', |
| | | width: '86%', |
| | | }, |
| | | xAxis: { |
| | | type: 'category', |
| | | axisLine: { |
| | | lineStyle: { |
| | | color: '#132987' |
| | | } |
| | | }, |
| | | axisLabel: { |
| | | textStyle: { |
| | | color: '#FFF', |
| | | fontSize: 12 |
| | | }, |
| | | }, |
| | | axisTick: { |
| | | show: false |
| | | }, |
| | | data: ['å è½½ä¸...'] |
| | | }, |
| | | yAxis: { |
| | | type: 'value', |
| | | axisLabel: { |
| | | textStyle: { |
| | | color: '#fff', |
| | | fontSize: 12, |
| | | }, |
| | | }, |
| | | axisLine: { |
| | | show: false, |
| | | }, |
| | | axisTick: { |
| | | show: false |
| | | }, |
| | | splitLine: { |
| | | show: true, |
| | | lineStyle: { |
| | | color: '#132987', |
| | | } |
| | | }, |
| | | }, |
| | | series: [ |
| | | { name: 'æåå
¥åº', type: 'line', data: [] }, |
| | | { name: 'æååºåº', type: 'line', data: [] }, |
| | | { name: '空æ¡åæµ', type: 'line', data: [] }, |
| | | { name: 'æåååº', type: 'line', data: [] } |
| | | ] |
| | | }; |
| | | this.timer = setInterval( |
| | | looper, |
| | | this.$store.state.setting.echartsAutoTime |
| | | ); |
| | | }, |
| | | }, |
| | | async fetchData() { |
| | | this.loading = true; |
| | | this.error = null; |
| | | |
| | | try { |
| | | console.log('æ£å¨è¯·æ±æ°æ®...'); |
| | | const response = await GetProWeekTasks({}); |
| | | console.log('宿´ååº:', response); // æå°å®æ´ååºæ¥çç»æ |
| | | |
| | | // ç´æ¥ä½¿ç¨responseä½ä¸ºæ°æ®ï¼æ ¹æ®å®é
ååºç»æè°æ´ï¼ |
| | | if (!response || !response.dateRange || !response.dailyStatistics) { |
| | | throw new Error('æ°æ®æ ¼å¼ä¸æ£ç¡®'); |
| | | } |
| | | |
| | | this.updateChart(response); // ç´æ¥ä¼ å
¥responseï¼èéresponse.data |
| | | } catch (error) { |
| | | console.error('è·åæ°æ®é误:', error); |
| | | this.error = error.message; |
| | | this.initEmptyChart(); |
| | | } finally { |
| | | this.loading = false; |
| | | } |
| | | }, |
| | | updateChart(data) { |
| | | |
| | | |
| | | const dates = data.dateRange; |
| | | const stats = data.dailyStatistics; |
| | | |
| | | const seriesData = { |
| | | 'æåå
¥åº': [], |
| | | 'æååºåº': [], |
| | | '空æ¡åæµ': [], |
| | | 'æåååº': [] |
| | | }; |
| | | |
| | | // æ ¹æ®å®é
æ°æ®æ ¼å¼è°æ´å段åï¼å°åå¼å¤´ï¼ |
| | | stats.forEach(day => { |
| | | seriesData['æåå
¥åº'].push(day.inProduct || 0); |
| | | seriesData['æååºåº'].push(day.outProduct || 0); |
| | | seriesData['空æ¡åæµ'].push(day.emptyProductBack || 0); |
| | | seriesData['æåååº'].push(day.inProductBack || 0); |
| | | }); |
| | | |
| | | this.options = { |
| | | ...this.options, |
| | | xAxis: { |
| | | ...this.options.xAxis, |
| | | data: dates |
| | | }, |
| | | series: this.options.series.map(series => ({ |
| | | ...series, |
| | | data: seriesData[series.name] || [] |
| | | })) |
| | | }; |
| | | }, |
| | | startAutoRefresh() { |
| | | this.stopAutoRefresh(); |
| | | this.timer = setInterval(() => { |
| | | this.fetchData(); |
| | | }, this.$store.state.setting.echartsAutoTime || 10000); |
| | | }, |
| | | stopAutoRefresh() { |
| | | if (this.timer) clearInterval(this.timer); |
| | | } |
| | | } |
| | | }; |
| | | </script> |
| | | |
| | | <style lang='scss' scoped> |
| | | .user_Overview { |
| | | li { |