<template> 
 | 
    <div class="main_app1" v-if="info"> 
 | 
        <div class="main_head"> 
 | 
            <div class="main_head_title"> 
 | 
                <span>入园人员统计总览</span> 
 | 
                <el-radio-group v-model="isGroupBy" size="mini" @change="getData(), getRataLists(), getReportLists()"> 
 | 
                    <el-radio-button :label="0">按车次统计</el-radio-button> 
 | 
                    <el-radio-button :label="1">按车辆统计</el-radio-button> 
 | 
                </el-radio-group> 
 | 
            </div> 
 | 
            <div class="main_head_bottom"> 
 | 
                <div class="main_head_item blue"> 
 | 
                    <span>{{info.todayTotal}}</span> 
 | 
                    <span>今日</span> 
 | 
                </div> 
 | 
                <div class="main_head_item red"> 
 | 
                    <span>{{info.yesterdayTotal}}</span> 
 | 
                    <span>昨日</span> 
 | 
                </div> 
 | 
                <div class="main_head_item yellow"> 
 | 
                    <span>{{info.weekTotal}}</span> 
 | 
                    <span>本周</span> 
 | 
                </div> 
 | 
                <div class="main_head_item orange"> 
 | 
                    <span>{{info.monthTotal}}</span> 
 | 
                    <span>本月</span> 
 | 
                </div> 
 | 
                <div class="main_head_item darkBlue"> 
 | 
                    <span>{{info.yearTotal}}</span> 
 | 
                    <span>本年</span> 
 | 
                </div> 
 | 
            </div> 
 | 
        </div> 
 | 
        <div class="main_content"> 
 | 
            <div class="type_wrap"> 
 | 
                <div class="title">全年入园人员趋势</div> 
 | 
                <div class="echart1" ref="typeRef" v-if="info.cumulativeDataList"></div> 
 | 
                <div style="width: 100%;height: 100%;display: flex;align-items: center;justify-content: center;" v-else> 
 | 
                    <img style="width: 200px;" src="@/assets/images/default_homeimg.png" alt=""> 
 | 
                </div> 
 | 
            </div> 
 | 
            <div class="dept_wrap"> 
 | 
                <div class="title"> 
 | 
                    <span>人员分类统计</span> 
 | 
                    <el-radio-group style="margin-left: 20px;" v-model="dateType" size="mini" @change="changeDateType"> 
 | 
                        <el-radio-button label="month">月</el-radio-button> 
 | 
                        <el-radio-button label="year">年</el-radio-button> 
 | 
                    </el-radio-group> 
 | 
                    <el-date-picker 
 | 
                        v-model="value" 
 | 
                        :type="dateType" 
 | 
                        size="mini" 
 | 
                        @change="getRataLists()" 
 | 
                        :value-format="dateType === 'month' ? 'yyyy-MM' : 'yyyy'" 
 | 
                        style="margin-left: 20px; width: 130px;" 
 | 
                        placeholder="请选择"> 
 | 
                    </el-date-picker> 
 | 
                </div> 
 | 
                <div id="echart2" ref="deptRef" v-if="listZB.length > 0"></div> 
 | 
                <div style="width: 100%;height: 100%;display: flex;align-items: center;justify-content: center;" v-else> 
 | 
                    <img style="width: 200px;" src="@/assets/images/default_homeimg.png" alt=""> 
 | 
                </div> 
 | 
            </div> 
 | 
        </div> 
 | 
        <div class="main_table"> 
 | 
            <div class="main_table_list"> 
 | 
                <div class="title" style="display: flex; align-items: center; justify-content: space-between;"> 
 | 
                    <div> 
 | 
                        <span>入园人员统计表</span> 
 | 
                        <el-radio-group style="margin-left: 20px;" v-model="radio" size="mini" @change="changeBB"> 
 | 
                            <el-radio-button label="month">月</el-radio-button> 
 | 
                            <el-radio-button label="year">年</el-radio-button> 
 | 
                        </el-radio-group> 
 | 
                        <el-date-picker 
 | 
                            v-model="date1" 
 | 
                            :type="radio" 
 | 
                            size="mini" 
 | 
                            @change="getReportLists()" 
 | 
                            :value-format="radio === 'month' ? 'yyyy-MM' : 'yyyy'" 
 | 
                            style="margin-left: 20px; width: 130px;" 
 | 
                            placeholder="请选择"> 
 | 
                        </el-date-picker> 
 | 
                    </div> 
 | 
                    <el-button type="primary" size="mini" style="margin-left: 20px;" @click="daochu">导出</el-button> 
 | 
                </div> 
 | 
                <div class="list_head"> 
 | 
                    <div class="list_head_item" v-for="(item, index) in column" :key="index">{{item}}</div> 
 | 
                </div> 
 | 
                <div class="table_box"> 
 | 
                    <div class="list_content" v-for="(item, index) in list" :key="index"> 
 | 
                        <div class="list_head_item">储运科</div> 
 | 
                        <div class="list_head_item">联合工房</div> 
 | 
                        <div class="list_head_item">232</div> 
 | 
                        <div class="list_head_item">储运科</div> 
 | 
                        <div class="list_head_item">联合工房</div> 
 | 
                        <div class="list_head_item">232</div> 
 | 
                        <div class="list_head_item">储运科</div> 
 | 
                        <div class="list_head_item">联合工房</div> 
 | 
                        <div class="list_head_item">232</div> 
 | 
                        <div class="list_head_item">232</div> 
 | 
                    </div> 
 | 
                </div> 
 | 
            </div> 
 | 
            <div class="main_table_list1"> 
 | 
                <div class="title"> 
 | 
                    <span>本年人员累计入园统计</span> 
 | 
                </div> 
 | 
                <div class="list_head"> 
 | 
                    <div class="list_head_item">车辆分类</div> 
 | 
                    <div class="list_head_item">入局次数</div> 
 | 
                </div> 
 | 
                <div class="table_box"> 
 | 
                    <div class="list_content" v-for="(item, index) in info.yearSortList" :key="index"> 
 | 
                        <div class="list_head_item">{{item.name}}</div> 
 | 
                        <div class="list_head_item">{{item.total}}</div> 
 | 
                    </div> 
 | 
                </div> 
 | 
            </div> 
 | 
        </div> 
 | 
    </div> 
 | 
