<template>
  <div>
    <div style="display: flex;flex-direction: row;flex-wrap: wrap;">
      <div v-for="(timeItem, index) in personList2" :key="index">
        <div class="right">
          <div
            style="font-size: 26px;text-align: center;margin: 0 0 5px 0;padding: 5px 0;background-color: #2394f2;color: #fff">
            {{ timeItem }}</div>
          <div v-for="(item, indexSon) in personList1[timeItem]" :key="indexSon" style="margin: 10px">
            <div style="display: flex;align-items: center">
              <div>
                <div
                  style="text-align: center;font-size: 20px;border-radius: 50%;width: 50px;height: 50px;line-height: 50px;background-color: #5daf34">
                  {{ indexSon + 1 }}</div>
              </div>
              <div style="margin-left: 10px;line-height: 1.5">
                <div style="margin: 5px 0">
                  <span style="font-size: 20px;font-weight: bolder">项目：</span>
                  <span style="font-size: 16px">{{ item.节点名称 }}</span>
                </div>
                <div style="margin: 5px 0">
                  <span style="font-size: 20px;font-weight: bolder">子项目：</span>
                  <span style="font-size: 16px">{{ item.子项目内容 }}</span>
                </div>
                <div style="margin: 5px 0">
                  <span style="font-size: 20px;font-weight: bolder">工作内容：</span>
                  <span style="font-size: 16px">{{ item.工作内容 }}</span>
                </div>
                <div style="margin: 5px 0">
                  <span style="font-size: 20px;font-weight: bolder;">开始：</span>
                  <span style="font-size: 16px">{{ item.计划开始时间 }}</span>
                  <span style="font-size: 20px;margin-left: 10px;font-weight: bolder">结束：</span>
                  <span style="font-size: 16px">{{ item.计划完成时间 }}</span>
                </div>
                <div style="margin: 5px 0">
                  <span style="font-size: 20px;font-weight: bolder;">备注：</span>
                  <span style="font-size: 16px">{{ item.备注 }}</span>
                </div>
              </div>
            </div>
            <div style="width: 100%;border: 1px solid #00893d" />
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import { mapGetters } from 'vuex'

export default {
  name: 'TodayCount',
  data() {
    return {
      personList2: [],
      personList1: [],
      timer: null,
    }
  },
  computed: {
    ...mapGetters(['isAdmin'])
  },
  created() {
  },
  mounted() {
    const scope = this
    this.clickItem()
    this.timer = setInterval(() => {
      scope.clickItem()
    }, 5 * 60 * 1000)
  },
  beforeDestroy() {
    clearInterval(this.timer)
  },
  methods: {
    // 点击某一项日期
    clickItem() {
      // 判断是否 为管理员，是的话则拉取人员列表，不是则拉去今日进度
      if (this.isAdmin == 1) {
        var param = []
        this.personList1 = []
        this.personList2 = []
        var Data = this.CreateData('11', '项目管理_今日填写情况_查询', param)
        this.ExecDatabase(Data).then(response => {
          if (response.data.length > 0) {
            for (const responseElement of response.data) {
              if (this.personList2.indexOf(responseElement.姓名) === -1) {
                this.personList2.push(responseElement.姓名)
              }
              if (this.personList1[responseElement.姓名]) {
                this.personList1[responseElement.姓名].push(responseElement)
              } else {
                this.personList1[responseElement.姓名] = []
                this.personList1[responseElement.姓名].push(responseElement)
              }
            }
          } else {
            this.$message.warning('该日期没有填写日报!')
          }
        })
      }
    }
  }
}
</script>
<style scoped lang="scss">
.right {
  width: 600px;
  height: 300px;
  overflow: auto;
  margin: 10px;
  background-color: #fff;
  border: 1px solid #e4e7ed;
  box-shadow: 0 2px 12px 0 #0000006e;

  table {
    width: 100%;
  }

  table tr {
    height: 70px;
  }

  table td,
  th {
    border: 1px solid #000000;
  }

  table th {
    font-size: 25px;
    text-align: center;
  }
}
</style>
