src/views/dashboard/WorkshopSectionSignage.vue
@@ -2,10 +2,12 @@
  <div class="page-container">
    <div class="content-container">
      <div style="width: 30%" class="left-col">
        <slot name="back_nav"></slot>
        <div class="back-nav" @click="$emit('backToLastSignage','BranchFactory')" v-if="userType>=3">
          <dv-decoration-7>上一级</dv-decoration-7>
        </div>
        <dv-border-box-9 style="padding: 15px">
          <div id="tech_condition_chart" style="width:100%;height: 230px;"></div>
          <div id="warranty_malfunction_chart" style="width:100%;height: 230px;"></div>
          <div id="tech_condition_chart" style="width:100%;height: 240px;"></div>
          <div id="warranty_malfunction_chart" style="width:100%;height: 240px;"></div>
          <div style="display: flex;">
            <div style="flex:0.5;display: flex;flex-direction:column;align-items: center">
@@ -70,12 +72,25 @@
        </dv-border-box-9>
      </div>
      <div style="width: 30%">
        <dv-border-box-9 style="padding: 30px 0">
          <div id="bar_chart" style="width:100%;height: 250px;"></div>
          <div id="double_bar_chart" style="width:100%;height: 300px;"></div>
          <div style="padding: 0 20px;">
            <dv-scroll-board :config="problemConfig" style="width:100%;height:220px"/>
        <dv-border-box-9 style="padding: 15px">
          <a-form layout="inline" @keyup.enter.native="$emit('switchToNextSignage', { signageName: 'Equipment', productionCode: equipmentId })">
            <a-form-item label="设备编号">
              <!--<a-input v-model="equipmentId" size="large"></a-input>-->
              <a-auto-complete
                v-model="equipmentId"
                placeholder="回车键查询"
                :allowClear="true"
                size="large"
              />
            </a-form-item>
          </a-form>
          <div style="display: flex;flex-wrap: wrap">
            <div id="gauge_chart1" style="width:50%;height: 200px;"></div>
            <div id="gauge_chart2" style="width:50%;height: 200px;"></div>
            <div id="gauge_chart3" style="width:50%;height: 200px;"></div>
            <div id="gauge_chart4" style="width:50%;height: 200px;"></div>
          </div>
          <div id="bar_chart" style="width:100%;height: 330px;"></div>
        </dv-border-box-9>
      </div>
    </div>
