<template>
  <Card title="质量管理">
    <div class="container">
      <div class="left">
        <div class="woriaTwo">
          <JRingChart
            :title="{
              text: '质量巡检',
              subTitle: `${safetyPatrolInspection.allTotal || 0}条`,
              fontSize: 16,
            }"
            :color="['#6EE4F0', '#E7622A']"
            :data="[
              {
                value: safetyPatrolInspection.allClose,
                name: '已巡检',
              },
              {
                value: safetyPatrolInspection.allNoClose,
                name: '未巡检',
              },
            ]"
            :radius="['43%', '60%']"
            :legend="false"
          />
        </div>
      </div>
      <div class="right">
        <div class="legend">
          <div class="row">
            <span
              >已闭合<span style="color: #6ee4f0; margin-left: 5px">{{
                safetyPatrolInspection.allClose || 0
              }}</span></span
            >
            <span
              >占比<span style="color: #6ee4f0; margin-left: 2px"
                >{{ safetyPatrolInspection.allCloseRatio || 0 }}%</span
              ></span
            >
          </div>
        </div>
        <div class="legend">
          <div class="row">
            <span
              >未闭合<span style="color: #e7622a; margin-left: 5px">{{
                safetyPatrolInspection.allNoClose || 0
              }}</span></span
            >
            <span
              >占比<span style="color: #e7622a; margin-left: 2px"
                >{{ safetyPatrolInspection.allNoCloseRatio || 0 }}%</span
              ></span
            >
          </div>
        </div>
      </div>
      <div class="count1">
        总次数<span>83</span
        >次
        <!-- 总次数<span>{{ allTotal2||0 }}</span
        >次 -->
      </div>
      <div class="count2">
        本周次数<span>{{ safetyPatrolInspection.weekTotal || 0 }}</span
        >次
      </div>
    </div>
  </Card>
</template>

<script>
import Card from "../components/Card";
import JRingChart from "../../common/jChart/pie/JRingChart.vue";
import { getAllAndWeekDataApi } from "@/assets/js/api/zhongjianFourth";
import { mapState } from "vuex";
import { resourceManagement } from '@/assets/js/api/zhongjianFourth'


export default {
  components: { Card, JRingChart },
  data() {
    return {
      safetyPatrolInspection: {
        allClose: 0, //所有已闭合
        allCloseRatio: 0, //所有已闭合占比
        allNoClose: 0, //所有未闭合
        allNoCloseRatio: 0, //所有未闭合占比
        allTotal: 0, //检查总数
        weekTotal: 0, //本周巡检总数
      },
      allTotal2: 0, //检查总数
    };
  },
  created() {
    this.getList()
    this.getAllTodayDataHdir();
  },
  computed: {
    ...mapState(["projectSn"]),
  },
  methods: {
    getAllTodayDataHdir() {
      getAllAndWeekDataApi({ projectSn: this.projectSn }).then((res) => {
        this.safetyPatrolInspection = res.result;
        console.log(this.safetyPatrolInspection, "getAllTodayDataHdir质量");

      });
    },
    getList() {
      resourceManagement({ projectSn: this.projectSn }).then(res => {
        console.log( "安全管理getAllTodayDataHdir------------111",res);
        this.allTotal2 = Number(res.result.constructionDay) + Number(this.safetyPatrolInspection.allTotal)
      })
    },
  },
};
</script>

<style lang="less" scoped>
.container {
  display: flex;

  width: 100%;
  height: 100%;
  padding: 8px 15px;
  .left {
    width: 100%;
    height: 100%;
    margin: -30px 0px 0px -77px;
  }
  .woriaTwo {
    width: 100%;
    height: 100%;
  }
  .right {
    width: 300px;
    height: 130px;
    background: url("~@/assets/images/zjsj/spliting.png");
    background-size: 100% 100%;
    margin-right: 23px;
    margin-top: 15px;
    .legend {
      position: relative;
      width: 160px;
      margin: 37px 0 -20px 25px;
            &::before {
        content: "";
        position: absolute;
        top: 1px;
        left: -10px;
        width: 6px;
        height: 6px;
      }

      &:nth-child(1)::before {
        width: 12px;
        height: 12px;
        background-color: #6ee4ef;
      }

      &:nth-child(2)::before {
        width: 12px;
        height: 12px;
        background-color: #e7622a;
      }

      .row {
        display: flex;

        span {
          text-align: center;

          &:first-child {
            width: 60%;
            margin-top: -8px;
          }

          &:last-child {
            width: 40%;
            margin-top: -8px;
          }
        }

        &:first-child {
          font-size: 14px;
        }

        &:last-child {
          height: 30px;
          line-height: 30px;
          font-size: 12px;
          // color: #6ae3eb;
        }
      }
    }
  }

  .count1,
  .count2 {
    width: 300px;
    padding-top: 170px;
    font-size: 16px;
    color: rgba(110, 228, 240, 0.85);
    display: flex;
    align-items: center;
    position: absolute;

    // margin-left: -300px;
    // margin: 0 322px 0 -413px;
    span {
      width: 90px;
      height: 40px;
      line-height: 40px;
      text-align: center;
      font-size: 20px;
      color: #fff;
      background: url(../assets/images/sourse/bg-car-count.png) no-repeat;
      background-size: 100% 100%;
      margin-right: 10px;
      margin-left: 10px;
    }
  }
  .count1 {
    margin: 20px 0 0 -13px;
  }
  .count2 {
    margin: 20px 0 0 210px;
  }
}
</style>