</template> 
 | 
  
 | 
<script> 
 | 
  import * as echarts from 'echarts' 
 | 
  import { getInParkUserData, getRataList, getReportList, reportExportExcel } from '@/api/business' 
 | 
  export default { 
 | 
    data() { 
 | 
      return { 
 | 
        info: null, 
 | 
        isGroupBy: 0, 
 | 
        radio: 'month', 
 | 
        value: '', 
 | 
        dateType: 'month', 
 | 
        date: '', 
 | 
        date1: '', 
 | 
  
 | 
        listZB: [], 
 | 
        column: [], 
 | 
        list: [] 
 | 
      } 
 | 
    }, 
 | 
    mounted() { 
 | 
      var now = new Date(); 
 | 
      var year = now.getFullYear(); 
 | 
      var month = now.getMonth() + 1 > 9 ? now.getMonth() + 1 : `0${now.getMonth() + 1}`; 
 | 
      this.value = `${year}-${month}` 
 | 
      this.date1 = `${year}-${month}` 
 | 
  
 | 
      this.getData() 
 | 
      this.getRataLists() 
 | 
      this.getReportLists() 
 | 
    }, 
 | 
    methods: { 
 | 
      // 导出 
 | 
      daochu() { 
 | 
        reportExportExcel({ dateStr: this.date1, isGroupBy: this.isGroupBy, type: 1 }).then(res => { 
 | 
          this.download(res) 
 | 
          console.log(res.data) 
 | 
        }) 
 | 
      }, 
 | 
      changeBB() { 
 | 
        if (this.radio === 'month') { 
 | 
          let now = new Date(); 
 | 
          let year = now.getFullYear(); 
 | 
          let month = now.getMonth() + 1 > 9 ? now.getMonth() + 1 : `0${now.getMonth() + 1}`; 
 | 
          this.date1 = `${year}-${month}` 
 | 
        } else { 
 | 
          let now = new Date(); 
 | 
          let year = now.getFullYear(); 
 | 
          this.date1 = `${year}` 
 | 
        } 
 | 
        this.getReportLists() 
 | 
      }, 
 | 
      // 入园车辆统计表 
 | 
      getReportLists() { 
 | 
        getReportList({ dateStr: this.date1, isGroupBy: this.isGroupBy, type: 1 }) 
 | 
          .then(res => { 
 | 
            console.log(res) 
 | 
  
 | 
            this.column = res.data.map(item => item[0]) 
 | 
  
 | 
            const keys = res.data.map(row => row[0]); // 获取键名 
 | 
            const values = res.data.map(row => row.slice(1, row.length)); // 获取值 
 | 
  
 | 
            this.list = values[0].map((_, index) => { 
 | 
              return keys.reduce((obj, key, i) => { 
 | 
                obj[key] = values[i][index]; 
 | 
                return obj; 
 | 
              }, {}); 
 | 
            }); 
 | 
          }) 
 | 
      }, 
 | 
      changeDateType() { 
 | 
        if (this.dateType === 'month') { 
 | 
          let now = new Date(); 
 | 
          let year = now.getFullYear(); 
 | 
          let month = now.getMonth() + 1 > 9 ? now.getMonth() + 1 : `0${now.getMonth() + 1}`; 
 | 
          this.value = `${year}-${month}` 
 | 
        } else { 
 | 
          let now = new Date(); 
 | 
          let year = now.getFullYear(); 
 | 
          this.value = `${year}` 
 | 
        } 
 | 
        this.getRataLists() 
 | 
      }, 
 | 
      // 车辆分类统计 
 | 
      getRataLists() { 
 | 
        getRataList({ dateStr: this.value, isGroupBy: this.isGroupBy, type: 1 }) 
 | 
          .then(res => { 
 | 
            console.log(res) 
 | 
            this.listZB = res 
 | 
            this.$nextTick(() => { 
 | 
              this.initDept() 
 | 
            }) 
 | 
          }) 
 | 
      }, 
 | 
      // 基础数据 
 | 
      getData() { 
 | 
        getInParkUserData({ isGroupBy: this.isGroupBy, type: 1 }).then(res => { 
 | 
          this.info = res 
 | 
          this.$nextTick(() => { 
 | 
            this.initType() 
 | 
          }) 
 | 
        }) 
 | 
      }, 
 | 
      // 全年入园车辆趋势 
 | 
      initType() { 
 | 
        if (!this.info.cumulativeDataList) return 
 | 
  
 | 
        const myChart = echarts.init(document.querySelector('.echart1')) 
 | 
  
 | 
        let names = this.info.cumulativeDataList.map(item => item.name) 
 | 
        let datas = this.info.cumulativeDataList.map(item => item.total) 
 | 
  
 | 
        let option = { 
 | 
          grid: { 
 | 
            left: '5%', 
 | 
            right: '10%', 
 | 
            bottom: '0%', 
 | 
            top: '20%', 
 | 
            containLabel: true 
 | 
          }, 
 | 
          xAxis: { 
 | 
            type: 'category', 
 | 
            data: names 
 | 
          }, 
 | 
          yAxis: { 
 | 
            type: 'value' 
 | 
          }, 
 | 
          series: [ 
 | 
            { 
 | 
              data: datas, 
 | 
              type: 'line' 
 | 
            } 
 | 
          ] 
 | 
        } 
 | 
        myChart.setOption(option) 
 | 
        window.addEventListener('resize', function () { // 执行 
 | 
          myChart.resize() 
 | 
        }) 
 | 
      }, 
 | 
      // 车辆分类统计 
 | 
      initDept() { 
 | 
        if (!this.listZB) return 
 | 
  
 | 
        const myChart = echarts.init(document.querySelector('#echart2')) 
 | 
  
 | 
        let data = this.listZB.map(item => { 
 | 
          return { 
 | 
            value: item.total, 
 | 
            name: item.name 
 | 
          } 
 | 
        }) 
 | 
  
 | 
        let option = { 
 | 
          series : [ 
 | 
            { 
 | 
              name: '访问来源', 
 | 
              type: 'pie', 
 | 
              radius: '55%', 
 | 
              data: data 
 | 
            } 
 | 
          ] 
 | 
        } 
 | 
        myChart.setOption(option) 
 | 
        window.addEventListener('resize', function () { // 执行 
 | 
          myChart.resize() 
 | 
        }) 
 | 
      }, 
 | 
      initDept3() { 
 | 
        const myChart = echarts.init(document.querySelector('#echart3')) 
 | 
  
 | 
        let option = { 
 | 
          grid: { 
 | 
            left: '5%', 
 | 
            right: '10%', 
 | 
            bottom: '0%', 
 | 
            top: '20%', 
 | 
            containLabel: true 
 | 
          }, 
 | 
          xAxis: { 
 | 
            type: 'category', 
 | 
            data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] 
 | 
          }, 
 | 
          yAxis: { 
 | 
            type: 'value' 
 | 
          }, 
 | 
          series: [ 
 | 
            { 
 | 
              data: [150, 230, 224, 218, 135, 147, 260], 
 | 
              type: 'line' 
 | 
            } 
 | 
          ] 
 | 
        } 
 | 
        myChart.setOption(option) 
 | 
        window.addEventListener('resize', function () { // 执行 
 | 
          myChart.resize() 
 | 
        }) 
 | 
      } 
 | 
    } 
 | 
  } 
 | 