@@ -84,6 +99,7 @@
<script>
  import signageApi from '@/api/signage'
  import moment from 'moment'
  export default {
    name: 'WorkshopSectionSignage',
@@ -91,6 +107,9 @@
      productionCode: {
        type: String,
        default: ''
      },
      userType: {
        type: Number
      }
    },
    data() {
@@ -120,34 +139,58 @@
        nextNextMonthMaintenancePlanNum: 0,
        lineChart: '',
        lineChartData: [],
        gaugeChart1: '',
        gaugeChart2: '',
        gaugeChart3: '',
        gaugeChart4: '',
        gaugeChartData1: [],
        gaugeChartData2: [],
        gaugeChartData3: [],
        gaugeChartData4: [],
        barChart: '',
        barChartData: [],
        doubleBarChart: '',
        doubleBarChartData: {},
        supportPlanList: [
        barChartData: [
          {
            label: '本月三保计划',
            value: 299,
            background: '#719D8E'
            name: '2640221',
            value: 20
          },
          {
            label: '本月完成',
            value: 229,
            background: '#409EFF'
            name: '2640222',
            value: 40
          },
          {
            label: '下月三保计划',
            value: 319,
            background: '#A8985D'
            name: '2640223',
            value: 70
          },
          {
            label: '下下月三保计划',
            value: 329,
            background: '#58D9F9'
            name: '2640224',
            value: 30
          },
          {
            name: '2640225',
            value: 35
          },
          {
            name: '2640226',
            value: 80
          },
          {
            name: '2640227',
            value: 40
          },
          {
            name: '12640220',
            value: 60
          },
          {
            name: '12640221',
            value: 40
          },
          {
            name: '12640222',
            value: 35
          }
        ],
        maintenanceConfig: {},
        problemConfig: {}
        equipmentId: ''
      }
    },
    mounted() {
@@ -158,22 +201,18 @@
    activated() {
      console.log('触发activated')
      this.handleWindowResize()
      if (this.barChartCarouselTime) clearInterval(this.barChartCarouselTime)
    },
    beforeDestroy() {
      window.removeEventListener('resize', this.handleWindowResize)
      if (this.barChartCarouselTime) clearInterval(this.barChartCarouselTime)
    },
    methods: {
      backToLastSignage() {
        console.log('触发上一级')
      },
      getChartDataByApi() {
        this.getTechConditionDataByApi()
        this.getWarrantyMalfunctionDataByApi()
        this.getRunningStateDataByApi()
        this.getMonthMaintenanceNumByApi()
        this.getBarChartDataByApi()
        this.getDoubleBarChartDataByApi()
      },
      /* 调用接口获取技术状态 */
@@ -235,33 +274,14 @@
          })
      },
      /* 调用接口获取设备OEE统计 */
      getBarChartDataByApi() {
        signageApi.getEquipmentOEEStatistics(this.productionCode)
          .then(res => {
            if (res.success) this.barChartData = res.result
            this.drawBarChart()
          })
      },
      /* 调用接口获取设备OEE和利用率对比 */
      getDoubleBarChartDataByApi() {
        signageApi.getEquipmentMonthStatisticsApi(this.productionCode)
          .then(res => {
            if (res.success) this.doubleBarChartData = res.result
            this.drawDoubleBarChart()
          })
      },
      /* 绘制图表汇总方法 */
      drawCharts() {
        this.drawRunningStateChart()
        this.drawTechConditionChart()
        this.drawWarrantyMalfunctionChart()
        this.drawLineChart()
        this.drawGaugeChart()
        this.drawBarChart()
        this.drawDoubleBarChart()
        this.drawProblemChart()
      },
      /* 绘制技术状态饼图 */
