<template>
  <div id="index" ref="appRef">
    <div class="bg">
      <dv-loading v-if="loading">Loading...</dv-loading>
      <div v-else class="host-body">
        <div class="d-flex jc-center">
          <dv-decoration-10 class="dv-dec-10" />
          <div class="d-flex jc-center">
            <dv-decoration-8 class="dv-dec-8" :color="decorationColor" />
            <div class="title">
              <span class="title-text">UAS-MES可视化平台</span>
              <dv-decoration-6
                class="dv-dec-6"
                :reverse="true"
                :color="['#50e3c2', '#67a1e5']"
              />
            </div>
            <dv-decoration-8
              class="dv-dec-8"
              :reverse="true"
              :color="decorationColor"
            />
          </div>
          <dv-decoration-10 class="dv-dec-10-s" />
        </div>

        <!-- 第二行 -->
        <div class="d-flex jc-between px-2">
          <div class="d-flex aside-width">
            <div class="react-left ml-4 react-l-s bg-color-blue">
              <span class="react-left"></span>
              <span class="text fw-b" style="font-size:24px;">贾维斯MES数据看板</span>
            </div>
            <div class="react-left ml-3">
              <span class="text">生产实况分析</span>
            </div>
          </div>
          <div class="d-flex aside-width">
            <div class="react-right bg-color-r mr-3">
             <!-- <span class="text ">设备运行分析</span>-->
              <span class="text" @click="fullScreen" ref="fullScreen">全屏</span>
              <span class="text" @click="exitFullScreen" ref="exitFullScreen"  style="display: none">退出全屏</span>
            </div>
            <div class="react-right mr-4 react-l-s" style="width: 900px">
              <span class="react-after"></span>
               <el-dropdown class="dropdown">
                <span class="el-dropdown-link" ref="echarType">
                  点胶车间<i class="el-icon-arrow-down el-icon&#45;&#45;right"></i>&nbsp;&nbsp;&nbsp;&nbsp;
                </span>
                  <el-dropdown-menu slot="dropdown">
                    <el-dropdown-item ><router-link to="dpl"> 多品类车间 </router-link></el-dropdown-item>
                    <el-dropdown-item ><router-link to="dip"> DIP车间 </router-link></el-dropdown-item>
                    <el-dropdown-item ><router-link to="package"> 包装车间 </router-link></el-dropdown-item>
                    <el-dropdown-item ><router-link to="assembly"> 组装车间 </router-link></el-dropdown-item>
                    <el-dropdown-item ><router-link to="smt">SMT车间</router-link></el-dropdown-item>
                    <el-dropdown-item ><router-link to="smttest">SMT测试车间</router-link></el-dropdown-item>
                    <el-dropdown-item class="dropdownitem"><router-link to="total"> 各车间总看板</router-link></el-dropdown-item>
                  </el-dropdown-menu>
            </el-dropdown>
              <el-select v-model="linecode" class="dropdown" @change ="handleBlur" style="width: 150px">
                <el-option
                        v-for="item in linedata"
                        :key="item.LI_CODE"
                        :label="item.LI_CODE"
                        :value="item.LI_CODE"
                ></el-option>
              </el-select>
              <span class="text">&nbsp;&nbsp;&nbsp;&nbsp;</span>
              <span class="text">{{ dateYear }} {{ dateWeek }} {{ dateDay }}</span>
            </div>
          </div>
        </div>

        <div class="body-box">
          <!-- 第三行数据 -->
          <div class="content-box">
            <div>
              <dv-border-box-12 v-show="linecode!='所有'">
                <centerLeft_two />
              </dv-border-box-12>
              <dv-border-box-12 v-show="linecode=='所有'">
                <centerLeft1ALL />
              </dv-border-box-12>
            </div>
            <div>
              <dv-border-box-12>
                <centerLeft1 />
              </dv-border-box-12>
            </div>
            <!-- 中间 -->
            <div>
              <dv-border-box-12>
                 <center />
              </dv-border-box-12>
            </div>
            <!-- 中间 -->
           <!-- <div>
              <centerRight2 />
            </div>-->
            <div>
              <dv-border-box-12>
                <centerRight1/>
              </dv-border-box-12>
            </div>
          </div>

          <!-- 第四行数据 -->
          <div class="bottom-box">
            <dv-border-box-12>
              <bottomLeft2 />
            </dv-border-box-12>
            <dv-border-box-12>
              <bottomRight />
            </dv-border-box-12>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import drawMixin from "../../utils/drawMixin";
