<!--
 * @Author: zwq
 * @Date: 2021-07-19 15:18:30
 * @LastEditors: zhp
 * @LastEditTime: 2024-01-08 16:06:49
 * @Description:
-->
<template>
  <div id="container" ref="container" class="visual-container" :style="styles">
    <el-row class="container-title" :style="{
      height: 88 + 'px',
      lineHeight: 88 + 'px',
      fontSize: 31 + 'px'
    }">
      <img src="../../assets/img/logo.png" style="width:1.1em;position:relative;top:.22em" alt="">
      许昌安彩深加工看板
      <h3 class="unit">单位：河南汇融科技服务有限公司</h3>
      <h3 class="time">{{ times }}</h3>
      <!-- <el-button
        type="text"
        class="title-button"
        :style="{ right: 33 + 'px', top: 37 + 'px' }"
        @click="changeFullScreen"
      >
        <svg-icon v-if="isFullScreen" icon-class="unFullScreenView" />
        <svg-icon v-else icon-class="fullScreenView" />
      </el-button> -->
    </el-row>
    <el-row class="container-main flex-col" type="flex">
      <el-row :style="{ padding: '0 ' + 9 + 'px' }" :gutter="15" type="flex" class="flex-1" style="height: 50%;">
        <el-col :style="{ margin: 8 + 'px' + ' 0' }" :span="8" height="100%">
          <base-container :title="'设备报警'" :size="'small'" :height="318" :title-icon="'eqAlarm'">
            <base-table1 :page="1" :limit="999" :show-index="false" :table-config="qualityYearTableProps"
              :table-data="equipmentList" />
          </base-container>
        </el-col>

        <el-col :style="{ margin: 8 + 'px' + ' 0' }" :span="8" height="100%">
          <base-container :title="'各工序缺陷汇总'" :size="'small'" :title-icon="'scrap'">
            <base-table1 :page="1" :limit="999" :show-index="false" :table-config="qualityMonthTableProps"
              :table-data="qualityMonthList" />
          </base-container>
        </el-col>

        <el-col :style="{ margin: 8 + 'px' + ' 0' }" :span="8" height="100%">
          <base-container :height="318" :size="'small'" :title="'工单监控'" :title-icon="'eqMonitoring'">
            <!-- <div style="width: 45%;position: absolute; top: 3em; right: 3em;">
              <top-radio-group />
            </div> -->

            <!-- 为外部添加一个容器并显式地设置一个高度: -->
            <!-- <div style="height: 300px;"> -->
            <div style="width:100%; overflow: hidden scroll;">
              <!-- <el-row style="margin-bottom: 1em">
                    <p class="now-team-title">加工工单进度</p>
                  </el-row> -->
              <el-row v-for="op in orderList" :key="op.id" style="margin-bottom: 1em">
                <!-- <el-col :span="12"> -->
                <el-progress :percentage="op.progressRate * 100" class="custom-progress-bar" />
                <!-- <p v-if="op.progressRate === 1" class="now-secondary-title" style="color:#4679FD">
                  <i class="el-icon-check" />
                  {{ op.name }}
                </p> -->
                <p class="now-secondary-title">{{ op.name }}</p>
                <!-- </el-col> -->
              </el-row>
              <!-- <el-row>
                    <el-progress :percentage="100" class="custom-progress-bar" />
                    <p class="now-secondary-title" style="color:#4679FD">
                      <i class="el-icon-check" />
                      成都碲化镉5000一期订单
                    </p>
                  </el-row>
                  <el-row>
                    <el-progress :percentage="85" class="custom-progress-bar" />
                    <p class="now-secondary-title">成都碲化镉二订单</p>
                  </el-row>
                  <el-row>
                    <el-progress :percentage="85" class="custom-progress-bar" />
                    <p class="now-secondary-title">长利订单1000</p>
                  </el-row>
                  <el-row>
                    <el-progress :percentage="85" class="custom-progress-bar" />
                    <p class="now-secondary-title">国际工程20号订单</p>
                  </el-row>
                  <el-row>
                    <el-progress :percentage="85" class="custom-progress-bar" />
                    <p class="now-secondary-title">铜铟镓硒眉山10万订单</p>
                  </el-row> -->
            </div>
            <!-- </div> -->
          </base-container>
        </el-col>
      </el-row>

      <el-row :style="{ padding: '0 ' + 9 + 'px' }" :gutter="12" type="flex" class="flex-1">
        <el-col :style="{ margin: 8 + 'px' + ' 0' }" :span="12">
          <base-container :height="256" :size="'middle'" :title="'能源监控'" :title-icon="'energyMonitoring'">
            <!-- <div style="width: 45%;position: absolute; top: 3em; right: 3em;">
              <top-radio-group />
            </div> -->
            <el-row :gutter="9">
              <el-col :style="{ margin: 8 + 'px' + ' 0' }" :span="24">
                <linear-bar-chart ref="EnergyMonitoringChart" :name-list="EnergyMonitoringNameList"
                  :data-list="EnergyMonitoringList" :height="359" />
              </el-col>
              <!-- <el-col :style="{ margin: 8 + 'px' + ' 0' }" :span="12">
                <base-table3
                  :page="2"
                  :limit="5"

                  :table-config="qualityTableProps2"
                  :table-data="qualityList2"
                />
              </el-col> -->
            </el-row>
          </base-container>
        </el-col>
        <el-col :style="{ margin: 8 + 'px' + ' 0' }" :span="12">
          <base-container :height="318 + 338 + 16" :size="'middle'" :title="'产线产量及良品率'" :title-icon="'productLine'">
            <!-- <div style="width: 45%;position: absolute; top: 3em; right: 3em;">
              <top-radio-group />
            </div> -->
            <!-- 像下面这样表格里的limit值，也许可以用js动态计算出来 -->
            <double-y-chart ref="productLineChart" :id=" 'doubleYChart' " :name-list="cxNameList"
              :data-list="cxDataList" :height="359" :show-legend="true" />
          </base-container>
        </el-col>
      </el-row>

      <!-- end  -->
      <!-- <el-col :span="16">
              <el-row>
                <el-col :style="{ margin: 8 + 'px' + ' 0' }" :span="24">
                  <base-container  :height="672">
                    <base-video :video-height="624"  />
                  </base-container>
                </el-col>
              </el-row>
            </el-col>
      -->
    </el-row>
  </div>
