zhongxiaoyu 1 年間 前
コミット
7f8808d761
1 ファイル変更45 行追加43 行削除
  1. 45 43
      src/views/dashboard/index.vue

+ 45 - 43
src/views/dashboard/index.vue

@@ -337,14 +337,20 @@ export default {
       }
     },
   },
+  watch: {
+    currentAirport(val) {
+      if (val) {
+        this.getAllData()
+      }
+    },
+  },
   created() {
     this.inHourDataOption.series[0].color = '#3FC9D5'
     this.outHourDataOption.series[0].color = '#527CF5'
     this.transHourDataOption.series[0].color = '#F5C871'
   },
   async mounted() {
-    await this.getAiportList()
-    this.getAllData()
+    this.getAiportList()
   },
   methods: {
     // 航站列表
@@ -496,47 +502,43 @@ export default {
     async getAllData() {
       this.loading = true
       try {
-        if (this.currentAirport) {
-          const io_types = ['离港', '进港', '中转']
-          const [
-            [outDateData],
-            [inDateData],
-            [transDateData],
-            outHourData,
-            inHourData,
-            transHourData,
-          ] = await Promise.all([
-            ...io_types.map(io_type => this.getDateData(io_type)),
-            ...io_types.map(io_type => this.getHourData(io_type)),
-            this.getCompanyData(),
-            this.getMap(),
-          ])
-          this.arrivalFlightCount = Number(inDateData.flights)
-          this.departureFlightCount = Number(outDateData.flights)
-          this.baggageCountItems[0].num =
-            Number(inDateData.bags) + Number(outDateData.bags)
-          this.baggageCountItems[1].num = Number(inDateData.bags)
-          this.baggageCountItems[2].num = Number(outDateData.bags)
-          this.baggageCountItems[3].num = Number(transDateData.bags)
-          this.inHourDataOption.xAxis.data = inHourData.map(
-            item => `${item.dat}${item.dat <= 12 ? 'am' : 'pm'}`
-          )
-          this.inHourDataOption.series[0].data = inHourData.map(
-            item => item.bags
-          )
-          this.outHourDataOption.xAxis.data = outHourData.map(
-            item => `${item.dat}${item.dat <= 12 ? 'am' : 'pm'}`
-          )
-          this.outHourDataOption.series[0].data = outHourData.map(
-            item => item.bags
-          )
-          this.transHourDataOption.xAxis.data = transHourData.map(
-            item => `${item.dat}${item.dat <= 12 ? 'am' : 'pm'}`
-          )
-          this.transHourDataOption.series[0].data = transHourData.map(
-            item => item.bags
-          )
-        }
+        const io_types = ['离港', '进港', '中转']
+        const [
+          [outDateData],
+          [inDateData],
+          [transDateData],
+          outHourData,
+          inHourData,
+          transHourData,
+        ] = await Promise.all([
+          ...io_types.map(io_type => this.getDateData(io_type)),
+          ...io_types.map(io_type => this.getHourData(io_type)),
+          this.getCompanyData(),
+          this.getMap(),
+        ])
+        this.arrivalFlightCount = Number(inDateData.flights)
+        this.departureFlightCount = Number(outDateData.flights)
+        this.baggageCountItems[0].num =
+          Number(inDateData.bags) + Number(outDateData.bags)
+        this.baggageCountItems[1].num = Number(inDateData.bags)
+        this.baggageCountItems[2].num = Number(outDateData.bags)
+        this.baggageCountItems[3].num = Number(transDateData.bags)
+        this.inHourDataOption.xAxis.data = inHourData.map(
+          item => `${item.dat}${item.dat <= 12 ? 'am' : 'pm'}`
+        )
+        this.inHourDataOption.series[0].data = inHourData.map(item => item.bags)
+        this.outHourDataOption.xAxis.data = outHourData.map(
+          item => `${item.dat}${item.dat <= 12 ? 'am' : 'pm'}`
+        )
+        this.outHourDataOption.series[0].data = outHourData.map(
+          item => item.bags
+        )
+        this.transHourDataOption.xAxis.data = transHourData.map(
+          item => `${item.dat}${item.dat <= 12 ? 'am' : 'pm'}`
+        )
+        this.transHourDataOption.series[0].data = transHourData.map(
+          item => item.bags
+        )
       } catch (error) {
         console.error(error)
       }