소스 검색

多条数据同时显示

wolyshaw 4 년 전
부모
커밋
b219537fb3

+ 15 - 4
src/views/main/baseinfo/business.vue

@@ -31,11 +31,22 @@ export default {
     },
     chartData() {
       const data = this.data[this.active] || {}
+      const values = Object.values(this.items)
+      const months = {}
+      for (const item of values) {
+        for (const row of (item.indexMonthData || [])) {
+          const key = this.$helpers.dayjs(row.month).month() + 1 + '月'
+          if (!months[key]) {
+            months[key] = {
+              '月份': key,
+            }
+          }
+          months[key][item.title] = row.percent
+        }
+      }
       return {
-        columns: ['月份', data.title],
-        rows: (data.indexMonthData || []).map(item => ({
-          '月份': this.$helpers.dayjs(item.month).month() + 1 + '月', [data.title]: item.percent,
-        }))
+        columns: ['月份', ...values.map(item => item.title)],
+        rows: Object.values(months)
       }
     }
   },

+ 15 - 4
src/views/main/baseinfo/curriculum.vue

@@ -30,11 +30,22 @@ export default {
     },
     chartData() {
       const data = this.data[this.active] || {}
+      const values = Object.values(this.items)
+      const months = {}
+      for (const item of values) {
+        for (const row of (item.indexMonthData || [])) {
+          const key = this.$helpers.dayjs(row.month).month() + 1 + '月'
+          if (!months[key]) {
+            months[key] = {
+              '月份': key,
+            }
+          }
+          months[key][item.title] = row.percent
+        }
+      }
       return {
-        columns: ['月份', data.title],
-        rows: (data.indexMonthData || []).map(item => ({
-          '月份': this.$helpers.dayjs(item.month).month() + 1 + '月', [data.title]: item.percent,
-        }))
+        columns: ['月份', ...values.map(item => item.title)],
+        rows: Object.values(months)
       }
     }
   },

+ 15 - 4
src/views/main/baseinfo/hr.vue

@@ -31,11 +31,22 @@ export default {
     },
     chartData() {
       const data = this.data[this.active] || {}
+      const values = Object.values(this.items)
+      const months = {}
+      for (const item of values) {
+        for (const row of (item.indexMonthData || [])) {
+          const key = this.$helpers.dayjs(row.month).month() + 1 + '月'
+          if (!months[key]) {
+            months[key] = {
+              '月份': key,
+            }
+          }
+          months[key][item.title] = row.percent
+        }
+      }
       return {
-        columns: ['月份', data.title],
-        rows: (data.indexMonthData || []).map(item => ({
-          '月份': this.$helpers.dayjs(item.month).month() + 1 + '月', [data.title]: item.percent,
-        }))
+        columns: ['月份', ...values.map(item => item.title)],
+        rows: Object.values(months)
       }
     }
   },

+ 15 - 4
src/views/main/baseinfo/management.vue

@@ -32,11 +32,22 @@ export default {
     },
     chartData() {
       const data = this.data[this.active] || {}
+      const values = Object.values(this.items)
+      const months = {}
+      for (const item of values) {
+        for (const row of (item.indexMonthData || [])) {
+          const key = this.$helpers.dayjs(row.month).month() + 1 + '月'
+          if (!months[key]) {
+            months[key] = {
+              '月份': key,
+            }
+          }
+          months[key][item.title] = row.percent
+        }
+      }
       return {
-        columns: ['月份', data.title],
-        rows: (data.indexMonthData || []).map(item => ({
-          '月份': this.$helpers.dayjs(item.month).month() + 1 + '月', [data.title]: item.percent,
-        }))
+        columns: ['月份', ...values.map(item => item.title)],
+        rows: Object.values(months)
       }
     }
   },

+ 15 - 4
src/views/main/baseinfo/operate.vue

@@ -31,11 +31,22 @@ export default {
     },
     chartData() {
       const data = this.data[this.active] || {}
+      const values = Object.values(this.items)
+      const months = {}
+      for (const item of values) {
+        for (const row of (item.indexMonthData || [])) {
+          const key = this.$helpers.dayjs(row.month).month() + 1 + '月'
+          if (!months[key]) {
+            months[key] = {
+              '月份': key,
+            }
+          }
+          months[key][item.title] = row.percent
+        }
+      }
       return {
-        columns: ['月份', data.title],
-        rows: (data.indexMonthData || []).map(item => ({
-          '月份': this.$helpers.dayjs(item.month).month() + 1 + '月', [data.title]: item.percent,
-        }))
+        columns: ['月份', ...values.map(item => item.title)],
+        rows: Object.values(months)
       }
     }
   },

+ 15 - 4
src/views/main/baseinfo/student.vue

@@ -30,11 +30,22 @@ export default {
     },
     chartData() {
       const data = this.data[this.active] || {}
+      const values = Object.values(this.items)
+      const months = {}
+      for (const item of values) {
+        for (const row of (item.indexMonthData || [])) {
+          const key = this.$helpers.dayjs(row.month).month() + 1 + '月'
+          if (!months[key]) {
+            months[key] = {
+              '月份': key,
+            }
+          }
+          months[key][item.title] = row.percent
+        }
+      }
       return {
-        columns: ['月份', data.title],
-        rows: (data.indexMonthData || []).map(item => ({
-          '月份': this.$helpers.dayjs(item.month).month() + 1 + '月', [data.title]: item.percent,
-        }))
+        columns: ['月份', ...values.map(item => item.title)],
+        rows: Object.values(months)
       }
     }
   },