</template>

<script>
import baseContainer from './components/baseContainer'
import baseTable1 from './components/baseTable'
// import baseTable2 from './components/baseTable'
// import baseTable3 from './components/baseTable'
import TopRadioGroup from './components/topRadioGroup'
// import pieChart1 from './components/PieChart'
// import pieChart2 from './components/PieChart'
// import pieChart3 from './components/PieChart'
// import { mapGetters } from 'vuex'
import screenfull from 'screenfull'
// import BaseVideo from './components/baseVideo.vue'
import alarmLevel from './components/alarmLevel'
// import axios from '@/utils/request'
import doubleYChart from './components/doubleYChart '
// import elementResizeDetectorMaker from 'element-resize-detector';
// var erd = elementResizeDetectorMaker(); //创建实例
// let resizeFun = null

import LinearBarChart from './components/linearBarChart'
const qualityTableProps1 = [
  {
    prop: 'name',
    label: '产线名称'
  },
  {
    prop: 'createTime',
    label: '发生时间'
  },
  {
    prop: 'code',
    label: '质量编码'
  },
  {
    prop: 'content',
    label: '质量内容'
  }
]
const qualityTableProps2 = [
  {
    prop: 'name',
    label: '工序名称'
  },
  {
    prop: 'createTime',
    label: '发生时间'
  },
  {
    prop: 'code',
    label: '质量编码'
  },
  {
    prop: 'content',
    label: '质量内容'
  }
]
const cxNameList = ['周一', '周二', '周三', '周四', '周五']

