<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">COSTEC-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;">柯赛科技数据看板</span>
            </div>
          </div>
          <div class="d-flex aside-width">
            <div class="react-right bg-color-r mr-3">
              <el-button type="text" class="text" style="width:50% ;font-size: 21px;" @click="fullScreen" ref="fullScreen"
                         v-show=!isFullScreen >全屏</el-button>
              <el-button type="text" class="text" style="width:50% ;font-size: 21px;" @click="exitFullScreen" ref="exitFullScreen" v-show=isFullScreen>退出全屏</el-button>
            </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--right"></i>&nbsp;&nbsp;&nbsp;&nbsp;
                </span>
                <el-dropdown-menu slot="dropdown">
                  <el-dropdown-item class="dropdownitem"><router-link to="total">总看板</router-link></el-dropdown-item>
                  <el-dropdown-item class="dropdownitem"><router-link to="prodline">车间看板</router-link></el-dropdown-item>
                  <el-dropdown-item class="dropdownitem"><router-link to="quality">品质看板</router-link></el-dropdown-item>
                  <el-dropdown-item class="dropdownitem"><router-link to="warehouse">仓库看板</router-link></el-dropdown-item>
                  <el-dropdown-item class="dropdownitem"><router-link to="zz">组装看板</router-link></el-dropdown-item>
                  <el-dropdown-item class="dropdownitem"><router-link to="compare">各车间进度</router-link></el-dropdown-item>
                </el-dropdown-menu>
              </el-dropdown>
              <span class="text">&nbsp;&nbsp;&nbsp;&nbsp;</span>
              <span class="text">{{ dateYear }} {{ dateWeek }} {{ dateDay }}</span>
            </div>
          </div>
        </div>

        <!-- 修改后的主体内容区域 -->
        <div class="body-box" style="height: calc(100vh - 120px); overflow: hidden;">
          <div class="bottom-box" style="height: 100%;">
            <dv-border-box-12 style="height: 100%;">
              <bottom1 />
            </dv-border-box-12>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import drawMixin from "../../utils/drawMixin";
import  common  from '../../utils/common';
import {formatTime} from '../../utils/index.js'
import bottom1 from './bottom1.vue'
import {mapMutations, mapState} from "vuex"

export default {
  mixins: [ drawMixin,common ],
  computed: {
    ...mapState(['user','factoryoptions','factory']),
  },
  data() {
    return {
      timing: null,
      timing2: null,
      timing3: null,
      loading: true,
      dateDay: null,
      dateYear: null,
      dateWeek: null,
      weekday: ['周日', '周一', '周二', '周三', '周四', '周五', '周六'],
      decorationColor: ['#568aea', '#000000'],
    }
  },
  components: {
    bottom1
  },
  created() {
    this.isFullScreen = document.fullscreenElement;
  },
  mounted() {
    this.timeFn();
    this.cancelLoading();
    this.autoFullScreen();
  },
  beforeDestroy () {
    clearInterval(this.timing);
    clearInterval(this.timing2);
  },
  methods: {
    ...mapMutations(['setFactory']),
    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
      }, 1000)
    },
    autoFullScreen(){
      if (!this.isFullScreen) {
        setTimeout(() => {
          this.$showMsgBox({
            caption: "提示",
            msg: '是否全屏展示？',
            callback: (data) => {
              if (data == "yes") {
                this.fullScreen();
              }
            }
          })
        }, 3000)
      }
    },
  }
}
</script>

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

.dropdown{
  font-size: 22px;
  color: #f7f8fa;
  transform: skewX(45deg);
  ::v-deep .el-select-dropdown {
    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);
  }
}

/* 新增样式 */
.bg {
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

.host-body {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.body-box {
  flex: 1;
  min-height: 0; /* 修复flex布局中内容溢出问题 */
}

.bottom-box {
  height: 100%;
  width: 100%;
}
</style>