<template>
  <div id="top-header">
    <div class="timers">
      {{ dateYear }} {{ dateWeek }} {{ dateDay }}
    </div>
    <div class="center-title">项目施工数据概览</div>

    <div class="top-header-select">
      <el-select v-model="value" placeholder="请选择">
        <el-option
          v-for="item in options"
          :key="item.value"
          :label="item.label"
          :value="item.value">
        </el-option>
      </el-select>
    </div>
  </div>
</template>

<script>
import { formatTime } from "@/utils/index.js";

export default {
  name: 'TopHeader',

  data() {
    return {
      timing: null,
      dateDay: null,
      dateYear: null,
      dateWeek: null,
      weekday: ["周日", "周一", "周二", "周三", "周四", "周五", "周六"],

      value: '1',
      options: [{
          value: '1',
          label: '雪花路'
      }]
    }
  },

  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);
      },
  },

  mounted() {
      this.timeFn()
  },

  
  beforeDestroy() {
    clearInterval(this.timing);
  }
}
</script>

<style lang="less">
#top-header {
  position: relative;
  width: 100%;
  height: 100px;
  display: flex;
  justify-content: space-between;
  flex-shrink: 0;
  background: url(../views/projectView/img/title.png) no-repeat;
  background-size: 100% 100%;

  .center-title {
    position: absolute;
    font-size: 30px;
    font-weight: bold;
    left: 50%;
    transform: translateX(-50%);
    line-height: 100px;
  }

  .timers {
    font-size: 22px;
    font-weight: bold;

    position: absolute;
    left: 8%;
    bottom: 24px;
  }

  .top-header-select {
    position: absolute;
    right: 8%;
    bottom: 24px;
    background: rgba(47,85,151,.58) !important;
    .el-select,
    .el-input__inner {
      background: transparent;
      width: 240px;
      height: 50px;
      border: none;
      font-size: 22px;
    }
  }
}
</style>
