weimingfei
2 天以前 221c873ee48ed5f44680578d32b0bbf19fd9e4c1
admin/src/views/business/carStatistics.vue
@@ -3,7 +3,7 @@
        <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-group v-model="isGroupBy" @change="getData(), getRataLists(), getReportLists()">
                    <el-radio-button :label="0">按车次统计</el-radio-button>
                    <el-radio-button :label="1">按车辆统计</el-radio-button>
                </el-radio-group>
@@ -34,30 +34,30 @@
        <div class="main_content">
            <div class="type_wrap">
                <div class="title">全年入园车辆趋势</div>
                <div id="echart1" ref="typeRef" v-if="info.cumulativeDataList"></div>
                <div style="width: 100%;height: 100%;display: flex;align-items: center;justify-content: center;" v-else>
                <div id="echart1" ref="typeRef" v-show="info.cumulativeDataList"></div>
                <div style="width: 100%;height: 100%;display: flex;align-items: center;justify-content: center;" v-show="!info.cumulativeDataList">
                    <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 style="margin-left: 20px;" v-model="dateType" @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"
                        :clearable="false"
                        @change="getRataLists()"
                        :value-format="dateType === 'month' ? 'yyyy-MM' : 'yyyy'"
                        style="margin-left: 20px; width: 130px;"
                        style="margin-left: 10px; width: 120px;"
                        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>
                <div id="echart_2" v-show="listZB.length > 0"></div>
                <div style="width: 100%;height: 100%;display: flex;align-items: center;justify-content: center;" v-show="listZB.length === 0">
                    <img style="width: 200px;" src="@/assets/images/default_homeimg.png" alt="">
                </div>
            </div>
@@ -65,56 +65,49 @@
        <div class="main_table">
            <div class="main_table_list">
                <div class="title" style="display: flex; align-items: center; justify-content: space-between;">
                    <div>
                    <div style="display: flex; align-items: center;">
                        <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 style="margin-left: 20px;" v-model="radio" @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="请选择">
                            v-model="date1"
                            :type="radio"
                            :clearable="false"
                            @change="getReportLists()"
                            :value-format="radio === 'month' ? 'yyyy-MM' : 'yyyy'"
                            style="margin-left: 10px; width: 120px;"
                            placeholder="请选择">
                        </el-date-picker>
                    </div>
                    <el-button type="primary" size="mini" style="margin-left: 20px;" @click="daochu">导出</el-button>
                    <el-button type="primary" style="margin-left: 20px;" icon="el-icon-upload2" @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>
                <template v-if="column.length > 0">
                    <el-table
                        style="width: 100%; margin-top: 15px;"
                        :data="list"
                        header-row-style="background-color: #F7F7F7;"
                        border
                    >
                        <el-table-column :prop="item" :label="item" align="center" :fixed="index === 0 ? true : index === column.length - 1 ? 'right' : false" v-for="(item, index) in column" :key="index"></el-table-column>
                    </el-table>
                </template>
                <div class="list_wu" v-else>暂无数据</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>
                <el-table
                    style="width: 100%; margin-top: 15px;"
                    :data="info.yearSortList"
                    header-row-style="background-color: #F7F7F7;"
                    border
                >
                    <el-table-column prop="name" label="车辆分类" align="center"></el-table-column>
                    <el-table-column prop="total" label="入园次数" align="center"></el-table-column>
                </el-table>
            </div>
        </div>
    </div>