const cxDataList = [
  {
    topColor: '#9DD5FF',
    bottomColor: '#1295FF',
    name: '电耗能',
    data: [100, 150, 121, 97, 140]
  },
  {
    topColor: '#FF8BC3',
    bottomColor: '#EB46A1',
    name: '水耗能',
    data: [110, 110, 151, 77, 110]
  },
  {
    topColor: '#85F6E9',
    bottomColor: '#2EC6B4',
    name: '天然气',
    data: [110, 120, 171, 287, 40]
  },
  {
    topColor: '#9496FF',
    bottomColor: '#6567FF',
    name: '焦炉煤气',
    data: [140, 157, 122, 27, 240]
  },
  {
    topColor: '#F68E8A',
    bottomColor: '#E95552',
    name: '余热发电',
    data: [170, 180, 127, 17, 340]
  },
  {
    topColor: '#FFE873',
    bottomColor: '#E7AE2A',
    name: '二氧化硫',
    data: [140, 160, 121, 57, 170]
  }
]

const qualityList1 = [
  { name: '钢一线', createTime: '2021.10.21 24:59:59', code: '2121321231', content: '气泡' },
  { name: '钢二线', createTime: '2021.11.22 24:59:59', code: '3321123213', content: '气泡' },
  { name: '钢三线', createTime: '2021.12.12 24:59:59', code: '4535435345', content: '气泡' },
  { name: '钢四线', createTime: '2021.12.20 24:59:59', code: '5465465466', content: '气泡' },
  { name: '钢五线', createTime: '2021.12.02 24:59:59', code: '2132131312', content: '气泡' },
  { name: '钢一线', createTime: '2021.10.21 24:59:59', code: '2121321231', content: '气泡' },
  { name: '钢二线', createTime: '2021.11.22 24:59:59', code: '3321123213', content: '气泡' },
  { name: '钢三线', createTime: '2021.12.12 24:59:59', code: '4535435345', content: '气泡' },
  { name: '钢四线', createTime: '2021.12.20 24:59:59', code: '5465465466', content: '气泡' },
  { name: '钢五线', createTime: '2021.12.02 24:59:59', code: '2132131312', content: '气泡' },
  { name: '钢一线', createTime: '2021.10.21 24:59:59', code: '2121321231', content: '气泡' },
  { name: '钢二线', createTime: '2021.11.22 24:59:59', code: '3321123213', content: '气泡' },
  { name: '钢三线', createTime: '2021.12.12 24:59:59', code: '4535435345', content: '气泡' },
  { name: '钢四线', createTime: '2021.12.20 24:59:59', code: '5465465466', content: '气泡' },
  { name: '钢五线', createTime: '2021.12.02 24:59:59', code: '2132131312', content: '气泡' },
  { name: '钢六线', createTime: '2021.12.11 24:59:59', code: '2132131212', content: '气泡' }
]
const qualityList2 = [
  { name: '上片', createTime: '2021.10.22 24:59:59', code: '2132132133', content: '气泡' },
  { name: '磨边', createTime: '2021.12.21 24:59:59', code: '2132131232', content: '气泡' },
  { name: '清洗', createTime: '2021.12.12 24:59:59', code: '1232131312', content: '气泡' },
  { name: '激光打孔', createTime: '2021.12.13 24:59:59', code: '2132132131', content: '气泡' },
  { name: 'AR镀膜', createTime: '2021.10.23 24:59:59', code: '2311212232', content: '气泡' },
  { name: '固化', createTime: '2021.09.22 24:59:59', code: '21321321312', content: '气泡' },
  { name: '清洗', createTime: '2021.12.12 24:59:59', code: '1232131312', content: '气泡' },
  { name: '激光打孔', createTime: '2021.12.13 24:59:59', code: '2132132131', content: '气泡' },
  { name: 'AR镀膜', createTime: '2021.10.23 24:59:59', code: '2311212232', content: '气泡' },
  { name: '固化', createTime: '2021.09.22 24:59:59', code: '21321321312', content: '气泡' },
  { name: '上片', createTime: '2021.10.22 24:59:59', code: '2132132133', content: '气泡' },
  { name: '磨边', createTime: '2021.12.21 24:59:59', code: '2132131232', content: '气泡' },
  { name: '清洗', createTime: '2021.12.12 24:59:59', code: '1232131312', content: '气泡' },
  { name: '激光打孔', createTime: '2021.12.13 24:59:59', code: '2132132131', content: '气泡' },
  { name: 'AR镀膜', createTime: '2021.10.23 24:59:59', code: '2311212232', content: '气泡' },
  { name: '固化', createTime: '2021.09.22 24:59:59', code: '21321321312', content: '气泡' },
  { name: '丝网印刷', createTime: '2021.12.21 24:59:59', code: '21321322132', content: '气泡' },
  { name: '钢化炉', createTime: '2021.12.20 24:59:59', code: '21321312321', content: '气泡' },
  { name: '检测设备', createTime: '2021.12.12 24:59:59', code: '21321322132', content: '气泡' },
  { name: '包装设备', createTime: '2021.12.23 24:59:59', code: '39284982931', content: '气泡' }
]
const legendData1 = [
  {
    name: '设备1',
    icon: 'circle',
    value: 196
  },
  {
    name: '设备2',
    icon: 'circle',
    value: 147
  },
  {
    name: '设备3',
    icon: 'circle',
    value: 24
  },
  {
    name: '设备4',
    icon: 'circle',
    value: 85
  },
  {
    name: '设备5',
    icon: 'circle',
    value: 8
  },
  {
    name: '设备6',
    icon: 'circle',
    value: 112
  },
  {
    name: '设备7',
    icon: 'circle',
    value: 146
  },
  {
    name: '设备8',
    icon: 'circle',
    value: 27
  },
  {
    name: '设备9',
    icon: 'circle',
    value: 2
  },
  {
    name: '设备10',
    icon: 'circle',
    value: 90
  }
]
const legendData2 = [
  {
    name: '磨边',
    icon: 'circle',
    value: 196
  },
  {
    name: '清洗',
    icon: 'circle',
    value: 135
  },
  {
    name: '固化',
    icon: 'circle',
    value: 144
  },
  {
    name: '镀膜',
    icon: 'circle',
    value: 97
  },
  {
    name: '激光打孔',
    icon: 'circle',
    value: 12
  },
  {
    name: '丝网印刷',
    icon: 'circle',
    value: 10
  },
  {
    name: '钢化炉',
    icon: 'circle',
    value: 3
  }
]
const legendData3 = [
  {
    name: '钢一线',
    icon: 'circle',
    value: 196
  },
  {
    name: '钢二线',
    icon: 'circle',
    value: 133
  },
  {
    name: '钢三线',
    icon: 'circle',
    value: 24
  },
  {
    name: '钢四线',
    icon: 'circle',
    value: 77
  },
  {
    name: '钢五线',
    icon: 'circle',
    value: 77
  }
]
const qualityYearTableProps = [
  {
    prop: 'name',
    label: '设备名称'
  },
  {
    prop: 'code',
    label: '设备编码'
  },
  {
    prop: 'status',
    label: '设备状态',
    // subcomponent: alarmLevel,
    align: 'center'
  },
  {
    prop: 'error',
    label: '是否故障'
  }
]

