| | |
| | | gaugeChart2: '', |
| | | gaugeChart3: '', |
| | | gaugeChart4: '', |
| | | gaugeChartData1: [], |
| | | gaugeChartData2: [], |
| | | gaugeChartData3: [], |
| | | gaugeChartData4: [], |
| | | gaugeChartData: { |
| | | utilizationRate: 0, |
| | | startRate: 0, |
| | | openRate: 0, |
| | | overallEquipmentEfficiency: 0 |
| | | }, |
| | | barChart: '', |
| | | barChartData: [], |
| | | equipmentId: '' |
| | |
| | | beforeDestroy() { |
| | | window.removeEventListener('resize', this.handleWindowResize) |
| | | if (this.barChartCarouselTime) clearInterval(this.barChartCarouselTime) |
| | | if (this.lineChartCarouselTime) clearInterval(this.lineChartCarouselTime) |
| | | }, |
| | | methods: { |
| | | getChartDataByApi() { |
| | |
| | | this.getRunningStateDataByApi() |
| | | this.getMonthMaintenanceNumByApi() |
| | | this.getLineChartDataByApi() |
| | | this.getGaugeChartDataByApi() |
| | | this.getBarChartDataByApi() |
| | | }, |
| | | |
| | |
| | | }) |
| | | }, |
| | | |
| | | /* 调用接口获取设备效率统计 */ |
| | | getGaugeChartDataByApi() { |
| | | signageApi.getEquipmentEfficiencyStatisticsApi(this.productionCode) |
| | | .then(res => { |
| | | console.log('res=', res) |
| | | if (res.success) this.gaugeChartData = res.result |
| | | this.drawGaugeChart(res.result.productionId) |
| | | }) |
| | | }, |
| | | |
| | | /* 调用接口获取上月OEE */ |
| | | getBarChartDataByApi() { |
| | | signageApi.getEquipmentOEEMonthStatisticsApi(this.productionCode) |
| | | .then(res => { |
| | | console.log('res=', res) |
| | | if (res.success) { |
| | | this.barChartData = res.result.map(item => { |
| | | return { |
| | |
| | | /* 绘制折线图 */ |
| | | drawLineChart() { |
| | | this.lineChart = this.$echarts.init(document.getElementById('line_chart')) |
| | | this.lineChartData.equipmentIdList.forEach(item => { |
| | | if (!this.lineChartData.dataList.map(item => item.equipmentId).includes(item)) { |
| | | const equipmentIdObj = { |
| | | equipmentId: item, |
| | | openRate: 0, |
| | | startRate: 0, |
| | | utilizationRate: 0 |
| | | } |
| | | this.lineChartData.dataList.push(equipmentIdObj) |
| | | } |
| | | }) |
| | | const equipmentIdList = this.lineChartData.dataList.map(item => item.equipmentId) |
| | | const newData = { |
| | | xAxis: this.lineChartData.dateList, |
| | | xAxis: equipmentIdList, |
| | | yAxis: [ |
| | | { |
| | | name: '利用率', |
| | |
| | | } |
| | | } |
| | | ], |
| | | series: seriesData |
| | | // dataZoom: { |
| | | // show: false, |
| | | // startValue: 0, // 从头开始。 |
| | | // endValue: 5 // 一次性展示几个 |
| | | // } |
| | | series: seriesData, |
| | | dataZoom: { |
| | | show: false, |
| | | startValue: 0, // 从头开始。 |
| | | endValue: 6 // 一次性展示几个 |
| | | } |
| | | } |
| | | this.lineChart.setOption(option, true) |
| | | |
| | | if (this.lineChartData.equipmentIdList.length <= 7) return |
| | | this.lineChartCarouselTime = setInterval(() => { |
| | | newData.xAxis.push(newData.xAxis.shift()) |
| | | newData.yAxis.forEach(item => item.value.push(item.value.shift())) |
| | | this.$nextTick(() => { |
| | | this.lineChart.setOption(option, true) |
| | | }) |
| | | }, 3000) |
| | | }, |
| | | |
| | | /* 绘制仪表盘图表 */ |
| | |
| | | } |
| | | }, |
| | | tooltip: { |
| | | trigger: 'item', |
| | | formatter: params => { |
| | | return params.seriesName + ':' + params.value + '%' |
| | | } |
| | |
| | | drawGaugeChart1(opt) { |
| | | this.gaugeChart1 = this.$echarts.init(document.getElementById('gauge_chart1')) |
| | | const option = Object.assign({}, opt) |
| | | option.title.text = '利用率' |
| | | option.title.text = moment().subtract(1, 'days').format('M月D日') + `利用率` |
| | | option.series[0].name = '利用率' |
| | | option.series[0].data = [52] |
| | | option.series[0].data = [this.gaugeChartData.utilizationRate] |
| | | this.gaugeChart1.setOption(option, true) |
| | | |
| | | this.gaugeChart1.getZr().on('click', params => { |
| | | // 仅有点击表盘区域才会有以下属性,topTarget表示触发事件对象,shape表示触发事件对象的图像属性,clockwise表示表盘是否以顺时针排列,默认为true |
| | | if (params.topTarget && params.topTarget.shape && params.topTarget.shape.clockwise !== undefined) { |
| | | this.$router.push({ |
| | | name: 'mdc-base-StatisticsChart', |
| | | params: { |
| | | isEquipment: false, |
| | | productionId: this.gaugeChartData.productionId, |
| | | tierName: this.gaugeChartData.productionName |
| | | } |
| | | }) |
| | | } |
| | | }) |
| | | }, |
| | | |
| | | /* 绘制开动率仪表盘图表 */ |
| | | drawGaugeChart2(opt) { |
| | | this.gaugeChart2 = this.$echarts.init(document.getElementById('gauge_chart2')) |
| | | const option = Object.assign({}, opt) |
| | | option.title.text = '开动率' |
| | | option.title.text = moment().subtract(1, 'days').format('M月D日') + '开动率' |
| | | option.series[0].name = '开动率' |
| | | option.series[0].data = [21] |
| | | option.series[0].data = [this.gaugeChartData.startRate] |
| | | this.gaugeChart2.setOption(option, true) |
| | | |
| | | this.gaugeChart2.getZr().on('click', params => { |
| | | // 仅有点击表盘区域才会有以下属性,topTarget表示触发事件对象,shape表示触发事件对象的图像属性,clockwise表示表盘是否以顺时针排列,默认为true |
| | | if (params.topTarget && params.topTarget.shape && params.topTarget.shape.clockwise !== undefined) { |
| | | this.$router.push({ |
| | | name: 'mdc-base-StatisticsChart', |
| | | params: { |
| | | isEquipment: false, |
| | | productionId: this.gaugeChartData.productionId, |
| | | tierName: this.gaugeChartData.productionName |
| | | } |
| | | }) |
| | | } |
| | | }) |
| | | }, |
| | | |
| | | /* 绘制开机率仪表盘图表 */ |
| | | drawGaugeChart3(opt) { |
| | | this.gaugeChart3 = this.$echarts.init(document.getElementById('gauge_chart3')) |
| | | const option = Object.assign({}, opt) |
| | | option.title.text = '开机率' |
| | | option.title.text = moment().subtract(1, 'days').format('M月D日') + '开机率' |
| | | option.series[0].name = '开机率' |
| | | option.series[0].data = [74] |
| | | option.series[0].data = [this.gaugeChartData.openRate] |
| | | this.gaugeChart3.setOption(option, true) |
| | | |
| | | this.gaugeChart3.getZr().on('click', params => { |
| | | // 仅有点击表盘区域才会有以下属性,topTarget表示触发事件对象,shape表示触发事件对象的图像属性,clockwise表示表盘是否以顺时针排列,默认为true |
| | | if (params.topTarget && params.topTarget.shape && params.topTarget.shape.clockwise !== undefined) { |
| | | this.$router.push({ |
| | | name: 'mdc-base-StatisticsChart', |
| | | params: { |
| | | isEquipment: false, |
| | | productionId: this.gaugeChartData.productionId, |
| | | tierName: this.gaugeChartData.productionName |
| | | } |
| | | }) |
| | | } |
| | | }) |
| | | }, |
| | | |
| | | /* 绘制OEE仪表盘图表 */ |
| | | drawGaugeChart4(opt) { |
| | | this.gaugeChart4 = this.$echarts.init(document.getElementById('gauge_chart4')) |
| | | const option = Object.assign({}, opt) |
| | | option.title.text = 'OEE' |
| | | option.title.text = moment().subtract(1, 'months').format('M月') + `OEE` |
| | | option.series[0].name = 'OEE' |
| | | option.series[0].data = [88] |
| | | option.series[0].data = [this.gaugeChartData.overallEquipmentEfficiency] |
| | | this.gaugeChart4.setOption(option, true) |
| | | |
| | | this.gaugeChart4.getZr().on('click', params => { |
| | | // 仅有点击表盘区域才会有以下属性,topTarget表示触发事件对象,shape表示触发事件对象的图像属性,clockwise表示表盘是否以顺时针排列,默认为true |
| | | if (params.topTarget && params.topTarget.shape && params.topTarget.shape.clockwise !== undefined) { |
| | | this.$router.push({ |
| | | name: 'mdc-base-StatisticsChart', |
| | | params: { |
| | | isEquipment: false, |
| | | productionId: this.gaugeChartData.productionId, |
| | | tierName: this.gaugeChartData.productionName |
| | | } |
| | | }) |
| | | } |
| | | }) |
| | | }, |
| | | |
| | | /* 绘制单柱图 */ |
| | |
| | | } |
| | | option.title.text = `${moment().subtract(1, 'months').format('M')}月OEE` |
| | | this.barChart.setOption(option, true) |
| | | |
| | | if (this.barChartData.length <= 6) return |
| | | this.barChartCarouselTime = setInterval(() => { |
| | | this.barChartData.push(this.barChartData.shift()) |