From 6b6eff08baa3d052b66fd2e68f1ac0d8495f6f8a Mon Sep 17 00:00:00 2001
From: riku <risaku@163.com>
Date: 星期四, 29 八月 2024 17:35:33 +0800
Subject: [PATCH] 修改历史数据获取逻辑

---
 src/components/search/SearchBar.vue |   87 ++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 77 insertions(+), 10 deletions(-)

diff --git a/src/components/search/SearchBar.vue b/src/components/search/SearchBar.vue
index 03e4082..d28abc0 100644
--- a/src/components/search/SearchBar.vue
+++ b/src/components/search/SearchBar.vue
@@ -1,14 +1,26 @@
 <template>
-  <BaseCard class="map-date-selector">
+  <BaseCard size="middle-s" direction="down">
     <template #content>
       <el-form :inline="true">
-        <OptionMission v-model="formSearch.missionCode"></OptionMission>
-        <OptionType v-model="formSearch.type"></OptionType>
+        <OptionMission v-model="mission"></OptionMission>
+        <OptionType v-model="formSearch.deviceType"></OptionType>
         <OptionDevice
-          :type="formSearch.type"
+          :type="formSearch.deviceType"
           v-model="formSearch.deviceCode"
         ></OptionDevice>
-        <OptionTime v-model="formSearch.timeArray"></OptionTime>
+        <OptionTime
+          v-model="formSearch.timeArray"
+          :start-date="dateRange[0]"
+          :end-date="dateRange[1]"
+        ></OptionTime>
+        <el-button
+          :loading="loading"
+          type="primary"
+          class="el-button-custom"
+          @click="handleClick"
+        >
+          鍒嗘瀽
+        </el-button>
       </el-form>
     </template>
   </BaseCard>
@@ -17,17 +29,72 @@
 <script>
 // 鎼滅储妗�
 export default {
+  props: {
+    loading: Boolean,
+    searchTime: Array
+  },
   data() {
     return {
+      mission: undefined,
       formSearch: {
-        missionCode: '',
-        type: '',
+        deviceType: '',
         deviceCode: '',
         timeArray: []
-      }
+      },
+      // 鍙�夋棩鏈熻寖鍥达紝鏍规嵁璧拌埅浠诲姟鍐冲畾
+      dateRange: []
     };
   },
-  method: {}
+  emits: ['search'],
+  watch: {
+    searchTime(nV, oV) {
+      if (nV != oV) {
+        this.formSearch.timeArray = this.searchTime;
+      }
+    },
+    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.deviceType = nV.deviceType;
+        this.formSearch.deviceCode = nV.deviceCode;
+
+        // 浠h〃棣栨杩涘叆鐣岄潰锛屾鏃惰嚜鍔ㄦ墽琛岄涓换鍔$殑鏁版嵁鏌ヨ鎿嶄綔
+        if (oV == undefined) {
+          setTimeout(() => {
+            this.handleClick();
+          }, 500);
+        }
+      }
+    }
+  },
+  methods: {
+    handleClick() {
+      this.$emit('search', { ...this.formSearch, mission: this.mission });
+    }
+  }
 };
 </script>
-<style scoped></style>
+<style scoped lang="scss">
+.map-date-selector {
+  display: inline-block;
+  position: relative;
+  /* left: 0;
+    right: 0;
+    top: 0px; */
+  /* padding: 0 4px; */
+  /* color: ffffffbd; */
+  /* background-color: antiquewhite; */
+}
+
+.p-events-auto {
+}
+
+.el-form-item {
+  margin-bottom: 0px;
+  margin-right: 8px !important;
+}
+</style>

--
Gitblit v1.9.3