const qualityYearList = [
  { eqName: '钢化炉', eqCode: '21321312', level: 1, content: 'Temperature high' },
  { eqName: '磨边机', eqCode: '32323232', level: 4, content: 'Device warning/alarm' },
  { eqName: '镀膜机', eqCode: '32213213', level: 3, content: 'Temperature high' },
  { eqName: '钢化清洗机', eqCode: '21321323', level: 1, content: 'P030: JET: Note: Transportation subsequent machine is not running' },
  { eqName: '固化机', eqCode: '21321321', level: 2, content: 'P040' },
  { eqName: '磨边清洗机', eqCode: '21321321', level: 2, content: 'M4033.6' },
  { eqName: '预热机', eqCode: '21321321', level: 2, content: 'M4033.6' },
  { eqName: '下片机', eqCode: '21321321', level: 3, content: 'P040' },
  {
    eqName: '冷却机', eqCode: '21321321', level: 4, content: 'P0xx: Pos. number exhaust UVnumber: Reserve' },
  {
    eqName: 'A储片机106', eqCode: '21321321', level: 1, content: 'P0xx: Pos. number exhaust UVnumber: Reserve' },
  { eqName: '二次清洗机', eqCode: '21321321', level: 2, content: 'Temperature high' },
  { eqName: '二次磨边机', eqCode: '21321321', level: 2, content: 'Temperature high' },
  { eqName: '测试设备', eqCode: '21321321', level: 2, content: 'Temperature high' }

]
const qualityMonthTableProps = [
  {
    prop: 'productionLineName',
    label: '产线名'
  },
  {
    prop: 'sectionName',
    label: '工序'
  },
  {
    prop: 'count',
    label: '损耗片数'
  },
  {
    prop: 'inspectionTypeName',
    label: '缺陷类型'
  },
]

