<template>
  <div class="statistics-box flex-row">
		<div class="statistics-all flex-row">
      <div class="statistics-progress">
        <div class="statistics-progress-num">
          <p>{{taskProgress?taskProgress:0 + '%'}}</p>
          <p>完成情况</p>
        </div>
        <el-progress :width="90" type="circle" :percentage="taskProgress?taskProgress:0" :show-text="false"></el-progress>
      </div>
      <div class="statistics-all-box flex-col">
        <span>总任务：<b>{{allCount}}</b></span>
        <span>已完成：<b>{{alreadyCount}}</b></span>
      </div>
    </div>
		<ul class="statistics-list flex-row">
      <li>
        <p class="statistics-list-text">现场未找到（需人工确认）：</p>
        <p class="statistics-list-num">{{notFoundCount}}</p>
      </li>
      <li>
        <p class="statistics-list-text">待验证任务：</p>
        <p class="statistics-list-num">{{waitCount}}</p>
      </li>
      <li>
        <p class="statistics-list-text">待撕码任务：</p>
        <p class="statistics-list-num">{{waitTearCount}}</p>
      </li>
      <li>
        <p class="statistics-list-text">待换码任务：</p>
        <p class="statistics-list-num">{{waitReplaceCount}}</p>
      </li>
    </ul>
	</div>
</template>

<script>
import { mapGetters } from "vuex"
import { queryTaskCount, countAssetsTask } from "@/api/data_admin/buildTaskApi"
export default {
  components: {
    
  },
  computed: {
    ...mapGetters("layout", ["projectId", "secret", "userId" ]),
    taskProgress(){
      if(typeof this.alreadyCount == 'number' && typeof this.allCount == 'number'){
        return Math.round(this.alreadyCount/this.allCount*100)
      }
    }
  },
  data() {
    return {
      allCount: '',//总任务
      alreadyCount: '',//已完成
      notFoundCount: '',//未找到
      waitCount: '',//未完成验证
      waitTearCount: '',//未完成撕码任务
      waitReplaceCount: ''//未完成换码任务
    }
  },
  created() {
    this.getTaskCount();
  },
  methods: {
    getTaskCount(){
      queryTaskCount({},(res) => {
        this.allCount = res.Count
      })
      queryTaskCount({Filters: `TaskState=0`},(res) => {
        this.alreadyCount = res.Count
      })
      queryTaskCount({Filters: `TaskState=-1`},(res) => {
        this.notFoundCount = res.Count
      })
      queryTaskCount({Filters: `TaskState=1`},(res) => {
        this.waitCount = res.Count
      })
      countAssetsTask({Filters: `TaskState=1&&TaskType='3'`},(res) => {
        this.waitTearCount = res.Count
      })
      countAssetsTask({Filters: `TaskState=1&&TaskType='2'`},(res) => {
        this.waitReplaceCount = res.Count
      })
    }
  }
}
</script>
<style lang="scss" scoped>
	.statistics-box {
		height: 120px;
    color: #333;
    .statistics-all{
      flex: 2;
      border: 1px solid #c9c9c9;
      margin-right: 10px;
      background: #fff;
      .statistics-progress{
        flex: 1;
        position: relative;
        height: 120px;
        box-sizing: border-box;
        text-align: center;
        padding: 15px 0;
        .statistics-progress-num{
          font-size: 12px;
          line-height: 18px;
          position: absolute;
          top: 50%;
          left: 50%;
          transform: translate(-50%, -50%);
        }
      }
      .statistics-all-box{
        flex: 1;
        font-weight: bold;
        padding: 25px 0;
        >span{
          flex: 1;
          font-size: 15px;
          line-height: 35px;
        } 
      }
    }
    .statistics-list{
      flex: 7;
      >li{
        flex: 1;
        border: 1px solid #c9c9c9;
        padding: 10px;
        margin-left: 10px;
        background: #fff;
        .statistics-list-text{
          font-size: 15px;
          line-height: 30px;
          font-weight: bold;
        }
        .statistics-list-num{
          text-align: center;
          font-size: 20px;
          line-height: 50px;
          font-weight: bold;
        }
      }
    }
	}
  .flex-row{
    display: flex;
		flex-direction: row;
  }
  .flex-col{
    display: flex;
		flex-direction: column;
  }
</style>