@@ -146,9 +139,9 @@
      this.value = `${year}-${month}`
      this.date1 = `${year}-${month}`
      this.getData()
      this.getRataLists()
      this.getReportLists()
        this.getData()
        this.getRataLists()
        this.getReportLists()
    },
    methods: {
      // 导出
@@ -175,19 +168,39 @@
      getReportLists() {
        getReportList({ dateStr: this.date1, isGroupBy: this.isGroupBy, type: 0 })
            .then(res => {
              console.log(res)
              this.column = res.data.map(item => item[0])
              this.column = res[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;
                }, {});
              this.list = res.slice(1).map(row => {
                const obj = {};
                this.column.forEach((header, index) => {
                  obj[header] = row[index];
                });
                return obj;
              });
              // const keys = res.map(row => row[0]); // 获取键名
              // const values = res.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;
              //   }, {});
              // });
              console.log(this.column)
              console.log(this.list)
              // if (res.length === 0) {
              //   this.column = []
              //   this.list = []
              //   return
              // }
              //
              // this.column = res[0]
              // this.list = res.slice(1, res.length);
              //
              // console.log(res)
            })
      },
      changeDateType() {
@@ -207,20 +220,25 @@
      getRataLists() {
        getRataList({ dateStr: this.value, isGroupBy: this.isGroupBy, type: 0 })
            .then(res => {
              console.log(res)
              this.listZB = res
              this.$nextTick(() => {
              // this.$nextTick(() => {
              //   this.initDept()
              // })
              setTimeout(() => {
                this.initDept()
              })
              },1000)
            })
      },
      // 基础数据
      getData() {
        getInParkUserData({ isGroupBy: this.isGroupBy, type: 0 }).then(res => {
          this.info = res
          this.$nextTick(() => {
          // this.$nextTick(() => {
          //   this.initType()
          // })
          setTimeout(() => {
            this.initType()
          })
          }, 1000)
        })
      },
      // 全年入园车辆趋势
@@ -233,10 +251,35 @@
        let datas = this.info.cumulativeDataList.map(item => item.total)
        let option = {
          tooltip: {
            trigger: 'axis',
            axisPointer: {
              type: 'line'
            }
          },
          legend: {
            show: false,
            orient: 'vertical',
            left: 'left'
          },
          graphic: {
            elements: [
              {
                type: 'text',
                left: 'left',
                top: 'top',
                style: {
                  text: '车辆数',
                  textAlign: 'center',
                  fill: '#333'
                }
              }
            ]
          },
          grid: {
            left: '5%',
            right: '10%',
            bottom: '0%',
            left: '0%',
            right: '5%',
            bottom: '10%',
            top: '20%',
            containLabel: true
          },
@@ -245,12 +288,63 @@
            data: names
          },
          yAxis: {
            type: 'value'
            type: 'value',
            axisLine: {
              show: true
            },
            axisLabel: {
              formatter: function (value) {
                // 四舍五入到最近的整数
                return Math.round(value);
              }
            }
          },
          series: [
            {
              data: datas,
              type: 'line'
              name: '入园车辆',
              type: 'line',
              areaStyle: {
                normal: {
                  color: {
                    x: 0,
                    y: 0,
                    x2: 0,
                    y2: 1,
                    colorStops: [{
                      offset: 0,
                      color: '#207FF7' // 0% 处的颜色
                    }, {
                      offset: 1,
                      color: 'rgba(255,255,255,.2)' // 100% 处的颜色
                    }],
                    globalCoord: false // 缺省为 false
                  }
                }
              },
              lineStyle: { // 线条样式
                color: {
                  type: 'linear',
                  x: 0,
                  y: 0,
                  x2: 0,
                  y2: 1,
                  colorStops: [{
                    offset: 0, color: '#207FF7' // 0% 处的颜色
                  }, {
                    offset: 1, color: '#207FF7' // 100% 处的颜色
                  }]
                },
                width: 2 // 线条粗细
              },
              symbol: 'circle',
              symbolSize: 10,
              itemStyle: {
                borderWidth: 1,
                borderColor: '#fff',
                color: '#207FF7'
              },
              smooth: false
            }
          ]
        }
