<!--
 * @Author: your name
 * @Date: 2022-04-11 15:07:47
 * @LastEditTime: 2022-04-12 09:55:18
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: /gassafety-progress/gassafetyprogress-web/src/views/operationMonitor/xunjianxuncha/topChars/left.vue
-->
<template>
  <div class="charsCom all-flex-h">
    <div class="title">入户安检统计</div>
    <div class="two all-flex">
      <div class="left">
        <div class="first">
          <!--<span class="text">巡检年度计划</span>-->
          <span class="text">居民用户安检</span>
          <span>{{maps.jmnum}}</span>
        </div>
        <div class="second all-flex">
          <div class="left">已安检</div>
          <div class="right">到访遇到</div>
          <div class="right">拒绝安检</div>
        </div>
        <div class="third all-flex">
          <div class="left">{{maps.jmdone}}</div>
          <div class="right">{{maps.jmnone}}</div>
          <div class="right">{{maps.jmrej}}</div>
        </div>
        <div class="first fourth">
          <div class="">安检完成比例</div>
        </div>

        <div class="fifth">
          <div class="contant">
            <Chars :options="jmoptions"></Chars>
          </div>
        </div>
      </div>

      <div class="left">
        <div class="first">
          <!--<span class="text">巡检年度计划</span>-->
          <span class="text">商业用户安检</span>
          <span>{{maps.synum}}</span>
        </div>
        <div class="second all-flex">
          <div class="left">已安检</div>
          <div class="right">到访遇到</div>
          <div class="right">拒绝安检</div>
        </div>
        <div class="third all-flex">
          <div class="left">{{maps.sydone}}</div>
          <div class="right">{{maps.synone}}</div>
          <div class="right">{{maps.syrej}}</div>
        </div>
        <div class="first fourth">
          <div class="">安检完成比例</div>
        </div>

        <div class="fifth">
          <div class="contant">
            <Chars :options="syoptions"></Chars>
          </div>
        </div>
      </div>

      <div class="right">
        <div class="first">
          <!--<span class="text">巡检完成情况</span>-->
          <span class="text">工业用户安检</span>
          <span>{{maps.gynum}}</span>
        </div>
        <div class="second all-flex">
          <div class="left">已安检</div>
          <div class="right">到访遇到</div>
          <div class="right">拒绝安检</div>
        </div>
        <div class="third all-flex">
          <div class="left">{{maps.gydone}}</div>
          <div class="right">{{maps.gynone}}</div>
          <div class="right">{{maps.gyrej}}</div>
        </div>
        <div class="first fourth">
          <div class="">安检完成比例</div>
        </div>
        <div class="fifth">
          <div class="contant">
            <Chars :options="gyoptions" ></Chars>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import Chars from "@/components/allCharsCom/Chars";
import { homepageStatistic,indoorStatistic } from "@/api/statistic/statisticAnalysis";
export default {
  components: {
    Chars,
  },
  props:{
    annual: {
      type: String,
      default: 2025,
    },
    companyInfoId: {
      type: String,
      default: 23,
    },
  },
  data(){
    return{
      totalObj: {
        taskTotal: 0,
        taskFeedbackTotal: 0
      },
      maps:{},
      jmoptions:{
        color:['red',"lightblue",'blue'],
        grid: {
          bottom: "7%",
          containLabel: true,
        },
        tooltip: {
          trigger: "item",
        },
        series: [
          {
            name: '状态占比',
            type: 'pie',
            radius: ['50%', '80%'],
            label: {
              show: true,
              position: 'center'
            },
            labelLine: {
              show: false
            },
            data: [
              {value: 0, name: '拒绝安检'},
              {value: 0, name: '到访不遇'},
              {value: 0, name: '已安检'},
            ]
          }
        ]
      },
      syoptions:{
        color:['red',"lightblue",'blue'],
        grid: {
          bottom: "7%",
          containLabel: true,
        },
        tooltip: {
          trigger: "item",
        },
        series: [
          {
            name: '状态占比',
            type: 'pie',
            radius: ['50%', '80%'],
            label: {
              show: true,
              position: 'center'
            },
            labelLine: {
              show: false
            },
            data: [
              {value: 0, name: '拒绝安检'},
              {value: 0, name: '到访不遇'},
              {value: 0, name: '已安检'},
            ]
          }
        ]
      },
      gyoptions:{
        color:['red',"lightblue",'blue'],
        grid: {
          bottom: "7%",
          containLabel: true,
        },
        tooltip: {
          trigger: "item",
        },
        series: [
          {
            name: '状态占比',
            type: 'pie',
            radius: ['50%', '80%'],
            label: {
              show: true,
              position: 'center'
            },
            labelLine: {
              show: false
            },
            data: [
              {value: 0, name: '拒绝安检'},
              {value: 0, name: '到访不遇'},
              {value: 0, name: '已安检'},
            ]
          }
        ]
      },
    }
  },
  created(){
    this.getStatiData();
  },
  watch: {
    annual(newVal, oldVal) {
        //console.log(`Message changed from "${oldVal}" to "${newVal}"`);
        this.getStatiData();
      },
    companyInfoId(newVal, oldVal){
      this.getStatiData();
    }

  },
  methods:{
    getStatiData() {
      indoorStatistic({companyInfoId:this.companyInfoId,annual:this.annual}).then(response => {
        this.maps = response.data;
        this.jmoptions.series[0].data = [
          {value: this.maps.jmrej, name: '拒绝安检'},
          {value: this.maps.jmnone, name: '到访不遇'},
          {value: this.maps.jmdone, name: '已安检'},
        ]
        this.syoptions.series[0].data = [
          {value: this.maps.syrej, name: '拒绝安检'},
          {value: this.maps.synone, name: '到访不遇'},
          {value: this.maps.sydone, name: '已安检'},
        ]
        this.gyoptions.series[0].data = [
          {value: this.maps.gyrej, name: '拒绝安检'},
          {value: this.maps.gynone, name: '到访不遇'},
          {value: this.maps.gydone, name: '已安检'},
        ]

      });
    },
  }
};
</script>

<style lang="scss" scoped>
.charsCom {
  width: 100%;
  height: 100%;
  color: #333333;
}
.title {
  text-align: center;
  font-size: 24px;
  margin-bottom: 7px;
}
.two {
  flex: 1;
  > .left {
    margin-right: 70px;
  }
  > .right {
  }
  > div {
    font-size: 16px;
    flex: 1;
    // display: flex;
    // flex-direction: column;
  }
  .left,
  .right {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    .first {
      margin-bottom: 6px;
      text-align: left;
      .text {
        display: inline-block;
        margin-right: 8px;
      }
    }
    .second {
      width: 250px;
      height: 30px;
      line-height: 30px;
      box-sizing: border-box;
      box-shadow: 0px 0px 3px 1px #dddddd;
      margin-bottom: 19px;

      > div {
        // flex: 1;
        text-align: center;

        &.left {
          color: #1d8cf3;
        }
        &.right {
          color: #00c3f1;
        }
      }
    }
    .third {
      text-align: center;
      width: 250px;
      margin-bottom: 24px;
    }
    .fifth {
      flex: 1;
      // background: red;
      padding-top: 5px;
      .contant {
        width: 120px;
        height: 120px;
        margin: 0 auto;
      }
    }
  }
}
</style>
