licp
2024-12-20 d975fc4756806f5b51f006c19c33571b9b8c0b3b
src/components/view/b4-inspection-item-statistics.vue
@@ -1,79 +1,107 @@
<template>
  <div class="inspection-main" v-loading="loading">
    <div class="inspection-content" style="height:100%">
      <!-- <p style="font-size: 16px;padding:19.5px 0px">检测项目统计</p> -->
      <div class="time" style="margin-bottom: 10px;">
        <el-radio-group v-model="type" size="small">
          <el-radio-button label="周" ></el-radio-button>
          <el-radio-button label="月"></el-radio-button>
          <el-radio-button label="年"></el-radio-button>
        </el-radio-group>
        <el-date-picker
          v-model="time.week"
          type="week"
          format="yyyy 第 WW 周"
          placeholder="选择周" size="small" v-if="type=='周'" @change="m=>changeTime(type,m)">
        </el-date-picker>
        <el-date-picker
          v-model="time.month"
          type="month"
          placeholder="选择月" size="small" v-if="type=='月'" @change="m=>changeTime(type,m)">
        </el-date-picker>
        <el-date-picker
          v-model="time.year"
          type="year"
          placeholder="选择年" size="small" v-if="type=='年'" @change="m=>changeTime(type,m)">
        </el-date-picker>
      </div>
      <el-row :gutter="20">
        <el-col :xs="12" :sm="8" :md="6" :lg="4" :xl="4" style="margin-bottom: 16px;">
          <div class="inspection-card inspection-head">
            <div class="inspection-head-left">
              <h4>今日项目接收</h4>
              <span >{{ pageData.RECEVICE }}</span>
              <div class="inspection-head-left-info">
                <img :src="`../../../static/img/daliy-${pageData.RECEIVE_RATIO<0?'down':'up'}.svg`" alt="">
                <span :class="{active:pageData.RECEIVE_RATIO<0}" class="num" v-html="`&nbsp; ${handleData(pageData.RECEIVE_RATIO)}%&nbsp; `"></span>
                <span style="font-size: 12px;">较昨天</span>
          <div class="inspection-card">
            <div class="inspection-head">
              <div class="inspection-head-left">
                <h4>本{{type}}项目接收</h4>
                <span >{{ pageData.RECEVICE }}</span>
              </div>
              <img src="../../../static/img/daliy-0.svg" alt="" srcset="">
            </div>
            <img src="../../../static/img/daliy-0.svg" alt="" srcset="">
            <div class="inspection-head-left-info">
              <img :src="`../../../static/img/daliy-${pageData.RECEIVE_RATIO<0?'down':'up'}.svg`" alt="">
              <span :class="{active:pageData.RECEIVE_RATIO<0}" class="num" v-html="`&nbsp; ${handleData(pageData.RECEIVE_RATIO)}%&nbsp; `"></span>
              <span style="font-size: 12px;">较上{{type}}</span>
            </div>
          </div>
        </el-col>
        <el-col :xs="12" :sm="8" :md="6" :lg="4" :xl="4" style="margin-bottom: 16px;">
          <div class="inspection-card inspection-head">
            <div class="inspection-head-left">
              <h4>今日项目完成</h4>
              <span >{{ pageData.FINISHE }}</span>
              <div class="inspection-head-left-info">
                <img :src="`../../../static/img/daliy-${pageData.FINISHE_RATIO<0?'down':'up'}.svg`" alt="">
                <span :class="{active:pageData.FINISHE_RATIO<0}" class="num" v-html="`&nbsp; ${handleData(pageData.FINISHE_RATIO)}%&nbsp; `"></span>
                <span style="font-size: 12px;">较昨天</span>
          <div class="inspection-card">
            <div class="inspection-head">
              <div class="inspection-head-left">
                <h4>本{{type}}项目完成</h4>
                <span >{{ pageData.FINISHE }}</span>
              </div>
              <img src="../../../static/img/daliy-1.svg" alt="" srcset="">
            </div>
            <img src="../../../static/img/daliy-1.svg" alt="" srcset="">
            <div class="inspection-head-left-info">
              <img :src="`../../../static/img/daliy-${pageData.FINISHE_RATIO<0?'down':'up'}.svg`" alt="">
              <span :class="{active:pageData.FINISHE_RATIO<0}" class="num" v-html="`&nbsp; ${handleData(pageData.FINISHE_RATIO)}%&nbsp; `"></span>
              <span style="font-size: 12px;">较上{{type}}</span>
            </div>
          </div>
        </el-col>
        <el-col :xs="12" :sm="8" :md="6" :lg="4" :xl="4" style="margin-bottom: 16px;">
          <div class="inspection-card inspection-head">
            <div class="inspection-head-left">
              <h4>今日项目剩余</h4>
              <span >{{ pageData.SURPLUS }}</span>
              <div class="inspection-head-left-info">
                <img :src="`../../../static/img/daliy-${pageData.SURPLUS_RATIO<0?'down':'up'}.svg`" alt="">
                <span :class="{active:pageData.SURPLUS_RATIO<0}" class="num" v-html="`&nbsp; ${handleData(pageData.SURPLUS_RATIO)}%&nbsp; `"></span>
                <span style="font-size: 12px;">较昨天</span>
          <div class="inspection-card">
            <div class="inspection-head">
              <div class="inspection-head-left">
                <h4>本{{type}}项目剩余</h4>
                <span >{{ pageData.SURPLUS }}</span>
              </div>
              <img src="../../../static/img/daliy-2.svg" alt="" srcset="">
            </div>
            <img src="../../../static/img/daliy-2.svg" alt="" srcset="">
            <div class="inspection-head-left-info">
              <img :src="`../../../static/img/daliy-${pageData.SURPLUS_RATIO<0?'down':'up'}.svg`" alt="">
              <span :class="{active:pageData.SURPLUS_RATIO<0}" class="num" v-html="`&nbsp; ${handleData(pageData.SURPLUS_RATIO)}%&nbsp; `"></span>
              <span style="font-size: 12px;">较上{{type}}</span>
            </div>
          </div>
        </el-col>
        <el-col :xs="12" :sm="8" :md="6" :lg="4" :xl="4" style="margin-bottom: 16px;">
          <div class="inspection-card inspection-head" style="flex-direction: column;padding-bottom: 5px;">
            <h4 style="margin-bottom: 5px;">今日项目合格率</h4>
            <h4 style="margin-bottom: 5px;">本{{type}}项目合格率</h4>
            <echart-module :id="'inspection-qualified'" :config="chartConfig2" :datas="chartData2" style="align-self: center;"></echart-module>
          </div>
        </el-col>
        <el-col :xs="12" :sm="8" :md="6" :lg="4" :xl="4" style="margin-bottom: 16px;">
          <div class="inspection-card inspection-head" style="flex-direction: column;padding-bottom: 5px;">
            <h4 style="margin-bottom: 5px;">今日项目完成率</h4>
            <h4 style="margin-bottom: 5px;">本{{type}}项目完成率</h4>
            <echart-module :id="'inspection-complete'" :config="chartConfig3" :datas="chartData3" style="align-self: center;"></echart-module>
          </div>
        </el-col>
        <el-col :xs="12" :sm="8" :md="6" :lg="4" :xl="4" style="margin-bottom: 16px;">
          <div class="inspection-card inspection-head" style="flex-direction: column;padding-bottom: 5px;">
            <h4 style="margin-bottom: 5px;">今日项目延期率</h4>
            <h4 style="margin-bottom: 5px;">本{{type}}项目延期率</h4>
            <echart-module :id="'inspection-extension'" :config="chartConfig4" :datas="chartData4" style="align-self: center;"></echart-module>
          </div>
        </el-col>
      </el-row>
      <el-row :gutter="20" style="height: calc(100% - 170px);">
      <el-row :gutter="20" style="height: calc(100% - 200px);">
        <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12" style="margin-bottom: 16px; height: 100%;">
          <div class="inspection-card chart-box" style="height: 100%;">
            <h4>近10日项目接收量</h4>
            <h4>本{{type}}项目接收量</h4>
            <echart-module :id="'inspection-left'" :config="chartConfig0" :datas="chartData0" style="height: calc(100% - 32px);"></echart-module>
          </div>
        </el-col>
        <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12" style="margin-bottom: 16px;height: 100%;">
          <div class="inspection-card chart-box" style="height: 100%;">
            <h4>近10日实际完成项目与接收项目对比</h4>
            <h4>本{{type}}实际完成项目与接收项目对比</h4>
            <echart-module :id="'inspection-right'" :config="chartConfig1" :datas="chartData1" style="height: calc(100% - 32px);"></echart-module>
          </div>
        </el-col>