@@ -261,9 +355,11 @@
      },
      // 车辆分类统计
      initDept() {
        if (!this.listZB) return
        if (this.listZB.length === 0) return
        const myChart = echarts.init(document.querySelector('#echart2'))
        const dom = document.getElementById('echart_2')
        console.log(dom)
        const myChart = echarts.init(dom)
        let data = this.listZB.map(item => {
          return {
@@ -273,11 +369,36 @@
        })
        let option = {
          tooltip: {
            trigger: 'item'
          },
          legend: {
            show: false,
            orient: 'vertical',
            left: 'left'
          },
          series : [
            {
              name: '访问来源',
              type: 'pie',
              radius: '55%',
              radius: ['34%', '50%'],
              labelLine: {
                normal: {
                  length: 30,
                  length2: 70,
                }
              },
              label: {
                formatter: "{a|{b}} {d}%",
                rich: {
                  a: {
                    color: '#333333',
                    fontSize: 14,
                    fontWeight: 500
                  }
                },
                padding: [0,-50,20,-100]
              },
              data: data
            }
          ]
@@ -329,21 +450,24 @@
        overflow-x: hidden;
        padding: 15px;
        box-sizing: border-box;
        background-color: #ffffff;
        background-color: #F4F7FC;
        .main_head {
            width: 100%;
            display: flex;
            align-items: center;
            flex-direction: column;
            margin-bottom: 20px;
            margin-bottom: 10px;
            background-color: #ffffff;
            padding: 20px;
            box-sizing: border-box;
            .main_head_title {
                width: 100%;
                display: flex;
                align-items: center;
                margin-bottom: 20px;
                span {
                    font-weight: 600;
                    font-size: 16px;
                    font-weight: 500;
                    font-size: 18px;
                    color: #222222;
                    margin-right: 30px;
                }
@@ -354,39 +478,40 @@
                align-items: center;
                justify-content: space-between;
                .blue {
                    border-left: 5px solid blue;
                    border-left: 8px solid #12BB8B;
                }
                .red {
                    border-left: 5px solid red;
                    border-left: 8px solid #F6CF46;
                }
                .yellow {
                    border-left: 5px solid yellow;
                    border-left: 8px solid #5DC9FB;
                }
                .orange {
                    border-left: 5px solid orange;
                    border-left: 8px solid #FF9E56;
                }
                .darkBlue {
                    border-left: 5px solid #0000a8;
                    border-left: 8px solid #6B6EFF;
                }
                .main_head_item {
                    width: 19%;
                    height: 70px;
                    height: 112px;
                    display: flex;
                    flex-direction: column;
                    align-items: center;
                    justify-content: center;
                    box-sizing: border-box;
                    border-radius: 5px;
                    background-color: #ffffff;
                    background-color: #F4F7FC;
                    span {
                        &:nth-child(1) {
                            font-size: 22px;
                            color: black;
                            font-weight: bold;
                            font-weight: 600;
                            font-size: 30px;
                            color: #222222;
                        }
                        &:nth-child(2) {
                            font-size: 16px;
                            color: black;
                            font-weight: 400;
                            font-size: 14px;
                            color: #222222;
                        }
                    }
                }
@@ -395,27 +520,39 @@
        .main_table {
            display: flex;
            align-items: center;
            align-items: start;
            justify-content: space-between;
            height: 300px;
            margin-top: 10px;
            .main_table_list {
                margin-left: 20px;
                flex: 1;
                background-color: #ffffff;
                padding: 20px;
                box-sizing: border-box;
                width: 69%;
                .title {
                    display: flex;
                    align-items: center;
                    span {
                        font-weight: 600;
                        font-size: 16px;
                        font-weight: 500;
                        font-size: 18px;
                        color: #222222;
                    }
                }
                .list_wu {
                    width: 100%;
                    height: 100px;
                    line-height: 100px;
                    text-align: center;
                    font-size: 16px;
                    color: #222222;
                }
                .list_head {
                    width: 100%;
                    height: 35px;
                    height: 50px;
                    display: flex;
                    align-items: center;
                    background-color: #ececec;
                    background-color: #F7F7F7;
                    border-left: 1px solid #DFE2E8;
                    border-top: 1px solid #DFE2E8;
                    margin-top: 15px;
                    .list_head_item {
                        flex: 1;
@@ -425,20 +562,25 @@
                        justify-content: center;
                        font-size: 13px;
                        color: #222222;
                        font-weight: 500;
                        border-right: 1px solid #DFE2E8;
                    }
                }
                .table_box {
                    width: 100%;
                    height: 234px;
                    border-bottom: 1px solid #DFE2E8;
                    .list_content {
                        width: 100%;
                        height: 40px;
                        height: 50px;
                        display: flex;
                        align-items: center;
                        border-left: 1px solid #DFE2E8;
                        border-top: 1px solid #DFE2E8;
                        .list_head_item {
                            flex: 1;
                            height: 100%;
                            display: flex;
                            border-right: 1px solid #DFE2E8;
                            align-items: center;
                            justify-content: center;
                            font-size: 13px;
@@ -448,48 +590,71 @@
                }
            }
            .main_table_list1 {
                margin-left: 20px;
                width: 300px;
                width: 30%;
                padding: 20px;
                box-sizing: border-box;
                flex-shrink: 0;
                background-color: #ffffff;
                .title {
                    font-weight: 600;
                    font-weight: 500;
                    font-size: 18px;
                    color: #222222;
                }
                .list_wu {
                    width: 100%;
                    height: 100px;
                    line-height: 100px;
                    text-align: center;
                    font-size: 16px;
                    color: #222222;
                }
                .list_head {
                    width: 100%;
                    height: 35px;
                    height: 50px;
                    display: flex;
                    align-items: center;
                    background-color: #ececec;
                    background-color: #F7F7F7;
                    border-left: 1px solid #DFE2E8;
                    border-top: 1px solid #DFE2E8;
                    margin-top: 15px;
                    .list_head_item {
                        flex: 1;
                        flex: 1.8;
                        height: 100%;
                        display: flex;
                        align-items: center;
                        justify-content: center;
                        font-size: 13px;
                        color: #222222;
                        font-weight: 500;
                        border-right: 1px solid #DFE2E8;
                        &:last-child {
                           flex: 1;
                        }
                    }
                }
                .table_box {
                    width: 100%;
                    height: 234px;
                    border-bottom: 1px solid #DFE2E8;
                    .list_content {
                        width: 100%;
                        height: 40px;
                        height: 50px;
                        display: flex;
                        align-items: center;
                        border-left: 1px solid #DFE2E8;
                        border-top: 1px solid #DFE2E8;
                        .list_head_item {
                            flex: 1;
                            flex: 1.8;
                            height: 100%;
                            display: flex;
                            align-items: center;
                            border-right: 1px solid #DFE2E8;
                            justify-content: center;
                            text-align: center;
                            font-size: 13px;
                            color: #222222;
                            &:last-child {
                                flex: 1;
                            }
                        }
                    }
                }
@@ -498,38 +663,43 @@
        .main_content {
            display: flex;
            height: 400px;
            align-items: center;
            justify-content: space-between;
            height: 350px;
            .title {
                font-weight: 600;
                font-size: 16px;
                font-weight: 500;
                font-size: 18px;
                color: #222222;
                /*margin-bottom: 20px;*/
                margin-top: 20px;
            }
            .type_wrap {
                flex: 11;
                flex-shrink: 0;
                height: calc(100% - 20px);
                flex: 1;
                height: 100%;
                background-color: #ffffff;
                padding: 20px;
                box-sizing: border-box;
                /*border-right: 12px solid #f7f7f7;*/
                #echart1 {
                    width: 100%;
                    height: calc(100% - 60px);
                    height: 100%;
                    margin-top: 18px;
                }
            }
            .dept_wrap {
                flex: 8;
                width: 420px;
                flex-shrink: 0;
                height: calc(100% - 20px);
                padding-left: 20px;
                #echart2 {
                height: 100%;
                background-color: #ffffff;
                padding: 20px;
                box-sizing: border-box;
                margin-left: 10px;
                #echart_2 {
                    width: 100%;
                    height: calc(100% - 60px);
                    height: 100%;
                }
            }
        }