zhengnaiwen_citu 3 月之前
父節點
當前提交
bf045f7c67
共有 1 個文件被更改,包括 20 次插入12 次删除
  1. 20 12
      src/views/dataChart/components/StatisticsCard.vue

+ 20 - 12
src/views/dataChart/components/StatisticsCard.vue

@@ -1,6 +1,6 @@
 <template>
   <div>
-    <m-search class="mb-3" :items="searchItems" v-model="searchValues"></m-search>
+    <m-search class="mb-3" :items="searchItems" v-model="searchValues" @search="onSearch"></m-search>
     <AnalysisChart shadow="always" :option="option" height="800" v-loading="loading"></AnalysisChart>
   </div>
 </template>
@@ -39,17 +39,25 @@ export default {
       }
     }
   },
-  async created () {
-    this.loading = true
-    try {
-      const { data } = await this.api({
-        ...this.searchValues
-      })
-      this.option = data
-    } catch (error) {
-      this.$message.error(error)
-    } finally {
-      this.loading = false
+  created () {
+    this.onInit()
+  },
+  methods: {
+    async onInit () {
+      this.loading = true
+      try {
+        const { data } = await this.api({
+          ...this.searchValues
+        })
+        this.option = data
+      } catch (error) {
+        this.$message.error(error)
+      } finally {
+        this.loading = false
+      }
+    },
+    onSearch () {
+      this.onInit()
     }
   }
 }