瀏覽代碼

分部数据等待接口

1
mo 2 年之前
父節點
當前提交
e53bbc0f8a
共有 1 個文件被更改,包括 52 次插入29 次删除
  1. 52 29
      src/views/main/baseinfo/modals/manageOrgan.vue

+ 52 - 29
src/views/main/baseinfo/modals/manageOrgan.vue

@@ -44,7 +44,7 @@ import { descs, chioseNum } from "../../constant";
 import { orderType } from "@/constant";
 
 export default {
-  props: ["data", "search",],
+  props: ["data", "search"],
   components: {
     // "ve-line": veLine,
     "count-to": countTo,
@@ -55,15 +55,16 @@ export default {
     legend() {
       return {
         left: "10px",
+        itemWidth: 30,
       };
     },
     items() {
       let obj = {};
       let arr = [
         "TOTAL_AMOUNT",
-        "FINANCE_AMOUNT",
-        "FINANCE_BALANCE_AMOUNT",
-        "FINANCE_PAY",
+        // "FINANCE_AMOUNT",
+        // "FINANCE_BALANCE_AMOUNT",
+        // "FINANCE_PAY",
       ];
       arr.forEach((str) => {
         if (this.data[str]) {
@@ -136,35 +137,58 @@ export default {
       ];
     },
     chartData() {
+      //
       const values = Object.values({ ...this.items, ...this.items2 });
-      console.log(values,'values')
-      const months = {};
+      const organ = {};
+      const organNameList = [];
+      // 计算总的百分比
+      for (const row of values[0].organIndexMonthData || []) {
+        const key = row.organName;
+        organ[key] = {
+          分部: row.organName,
+        };
+        for (const item of values) {
+          if (item.title == row.title) {
+            organ[key][item.title] = row.percent;
+          }
+
+          if (item.title == "总收入" && row.title == "总收入") {
+            organ[key]["百分比"] = ((row.percent / item.percent) * 100).toFixed(
+              2
+            );
+          }
+        }
+      }
       for (const item of values) {
-        for (const row of item.indexMonthData || []) {
-          const key = this.$helpers.dayjs(row.month).format("YYYY-MM-DD");
-          if (!months[key]) {
-            months[key] = {
-              日期: key,
-            };
+        for (const row of item.organIndexMonthData || []) {
+
+          if(item.title == row.title){
+             console.log(item.title,row.title,row.percent, row.organName)
+
+              // organ[row.organName][row.title] = row.percent
           }
-          months[key][item.title] = row.percent;
+
         }
       }
-      console.log(months,'months');
+
+      // const months = {};
+      // for (const item of values) {
+      //   for (const row of item.indexMonthData || []) {
+      //     const key = this.$helpers.dayjs(row.month).format("YYYY-MM-DD");
+      //     if (!months[key]) {
+      //       months[key] = {
+      //         日期: key,
+      //       };
+      //     }
+      //     months[key][item.title] = row.percent;
+      //   }
+      // }
+      console.log(organ);
+      console.log(values);
+      return;
       return {
-        columns: [
-          "日期",
-          "总收入",
-          "现金收入",
-          "余额收入",
-          "财务支出",
-          "报名缴费收入",
-          "网管课收入",
-          "其他收入",
-          "乐团续费收入",
-          "VIP课收入",
-        ],
-        rows: Object.values(months),
+        columns: ["分部", "百分比"],
+        rows: Object.values(organ),
         loading: true,
       };
     },
@@ -211,7 +235,6 @@ export default {
     dataEmpty() {
       return !this.chartData.rows.length;
     },
-
   },
   data() {
     // this.chartSettings = {
@@ -225,7 +248,7 @@ export default {
       endDate: "",
       show: true,
       activeName: "first",
-      timer:'day'
+      timer: "day",
     };
   },
   mounted() {