<template>
  <div class="container">
    <div class="block1">
      <layout-title title="安全作业状态统计" />
      <div class="option">
        <div
          class="list"
          v-for="(item, index) in data.block1OptionsList"
          :key="index"
        >
          <img :src="item.img" alt="" class="img" />
          <div class="label">{{ item.label }}</div>
          <div class="num">
            <count-up :end-val="item.count"></count-up>
          </div>
        </div>
      </div>
    </div>

    <div class="block2">
      <layout-title title="安全作业情况统计" />
      <div class="option" id="main1"></div>
    </div>
    <div class="block3">
      <layout-title title="安全作业记录" />
      <div class="option">
        <div class="table">
          <div class="tr">
            <div class="td">序号</div>
            <div class="td">作业类型</div>
            <div class="td">状态</div>
            <div class="td">下一步操作人</div>
          </div>
          <div class="tr" v-for="(item, index) in data.block3List" :key="index">
            <template v-if="index < 10">
              <div class="td">{{ index + 1 }}</div>
              <div class="td line-1">
                <el-tooltip :content="formatWork(item)">{{
                  formatWork(item)
                }}</el-tooltip>
              </div>
              <div class="td line-1">
                <el-tooltip :content="item.STEP_NAME">{{
                  item.STEP_NAME
                }}</el-tooltip>
              </div>
              <div class="td line-1">
                <el-tooltip :content="item.NEXT_STEP_NAME">{{
                  item.NEXT_STEP_NAME
                }}</el-tooltip>
              </div>
            </template>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script setup>
import LayoutTitle from "./title.vue";
import CountUp from "vue-countup-v3";
import { onMounted, reactive } from "vue";
import echarts5 from "../js/echarts5.js";
import { getEightWorks } from "@/request/map";

const data = reactive({
  block1OptionsList: [
    {
      img: new URL("/src/assets/images/map/img4.png", import.meta.url).href,
      label: "申请数",
      count: 0,
    },
    {
      img: new URL("/src/assets/images/map/img5.png", import.meta.url).href,
      label: "审批中",
      count: 0,
    },
    {
      img: new URL("/src/assets/images/map/img6.png", import.meta.url).href,
      label: "归档数",
      count: 0,
    },
  ],
  block3List: [],
});
onMounted(async () => {
  const { staMapCount, monthMapCount, eightworks } = await getEightWorks();
  data.block1OptionsList[0].count = staMapCount.total;
  data.block1OptionsList[1].count = staMapCount.flowing;
  data.block1OptionsList[2].count = staMapCount.finished;
  echarts5("main1", monthMapCount);

  data.block3List = eightworks.filter((item) => {
    return item.NEXT_STEP_ID !== 99 && item.STATUS === 1;
  });
});

const formatWork = (work) => {
  let type = "";
  switch (work.WORK_TYPE) {
    case "HOTWORK":
      type = "动火作业";
      break;
    case "CONFINEDSPACE":
      type = "受限空间作业";
      break;
    case "HIGHWORK":
      type = "高处作业";
      break;
  }
  return type + "编号:" + work.CHECK_NO;
};
</script>
<style scoped lang="scss">
.container {
  width: 100%;

  .block1 {
    width: 430px;

    .option {
      width: 100%;
      min-height: 100px;
      background-image: linear-gradient(
        to bottom,
        rgba(0, 0, 0, 0),
        rgba(0, 0, 0, 0.8)
      );
      border-radius: 10px;
      border: 1px solid;
      border-image: linear-gradient(
          to bottom,
          rgba(58, 122, 149, 0),
          rgba(16, 188, 236, 1)
        )
        1;
      border-top: none;
      display: flex;
      justify-content: space-around;
      padding: 20px 0;
      text-align: center;

      .list {
        text-align: center;
        width: 33%;

        .img {
          animation: slideY 2s infinite;
        }

        .label {
          margin-top: 5px;
        }

        .num {
          font-size: 24px;
          margin-top: 10px;
          background: linear-gradient(to top, #ffffff, #00a8ff);
          -webkit-background-clip: text;
          -webkit-text-fill-color: transparent;
          font-weight: bold;
          font-family: "Pingfang SC", "Microsoft YaHei", "Monospaced Number",
            "Chinese Quote", -apple-system, BlinkMacSystemFont, "Segoe UI",
            Roboto, "PingFang SC", "Hiragino Sans GB", "Helvetica Neue",
            Helvetica, Arial, sans-serif;
          text-shadow: 0 0 20px #2c67ec;
        }
      }
    }
  }

  .block2 {
    width: 430px;
    margin-top: 10px;

    .option {
      width: 100%;
      min-height: 100px;
      background-image: linear-gradient(
        to bottom,
        rgba(0, 0, 0, 0),
        rgba(0, 0, 0, 0.8)
      );
      border-radius: 10px;
      border: 1px solid;
      border-image: linear-gradient(
          to bottom,
          rgba(58, 122, 149, 0),
          rgba(16, 188, 236, 1)
        )
        1;
      border-top: none;
      padding: 20px 0;
      height: 225px;
    }
  }

  .block3 {
    width: 430px;
    margin-top: 10px;

    .option {
      width: 100%;
      min-height: 100px;
      background-image: linear-gradient(
        to bottom,
        rgba(0, 0, 0, 0),
        rgba(0, 0, 0, 0.8)
      );
      border-radius: 10px;
      border: 1px solid;
      border-image: linear-gradient(
          to bottom,
          rgba(58, 122, 149, 0),
          rgba(16, 188, 236, 1)
        )
        1;
      border-top: none;
      padding: 10px;

      .table {
        margin-top: 5px;

        .tr {
          display: flex;

          &:nth-child(odd) {
            background-color: rgba(42, 86, 158, 0.53);
          }

          .td {
            flex: 1;
            text-align: center;
            font-size: 14px;
            color: #fff;
            padding: 10px 10px;

            &:nth-child(1) {
              flex-basis: 20px;
            }

            &:nth-child(2) {
              flex-basis: 30%;
            }

            &:nth-child(4) {
              flex-basis: 15%;
            }
          }

          .empty {
            flex: 1;
            text-align: center;
            font-size: 12px;
            color: #fff;
            padding: 5px;
          }
        }
      }
    }
  }

  @keyframes slideY {
    0% {
      transform: translateY(0);
    }
    50% {
      transform: translateY(-5px);
    }
    100% {
      transform: translateY(0);
    }
  }
}
</style>