<template>
  <div>
    <!--        一、内容选取-->
    <el-form>
      <div style="text-align: left;padding-bottom: 1%;font: bold 16px 新宋体">一、时间选取</div>
      <el-form-item>
        <el-select
        v-model="dataForm.totalDate"
        placeholder="选择时间"
        style="width: 80%;"
        >
        <el-option
          v-for="item in timeList"
          :key="item"
          :label="item"
          :value="item"
          @click.native="getList()"
        ></el-option>
        </el-select>
      </el-form-item>
      <div style="text-align: left;padding: 8% 0 1% 2%;font: bold 16px 新宋体">二、已安排的内容</div>
      <el-form-item>
        <div>
          <div class="showDivDo" style="margin-bottom:2%"></div>
          <div v-if="dataList.length > 0">
            <div v-for="(item,indexFa) in dataList" :key="indexFa" style="font-size: 14px">
              <div v-if="indexFa === 0">
                <span v-if="item.projectNewName !==undefined && item.projectNewName !== null">立项名称：{{ item.projectNewName }}</span>
                <span v-else>立项名称：{{ item.project }}</span>
              </div>
              <div v-else style="padding-top: 10%">
                <span v-if="item.projectNewName !==undefined && item.projectNewName !== null">立项名称：{{ item.projectNewName }}</span>
                <span v-else>立项名称：{{ item.project }}</span>
              </div>
              <div style="margin:1% 0 0 5%">
                <div v-if="item.totalProjectId !== null">
                  <div style="padding: 1%">
                    1.立项属性:
                  </div>
                  <div style="margin-left: 10%">
                    <span>① 立项名称：{{ item.projectNewName?item.projectNewName:item.project }}<br></span>
                    <span>② 建设单位：{{ item.jsdw?item.jsdw:"暂无"}}<br></span>
                    <span>③ 年份：{{ item.projectYear?item.projectYear:"暂无" }}<br></span>
                    <span>④ 开工时间：{{ item.projectStart?item.projectStart:"暂无" }}<br></span>
                    <span>⑤ 竣工时间：{{ item.projectEnd?item.projectEnd:"暂无" }}<br></span>
                    <span>⑥ 施工地点：{{ item.sgdd?item.sgdd:"暂无" }}<br></span>
                    <span>⑦ 施工进度：{{ item.sgjd?item.sgjd:"暂无" }}<br></span>
                    <span>⑧ 负责工长：{{ item.fzgz?item.fzgz:"暂无" }}<br></span>
                    <!--                  <span>工程类别：{{ itemDic.name }};</span>-->
                  </div>
                </div>
                <div v-else>
                  <span>1.立项属性:暂无<br></span>
                </div>
                <div v-if="item.totalProjectId !== null && dataContractList[0] !== null">
                  <div style="padding: 1%">
                    2.合同属性:
                  </div>
                  <div v-if="dataContractList.length > 0">
                    <div style="margin-left: 10%">
                <span>① 合同名称：{{
                    dataContractList[0][item.totalProjectId].contractNewName ? dataContractList[0][item.totalProjectId].contractNewName : dataContractList[0][item.planProjectId].contractName
                  }};<br></span>
                      <span>② 直非友：{{ dataContractList[0][item.totalProjectId].zfy?dataContractList[0][item.totalProjectId].zfy:"暂无" }};<br></span>
                      <span>③ 合同年份：{{ dataContractList[0][item.totalProjectId].contractYear?dataContractList[0][item.totalProjectId].contractYear:"暂无" }};<br></span>
                      <span>④ 施工单位：{{ dataContractList[0][item.totalProjectId].sgdw?dataContractList[0][item.totalProjectId].sgdw:"暂无" }};<br></span>
                      <span>⑤ 监理单位：{{ dataContractList[0][item.totalProjectId].jldw?dataContractList[0][item.totalProjectId].jldw:"暂无" }};<br></span>
                      <span>⑥ 一审单位：{{ dataContractList[0][item.totalProjectId].ysdw?dataContractList[0][item.totalProjectId].ysdw:"暂无" }};<br></span>
                      <span>⑦ 二审单位：{{ dataContractList[0][item.totalProjectId].esdw?dataContractList[0][item.totalProjectId].esdw:"暂无" }};<br></span>
                    </div>
                  </div>
                </div>
                <div v-else>
                  <span>2.合同属性:暂无<br></span>
                </div>
                <div style="padding-top: 1%">
                  <span>3.是否一天:{{ item.oneDay ? item.oneDay : "暂无" }}<br></span>
                </div>
                <div style="padding: 1%;">
                  <div v-if="item.totalDdId === null && item.selectPersionId === null">4.人员列表: 带队人：暂无;施工人员：暂无</div>
                  <div v-else-if="item.totalDdId !== null && item.selectPersionId === null">
                    <span>4.人员列表: 带队人：{{ item.ddName }};施工人员：暂无</span>
                  </div>
                  <div v-else-if="item.totalDdId === null && item.selectPersionId !== null">4.人员列表:
                    带队人：暂无;施工人员：{{ item.selectPer }}
                  </div>
                  <div v-else>4.人员列表: 带队人：{{ item.ddName }};施工人员：{{ item.selectPer }}</div>
                </div>
                <div style="padding: 1%;">
                  <span v-if="item.totalSgSummary !== null">5.施工内容:{{ item.totalSgSummary }}<br></span>
                  <span v-else>5.施工内容:暂无<br></span>
                </div>
                <div style="padding: 1%">
                  <span v-if="item.totalCl !== null">6.材料:{{ item.totalCl }}<br></span>
                  <span v-else>6.材料:暂无<br></span>
                </div>
                <div style="padding: 1%">
                  <span v-if="item.totalJx !== null">7.机械:{{ item.totalJx }}</span>
                  <span v-else>7.机械:暂无</span>
                </div>
              </div>
            </div>
          </div>
          <div v-else style="text-align: center">
            <div style="margin-top: 4%">暂无今日总结</div>
          </div>
          <div class="showDivDo" style="margin-bottom:2%"></div>
        </div>
      </el-form-item>
    </el-form>
    <!--       二、 已安排的内容-->
    <div style="padding: 2% 0;text-align: center">
      <el-button type="success" @click="copy">一键复制
      </el-button>
    </div>
  </div>
