From 27fa305bf0c3a4405366a966c28b4d32203106b8 Mon Sep 17 00:00:00 2001 From: yangfeng <wanwan926_4@163.com> Date: 星期二, 05 十二月 2023 16:32:46 +0800 Subject: [PATCH] 人员生产效率、物料需求统计 --- src/views/cockpitPage/components/PerSonnelProductivity.vue | 65 ++++++++++++++++---------------- 1 files changed, 33 insertions(+), 32 deletions(-) diff --git a/src/views/cockpitPage/components/PerSonnelProductivity.vue b/src/views/cockpitPage/components/PerSonnelProductivity.vue index 193499c..27a0c8b 100644 --- a/src/views/cockpitPage/components/PerSonnelProductivity.vue +++ b/src/views/cockpitPage/components/PerSonnelProductivity.vue @@ -16,46 +16,49 @@ import ChartTitle from "@/views/cockpitPage/components/ChartTitle.vue"; //寮曞叆echart import * as echarts from "echarts"; +let myChart; export default { components: { ChartTitle, }, - props: {}, + props: { + chartData: { + type: Object, + require: true, + default: () => { + return { + datax: [], + datay: [], + }; + }, + }, + }, data() { return { - chartData: { - datax: [ - "浜哄憳1", - "浜哄憳2", - "浜哄憳3", - "浜哄憳4", - "浜哄憳5", - "浜哄憳6", - "浜哄憳7", - "浜哄憳8", - "浜哄憳9", - ], - datay: [120, 200, 150, 380, 470, 150, 230, 330, 190, 440], - }, + startValue: 0, + endValue: 5, + chartTimer: null, }; }, - mounted() { - this.pieChart("chart", this.chartData); - let chartData2 = [ - { value: 10, name: "涓�绫�" }, - { value: 20, name: "浜岀被" }, - { value: 60, name: "涓夌被" }, - { value: 10, name: "鍥涚被" }, - ]; - this.getChartRight("chart2", chartData2); + watch: { + "chartData.datay"(val) { + this.startValue = 0; + this.endValue = 5; + this.pieChart("chart", this.chartData); + }, }, - watch: {}, + mounted() {}, methods: { //鍦ㄨ亴 pieChart(chartName, data) { let that = this; + clearInterval(this.chartTimer); let chartDom = this.$refs[chartName]; - let myChart = echarts.init(chartDom); + // let myChart = echarts.init(chartDom); + if (myChart != null && myChart != "" && myChart != undefined) { + myChart.dispose(); //閿�姣� + } + myChart = echarts.init(chartDom); let option; let lineColor = "#35ddc74d"; if (data) { @@ -78,8 +81,8 @@ type: "inside", yAxisIndex: 0, show: false, - startValue: 0, // 浠庡ご寮�濮� - endValue: 5, // 涓�娆℃�у睍绀哄嚑涓� + startValue: this.startValue, // 浠庡ご寮�濮� + endValue: this.endValue, // 涓�娆℃�у睍绀哄嚑涓� }, ], legend: { @@ -183,10 +186,8 @@ }, ], }; - - setInterval(function () { - // 姣忔鍚戝乏婊戝姩涓�涓紝鏈�鍚庝竴涓粠澶村紑濮嬨�� - if (option.dataZoom[0].endValue == that.chartData.datay.length) { + this.chartTimer = setInterval(function () { + if (option.dataZoom[0].endValue == data.datay.length) { option.dataZoom[0].startValue = 0; option.dataZoom[0].endValue = 5; } else { -- Gitblit v1.8.0