From 0e997dbbfeacaf72e91380d035265836b8df8a7d Mon Sep 17 00:00:00 2001
From: rk <94314517@qq.com>
Date: 星期五, 13 三月 2026 16:39:34 +0800
Subject: [PATCH] 报表数据

---
 admin/src/views/business/carStatistics.vue |  611 ++++++++++++++++++++++++++++--------------------------
 1 files changed, 315 insertions(+), 296 deletions(-)

diff --git a/admin/src/views/business/carStatistics.vue b/admin/src/views/business/carStatistics.vue
index d179507..4a7582b 100644
--- a/admin/src/views/business/carStatistics.vue
+++ b/admin/src/views/business/carStatistics.vue
@@ -84,14 +84,14 @@
                     <el-button type="primary" style="margin-left: 20px;" icon="el-icon-upload2" @click="daochu">瀵煎嚭</el-button>
                 </div>
                 <template v-if="column.length > 0">
-                    <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" v-for="(child, i) in item" :key="i">{{child}}</div>
-                        </div>
-                    </div>
+                    <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>
@@ -99,325 +99,346 @@
                 <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>
 </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: '',
+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: []
+      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: 0 }).then(res => {
+        this.download(res)
+        console.log(res.data)
+      })
+    },
+    changeBB () {
+      if (this.radio === 'month') {
+        const now = new Date()
+        const year = now.getFullYear()
+        const month = now.getMonth() + 1 > 9 ? now.getMonth() + 1 : `0${now.getMonth() + 1}`
+        this.date1 = `${year}-${month}`
+      } else {
+        const now = new Date()
+        const year = now.getFullYear()
+        this.date1 = `${year}`
       }
+      this.getReportLists()
     },