</template>

<script>
import {isAuth} from '../../utils'

export default {
  components: {},
  data () {
    return {
      editShow: false,
      dataContractList: [], // 合同信息数组
      dataForm: {
        totalDate: ''
      },
      copyText: '', // 一键复制
      sgry: '', // 施工人员
      dataList: [],
      timeList: []
    }
  },
  methods: {
    // 根据时间获取所有符合条件的今日总结信息
    getList () {
      // console.log(this.dataForm.totalDate)
      this.dataList = []
      this.dataContractList = []
      this.dataProjectList = []
      this.$http.request({
        url: this.$http.adornUrl('/business/businesstotal/getListByTimeNew/' + this.dataForm.totalDate),
        method: 'get'
      }).then(({data}) => {
        if (data && data.code === 0) {
          if (data.page.list.length > 0) {
            this.dataList = data.page.list
          }
          // console.log(this.dataList)
          if (data.page.contractList.length > 0) {
            this.dataContractList = data.page.contractList
          }
          // console.log(this.dataContractList)
          this.copyText = data.page.copy
        }
      })
    },

    copy () {
      // const that = this
      // console.log(JSON.stringify(this.dataProjectList));
      navigator.clipboard.writeText(this.copyText)
      this.$message('复制成功')
    },
    getDataList () {
      // 获取所有的总结的总结时间
      this.$http.request({
        url: this.$http.adornUrl('/business/businesstotal/getTimeList'),
        method: 'get'
      }).then(({data}) => {
        // console.log(data);
        if (data && data.code === 0) {
          data.page.forEach((item, index) => {
            this.timeList.push(item)
          })
          // console.log(this.pickerValueArray);
        }
      })
      let nowDate = new Date()
      let date = {
        year: nowDate.getFullYear(),
        month: nowDate.getMonth() + 1,
        date: nowDate.getDate()
      }
      if (date.month !== 10 && date.month !== 11 && date.month !== 12) {
        date.month = '0' + date.month
      }
      if (date.date === 1 || date.date === 2 || date.date === 3 || date.date === 4 || date.date === 5 || date.date === 6 ||
        date.date === 7 || date.date === 8 || date.date === 9) {
        date.date = '0' + date.date
      }
      this.dataForm.totalDate = date.year + '-' + date.month + '-' + date.date
      console.log(this.dataForm.totalDate)
      this.getList()
    }
  },

  mounted () {
    this.editShow = false
    this.editShow = isAuth('business:businesstotal:save')
  }
}
</script>

<style scoped>
.btn {
  text-align: center;
  border-radius: 8px;
  width: 24%;
  height: 25px;
  font-size: 11px;
  font-weight: bold;
  display: flex;
  justify-content: center;
  align-items: center;
}

.showDivDo {
  border-bottom: 2px solid #fde866;
  text-align: center;
}

/* 小箭头 */
.arrowOpen {
  /* 设置透明背景色 */
  border: 6px solid transparent;
  border-top-color: black;
  margin-top: 3%;
}

.showDiv {
  border-bottom: 1px solid black;
  text-align: center;
}

.btnBu {
  text-align: center;
  width: 28%;
  margin-top: 4%;
  background-color: #fde866;
  height: 5vh;
  border-radius: 5px;
  font-size: 14px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-weight: bold;
}

/*格式上下左右居中通用模块*/
.tYStyle {
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
}
</style>
