<template>
  <Card title="安全教育">
    <div class="containerBox">
      <!-- 入场三级交底 -->
      <div class="centerLeft">
        <div class="text">
          入场<span
            style="
              width: 100px;
              height: 100px;
              border-bottom: 1px solid #f56c35;
              padding: 0 0 5px 0;
            "
            >三级</span
          >交底
        </div>

        <div class="textDivBox">
          <div class="textDiv">
            <span>{{ threeLevel.projectWorkerNumber }}</span>
            <p>项目总人数</p>
          </div>
          <div class="textDiv">
            <span>{{ threeLevel.projectTrainWorkerNumber }}</span>
            <p>项目培训人数</p>
          </div>
          <div class="textDiv">
            <span>{{ threeLevel.projectTrainRatio }}%</span>
            <p>项目培训率</p>
          </div>
        </div>

        <div class="tableDiv">
          <div class="tableSon">
            <div class="row">培训主题</div>
            <div class="row">培训人</div>
            <div class="row">培训课时(h)</div>
            <div class="row">培训时间</div>
          </div>
          <div class="tbody">
            <vue-scroll>
              <div
                class="row"
                v-for="i in threeLevel.workerSafeEducationList"
                :key="i.id"
              >
                <div class="td">{{ i.eduCourseName }}</div>
                <div class="td">{{ i.eduTeacher }}</div>
                <div class="td">
                  {{ i.eduClasshour != 0 ? i.eduClasshour / 60 : 0 }}
                </div>
                <div class="td">{{ i.eduTime }}</div>
              </div>
              <div
                class="row"
                v-if="threeLevel.workerSafeEducationList.length == 0"
              >
                <div
                  style="
                    font-size: 14px;
                    color: #999;
                    text-align: center;
                    width: 100%;
                    line-height: 300px;
                  "
                >
                  暂无数据
                </div>
              </div>
            </vue-scroll>
          </div>
        </div>
      </div>
      <!-- 每日班前喊话 -->
      <div class="centerC">
        <div class="text">
          每日<span
            style="
              width: 100px;
              height: 100px;
              border-bottom: 1px solid #f56c35;
              padding: 0 0 5px 0;
            "
            >班前</span
          >喊话
        </div>

        <div class="textDivBox">
          <div class="textDiv">
            <span>{{ shouting.allCount }}</span>
            <p>今日班前喊话次数</p>
          </div>
          <div class="textDiv">
            <span>{{ shouting.todayCount }}</span>
            <p>班前喊话次数</p>
          </div>
        </div>

        <div class="tableDiv">
          <div class="tableSon">
            <div class="row">时间</div>
            <div class="row">负责人</div>
            <div class="row">班组</div>
            <div class="row">照片</div>
          </div>
          <div class="tbody">
            <vue-scroll>
              <div
                class="row"
                v-for="(item, index) in shouting.shoutInfoList"
                :key="index"
              >
                <div class="td">{{ item.shoutTime }}</div>
                <div class="td">{{ item.dutyUserName }}</div>
                <div class="td">{{ item.teamName }}</div>
                <div class="td"><img :src="item.shoutImage" /></div>
              </div>
              <div class="row" v-if="shouting.shoutInfoList.length == 0">
                <div
                  style="
                    font-size: 14px;
                    color: #999;
                    text-align: center;
                    width: 100%;
                    line-height: 300px;
                  "
                >
                  暂无数据
                </div>
              </div>
            </vue-scroll>
          </div>
        </div>
      </div>
      <!-- 安全交底 -->
      <div class="centerRight">
        <div class="text">
          <!-- <div class="text">每日<span style="width:100px;height:100px;border-bottom:1px solid #F56C35;padding:0 0 5px 0">班前</span>喊话</div> -->

          安<span
            style="
              width: 100px;
              height: 100px;
              border-bottom: 1px solid #f56c35;
              padding: 0 0 5px 0;
            "
            >全交</span
          >底
        </div>

        <div class="textDivBox">
          <div class="textDiv">
            <span>{{ safetyDisclosure.trainNumber }}次</span>
            <p>培训次数</p>
          </div>
          <div class="textDiv">
            <span>{{ safetyDisclosure.specialOperationsNumber }}次</span>
            <p>特种作业</p>
          </div>
          <div class="textDiv">
            <span>{{ safetyDisclosure.disclosureInRainySeasonNumber }}次</span>
            <p>雨季交底</p>
          </div>
          <div class="textDiv">
            <span>{{ safetyDisclosure.electricityDisclosureNumber }}次</span>
            <p>用电交底</p>
          </div>
        </div>

        <div class="tableDiv">
          <div class="tableSon">
            <div class="row">交底主题</div>
            <div class="row">类型</div>
            <div class="row">负责人</div>
            <div class="row">交底时间</div>
          </div>
          <div class="tbody">
            <vue-scroll>
              <div
                class="row"
                v-for="(item,index) in safetyDisclosureDate" :key="index"
              >
                <div class="td">{{ item.eduCourseName }}</div>
                <div class="td">{{item.eduTypeList[item.eduType] }}</div>
                <div class="td">{{ item.eduTeacher }}</div>
                <div class="td">{{ item.eduTime }}</div>
              </div>
              <div
                class="row"
                v-if="safetyDisclosureDate.length == 0"
              >
                <div
                  style=" font-size: 14px;color: #999; text-align: center;
                    width: 100%;
                    line-height: 300px;
                  "
                >
                  暂无数据
                </div>
              </div>
            </vue-scroll>
          </div>
        </div>
      </div>
    </div>
  </Card>