const orderProcessList = [
  {
    id: '1', outRate: '.8', name: '凯盛0322'
  }, {
    id: '2', outRate: '.4', name: '光伏玻璃4.0'
  }, {
    id: '3', outRate: '.5', name: '光伏玻璃3.0'
  }, {
    id: '4', outRate: '.3', name: '光伏玻璃2.0'
  }, {
    id: '5', outRate: '.5', name: '光伏玻璃1.0'
  }, {
    id: '6', outRate: '.8', name: '光伏玻璃'
  },
  {
    id: '7', outRate: '.8', name: '统计订单'
  }
]
export default {
  name: 'ProductionMonitoringCockpit',
  components: {
    baseContainer,
    baseTable1,
    // baseTable2,
    // baseTable3,
    TopRadioGroup,
    doubleYChart,
    LinearBarChart
    // pieChart1,
    // pieChart2
    // pieChart3
    // BaseVideo
  },
  data() {
    return {
      beilv2: 1,
      beilv: 1,
      value: 100,
      orderList:[],
      times: '',
      EnergyMonitoringNameList: [],
      equipmentList:[],
      EnergyMonitoringList: [],
      // offsetWidth: null,
      qualityYearTableProps,
      cxNameList,
      cxDataList,
      productLineList:[],
      qualityYearList,
      clientWidth: 0,
      containerWidth: 111111,
      isFullScreen: false,
      // orderProcessList: [],
      orderProcessList,
      qualityTableProps1,
      qualityMonthList:[],
      qualityMonthTableProps,
      modelMonth: '',
      qualityList1,
      qualityTableProps2,
      qualityList2,
      dateType: '0',
      legendData1,
      legendData2,
      legendData3
    }
  },
  computed: {
    // ...mapGetters(['sidebar']),
    styles() {
      const v = Math.floor(this.value * this.beilv2 * 100) / 10000
      return {
        transform: `scale(${v})`,
        transformOrigin: 'top left'
      }
    }
  },

  watch: {
    clientWidth(val) {
      if (!this.timer) {
        this.clientWidth = val
        this.beilv2 = this.clientWidth / 1920
        this.timer = true
        let _this = this
        setTimeout(function () {
          _this.timer = false
        }, 500)
      }
      // 这里可以添加修改时的方法
      this.windowWidth(val);
    }
  },
  created() {
    // this.fetchList('exception-alarm')
    // this.fetchList('inAndOutOfEachLine')
    // this.fetchList('order-process')
    // this.fetchList('line-chart-data')
    this.init()
  },
  mounted() {
    this.getList()
    this.initWebSocket()
    this.SJGInitWebSocket()
    this.getTimes()
    const _this = this;
    _this.beilv2 = document.documentElement.clientWidth / 1920
    window.onresize = () => {
      return (() => {
        _this.clientWidth = `${document.documentElement.clientWidth}`
        this.beilv2 = _this.clientWidth / 1920
      })()
    }
    // const _this = this;
    // window.onresize = () => {
    //   return (() => {
    //     _this.clientWidth = `${document.documentElement.clientWidth}`
    //     this.beilv2 = _this.clientWidth / 1920
    //   })()
    // }
    // this.beilv2 = window.innerWidth / 1920
    // addEventListener('resize', resizeFun = () => {
    //   this.beilv2 = window.innerWidth / 1920
    // })
    // erd.listenTo(document, (element) => {
    //   console.log(element.offsetWidth)
    //   this.beilv2 = element.offsetWidth / 1920

    //   // var width = element.offsetWidth;
    //   // var height = element.offsetHeight;
    // });
  },
  // beforeDestroy() {
  //   //离开页面删除检测器和所有侦听器
  //   // erd.uninstall(document); //这里用ref是因为vue离开页面后获取不到dom
  //   removeEventListener('resize', resizeFun)
  // },
  methods: {
    getList() {
      this.$axios.get(
        'base/core-production-line/listAll',
        'get',
        this.queryParams
      ).then((res) => {
        // console.log('11111', res);
        this.productLineList = res.data
      })
      this.$axios.get(
        'base/quality-inspection-record/dayStatistics',
        'get',
      ).then((res) => {
        // console.log('11111', res);
        this.qualityMonthList = res.data ? res.data : []
      })
    },
    getTimes() {
      setInterval(this.getTimesInterval, 1000);
    },
    getTimesInterval: function () {
      let _this = this;
      let year = new Date().getFullYear(); //获取当前时间的年份
      let month = new Date().getMonth() + 1; //获取当前时间的月份
      let day = new Date().getDate(); //获取当前时间的天数
      let hours = new Date().getHours(); //获取当前时间的小时
      let minutes = new Date().getMinutes(); //获取当前时间的分数
      let seconds = new Date().getSeconds(); //获取当前时间的秒数
      //当小于 10 的是时候，在前面加 0
      if (hours < 10) {
        hours = "0" + hours;
      }
      if (minutes < 10) {
        minutes = "0" + minutes;
      }
      if (seconds < 10) {
        seconds = "0" + seconds;
      }
      //拼接格式化当前时间
      this.times = year + "-" + month + "-" + day + " " + hours + ":" + minutes + ":" + seconds;
    },
    initWebSocket() {
      if (typeof (WebSocket) === 'undefined') {
        alert('您的浏览器不支持WebSocket')
      } else {
        let date = new Date().valueOf()
        const wsUrl = process.env.VUE_APP_Socket_API + `/websocket/message?userId=EN${date}`
        // const wsUrl = 'ws://192.168.1.104:48082/websocket/message?userId=SJG'
        // const wsUrl = 'ws://10.70.2.2:8080/websocket/message?userId=EN111'
        // 实例化 WebSocket
        this.websocket = new WebSocket(wsUrl)
        // 监听 WebSocket 连接
        this.websocket.onopen = this.websocketOnOpen
        // 监听 WebSocket 错误信息
        this.websocket.onerror = this.websocketOnError
        // 监听 WebSocket 消息
        this.websocket.onmessage = this.websocketOnMessage
        // 监听 webSocket 断开信息
        this.websocket.onclose = this.websocketClose
      }
    },
    SJGInitWebSocket() {
      if (typeof (WebSocket) === 'undefined') {
        alert('您的浏览器不支持WebSocket')
      } else {
        // const wsUrl = `ws://10.70.2.2:8080/websocket/message?userId=EN${date}`
        // const wsUrl = 'ws://192.168.1.104:48082/websocket/message?userId=SJG'
        let date = new Date().valueOf()
        // console.log(date);
        console.log(process.env);
        const SJGWsUrl = process.env.VUE_APP_Socket_API + `/websocket/message?userId=SJG${date}`
        this.SJGWebsocket = new WebSocket(SJGWsUrl)
        // 监听 WebSocket 连接
        this.SJGWebsocket.onopen = this.SJGWebsocketOnOpen
        // 监听 WebSocket 错误信息
        this.SJGWebsocket.onerror = this.SJGWebsocketOnError
        // 监听 WebSocket 消息
        this.SJGWebsocket.onmessage = this.SJGWebsocketOnMessage
        // 监听 webSocket 断开信息
        this.SJGWebsocket.onclose = this.SJGWebsocketClose
      }
    },
    SJGWebsocketOnOpen() {
      console.log('socket连接成功')
      // console.log(this.SJGWebsocket.onmessage);
      this.SJGWebsocket.onmessage()
    },
    // 连接建立失败重连
    SJGWebsocketOnError(e) {
      // console.log('11111', e)
      this.SJGInitWebSocket()
    },
    // 数据接收
    SJGWebsocketOnMessage(e) {
      // console.log(1111, e)
      this.SJGWsData = e?.data ? JSON.parse(e?.data) : {}
      // console.log(this.wsData.detData);
      // console.log('22222', this.wsData.data)
      if (this.SJGWsData.type === 'order') {
        this.orderList = this.SJGWsData.detData.map((ele, index) => {
          if (ele.progressRate != 1) {
            return {
              id: ele.id,
              name: ele.name,
              progressRate: ele.progressRate.toFixed(3)
            }
          }
        });
        console.log(this.orderList)
      } else if (this.SJGWsData.type === 'equipment') {
        this.equipmentList = this.SJGWsData.detData.map((ele, index) => {
          // if (ele.progressRate != 1) {
            return {
              id: ele.id,
              name: ele.name,
              code: ele.code,
              status: ele.status,
              error: ele.error=== true ? '是' : '否'
            }
          // }
        });
        // console.log(SJGWsData.orderList)
      } else if (this.SJGWsData.type === 'productline') {
        // console.log(this.wsData.detData);
        let nameList = []
        let passRateList = []
        let outputNumList = []

        // console.log('2222222222', this.productLineList);
        this.productLineList.forEach((item) => {
          this.SJGWsData.detData.forEach((ele) => {
            if (item.id == ele.productionLineId) {
              nameList.push(item.name)
            }
          })
        })
        // progressRateList = EnergyNameList
        // let EnergyDataList = []
        this.SJGWsData.detData.forEach((ele) => {
          passRateList.push(ele.passRate *100
          )
        })
        this.SJGWsData.detData.forEach((ele) => {
          outputNumList.push(ele.outputNum
          )
        })
        // console.log(this.EnergyMonitoringNameList)
        // console.log(this.EnergyMonitoringList)
        // this.$nextTick(() => {
        this.$refs.productLineChart.initChart(Array.from(new Set(nameList)), passRateList, outputNumList)
      }
    },
    // 数据发送
    // SJGWebsocketSend() {
    //   this.websocket.send('11111')
    // },
    // // 关闭
    // SJGWebsocketClose(e) {
    //   console.log('WebSocket 断开连接', e)
    // },
    // // 连接建立之后执行send方法发送数据
    websocketOnOpen() {
      console.log('socket连接成功')
      this.websocket.onmessage()
    },
    // 连接建立失败重连
    websocketOnError(e) {
      console.log('11111', e)
      this.initWebSocket()
    },
    // 数据接收
    websocketOnMessage(e) {
      // console.log(1111, e)
      this.wsData = e?.data ? JSON.parse(e?.data) : {}
      // console.log('22222', this.wsData.data)
      if (this.wsData.type === 'EnergyMonitoring') {
        let EnergyNameList = []
        this.wsData.data.forEach((ele) => {
          EnergyNameList.push(ele.lineName)
        })
        this.EnergyMonitoringNameList = EnergyNameList
        let EnergyDataList = []
        this.wsData.data.forEach((ele) => {
          EnergyDataList.push(ele.useQuantity
            // {
            //   type: 'bar',
            //   data: ele.useQuantity,
            //   barWidth: 6

            // }
          )
        })
        this.EnergyMonitoringList = EnergyDataList
        console.log(EnergyDataList)
        // console.log(this.EnergyMonitoringNameList)
        // console.log(this.EnergyMonitoringList)
        // this.$nextTick(() => {
        this.$refs.EnergyMonitoringChart.initChart(this.EnergyMonitoringNameList, this.EnergyMonitoringList)
        // })
      }
    },
    // 数据发送
    websocketSend() {
      this.websocket.send('11111')
    },
    // 关闭
    websocketClose(e) {
      // console.log('WebSocket 断开连接', e)
    },
    windowWidth(value) {
      this.clientWidth = value
      this.beilv2 = this.clientWidth / 1920
    },
    // fetchList(type) {
    //   switch (type) {
    //     case 'order-process':
    //       return axios({
    //         url: '/analysis/factory-monitor/order',
    //         method: 'post'
    //       }).then(res => {
    //         if (res.data) {
    //           this.orderProcessList = res.data
    //           // this.orderProcessList = [
    //           //   { id: 1, name: '订单1', outRate: 0.5 },
    //           //   { id: 2, name: '订单2', outRate: 0.54 },
    //           //   { id: 3, name: '订单3', outRate: 0.45 },
    //           //   { id: 4, name: '订单4', outRate: 0.65 },
    //           //   { id: 5, name: '订单5', outRate: 0.35 },
    //           //   { id: 6, name: '订单6', outRate: 0.15 },
    //           //   { id: 7, name: '订单7', outRate: 0.5 },
    //           //   { id: 8, name: '订单8', outRate: 0.5 }
    //           // ]
    //         } else {
    //           this.orderProcessList.splice(0)
    //         }
    //       })
    //   }
    // },
    change() {
      this.isFullScreen = screenfull.isFullscreen
    },
    init() {
      if (screenfull.enabled) {
        screenfull.on('change', this.change)
      }
    },
    destroy() {
      if (screenfull.enabled) {
        screenfull.off('change', this.change)
      }
    },
    changeFullScreen() {
      this.containerWidth = 223223223
      if (!screenfull.enabled) {
        this.$message({
          message: 'you browser can not work',
          type: 'warning'
        })
        return false
      }
      screenfull.toggle(this.$refs.container)
    }
  }
}
</script>