-    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}`
+    // 鍏ュ洯杞﹁締缁熻琛�
+    getReportLists () {
+      getReportList({ dateStr: this.date1, isGroupBy: this.isGroupBy, type: 0 })
+        .then(res => {
+          this.column = res[0]
 
-        this.getData()
-        this.getRataLists()
-        this.getReportLists()
-    },
-    methods: {
-      // 瀵煎嚭
-      daochu() {
-        reportExportExcel({ dateStr: this.date1, isGroupBy: this.isGroupBy, type: 0 }).then(res => {
-          this.download(res)
-          console.log(res.data)
+          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)
         })
-      },
-      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: 0 })
-            .then(res => {
-              if (res.length === 0) {
-                this.column = []
-                this.list = []
-                return
-              }
-
-              this.column = res[0]
-              this.list = res.slice(1, res.length);
-
-              console.log(res)
-            })
-      },
-      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: 0 })
-            .then(res => {
-              this.listZB = res
-              // this.$nextTick(() => {
-              //   this.initDept()
-              // })
-              setTimeout(() => {
-                this.initDept()
-              },1000)
-            })
-      },
-      // 鍩虹鏁版嵁
-      getData() {
-        getInParkUserData({ isGroupBy: this.isGroupBy, type: 0 }).then(res => {
-          this.info = res
+    },
+    changeDateType () {
+      if (this.dateType === 'month') {
+        const now = new Date()
+        const year = now.getFullYear()
+        const month = now.getMonth() + 1 > 9 ? now.getMonth() + 1 : `0${now.getMonth() + 1}`
+        this.value = `${year}-${month}`
+      } else {
+        const now = new Date()
+        const year = now.getFullYear()
+        this.value = `${year}`
+      }
+      this.getRataLists()
+    },
+    // 杞﹁締鍒嗙被缁熻
+    getRataLists () {
+      getRataList({ dateStr: this.value, isGroupBy: this.isGroupBy, type: 0 })
+        .then(res => {
+          this.listZB = res
           // this.$nextTick(() => {
-          //   this.initType()
+          //   this.initDept()
           // })
           setTimeout(() => {
-            this.initType()
+            this.initDept()
           }, 1000)
         })
-      },
-      // 鍏ㄥ勾鍏ュ洯杞﹁締瓒嬪娍
-      initType() {
-        if (!this.info.cumulativeDataList) return
+    },
+    // 鍩虹鏁版嵁
+    getData () {
+      getInParkUserData({ isGroupBy: this.isGroupBy, type: 0 }).then(res => {
+        this.info = res
+        // this.$nextTick(() => {
+        //   this.initType()
+        // })
+        setTimeout(() => {
+          this.initType()
+        }, 1000)
+      })
+    },
+    // 鍏ㄥ勾鍏ュ洯杞﹁締瓒嬪娍
+    initType () {
+      if (!this.info.cumulativeDataList) return
 
-        const myChart = echarts.init(document.querySelector('#echart1'))
+      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)
+      const names = this.info.cumulativeDataList.map(item => item.name)
+      const 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: '0%',
-            right: '5%',
-            bottom: '10%',
-            top: '20%',
-            containLabel: true
-          },
-          xAxis: {
-            type: 'category',
-            data: names
-          },
-          yAxis: {
-            type: 'value',
-            axisLine: {
-              show: true
-            },
-            axisLabel: {
-              formatter: function (value) {
-                // 鍥涜垗浜斿叆鍒版渶杩戠殑鏁存暟
-                return Math.round(value);
-              }
-            }
-          },
-          series: [
+      const option = {
+        tooltip: {
+          trigger: 'axis',
+          axisPointer: {
+            type: 'line'
+          }
+        },
+        legend: {
+          show: false,
+          orient: 'vertical',
+          left: 'left'
+        },
+        graphic: {
+          elements: [
             {
-              data: datas,
-              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: { // 绾挎潯鏍峰紡
+              type: 'text',
+              left: 'left',
+              top: 'top',
+              style: {
+                text: '杞﹁締鏁�',
+                textAlign: 'center',
+                fill: '#333'
+              }
+            }
+          ]
+        },
+        grid: {
+          left: '0%',
+          right: '5%',
+          bottom: '10%',
+          top: '20%',
+          containLabel: true
+        },
+        xAxis: {
+          type: 'category',
+          data: names
+        },
+        yAxis: {
+          type: 'value',
+          axisLine: {
+            show: true
+          },
+          axisLabel: {
+            formatter: function (value) {
+              // 鍥涜垗浜斿叆鍒版渶杩戠殑鏁存暟
+              return Math.round(value)
+            }
+          }
+        },
+        series: [
+          {
+            data: datas,
+            name: '鍏ュ洯杞﹁締',
+            type: 'line',
+            areaStyle: {
+              normal: {
                 color: {
-                  type: 'linear',
                   x: 0,
                   y: 0,
                   x2: 0,
                   y2: 1,
                   colorStops: [{
-                    offset: 0, color: '#207FF7' // 0% 澶勭殑棰滆壊
+                    offset: 0,
+                    color: '#207FF7' // 0% 澶勭殑棰滆壊
                   }, {
-                    offset: 1, color: '#207FF7' // 100% 澶勭殑棰滆壊
-                  }]
-                },
-                width: 2 // 绾挎潯绮楃粏
+                    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% 澶勭殑棰滆壊
+                }]
               },
-              symbol: 'circle',
-              symbolSize: 10,
-              itemStyle: {
-                borderWidth: 1,
-                borderColor: '#fff',
-                color: '#207FF7'
-              },
-              smooth: false
-            }
-          ]
-        }
-        myChart.setOption(option)
-        window.addEventListener('resize', function () { // 鎵ц
-          myChart.resize()
-        })
-      },
-      // 杞﹁締鍒嗙被缁熻
-      initDept() {
-        if (this.listZB.length === 0) return
-
-        const dom = document.getElementById('echart_2')
-        console.log(dom)
-        const myChart = echarts.init(dom)
-
-        let data = this.listZB.map(item => {
-          return {
-            value: item.total,
-            name: item.name
+              width: 2 // 绾挎潯绮楃粏
+            },
+            symbol: 'circle',
+            symbolSize: 10,
+            itemStyle: {
+              borderWidth: 1,
+              borderColor: '#fff',
+              color: '#207FF7'
+            },
+            smooth: false
           }
-        })
+        ]
+      }
+      myChart.setOption(option)
+      window.addEventListener('resize', function () { // 鎵ц
+        myChart.resize()
+      })
+    },
+    // 杞﹁締鍒嗙被缁熻
+    initDept () {
+      if (this.listZB.length === 0) return
 
-        let option = {
-          tooltip: {
-            trigger: 'item'
-          },
-          legend: {
-            show: false,
-            orient: 'vertical',
-            left: 'left'
-          },
-          series : [
-            {
-              name: '璁块棶鏉ユ簮',
-              type: 'pie',
-              radius: ['34%', '50%'],
-              labelLine: {
-                normal: {
-                  length: 30,
-                  length2: 70,
+      const dom = document.getElementById('echart_2')
+      console.log(dom)
+      const myChart = echarts.init(dom)
+
+      const data = this.listZB.map(item => {
+        return {
+          value: item.total,
+          name: item.name
+        }
+      })
+
+      const option = {
+        tooltip: {
+          trigger: 'item'
+        },
+        legend: {
+          show: false,
+          orient: 'vertical',
+          left: 'left'
+        },
+        series: [
+          {
+            name: '璁块棶鏉ユ簮',
+            type: 'pie',
+            radius: ['34%', '50%'],
+            labelLine: {
+              normal: {
+                length: 30,
+                length2: 70
+              }
+            },
+            label: {
+              formatter: '{a|{b}} {d}%',
+              rich: {
+                a: {
+                  color: '#333333',
+                  fontSize: 14,
+                  fontWeight: 500
                 }
               },
-              label: {
-                formatter: "{a|{b}} {d}%",
-                rich: {
-                  a: {
-                    color: '#333333',
-                    fontSize: 14,
-                    fontWeight: 500
-                  }
-                },
-                padding: [0,-50,20,-100]
-              },
-              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()
-        })
+              padding: [0, -50, 20, -100]
+            },
+            data: data
+          }
+        ]
       }
+      myChart.setOption(option)
+      window.addEventListener('resize', function () { // 鎵ц
+        myChart.resize()
+      })
+    },
+    initDept3 () {
+      const myChart = echarts.init(document.querySelector('#echart3'))
+
+      const 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>
@@ -505,7 +526,7 @@
                 background-color: #ffffff;
                 padding: 20px;
                 box-sizing: border-box;
-                flex: 1;
+                width: 69%;
                 .title {
                     display: flex;
                     align-items: center;
@@ -568,8 +589,7 @@
                 }
             }
             .main_table_list1 {
-                margin-left: 10px;
-                width: 420px;
+                width: 30%;
                 padding: 20px;
                 box-sizing: border-box;
                 flex-shrink: 0;
@@ -659,7 +679,6 @@
                 padding: 20px;
                 box-sizing: border-box;
                 /*border-right: 12px solid #f7f7f7;*/
-
 
                 #echart1 {
                     width: 100%;

--
Gitblit v1.9.3