</template>

<script>
import Card from "../components/Card.vue";
import { mapState } from "vuex";
import {
  getThreeLevelDataByProjectSnApi,
  getSecurityDataByProjectSnApi,
  getTodayInfoByProjectSnApi,
} from "@/assets/js/api/zhongjianFourth";
export default {
  components: {
    Card,
  },
  data() {
    return {
      threeLevel: {
        workerSafeEducationList: [],
      },
      safetyDisclosure: {},//安全交底
      safetyDisclosureDate:[],//安全交底
      shouting: {
        shoutInfoList: [],
      },
      eduTypeList: {
        1: "入场三级教育",
        2: "定期安全教育",
        3: "日常安全交底",
        4: "VR安全教育",
        5: "班前教育",
        6: "日常教育（日常违规教育)",
        7: "每日交底（方案交底）",
        8: "每日交底（安全技术交底）",
        9: "每日交底（大工程交底）",
        10: "入职培训",
      },
    };
  },
  computed: {
    ...mapState(["projectSn"]),
  },
  created() {
    this.getThreeLevelDataByProjectSn();
    this.getSecurityDataByProjectSn();
    this.getTodayInfoByProjectSn();
  },
  methods: {
    // 进场三级交底
    getThreeLevelDataByProjectSn() {
      getThreeLevelDataByProjectSnApi({ projectSn: this.projectSn }).then(
        (res) => {
          console.log(res, "getThreeLevelDataByProjectSn-----------");
          this.threeLevel = res.result;
        }
      );
    },
    //安全交底
    getSecurityDataByProjectSn() {
      getSecurityDataByProjectSnApi({ projectSn: this.projectSn }).then(
        (res) => {
          this.safetyDisclosure = res.result;
          this.safetyDisclosureDate=res.result.workerSafeEducationList
        }
      );
    },
    //班前喊话
    getTodayInfoByProjectSn() {
      getTodayInfoByProjectSnApi({ projectSn: this.projectSn }).then((res) => {
        console.log(res, "getTodayInfoByProjectSnApi");
        this.shouting = res.result;
      });
    },
  },
};
</script>

<style lang="less" scoped>
.containerBox {
  width: 100%;
  height: 100%;
  margin-top: 2%;
  display: flex;
  justify-content: space-between;
  .centerLeft,
  .centerC,
  .centerRight {
    width: 340px;
    height: 95%;
    .text {
      text-align: center;
      margin-bottom: 20px;
      font-size: 14px;
      .el-icon-minus {
      }
    }
    .textDivBox {
      width: 340px;
      height: 8%;
      display: flex;
      justify-content: space-between;
      .textDiv {
        background: rgba(111, 202, 226, 0.65);
        border-radius: 2px 2px 2px 2px;
        opacity: 1;
        font-size: 12px;
        width: 100px;
        height: 41px;
        //  background-color: #6fcae2;
        div {
          text-align: center;
        }
        span {
          display: block;
          text-align: center;
          margin-top: 5px;
        }
        p {
          text-align: center;
        }
      }
    }
    .tableDiv {
      margin-top: 12px;
      width: 100%;
      height: calc(85%);
      .tableSon {
        width: 100%;
        background: rgba(111, 202, 226, 0.3);
        border-radius: 0px 0px 0px 0px;
        opacity: 1;
        height: 27px;
        display: flex;
        justify-content: space-around;
        align-items: center;
        color: #fff;
        font-size: 12px;
        // opacity: 0.2;
        .row {
          color: #fff !important;
        }
      }
      .tbody {
        width: 100%;
        height: calc(100% - 60px);
        font-size: 12px;
        margin-right: 5px;
      }
      .tableSon .row,
      .tbody .row {
        display: flex;
        text-align: center;
        justify-content: left;
        //height: 40px;
        line-height: 38px;
        .td {
          color: #fff;
          &:nth-child(1) {
            flex: 1;
          }
          &:nth-child(2) {
            flex: 1;
          }
          &:nth-child(3) {
            flex: 1;
          }
          &:nth-child(4) {
            flex: 1;
            margin-right: 15px;
          }
        }
      }
    }
  }
  .centerC {
    .textDiv {
      flex: 1;
      &:nth-child(2) {
        margin-left: 20px;
      }
    }
    img {
      width: 48px;
      height: 26px;
      border-radius: 0px 0px 0px 0px;
      opacity: 1;
      margin-top: 5px;
    }
  }
  .centerRight {
    .textDivBox {
      width: 360px;
      height: 8%;
      display: flex;
      justify-content: space-between;
      .textDiv {
        margin-right: 20px;
        font-size: 12px;
        width: 100px;
        height: 41px;
      }
    }
  }
}
</style>