<style lang="scss" scoped>
.visual-container {
  width: 1920px;
  height: 1080px;
  background: url('../../assets/img/OperationalOverview/back.png') no-repeat;
  background-size: cover;
  // opacity: .8;
  .container-title {
    width: 100%;
    background: url('../../assets/img/OperationalOverview/title.png') no-repeat;
    background-size: 100% 100%;
    color: #00fff0;
    text-align: center;
      .unit {
          position: absolute;
          left: 260px;
          top: 25px;
          font-size: 20px;
        }

        .time {
          position: absolute;
          left: 1360px;
          top: 25px;
          font-size: 20px;
        }
    .title-button {
      color: #00fff0;
      font-size: 20px;
      position: absolute;
    }
  }

  .container-main {
    padding: 10px;
  }
}

.now-team-title {
  margin: 0;
  margin-top: -1em;
  font-size: 1.2em;
  line-height: 2em;
  color: #fff;
}

.main-title {
  text-align: center;
}

.now-secondary-title {
  margin: 0;
  font-size: 1em;
  line-height: 2em;
  color: #fff;
}

.now-team-content {
  font-size: 3em;
  line-height: 1em;
  color: #52fff1;
  text-align: center;
}

::v-deep .el-progress-bar__inner {
  background-color: unset;
  background-image: linear-gradient(to right, #4573fe, #47f8dc);
}
// ::v-deep .el-progress-bar__outer {
//   background-color:rgba(71, 248, 220, 1);
//   // background-image: rgba(71, 248, 220, 1))
// }
 .visual-select {
   position: absolute;
   right: 1em;
   top: 2em;
 }

// .container-main {
//    padding: 5px;
//  }
</style>

<style lang="scss">
.visual-container {
  ::-webkit-scrollbar {
    width: 8px;
    height: 8px;
    background-color: transparent;
  }

  ::-webkit-scrollbar-track-piece {
    background: #1b2b3d;
  }

  ::-webkit-scrollbar-corner {
    background: #1b2b3d;
  }

  ::-webkit-scrollbar-track {
    width: 6px;
    background: #1b2b3d;
    -webkit-border-radius: 2em;
    -moz-border-radius: 2em;
    border-radius: 2em;
  }

  ::-webkit-scrollbar-thumb {
    background: rgba($color: #5bc4be, $alpha: 0.7);
    background-clip: padding-box;
    min-height: 28px;
    -webkit-border-radius: 2em;
    -moz-border-radius: 2em;
    border-radius: 2em;
    transition: background-color 0.3s;
    cursor: pointer;
  }

  ::-webkit-scrollbar-thumb:hover {
    background-color: rgba($color: #5bc4be, $alpha: 1);
  }
}
.coldSelect{
  .el-input {
      min-height: 10px;
    }

    .el-input__inner {
      background-color: rgba($color: #31878c, $alpha: 0.29);
      border: rgba($color: #31878c, $alpha: 0.29);
      color: aliceblue;
    }

    .el-divider--vertical {
      height: 174px;
      width: 1px;
      border: rgba(255, 255, 255, 0.15);
      color: rgba(255, 255, 255, 0.15);
      margin-left: 3em;
    }
}

</style>

<style scoped>
.flex-col {
  flex-direction: column;
}

.flex-1 {
  flex: 1 1;
}
.h-full {
  height: calc(100vh - 150px);
}
/* .container-main {
  min-height: calc(100vh - 10em);
} */
</style>
