<template>
  <div class="hidden-danger-detection">
    <div class="hidden-danger-detection_top">
      <div>按排查进度分：</div>
      <div class="hidden-danger-detection_top_inner">
        <hidden-danger-total :number="yhds" label="总数" unit="栋/次" />
        <hidden-danger-total :number="yhgs" label="隐患数" unit="栋/条" />
      </div>
    </div>
    <div class="hidden-danger-detection_bottom">
      <div class="item">
        <HiddenDangerType :yhType="yhType" />
      </div>
      <div class="item">
        <Rectification :ScheduletList="ScheduletList"/>
      </div>
    </div>
  </div>
</template>

<script>
import HiddenDangerTotal from "@/components/HiddenDangerTotal.vue";
import HiddenDangerType from "./HiddenDangerType.vue";
import Rectification from "./RectificationChart.vue";
import { getPcjd,getYhlx,getYhzt } from "@/api/index.js";
export default {
  name: "HiddenDangerDetection",
  components: {
    HiddenDangerTotal,
    HiddenDangerType,
    Rectification,
  },
  props:{
    qy:String
  },
  data(){
    return{
      yhds:'',
      yhgs:'',
     yhType:[],
      ypclds:'',
      list:[],
      ScheduletList:[],
           // 传参
           params:{
        pageSize:100,
        pageNum:1,
      },

    }
  },
  watch:{
    qy(){
      this.getNum()
    this.getType()
    this.getSchedulet()
    }
  },
  methods:{
    getNum(){
      getPcjd({...this.params,qy:this.qy==='重庆市'?'':this.qy}).then(res=>{
        this.list=res.data.rows.map(item=>{
          this.yhds=item.yhds+'/'+item.yhgs
          this.yhgs=item.ypclds+'/'+item.ypcldcs
        })
      })
    },
    // 隐患类型
    getType(){
      getYhlx({...this.params,qy:this.qy==='重庆市'?'':this.qy}).then(res=>{
        const data = res.data.rows[0];
        if (data) {
          this.yhType= [
             {
                value: data.xfss,
                name: "消防设施",
              },
              {
                value: data.smtd,
                name: "生命通道",
              },
              {
                value: data.ydyq,
                name: "用电用气",
              },
              {
                value: data.xfgl,
                name: "消防管理",
              },
          ]
        }
      })
    },
    // 整改进度
    getSchedulet(){
      getYhzt({...this.params,qy:this.qy==='重庆市'?'':this.qy}).then(res=>{
        const data = res.data.rows[0];
        if (data) {
          this.ScheduletList= [
             {
                value: data.djh,
                name: "待计划整改",
              },
              {
                value: data.dzg,
                name: "已计划待整改",
              },
              {
                value: data.yzg,
                name: "已整改",
              },
          ]
        }
    })
    }
  },
  created(){
    this.getNum()
    this.getType()
    this.getSchedulet()
  }
};
</script>

<style scoped lang="less">
.hidden-danger-detection_top {
  margin: 5px 4px;
  background-color: rgba(0, 213, 255, 0.12);
  padding: 8px;
  display: flex;
  align-items: center;
  .hidden-danger-detection_top_inner {
    display: flex;
  }
}

.hidden-danger-detection_bottom {
  display: flex;
  margin: 0px 4px;
  gap: 4px;
  .item {
    background-color: rgba(0, 213, 255, 0.12);
    height: 231px;
    &:nth-child(1) {
      width: 200px;
    }
    &:nth-child(2) {
      width: 234px;
    }
  }
}
</style>
