فهرست منبع

试图添加定时器

zhaoke 1 سال پیش
والد
کامیت
b7763df89c
3فایلهای تغییر یافته به همراه44 افزوده شده و 6 حذف شده
  1. 13 2
      src/views/newArrival/index.vue
  2. 18 2
      src/views/newDeparture/index.vue
  3. 13 2
      src/views/newTransfer/index.vue

+ 13 - 2
src/views/newArrival/index.vue

@@ -80,7 +80,8 @@ export default {
       },
       loading: false,
       AirportList: [],
-      tableTag: {}
+      tableTag: {},
+      timer: null
     };
   },
   computed: {
@@ -92,6 +93,15 @@ export default {
   created () {
     this.getAirPortData()
   },
+  mounted () {
+    this.timer = setInterval(() => {
+      this.getAirPortData()
+    }, LOOP_INTERVAL.arrivalTable)
+  },
+  destroyed () {
+    clearInterval(this.timer)
+    this.timer = null
+  },
   methods: {
     airPortChange (val) {
       this.formData.currentAirport = val
@@ -132,7 +142,8 @@ export default {
         if (Number(res.code) === 0) {
           this.AirportList = res.returnData;
           if (type) {
-            this.formData.currentAirport = this.TauthId ? res.returnData[0].IATACode : "PEK";
+            const flag = res.returnData.filter(item => item.IATACode == 'CAN');
+            this.formData.currentAirport = this.TauthId && flag.length ? 'CAN' : res.returnData[0].IATACode;
           }
           this.tableTag = {
             filter: this.formatParams()

+ 18 - 2
src/views/newDeparture/index.vue

@@ -11,6 +11,11 @@
     <div ref="formWrap" class="terminal-form-wrap">
       <el-form ref="form" :inline="true" :model="formData" :rules="rules" class="form">
         <div class="form-left">
+          <!-- <el-form-item prop="company">
+            <el-select v-model="formData.company" class="input-shadow" size="small" style="width: 150px" filterable default-first-option placeholder="请选择航班属性" @change="airPortChange">
+              <el-option v-for="(item, index) in companyOptions" :key="index" :label="item.label" :value="item.value" />
+            </el-select>
+          </el-form-item> -->
           <el-form-item prop="currentAirport">
             <el-select v-model="formData.currentAirport" class="input-shadow" size="small" style="width: 150px" filterable default-first-option placeholder="请选择机场" @change="airPortChange">
               <el-option v-for="(item, index) in AirportList" :key="index" :label="item.IATACode" :value="item.IATACode" />
@@ -80,7 +85,8 @@ export default {
       },
       loading: false,
       AirportList: [],
-      tableTag: {}
+      tableTag: {},
+      timer: null
     };
   },
   computed: {
@@ -92,6 +98,15 @@ export default {
   created () {
     this.getAirPortData()
   },
+  mounted () {
+    this.timer = setInterval(() => {
+      this.getAirPortData()
+    }, LOOP_INTERVAL.departureTable)
+  },
+  destroyed () {
+    clearInterval(this.timer)
+    this.timer = null
+  },
   methods: {
     airPortChange (val) {
       this.formData.currentAirport = val
@@ -132,7 +147,8 @@ export default {
         if (Number(res.code) === 0) {
           this.AirportList = res.returnData;
           if (type) {
-            this.formData.currentAirport = this.TauthId ? res.returnData[0].IATACode : "PEK";
+            const flag = res.returnData.filter(item => item.IATACode == 'CAN');
+            this.formData.currentAirport = this.TauthId && flag.length ? 'CAN' : res.returnData[0].IATACode;
           }
           this.tableTag = {
             filter: this.formatParams()

+ 13 - 2
src/views/newTransfer/index.vue

@@ -83,7 +83,8 @@ export default {
       },
       loading: false,
       AirportList: [],
-      tableTag: {}
+      tableTag: {},
+      timer: null
     };
   },
   computed: {
@@ -95,6 +96,15 @@ export default {
   created () {
     this.getAirPortData()
   },
+  mounted () {
+    this.timer = setInterval(() => {
+      this.getAirPortData()
+    }, LOOP_INTERVAL.transferArrivalTable)
+  },
+  destroyed () {
+    clearInterval(this.timer)
+    this.timer = null
+  },
   methods: {
     airPortChange (val) {
       this.formData.currentAirport = val
@@ -140,7 +150,8 @@ export default {
         if (Number(res.code) === 0) {
           this.AirportList = res.returnData;
           if (type) {
-            this.formData.currentAirport = this.TauthId ? res.returnData[0].IATACode : "PEK";
+            const flag = res.returnData.filter(item => item.IATACode == 'CAN');
+            this.formData.currentAirport = this.TauthId && flag.length ? 'CAN' : res.returnData[0].IATACode;
           }
           this.tableTag = {
             filter: this.formatParams()