408249787 2 年之前
父节点
当前提交
4217492509
共有 2 个文件被更改,包括 6 次插入3 次删除
  1. 3 2
      src/views/statisticView/DayStatistics.vue
  2. 3 1
      src/views/statisticView/MonthStatistics.vue

+ 3 - 2
src/views/statisticView/DayStatistics.vue

@@ -25,7 +25,7 @@
             <thead>
               <tr >
                 <th rowspan="2" class="list-header" style="color:#fff">时间</th>
-                <th colspan="2" class="list-header" style="color:#fff" v-for="(item,i) in dataInfo[0].lines" :key="i"> {{ item.name }}</th>
+                <th colspan="2" class="list-header" style="color:#fff" v-for="(item,i) in title" :key="i"> {{ item }}</th>
               </tr>
               <tr>
                 <template v-for="i in 6 ">
@@ -65,6 +65,7 @@ export default {
     return {
       time: '',
       dataInfo: [],
+      title: [],
       total: []
     }
   },
@@ -85,6 +86,7 @@ export default {
         this.dataInfo = res.data
         this.total = res.data.reduce((pre, list, index) => {
           pre = list.lines.map((item, i) => {
+            if (index === 0) this.title.push(item.name)
             const newItem = {
               positive: (item.positive ? item.positive : 0) + (index === 0 ? 0 : pre[i].positive)
             }
@@ -92,7 +94,6 @@ export default {
           })
           return pre
         }, [])
-        console.log(this.total)
       })
     },
     onDateChange (value, dateString) {

+ 3 - 1
src/views/statisticView/MonthStatistics.vue

@@ -22,7 +22,7 @@
             <thead>
               <tr >
                 <th rowspan="2" class="list-header" style="color:#fff">时间</th>
-                <th class="list-header" style="color:#fff" v-for="(item,i) in dataInfo[0].lines" :key="i"> {{ item.name }}</th>
+                <th colspan="2" class="list-header" style="color:#fff" v-for="(item,i) in title" :key="i"> {{ item }}</th>
               </tr>
               <tr>
                 <template v-for="i in 6 ">
@@ -62,6 +62,7 @@ export default {
     return {
       time: '',
       dataInfo: [],
+      title: [],
       total: []
     }
   },
@@ -80,6 +81,7 @@ export default {
         this.dataInfo = res.data
         this.total = res.data.reduce((pre, list, index) => {
           pre = list.lines.map((item, i) => {
+            if (index === 0) this.title.push(item.name)
             const newItem = {
               positive: (item.positive ? item.positive : 0) + (index === 0 ? 0 : pre[i].positive)
             }