import { formatTime } from '../../utils/index.js'
import centerLeft1 from './centerLeft1'
import centerLeft_two from './centerLeft_two'
import centerRight1 from './centerRight1'
import center from './center'
import bottomLeft2 from './bottomLeft2'
import bottomRight from './bottomRight'
import centerLeft1ALL from "@/views/dj/centerLeft1ALL.vue";

export default {
  mixins: [ drawMixin ],
  data() {
    return {
      timing: null,
      loading: true,
      dateDay: null,
      dateYear: null,
      dateWeek: null,
      weekday: ['周日', '周一', '周二', '周三', '周四', '周五', '周六'],
      decorationColor: ['#568aea', '#000000'],
      workshopoptions:[
        {label: 'SMT', value: 'SMT'},
        {label: '组装', value: '组装'},
      ],
      isShow:false
    }
  },
  components: {
    centerLeft1ALL,
    centerLeft1,
    centerLeft_two,
    centerRight1,
    center,
    bottomLeft2,
    bottomRight
  },
  created() {
    this.getLines();
  },
  mounted() {
    this.timeFn()
    this.cancelLoading()
  },
  beforeDestroy () {
    clearInterval(this.timing)
    clearInterval(this.intervalId)
  },
  methods: {
    timeFn() {
      this.timing = setInterval(() => {
        this.dateDay = formatTime(new Date(), 'HH: mm: ss')
        this.dateYear = formatTime(new Date(), 'yyyy-MM-dd')
        this.dateWeek = this.weekday[new Date().getDay()]
      }, 1000)
    },
    cancelLoading() {
      setTimeout(() => {
        this.loading = false
      }, 5000)
    },
    handleBlur (val){
      sessionStorage.setItem('li_code',val);
      this.$cookie.set("PC_LI_CODE", val, {
        expires: 30,
      });
      location.reload();
    },
    goSMT(){
      this.$router.push('/smt');
    },
    goAssembly(){
      this.$router.push('/assembly');
    },
    getLines (){
      this.$http.get("kanban/getLinesByWorkCenter.action?wccode=点胶").then(
              (res)=>{
                if(res.data.linedata) {
                  const data = res.data.linedata.concat({'LI_CODE':'所有','LI_NAME':'所有'});
                  if(this.$cookie.get("PC_LI_CODE") && data.some(item => item.LI_CODE === this.$cookie.get("PC_LI_CODE")) ){
                    sessionStorage.setItem('li_code', this.$cookie.get("PC_LI_CODE"));
                  }else {
                    sessionStorage.setItem('li_code', data[0].LI_CODE);
                    this.$cookie.set("PC_LI_CODE", data[0].LI_CODE, {
                      expires: 30,
                    });
                  }
                  this.linedata = data;
                }else{
                  sessionStorage.setItem('li_code','');
                }
                this.linecode = sessionStorage.getItem("li_code");
              },(result)=>{
                console.error(result)
              });
    }
  },
}


</script>

<style lang="scss" scoped>
@import '../../assets/scss/indexpackage.scss';

.dropdown{
  font-size: 18px;
  color: #568aea;
  transform: skewX(45deg);
  ::v-deep .el-select-dropdown {
    /* // 若不将下拉框的背景颜色设置为：transparent，那么做不出来半透明的效果；
    // 因为其最终的显示为：下拉框有一个背景颜色且下拉框的字体有一个背景颜色，重叠后的效果展示； */
    border: 1px solid #0f1325;
    background: #04308D !important;
  }

  ::v-deep .el-input__inner {
    background-color: #0f1325;
    color: #fff;
    border: 1px solid #0f1325;
  }

  .el-select-dropdown__item {
    color: #fff;
    background-color: #0f1325;
  }
  ::v-deep .el-select-dropdown {
    background-color: transparent;
    border: 1px solid #0f1325;
  }
  ::v-deep.el-select-dropdown__list {
    padding: 0;
  }
  ::v-deep.el-popper[x-placement^="bottom"] {
    margin-top: 0px;
  }
  ::v-deep.el-popper .popper__arrow,
  ::v-deep.el-popper .popper__arrow::after {
    display: none;
  }
  .el-select-dropdown__item:hover {
    background-color: rgba(0, 225, 219, 0.690196078431373);
  }
}
</style>