@@ -311,7 +331,7 @@
            {
              type: 'pie',
              // selectedMode: "single",
              radius: ['30%', '50%'],
              radius: ['40%', '60%'],
              center: ['50%', '50%'],
              color: [
                '#0AA012',
@@ -390,7 +410,7 @@
            {
              type: 'pie',
              // selectedMode: "single",
              radius: ['30%', '50%'],
              radius: ['40%', '60%'],
              center: ['50%', '50%'],
              color: [
                '#00CED1',
@@ -468,9 +488,9 @@
          series: [
            {
              type: 'pie',
              roseType: 'angle', // 玫瑰图
              // roseType: 'angle', // 玫瑰图
              // selectedMode: "single",
              radius: ['30%', '70%'],
              radius: ['35%', '55%'],
              center: ['50%', '50%'],
              color: [
                '#686869',
@@ -484,7 +504,7 @@
                color: 'inherit',
                // textBorderColor: 'inherit',
                // textBorderWidth: 1,
                fontSize: 16,
                fontSize: 30,
                formatter: function(params) {
                  if (params.name !== '') {
                    return `${params.name}:${params.value}`
@@ -493,8 +513,8 @@
              },
              labelLine: {
                show: true,
                length2: 10,
                length: 10
                length2: 20,
                length: 30
              },
              data: this.runningStateData
            }
@@ -507,19 +527,19 @@
      drawLineChart() {
        this.lineChart = this.$echarts.init(document.getElementById('line_chart'))
        const newData = {
          xAxis: ['2640221', '2640223', '2640224', '2640225', '2640226', '2640227', '2640228', '2640229', '12640220', '12640221', '12640222'],
          xAxis: ['3月19日', '3月20日', '3月21日', '3月22日', '3月23日', '3月24日', '3月25日'],
          yAxis: [
            {
              name: '利用率',
              value: [20, 60, 55, 36, 52, 52, 63, 78, 23, 42, 65]
              value: [200, 600, 550, 360, 520, 520, 630, 780, 230, 420, 650, 700]
            },
            {
              name: '开动率',
              value: [23, 63, 44, 40, 74, 80, 60, 90, 70, 40, 70]
              value: [230, 630, 440, 400, 740, 800, 600, 900, 700, 400, 700, 400]
            },
            {
              name: '开机率',
              value: [90, 70, 40, 70, 80, 65, 73, 60, 70, 90, 40]
              value: [900, 700, 400, 700, 800, 605, 730, 600, 700, 900, 400, 605]
            }
          ],
          yAxisName: '前7天利用率'
@@ -544,7 +564,6 @@
            data: item1.value // 折线图的数据
          }
        })
        const option = {
          grid: {
            containLabel: true,
@@ -565,7 +584,7 @@
            data: legendData,
            itemGap: 10,
            textStyle: {
              fontSize: 16,
              fontSize: 14,
              color: '#ccc'
            }
          },
@@ -573,10 +592,10 @@
            triggerEvent: true,
            data: newData.xAxis || [],
            axisLabel: {
              interval: 1,
              interval: 0,
              show: true,
              fontSize: 12,
              color: '#50729A',
              color: '#50729A'
              // rotate: -30,
            },
            axisLine: {
@@ -587,7 +606,7 @@
            },
            axisTick: {
              show: true,
              alignWithLabel:true,
              alignWithLabel: true
            }
          },
          yAxis: [
@@ -598,6 +617,7 @@
                fontSize: 18,
                padding: [0, 0, 0, 80]
              },
              nameGap: 30,
              type: 'value',
              position: 'left',
              axisLine: {
@@ -622,7 +642,6 @@
              splitNumber: 5,
              axisLabel: {
                show: true,
                fontSize: 16,
                color: '#50729A'
              },
              axisLine: {
@@ -642,16 +661,166 @@
              }
            }
          ],
          series: seriesData
          series: seriesData,
          // dataZoom: {
          //   show: false,
          //   startValue: 0, // 从头开始。
          //   endValue: 5 // 一次性展示几个
          // }
        }
        this.lineChart.setOption(option, true)
        // if (newData.xAxis.length <= 6) return
        // this.lineChartCarouselTime = setInterval(() => {
        //   this.barChartData.push(this.barChartData.shift())
        //   newData.xAxis.push(newData.xAxis.shift())
        //   newData.yAxis.forEach(item => item.value.push(item.value.shift()))
        //   this.$nextTick(() => {
        //     this.lineChart.setOption(option, true)
        //   })
        // }, 3000)
      },
      /* 绘制仪表盘图表 */
      drawGaugeChart() {
        const option = {
          title: {
            show: true, // 是否显示标题,默认为true
            text: '', // 主标题文本
            x: 'center', // 标题水平安放位置,可选值为'left'、'center'、'right'或具体的水平坐标值
            y: 'top', // 标题垂直安放位置,可选值为'top'、'bottom'、'center'或具体的垂直坐标值
            textStyle: {
              // 主标题文本样式
              fontSize: 18,
              fontWeight: 'normal',
              color: '#00A8AC',
              fontWeight: 'bold'
            }
          },
          tooltip: {
            formatter: '{a} <br/>{b} : {c}%'
          },
          grid: {
            left: '1%',
            top: '1%',
            right: '10%',
            bottom: '1%'
          },
          series: [
            {
              name: '利用率',
              type: 'gauge',
              radius: '80%',
              center: ['50%', '60%'],    // 默认全局居中
              pointer: {
                width: 6,
                length: '50%',
                itemStyle: {
                  color: 'inherit'
                }
              },
              splitLine: {
                show: true,
                length: 10,
                lineStyle: {
                  color: '#fff',
                  width: 2
                }
              },
              axisTick: {
                length: 5,
                lineStyle: {
                  color: '#fff',
                  width: 1
                }
              },
              axisLabel: {
                show: false,
                fontSize: 18,
                formatter: function(value) {
                  return value + '%'
                }
              },
              axisLine: {
                lineStyle: { // 属性lineStyle控制线条样式
                  color: [ //表盘颜色
                    [0.3, '#E7781E'],//0-30%处的颜色
                    [0.7, '#C5C039'],//30%-60%处的颜色
                    [1, '#21C77F']//90%-100%处的颜色
                  ],
                  width: 15//表盘宽度
                }
              },
              detail: {
                formatter: '{score|{value}%}',
                offsetCenter: [0, '50%'],
                height: 30,
                rich: {
                  score: {
                    fontSize: 20
                  }
                }
              },
              data: [{ value: 100 }]
            }
          ]
        }
        this.drawGaugeChart1(option)
        this.drawGaugeChart2(option)
        this.drawGaugeChart3(option)
        this.drawGaugeChart4(option)
      },
      /* 绘制利用率仪表盘图表 */
      drawGaugeChart1(opt) {
        this.gaugeChart1 = this.$echarts.init(document.getElementById('gauge_chart1'))
        const option = Object.assign({}, opt)
        option.title.text = '利用率'
        this.gaugeChart1.setOption(option, true)
      },
      /* 绘制开动率仪表盘图表 */
      drawGaugeChart2(opt) {
        this.gaugeChart2 = this.$echarts.init(document.getElementById('gauge_chart2'))
        const option = Object.assign({}, opt)
        option.title.text = '开动率'
        this.gaugeChart2.setOption(option, true)
      },
      /* 绘制开机率仪表盘图表 */
      drawGaugeChart3(opt) {
        this.gaugeChart3 = this.$echarts.init(document.getElementById('gauge_chart3'))
        const option = Object.assign({}, opt)
        option.title.text = '开机率'
        this.gaugeChart3.setOption(option, true)
      },
      /* 绘制OEE仪表盘图表 */
      drawGaugeChart4(opt) {
        this.gaugeChart4 = this.$echarts.init(document.getElementById('gauge_chart4'))
        const option = Object.assign({}, opt)
        option.title.text = 'OEE'
        this.gaugeChart4.setOption(option, true)
      },
      /* 绘制单柱图 */
      drawBarChart() {
        this.barChart = this.$echarts.init(document.getElementById('bar_chart'))
        const xAisData = this.barChartData.map(item => item.name)
        const option = {
          height: 260,
          title: {
            show: true, // 是否显示标题,默认为true
            text: '上个月OEE', // 主标题文本
            x: 'center', // 标题水平安放位置,可选值为'left'、'center'、'right'或具体的水平坐标值
            y: 'top', // 标题垂直安放位置,可选值为'top'、'bottom'、'center'或具体的垂直坐标值
            textStyle: {
              // 主标题文本样式
              fontSize: 18,
              fontWeight: 'normal',
              color: '#00A8AC',
              fontWeight: 'bold'
            }
          },
          tooltip: {
            trigger: 'axis',
            axisPointer: {
@@ -666,186 +835,79 @@
          },
          grid: {
            top: '15%',
            left: '10%'
            left: '6%',
            right: '3%'
          },
          xAxis: [{
            name: 'OEE车间',
            nameLocation: 'middle',
            nameGap: 30, // x轴name与横坐标轴线的间距
            type: 'category',
            data: this.barChartData.map(item => item.name),
            axisLine: {
              lineStyle: {
                color: '#FFFFFF'
              }
            },
            axisLabel: {
              margin: 10,
              color: '#e2e9ff',
              textStyle: {
                fontSize: 12
              }
            },
            axisTick: {
              show: false
            }
          }],
          yAxis: [{
            name: '数量',
            nameLocation: 'middle',
            nameGap: 30, // x轴name与横坐标轴线的间距
            axisLabel: {
              formatter: '{value}',
              color: '#e2e9ff'
            },
            axisTick: {
              show: false
            },
            axisLine: {
              show: false,
              lineStyle: {
                color: '#FFFFFF'
              }
            },
            splitLine: {
              lineStyle: {
                color: 'rgba(255,255,255,0.12)'
              }
            }
          }],
          series: [{
            type: 'bar',
            data: this.barChartData,
            barWidth: '15%',
            itemStyle: {
              color: '#7DB17F'
            },
            label: {
              show: true,
              lineHeight: 10,
              formatter: params => {
                if (+params.value === 0) return ''
                else return params.value
          xAxis: [
            {
              // name: '上个月OEE',
              // nameLocation: 'middle',
              // nameGap: 40, // x轴name与横坐标轴线的间距
              type: 'category',
              data: xAisData,
              axisLine: {
                lineStyle: {
                  color: '#50729A'
                }
              },
              position: 'inside',
              textStyle: {
                color: '#fff',
                fontSize: 18
              axisLabel: {
                show: true, // 是否显示刻度标签,默认显示
                interval: 0, // 坐标轴刻度标签的显示间隔,在类目轴中有效;默认会采用标签不重叠的策略间隔显示标签;可以设置成0强制显示所有标签;如果设置为1,表示『隔一个标签显示一个标签』,如果值为2,表示隔两个标签显示一个标签,以此类推。
                // rotate: this.barChartData.length >= 5 ? -30 : 0, // 刻度标签旋转的角度,在类目轴的类目标签显示不下的时候可以通过旋转防止标签之间重叠;旋转的角度从-90度到90度
                inside: false, // 刻度标签是否朝内,默认朝外
                margin: 6 // 刻度标签与轴线之间的距离
              },
              axisTick: {
                show: true,
                alignWithLabel: true
              }
            }
          }]
        }
        this.barChart.setOption(option, true)
      },
      /* 绘制双柱图 */
      drawDoubleBarChart() {
        this.doubleBarChart = this.$echarts.init(document.getElementById('double_bar_chart'))
        const option = {
          color: ['#4992FF', '#4DC0B1'],
          tooltip: {
            confine: true,
            formatter: function(params) {
              return '<span style="font-weight:bolder;">' + params.name + '</span><br/>' +
                '<span style="display:inline-block; width:10px; height:10px; border-radius:100px; margin-right:5px; background:' + params.color + '"></span>' + params.seriesName + ' : ' + params.value + '%'
            }
          },
          grid: {
            left: '5%',
            right: '4%',
            bottom: '10%',
            top: '20%',
            containLabel: true
          },
          legend: {
            icon: 'roundRect',
            orient: 'horizontal',
            left: 'center',
            itemWidth: 14,
            itemHeight: 14,
            formatter: ['{a|{name}}'].join('\n'),
            textStyle: {
              fontSize: 14,
              color: '#6A93B9',
              height: 8,
              rich: {
                a: {
                  verticalAlign: 'bottom'
            }],
          yAxis: [
            {
              // name: '数量',
              // nameLocation: 'middle',
              // nameGap: 30, // x轴name与横坐标轴线的间距
              position: 'left',
              axisLabel: {
                formatter: '{value}',
                color: '#50729A'
              },
              axisTick: {
                show: false
              },
              axisLine: {
                show: true,
                lineStyle: {
                  color: '#50729A'
                }
              },
              splitLine: {
                show: false,
                lineStyle: {
                  color: 'rgba(255,255,255,0.12)'
                }
              }
            },
            data: ['OEE', '利用率']
          },
          xAxis: {
            type: 'category',
            data: this.doubleBarChartData.dateList,
            axisLine: {
              lineStyle: {
                color: 'rgba(255,255,255,0.45)'
            {
              position: 'right',
              axisLine: {
                show: true,
                lineStyle: {
                  color: '#50729A'
                }
              }
            },
            axisLabel: {
              fontSize: 12,
              color: '#6A93B9'
            },
            axisTick: {
              show: false
            }
          },
          yAxis: [{
            name: '%',
            type: 'value',
            min: 0,
            minInterval: 1,
            splitArea: {
              show: false
            },
            axisLine: {
              show: false
            },
            axisTick: {
              show: false
            },
            splitLine: {
              lineStyle: {
                color: 'rgba(255, 255, 255, 0.15)'
                // type: 'dashed', // dotted 虚线
              }
            },
            axisLabel: {
              fontSize: 12,
              color: '#6A93B9',
              fontFamily: 'Bebas'
            }
          }, {
            type: 'value',
            axisLine: {
              show: false
            },
            axisTick: {
              show: false
            },
            splitLine: {
              show: false
            },
            axisLabel: {
              fontSize: 12,
              formatter: '{value}%', // 右侧Y轴文字显示
              fontFamily: 'Bebas',
              color: '#6A93B9'
            },
            splitArea: {
              show: false
            }
          }],
          ],
          series: [{
            type: 'bar',
            barWidth: 15,
            itemStyle: { barBorderRadius: [3, 3, 0, 0] },
            name: 'OEE',
            data: this.doubleBarChartData.oeeList,
            data: this.barChartData,
            barWidth: '25%',
            itemStyle: {
              color: '#129FC6',
              barBorderRadius: [10, 10, 10, 10]
            },
            label: {
              show: true,
              show: false,
              lineHeight: 10,
              formatter: params => {
                if (+params.value === 0) return ''
@@ -853,48 +915,27 @@
              },
              position: 'inside',
              textStyle: {
                color: '#fff',
                fontSize: 12
                color: '#50729A',
                fontSize: 18
              }
            }
          }, {
            type: 'bar',
            barWidth: 15,
            itemStyle: { barBorderRadius: [3, 3, 0, 0] },
            name: '利用率',
            data: this.doubleBarChartData.utilizationList,
            label: {
              show: true,
              lineHeight: 10,
              formatter: params => {
                if (+params.value === 0) return ''
                else return params.value
              },
              position: 'inside',
              textStyle: {
                color: '#fff',
                fontSize: 12
              }
            }
          }],
          dataZoom: {
            show: false,
            startValue: 0, // 从头开始。
            endValue: 5 // 一次性展示几个
          }
          ]
        }
        this.doubleBarChart.setOption(option, true)
      },
      /* 绘制问题滚动表 */
      drawProblemChart() {
        this.problemConfig = {
          indexHeader: '序号',
          header: ['时间', '问题内容'],
          headerBGC: '#83B883',
          oddRowBGC: '#556955',
          evenRowBGC: '#556955',
          data: [],
          index: true,
          columnWidth: [100, 300, 300],
          align: ['center']
        }
        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())
          xAisData.push(xAisData.shift())
          this.$nextTick(() => {
            this.barChart.setOption(option, true)
          })
        }, 3000)
      },
      /**
@@ -902,12 +943,15 @@
       * 调整图表尺寸以适应分辨率
       */
      handleWindowResize() {
        if (this.runningStateChart) this.runningStateChart.resize()
        if (this.efficiencyChart) this.efficiencyChart.resize()
        if (this.techConditionChart) this.techConditionChart.resize()
        if (this.warrantyMalfunctionChart) this.warrantyMalfunctionChart.resize()
        if (this.runningStateChart) this.runningStateChart.resize()
        if (this.lineChart) this.lineChart.resize()
        if (this.gaugeChart1) this.gaugeChart1.resize()
        if (this.gaugeChart2) this.gaugeChart2.resize()
        if (this.gaugeChart3) this.gaugeChart3.resize()
        if (this.gaugeChart4) this.gaugeChart4.resize()
        if (this.barChart) this.barChart.resize()
        if (this.doubleBarChart) this.doubleBarChart.resize()
      }
    }
  }
@@ -936,6 +980,17 @@
      justify-content: space-between;
      .left-col {
        .back-nav {
          width: 100px;
          height: 30px;
          color: #eee;
          position: absolute;
          top: 50px;
          left: 10px;
          cursor: pointer;
          z-index: 9999
        }
        .support-plan-container {
          width: 100%;
          display: flex;
@@ -977,7 +1032,28 @@
    }
  }
  /deep/ .dv-scroll-board .header {
    height: 35px;
  /deep/ .ant-form.ant-form-inline {
    text-align: center;
    margin-bottom: 20px;
  }
  /deep/ .ant-form .ant-form-item-label label {
    color: #fff;
    font-size: 18px;
  }
  /deep/ .ant-select-selection {
    background: transparent !important;
  }
  /deep/ .ant-select-selection__clear {
    background: transparent !important;
    color: #fff;
  }
  /deep/ .ant-input {
    border: 1px solid #689ACA;
    color: #fff;
    background: transparent !important;
  }
</style>