</script> 
 | 
  
 | 
<style lang="scss" scoped> 
 | 
    .main_app1 { 
 | 
        width: 100%; 
 | 
        height: calc(100% - 44px); 
 | 
        overflow-y: auto; 
 | 
        overflow-x: hidden; 
 | 
        padding: 15px; 
 | 
        box-sizing: border-box; 
 | 
        background-color: #ffffff; 
 | 
        .main_head { 
 | 
            width: 100%; 
 | 
            display: flex; 
 | 
            align-items: center; 
 | 
            flex-direction: column; 
 | 
            margin-bottom: 20px; 
 | 
            .main_head_title { 
 | 
                width: 100%; 
 | 
                display: flex; 
 | 
                align-items: center; 
 | 
                margin-bottom: 20px; 
 | 
                span { 
 | 
                    font-weight: 600; 
 | 
                    font-size: 16px; 
 | 
                    color: #222222; 
 | 
                    margin-right: 30px; 
 | 
                } 
 | 
            } 
 | 
            .main_head_bottom { 
 | 
                width: 100%; 
 | 
                display: flex; 
 | 
                align-items: center; 
 | 
                justify-content: space-between; 
 | 
                .blue { 
 | 
                    border-left: 5px solid blue; 
 | 
                } 
 | 
                .red { 
 | 
                    border-left: 5px solid red; 
 | 
                } 
 | 
                .yellow { 
 | 
                    border-left: 5px solid yellow; 
 | 
                } 
 | 
                .orange { 
 | 
                    border-left: 5px solid orange; 
 | 
                } 
 | 
                .darkBlue { 
 | 
                    border-left: 5px solid #0000a8; 
 | 
                } 
 | 
                .main_head_item { 
 | 
                    width: 19%; 
 | 
                    height: 70px; 
 | 
                    display: flex; 
 | 
                    flex-direction: column; 
 | 
                    align-items: center; 
 | 
                    justify-content: center; 
 | 
                    box-sizing: border-box; 
 | 
                    border-radius: 5px; 
 | 
                    background-color: #ffffff; 
 | 
                    span { 
 | 
                        &:nth-child(1) { 
 | 
                            font-size: 22px; 
 | 
                            color: black; 
 | 
                            font-weight: bold; 
 | 
                        } 
 | 
                        &:nth-child(2) { 
 | 
                            font-size: 16px; 
 | 
                            color: black; 
 | 
                        } 
 | 
                    } 
 | 
                } 
 | 
            } 
 | 
        } 
 | 
  
 | 
        .main_table { 
 | 
            display: flex; 
 | 
            align-items: center; 
 | 
            justify-content: space-between; 
 | 
            height: 300px; 
 | 
            .main_table_list { 
 | 
                margin-left: 20px; 
 | 
                flex: 1; 
 | 
                .title { 
 | 
                    display: flex; 
 | 
                    align-items: center; 
 | 
                    span { 
 | 
                        font-weight: 600; 
 | 
                        font-size: 16px; 
 | 
                        color: #222222; 
 | 
                    } 
 | 
                } 
 | 
                .list_head { 
 | 
                    width: 100%; 
 | 
                    height: 35px; 
 | 
                    display: flex; 
 | 
                    align-items: center; 
 | 
                    background-color: #ececec; 
 | 
                    margin-top: 15px; 
 | 
                    .list_head_item { 
 | 
                        flex: 1; 
 | 
                        height: 100%; 
 | 
                        display: flex; 
 | 
                        align-items: center; 
 | 
                        justify-content: center; 
 | 
                        font-size: 13px; 
 | 
                        color: #222222; 
 | 
                    } 
 | 
                } 
 | 
                .table_box { 
 | 
                    width: 100%; 
 | 
                    height: 234px; 
 | 
                    .list_content { 
 | 
                        width: 100%; 
 | 
                        height: 40px; 
 | 
                        display: flex; 
 | 
                        align-items: center; 
 | 
                        .list_head_item { 
 | 
                            flex: 1; 
 | 
                            height: 100%; 
 | 
                            display: flex; 
 | 
                            align-items: center; 
 | 
                            justify-content: center; 
 | 
                            font-size: 13px; 
 | 
                            color: #222222; 
 | 
                        } 
 | 
                    } 
 | 
                } 
 | 
            } 
 | 
            .main_table_list1 { 
 | 
                margin-left: 20px; 
 | 
                width: 300px; 
 | 
                flex-shrink: 0; 
 | 
                .title { 
 | 
                    font-weight: 600; 
 | 
                    font-size: 16px; 
 | 
                    color: #222222; 
 | 
                } 
 | 
                .list_head { 
 | 
                    width: 100%; 
 | 
                    height: 35px; 
 | 
                    display: flex; 
 | 
                    align-items: center; 
 | 
                    background-color: #ececec; 
 | 
                    margin-top: 15px; 
 | 
                    .list_head_item { 
 | 
                        flex: 1; 
 | 
                        height: 100%; 
 | 
                        display: flex; 
 | 
                        align-items: center; 
 | 
                        justify-content: center; 
 | 
                        font-size: 13px; 
 | 
                        color: #222222; 
 | 
                    } 
 | 
                } 
 | 
                .table_box { 
 | 
                    width: 100%; 
 | 
                    height: 234px; 
 | 
                    .list_content { 
 | 
                        width: 100%; 
 | 
                        height: 40px; 
 | 
                        display: flex; 
 | 
                        align-items: center; 
 | 
                        .list_head_item { 
 | 
                            flex: 1; 
 | 
                            height: 100%; 
 | 
                            display: flex; 
 | 
                            align-items: center; 
 | 
                            justify-content: center; 
 | 
                            text-align: center; 
 | 
                            font-size: 13px; 
 | 
                            color: #222222; 
 | 
                        } 
 | 
                    } 
 | 
                } 
 | 
            } 
 | 
        } 
 | 
  
 | 
        .main_content { 
 | 
            display: flex; 
 | 
            height: 400px; 
 | 
  
 | 
            .title { 
 | 
                font-weight: 600; 
 | 
                font-size: 16px; 
 | 
                color: #222222; 
 | 
                /*margin-bottom: 20px;*/ 
 | 
                margin-top: 20px; 
 | 
            } 
 | 
  
 | 
            .type_wrap { 
 | 
                flex: 11; 
 | 
                flex-shrink: 0; 
 | 
                height: calc(100% - 20px); 
 | 
                /*border-right: 12px solid #f7f7f7;*/ 
 | 
  
 | 
  
 | 
                .echart1 { 
 | 
                    width: 100%; 
 | 
                    height: calc(100% - 60px); 
 | 
                } 
 | 
            } 
 | 
  
 | 
            .dept_wrap { 
 | 
                flex: 8; 
 | 
                flex-shrink: 0; 
 | 
                height: calc(100% - 20px); 
 | 
                padding-left: 20px; 
 | 
  
 | 
                #echart2 { 
 | 
                    width: 100%; 
 | 
                    height: calc(100% - 60px); 
 | 
                } 
 | 
            } 
 | 
        } 
 | 
    } 
 | 
</style> 
 |