@@ -85,6 +113,9 @@
  <script>
  import EchartModule from '../tool/echart.vue'
  import {
      getYearAndMonthAndDays
   } from '../../util/date'
  export default {
    components: {EchartModule},
    data(){
@@ -112,11 +143,11 @@
          xData:[],
          yData:[
            {
              title:'今日接收',
              title:'接收',
              data:[]
            },
            {
              title:'今日完成',
              title:'完成',
              data:[]
            },
          ]
@@ -128,8 +159,8 @@
          type:'pie'
        },
        chartData2:{
          title:'今日项目合格率',
          percentage:'68%',
          title:'项目合格率',
          percentage:'0',
          color:['#1CCAB8','#E1E4E8'],
          data:[
            {
@@ -149,17 +180,17 @@
          type:'pie'
        },
        chartData3:{
          title:'今日项目完成率',
          percentage:'68%',
          title:'项目完成率',
          percentage:'0',
          color:['#FBB647','#E1E4E8'],
          data:[
            {
              name:'完成',
              value:'68'
              value:'0'
            },
            {
              name:'未完成',
              value:'32'
              value:'0'
            },
          ]
        },
@@ -170,26 +201,55 @@
          type:'pie'
        },
        chartData4:{
          title:'今日项延期率',
          percentage:'68%',
          title:'项延期率',
          percentage:'0',
          color:['#FF3838','#E1E4E8'],
          data:[
            {
              name:'延期',
              value:'68'
              value:'0'
            },
            {
              name:'未延期',
              value:'32'
              value:'0'
            },
          ]
        },
        loading:false,
        pageData:{}
        pageData:{},
        timers:null,
        type:'周',
        time:{
          week:'',
          month:'',
          year:'',
        },
        startTime:'',
        endTime:''
      }
    },
    watch:{
    type(val){
      switch(val){
        case '周':
          this.time.week = new Date()
          this.changeTime(val,this.time.week)
          break;
        case '月':
          this.time.month = new Date()
          this.changeTime(val,this.time.month)
          break;
        case '年':
          this.time.year = new Date()
          this.changeTime(val,this.time.year)
          break;
      }
    }
  },
    mounted(){
      this.init()
      this.changeTime(this.type)
      // this.timers&&clearInterval(this.timers);
      // setInterval(this.changeTime(this.type),1000*60*5)
    },
    methods:{
      init(){
@@ -199,21 +259,25 @@
      this.chartConfig3.isLoading = false
      this.chartConfig4.isLoading = false
      this.loading = true;
      this.$axios.get(this.$api.report.testProductByDay).then(res => {
      this.$axios.get(this.$api.report.testProductByDay+'?startTime='+this.startTime+'&endTime='+this.endTime+'&type='+this.type).then(res => {
        if (res.code == 201) return
        this.pageData = this.HaveJson(res.data)
        let xData = res.data.DAYS.map(m=>{
          let arr = m.split('-')
          return `${arr[1]}-${arr[2]}`
          if(this.type=='年'){
            return `${arr[1]}月`
          }else{
            return `${arr[1]}-${arr[2]}`
          }
        })
        this.chartData0.xData = xData
        this.chartData1.xData = xData
        this.chartData0.yData[0].data = this.pageData.RECETENDAYS
        this.chartData1.yData[0].data = this.pageData.RECETENDAYS
        this.chartData1.yData[1].data = this.pageData.FINISHTENDAYS
        this.chartData2.percentage = this.pageData.ACCEPT_RATE_TODAY*100+'%'
        this.chartData3.percentage = this.pageData.FINISH_RATE_TODAY*100+'%'
        this.chartData4.percentage = this.pageData.DELAY_RATE_TODAY*100+'%'
        this.chartData2.percentage = (this.pageData.ACCEPT_RATE_TODAY*100).toFixed(0)+'%'
        this.chartData3.percentage = (this.pageData.FINISH_RATE_TODAY*100).toFixed(0)+'%'
        this.chartData4.percentage = (this.pageData.DELAY_RATE_TODAY*100).toFixed(0)+'%'
        this.chartData2.data[0].value = this.pageData.ACCEPT
        this.chartData2.data[1].value = this.pageData.FINISHE - this.pageData.ACCEPT
        this.loading = false;
@@ -227,14 +291,46 @@
        this.chartConfig3.isLoading = true
        this.chartConfig4.isLoading = true
      })
    },
      },
      handleData(val){
        if(val){
          return Math.abs(val)*100;
          let num = Math.abs(val)*100
          return num.toFixed(0);
        }else{
          return '0'
        }
      },
      changeTime(type,m){
        if(m){
          switch(type){
            case '周':
              this.startTime  = getYearAndMonthAndDays(new Date(this.time.week.getTime() - 24 * 60 * 60 * 1000))
              this.endTime = getYearAndMonthAndDays(new Date(this.time.week.getTime() + 24 * 60 * 60 * 1000 * 5))
              break;
            case '月':
              const year = new Date(this.time.month).getFullYear();
              const month = new Date(this.time.month).getMonth();
              const day = new Date(year, month + 1, 0).getDate(); //
              // 设置起始日期和结束日期
              this.startTime = `${year}-${month + 1}-01`
              this.endTime = `${year}-${month + 1}-${day}` // 月末
              break;
            case '年':
              const year0 = new Date(this.time.year).getFullYear();
              this.startTime = `${year0}-01-01`; // 年初
              this.endTime = `${year0}-12-31`; // 年末
              break;
          }
        }else{
          this.startTime = getYearAndMonthAndDays(new Date((new Date).getTime() - 24 * 60 * 60 * 1000))
          this.endTime = getYearAndMonthAndDays(new Date((new Date).getTime() + 24 * 60 * 60 * 1000 * 5))
          this.time.week = new Date()
        }
        this.init()
      }
    },
    deactivated(){
      this.timers&&clearInterval(this.timers);
    }
  }
  </script>
@@ -254,11 +350,11 @@
    background: #FFFFFF;
    border-radius: 14px;
    box-shadow: 6px 6px 54px 0px rgba(0,0,0,0.05);
    padding: 16px;
  box-sizing: border-box;
  }
  .inspection-head{
    padding: 16px;
    box-sizing: border-box;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
@@ -275,23 +371,23 @@
  .inspection-head-left>span{
    font-family: Nunito Sans-Bold;color: #202224;
    font-weight: bold;
    font-size: 28px;
    font-size: 24px;
    display: inline-block;
    margin-bottom: 16px;
    margin-bottom: 18px;
  }
  .inspection-head-left .inspection-head-left-info{
  .inspection-head-left-info{
    display: flex;
    align-items: center;
    font-size: 16px;
    color: #202224;
  }
  .inspection-head-left .inspection-head-left-info .num{
  .num{
    color: #00B69B;
  }
  .inspection-head-left .inspection-head-left-info .num.active{
  .num.active{
    color: #F93C65;
  }