From d0b163b5f1114a93b5d0f04e77a00ed8adb91894 Mon Sep 17 00:00:00 2001
From: 田源 <lastanimals@163.com>
Date: 星期四, 14 十二月 2023 20:18:37 +0800
Subject: [PATCH] 整合代码

---
 Source/UBCS-WEB/src/views/statistic/statisticPage.vue |  108 +++++++++++++++++++++++++++++------------------------
 1 files changed, 59 insertions(+), 49 deletions(-)

diff --git a/Source/UBCS-WEB/src/views/statistic/statisticPage.vue b/Source/UBCS-WEB/src/views/statistic/statisticPage.vue
index cb12b69..87f13cb 100644
--- a/Source/UBCS-WEB/src/views/statistic/statisticPage.vue
+++ b/Source/UBCS-WEB/src/views/statistic/statisticPage.vue
@@ -2,14 +2,14 @@
   <!--  鏂板鍙充晶鎸夐挳-->
   <div>
     <div style=" display: flex; justify-content: flex-end;">
-      <el-button plain type="primary" @click="addHandler">鏂板</el-button>
+      <el-button plain type="primary" @click="addHandler">閰嶇疆</el-button>
     </div>
     <!--  鏂板瀵硅瘽妗�-->
     <el-dialog
       :visible.sync="addVisible"
       append-to-body
       class="avue-dialog avue-dialog--top"
-      title="鏂板鏁版嵁缁熻鍒嗘瀽"
+      title="閰嶇疆鏁版嵁缁熻鍒嗘瀽"
       top="-50px"
     >
       <el-table
@@ -26,18 +26,16 @@
         <el-table-column
           align="center"
           label="涓绘暟鎹簱鍚�"
-          prop="menuName">
+          prop="menuName"
+          width="300">
         </el-table-column>
         <el-table-column
           align="center"
           label="绫诲瀷"
           prop="codeType">
           <template slot-scope="{ row }">
-            <el-select v-model="row.codeType" placeholder="璇烽�夋嫨鍥捐〃绫诲瀷">
-              <el-option label="鎶樼嚎鍥�" value="0"></el-option>
-              <el-option label="楗肩姸鍥�" value="1"></el-option>
-              <el-option label="鏌辩姸鍥�" value="2"></el-option>
-              <el-option label="鏌辩姸鎶樼嚎鍥�" value="3"></el-option>
+            <el-select v-model="row.codeType" :multiple="true" limit="4" placeholder="璇烽�夋嫨鍥捐〃绫诲瀷" style="width: 400px">
+              <el-option v-for="(item) in selectList" :label="item.label" :value="item.value"></el-option>
             </el-select>
           </template>
         </el-table-column>
@@ -48,7 +46,7 @@
   </span>
     </el-dialog>
     <!--    echarts缁勪欢-->
-    <div style="margin-top: 15px">
+    <div style="margin-top: 15px;padding-bottom: 35px">
       <lineChart v-for="(item,index) in lineList" :key="index" :chartName="item.menuName"
                  :lineData="item.menuData"></lineChart>
       <pieChart v-for="(item,index) in pieList" :key="index" :chartName="item.menuName"
@@ -66,7 +64,7 @@
 import pieChart from "../../components/StatisticsComponent/pieChart"
 import ColumnarChart from "../../components/StatisticsComponent/ColumnarChart"
 import mixCart from "../../components/StatisticsComponent/mixCart"
-import {getStatisticAnalysis} from "@/api/statistic/chart"
+import {getStatisticAnalysis,getBtmAndChart,saveStatisticAnalysis} from "@/api/statistic/chart"
 import {getList} from "@/api/system/statistic";
 
 export default {
@@ -79,7 +77,26 @@
   name: "statisticPage",
   data() {
     return {
-      menuList:[],
+      selectValue: '',
+      selectList: [
+        {
+          label: '鎶樼嚎鍥�',
+          value: '0'
+        },
+        {
+          label: '楗肩姸鍥�',
+          value: '1'
+        },
+        {
+          label: '鏌辩姸鍥�',
+          value: '2'
+        },
+        {
+          label: '鍫嗗彔鎶樼嚎鍥�',
+          value: '3'
+        }
+      ],
+      menuList: [],
       dataKeyList: [],
       addVisible: false,
       chartName: "",
@@ -92,13 +109,27 @@
     }
   },
   created() {
-    this.getMasterList()
+    this.getMasterList();
+    this.getEcharts()
   },
   methods: {
     getMasterList() {
       const userId = localStorage.getItem('userId');
       getList({userId: userId}).then(res => {
         this.tableData = res.data.data;
+      }).catch(error=>{
+        this.$message.error(error)
+      })
+    },
+    getEcharts(){
+      getBtmAndChart().then(res=>{
+        const btmNames = Object.keys(res.data.data).join(',');
+        console.log(btmNames);
+        if(btmNames){
+          getStatisticAnalysis({btmNames}).then(item=>{
+            console.log(item)
+          })
+        }
       })
     },
     //鏂板
@@ -110,7 +141,7 @@
       this.addVisible = false;
     },
     //淇濆瓨
-    addSaveHandler() {
+     async addSaveHandler() {
       if (this.selectData.length <= 0) {
         this.$message.warning('璇疯嚦灏戦�夋嫨涓�鏉℃暟鎹紒');
         return;
@@ -121,42 +152,19 @@
         return;
       }
 
-      this.dataKeyList = this.selectData.map(obj => obj.code)
-      const btmName = this.dataKeyList.join(",");
-      if (btmName) {
-        this.menuList=[
-          {
-            menuData: [
-              [0, 0, 0, 0, 0, 0, 4, 9, 12, 12, 12, 12],
-              [0, 0, 0, 0, 0, 0, 4, 5, 3, 0, 0, 0]
-            ],
-            code:1
-          },
-          {
-            menuData: [
-              [0, 0, 0, 1, 1, 1, 1, 1, 1, 29, 5315, 5315],
-              [0, 0, 0, 1, 0, 0, 0, 0, 0, 28, 5286, 0]
-            ],
-            code:2
-          },
-          {
-            menuData: [
-              [0, 58, 60, 61, 75, 84, 145, 162, 166, 177, 186, 186],
-              [0, 58, 2, 1, 14, 9, 61, 17, 4, 11, 9, 0]
-            ],
-            code:3
-          }
-        ]
-        this.nextSave();
-        this.$message.success('淇濆瓨鎴愬姛')
-        // getStatisticAnalysis({btmNames: btmName}).then(res => {
-          // this.menuList = res.data.data;
-          // this.nextSave();
-          // this.$message.success('淇濆瓨鎴愬姛')
-        // });
-      }else {
-        this.$message.warning('璇烽�夋嫨鏁版嵁锛�')
-      }
+      const newArray = this.selectData.map(item => {
+        return {
+          btmname: item.code,
+          chartIds: item.codeType.join(',')
+        }
+      })
+       saveStatisticAnalysis(newArray).then(res => {
+          this.menuList = res.data.data;
+          this.nextSave();
+          this.$message.success('淇濆瓨鎴愬姛')
+        }).catch(error=>{
+          this.$message.error(error)
+        });
     },
     nextSave() {
       const typeList = {
@@ -173,6 +181,8 @@
         const dataKey = typeList[item.codeType];
         if (dataKey) {
           this[dataKey].push(item);
+          this[dataKey].forEach(res => {
+          })
           hasValidData = true;
         }
       });

--
Gitblit v1.9.3