src/views/dashboard/BranchFactorySignage.vue
@@ -110,20 +110,7 @@
        nextNextMonthMaintenancePlanNum: 0,
        twoMaintenanceChartData: [['-', '-', '-']],
        barChart: '',
        barChartData: [
          {
            'value': '34',
            'name': '401一工段',
            'productionCode': '4215215621',
            'productionId': '1729761410329280513'
          },
          {
            'value': '77',
            'name': '401二工段',
            'productionCode': '8563354643',
            'productionId': '1729783206308302849'
          }
        ],
        barChartData: [],
        doubleBarChart: '',
        doubleBarChartData: {},
        maintenanceConfig: {},
@@ -132,13 +119,14 @@
    },
    mounted() {
      window.addEventListener('resize', this.handleWindowResize)
      this.drawCharts()
      this.getChartDataByApi()
      this.drawProblemChart()
    },
    beforeDestroy() {
      window.removeEventListener('resize', this.handleWindowResize)
    },
    methods: {
      /* 调用接口获取图表数据汇总方法 */
      getChartDataByApi() {
        this.getRunningStateDataByApi()
        this.getEfficiencyDataByApi()
@@ -146,12 +134,19 @@
        this.getWarrantyMalfunctionDataByApi()
        this.getMonthMaintenanceNumByApi()
        this.getTwoMaintenanceChartDataByApi()
        // this.getBarChartDataByApi()
        this.getBarChartDataByApi()
        this.getDoubleBarChartDataByApi()
      },
      /* 调用接口获取设备运行状态 */
      getRunningStateDataByApi() {
        this.runningStateChart = this.$echarts.init(document.getElementById('running_state_chart'))
        this.runningStateChart.showLoading({
          text: '数据加载中 ...',
          color: '#0696e1', // 加载动画颜色
          textColor: '#fff',
          maskColor: 'rgba(1, 25, 75, 0.2)' // 遮罩层
        })
        signageApi.getEquipmentStatusStatisticsApi(this.productionCode)
          .then(res => {
            if (res.success) this.runningStateData = res.result.list
@@ -161,6 +156,13 @@
      /* 调用接口获取设备利用率 */
      getEfficiencyDataByApi() {
        this.efficiencyChart = this.$echarts.init(document.getElementById('efficiency_chart'))
        this.efficiencyChart.showLoading({
          text: '数据加载中 ...',
          color: '#0696e1', // 加载动画颜色
          textColor: '#fff',
          maskColor: 'rgba(1, 25, 75, 0.2)' // 遮罩层
        })
        signageApi.getEquipmentUtilizationStatisticsApi(this.productionCode)
          .then(res => {
            if (res.success) this.efficiencyData = res.result
@@ -170,9 +172,16 @@
      /* 调用接口获取技术状态 */
      getTechConditionDataByApi() {
        this.techConditionChart = this.$echarts.init(document.getElementById('tech_condition_chart'))
        this.techConditionChart.showLoading({
          text: '数据加载中 ...',
          color: '#0696e1', // 加载动画颜色
          textColor: '#fff',
          maskColor: 'rgba(1, 25, 75, 0.2)' // 遮罩层
        })
        signageApi.getEquipmentTechnologyStatusListApi(this.productionCode)
          .then(res => {
            if (res.success) {
            if (res.success && res.result) {
              this.techConditionData = [
                { value: res.result[0].qualifiedCount, name: '合格' },
                { value: res.result[0].disabledCount, name: '禁用' },
@@ -185,9 +194,16 @@
      /* 调用接口获取设备报修故障 */
      getWarrantyMalfunctionDataByApi() {
        this.warrantyMalfunctionChart = this.$echarts.init(document.getElementById('warranty_malfunction_chart'))
        this.warrantyMalfunctionChart.showLoading({
          text: '数据加载中 ...',
          color: '#0696e1', // 加载动画颜色
          textColor: '#fff',
          maskColor: 'rgba(1, 25, 75, 0.2)' // 遮罩层
        })
        signageApi.getReportRepairEquipmentListApi(this.productionCode)
          .then(res => {
            if (res.success) {
            if (res.success && res.result) {
              this.warrantyMalfunctionData = [
                { value: res.result[0].failurTotalCount, name: '报修' },
                { value: res.result[0].stopCount, name: '停机' },
@@ -229,6 +245,13 @@
      /* 调用接口获取设备OEE统计 */
      getBarChartDataByApi() {
        this.barChart = this.$echarts.init(document.getElementById('bar_chart'))
        this.barChart.showLoading({
          text: '数据加载中 ...',
          color: '#0696e1', // 加载动画颜色
          textColor: '#fff',
          maskColor: 'rgba(1, 25, 75, 0.2)' // 遮罩层
        })
        signageApi.getEquipmentOEEStatistics(this.productionCode)
          .then(res => {
            if (res.success) this.barChartData = res.result
@@ -238,6 +261,13 @@
      /* 调用接口获取设备OEE和利用率对比 */
      getDoubleBarChartDataByApi() {
        this.doubleBarChart = this.$echarts.init(document.getElementById('double_bar_chart'))
        this.doubleBarChart.showLoading({
          text: '数据加载中 ...',
          color: '#0696e1', // 加载动画颜色
          textColor: '#fff',
          maskColor: 'rgba(1, 25, 75, 0.2)' // 遮罩层
        })
        signageApi.getEquipmentMonthStatisticsApi(this.productionCode)
          .then(res => {
            if (res.success) this.doubleBarChartData = res.result
@@ -245,21 +275,8 @@
          })
      },
      /* 绘制图表汇总方法 */
      drawCharts() {
        this.drawRunningStateChart()
        this.drawEfficiencyChart()
        this.drawTechConditionChart()
        this.drawWarrantyMalfunctionChart()
        this.drawMaintenanceChart()
        this.drawBarChart()
        this.drawDoubleBarChart()
        this.drawProblemChart()
      },
      /* 绘制设备运行状态玫瑰饼图 */
      drawRunningStateChart(productionId) {
        this.runningStateChart = this.$echarts.init(document.getElementById('running_state_chart'))
        const option = {
          title: {
            show: true, // 是否显示标题,默认为true
@@ -336,6 +353,7 @@
          ]
        }
        this.runningStateChart.setOption(option, true)
        this.runningStateChart.hideLoading()
        this.runningStateChart.on('click', params => {
          console.log('params', params)
@@ -348,7 +366,6 @@
      /* 绘制设备利用率胶囊图 */
      drawEfficiencyChart() {
        this.efficiencyChart = this.$echarts.init(document.getElementById('efficiency_chart'))
        const data = this.efficiencyData
        const colorArray = [
          {
@@ -379,7 +396,13 @@
            bottom: '#F7B7A0'
          }
        ]
        const defaultData = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100]
        const defaultData = []
        const dataMax = +data.sort((x, y) => +y.value - +x.value)[0].value
        let yAxisMax
        if (dataMax === 0) yAxisMax = 1 // 若数据中最大值为0,则将背景默认值设置为1
        else yAxisMax = Math.ceil(dataMax / 5) * 5 // 设置柱图背景阴影默认值,思路为数据最大值最接近的能被5整除的数字
        const yAxisInterval = yAxisMax / 5 // 同时将刻度值分成5份
        data.forEach(item => defaultData.push(yAxisMax))
        const option = {
          title: {
            show: true, // 是否显示标题,默认为true
@@ -422,6 +445,9 @@
              }
            },
            show: true,
            min: 0,
            max: 'dataMax',
            interval: yAxisInterval,
            type: 'value',
            axisTick: {
              show: false
@@ -537,6 +563,7 @@
        }
        option.title.text = `${moment().format('M月D日')}利用率`
        this.efficiencyChart.setOption(option, true)
        this.efficiencyChart.hideLoading()
        this.efficiencyChart.on('click', params => {
          // 点击触发的为柱状体,除此除外是标题
@@ -565,7 +592,6 @@
      /* 绘制技术状态饼图 */
      drawTechConditionChart() {
        this.techConditionChart = this.$echarts.init(document.getElementById('tech_condition_chart'))
        const option = {
          height: 300,
          title: {
@@ -640,11 +666,11 @@
          ]
        }
        this.techConditionChart.setOption(option, true)
        this.techConditionChart.hideLoading()
      },
      /* 绘制设备报修故障饼图 */
      drawWarrantyMalfunctionChart() {
        this.warrantyMalfunctionChart = this.$echarts.init(document.getElementById('warranty_malfunction_chart'))
        const option = {
          height: 300,
          title: {
@@ -719,6 +745,7 @@
          ]
        }
        this.warrantyMalfunctionChart.setOption(option, true)
        this.warrantyMalfunctionChart.hideLoading()
      },
      /* 绘制车间保养滚动表 */
@@ -739,8 +766,13 @@
      /* 绘制单柱图 */
      drawBarChart() {
        this.barChart = this.$echarts.init(document.getElementById('bar_chart'))
        const defaultData = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100]
        const defaultData = []
        const dataMax = +this.barChartData.sort((x, y) => +y.value - +x.value)[0].value
        let yAxisMax
        if (dataMax === 0) yAxisMax = 1 // 若数据中最大值为0,则将背景默认值设置为1
        else yAxisMax = Math.ceil(dataMax / 5) * 5 // 设置柱图背景阴影默认值,思路为数据最大值最接近的能被5整除的数字
        const yAxisInterval = yAxisMax / 5 // 同时将刻度值分成5份
        this.barChartData.forEach(item => defaultData.push(yAxisMax))
        const option = {
          title: {
            show: true, // 是否显示标题,默认为true
@@ -801,7 +833,9 @@
          }],
          yAxis: [{
            name: '%',
            max: 100,
            min: 0,
            max: yAxisMax,
            interval: yAxisInterval,
            axisLabel: {
              formatter: '{value}',
              color: '#e2e9ff'
@@ -857,6 +891,7 @@
        }
        option.title.text = moment().subtract(1, 'months').format('M月') + `OEE车间`
        this.barChart.setOption(option, true)
        this.barChart.hideLoading()
        this.barChart.on('click', params => {
          console.log('params', params)
@@ -874,7 +909,6 @@
      /* 绘制双柱图 */
      drawDoubleBarChart() {
        this.doubleBarChart = this.$echarts.init(document.getElementById('double_bar_chart'))
        const option = {
          color: ['#409EFF', '#0FC61A'],
          tooltip: {
@@ -1017,6 +1051,7 @@
          ]
        }
        this.doubleBarChart.setOption(option, true)
        this.doubleBarChart.hideLoading()
      },
      /* 绘制问题滚动表 */