From 42f42dc88214f283b43c422f37e10ab45c5c5578 Mon Sep 17 00:00:00 2001
From: riku <risaku@163.com>
Date: 星期三, 12 三月 2025 17:32:13 +0800
Subject: [PATCH] 1. 新增绘图模式的切换 2. 新增行政区划的切换展示

---
 src/components/search/SearchBar.vue |   67 +++++++++++++++++++++++++--------
 1 files changed, 50 insertions(+), 17 deletions(-)

diff --git a/src/components/search/SearchBar.vue b/src/components/search/SearchBar.vue
index a7de11b..a6fe820 100644
--- a/src/components/search/SearchBar.vue
+++ b/src/components/search/SearchBar.vue
@@ -2,11 +2,15 @@
   <BaseCard size="middle-s" direction="down">
     <template #content>
       <el-form :inline="true">
-        <OptionMission v-model="mission"></OptionMission>
-        <OptionType v-model="formSearch.type"></OptionType>
+        <OptionMission v-model="mission" @init-over="initOver"></OptionMission>
+        <OptionType
+          v-model="formSearch.deviceType"
+          @init-over="initOver"
+        ></OptionType>
         <OptionDevice
-          :type="formSearch.type"
+          :type="formSearch.deviceType"
           v-model="formSearch.deviceCode"
+          @init-over="initOver"
         ></OptionDevice>
         <OptionTime
           v-model="formSearch.timeArray"
@@ -27,6 +31,12 @@
 </template>
 
 <script>
+// 鍙兘浼氭湁寤舵椂鍒濆鍖栫殑閫夐」鎬绘暟锛屽寘鎷蛋鑸换鍔°�佽澶囩被鍨嬨�佽澶囩紪鍙�
+const MAX_INIT = 3;
+// 宸插垵濮嬪寲鐨勯�夐」鏁�
+let initCount = 0;
+let initEvents = [];
+
 // 鎼滅储妗�
 export default {
   props: {
@@ -37,7 +47,7 @@
     return {
       mission: undefined,
       formSearch: {
-        type: '',
+        deviceType: '',
         deviceCode: '',
         timeArray: []
       },
@@ -54,27 +64,50 @@
     },
     mission(nV, oV) {
       if (nV != oV) {
-        this.formSearch.timeArray = [
-          new Date(nV.startTime),
-          new Date(nV.endTime)
-        ];
-        this.dateRange = [new Date(nV.startTime), new Date(nV.endTime)];
-        this.formSearch.type = nV.deviceType;
-        this.formSearch.deviceCode = nV.deviceCode;
+        this.onInit(() => {
+          this.formSearch.timeArray = [
+            new Date(nV.startTime),
+            new Date(nV.endTime)
+          ];
+          this.dateRange = [new Date(nV.startTime), new Date(nV.endTime)];
+          this.formSearch.deviceType = nV.deviceType;
+          this.formSearch.deviceCode = nV.deviceCode;
 
-        // 浠h〃棣栨杩涘叆鐣岄潰锛屾鏃惰嚜鍔ㄦ墽琛岄涓换鍔$殑鏁版嵁鏌ヨ鎿嶄綔
-        if (oV == undefined) {
-          setTimeout(() => {
-            this.handleClick();
-          }, 500);
-        }
+          // 浠h〃棣栨杩涘叆鐣岄潰锛屾鏃惰嚜鍔ㄦ墽琛岄涓换鍔$殑鏁版嵁鏌ヨ鎿嶄綔
+          if (oV == undefined) {
+            setTimeout(() => {
+              this.handleClick();
+            }, 500);
+          }
+        });
       }
     }
   },
   methods: {
+    // 鍚勯�夐」鍒濆鍖栧姞杞藉畬鎴愬垽瀹�
+    initOver() {
+      initCount++;
+      if (initCount == MAX_INIT && initEvents.length > 0) {
+        initEvents.forEach((e) => {
+          e();
+        });
+        initEvents = [];
+      }
+    },
+    onInit(event) {
+      if (initCount == MAX_INIT) {
+        event();
+      } else {
+        initEvents.push(event);
+      }
+    },
     handleClick() {
       this.$emit('search', { ...this.formSearch, mission: this.mission });
     }
+  },
+  created() {
+    initCount = 0;
+    initEvents = [];
   }
 };
 </script>

--
Gitblit v1.9.3