From c35074e0e33054bb6c5ada22f8104422ae953b17 Mon Sep 17 00:00:00 2001
From: riku <risaku@163.com>
Date: 星期五, 21 二月 2025 17:19:04 +0800
Subject: [PATCH] 1. 新增默认加载时先判断各选项是否获取完成逻辑
---
src/views/historymode/HistoryMode.vue | 2
src/api/index.js | 2
src/components/search/OptionDevice.vue | 3 +
src/components/search/OptionMission.vue | 3 +
src/components/search/SearchBar.vue | 59 ++++++++++++++++++++++-------
src/components/search/OptionType.vue | 3 +
6 files changed, 52 insertions(+), 20 deletions(-)
diff --git a/src/api/index.js b/src/api/index.js
index c0264f8..c19983c 100644
--- a/src/api/index.js
+++ b/src/api/index.js
@@ -15,7 +15,7 @@
const $http = axios.create({
baseURL: ip1,
- timeout: 20000
+ timeout: 30000
});
//娣诲姞鎷︽埅鍣�
diff --git a/src/components/search/OptionDevice.vue b/src/components/search/OptionDevice.vue
index a6d3c47..0b56362 100644
--- a/src/components/search/OptionDevice.vue
+++ b/src/components/search/OptionDevice.vue
@@ -27,7 +27,7 @@
type: String,
modelValue: String
},
- emits: ['update:modelValue'],
+ emits: ['update:modelValue', 'initOver'],
data() {
return {};
},
@@ -61,6 +61,7 @@
this.deviceStore.fetchDevice().then((res) => {
if (res.success && res.data.length > 0) {
this.handleChange(this.deviceOptions[0].value);
+ this.$emit('initOver');
}
});
},
diff --git a/src/components/search/OptionMission.vue b/src/components/search/OptionMission.vue
index f58d98f..dd8ea00 100644
--- a/src/components/search/OptionMission.vue
+++ b/src/components/search/OptionMission.vue
@@ -31,7 +31,7 @@
type: String,
modelValue: String
},
- emits: ['update:modelValue', 'change'],
+ emits: ['update:modelValue', 'initOver'],
data() {
return {
index: undefined
@@ -46,6 +46,7 @@
if (res.success && res.data.length > 0) {
this.index = 0;
this.handleChange(0);
+ this.$emit('initOver');
}
});
},
diff --git a/src/components/search/OptionType.vue b/src/components/search/OptionType.vue
index c28a189..f1997b3 100644
--- a/src/components/search/OptionType.vue
+++ b/src/components/search/OptionType.vue
@@ -32,7 +32,7 @@
},
modelValue: String
},
- emits: ['update:modelValue'],
+ emits: ['update:modelValue', 'initOver'],
data() {
return {
typeList: typeList(),
@@ -54,6 +54,7 @@
}
},
mounted() {
+ this.$emit('initOver');
this.handleChange(this.typeList[0].value);
}
};
diff --git a/src/components/search/SearchBar.vue b/src/components/search/SearchBar.vue
index d28abc0..6c0dad6 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.deviceType"></OptionType>
+ <OptionMission v-model="mission" @init-over="initOver"></OptionMission>
+ <OptionType
+ v-model="formSearch.deviceType"
+ @init-over="initOver"
+ ></OptionType>
<OptionDevice
: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: {
@@ -54,24 +64,43 @@
},
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;
+ 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 });
}
diff --git a/src/views/historymode/HistoryMode.vue b/src/views/historymode/HistoryMode.vue
index b63cf49..e7978dd 100644
--- a/src/views/historymode/HistoryMode.vue
+++ b/src/views/historymode/HistoryMode.vue
@@ -145,10 +145,10 @@
// 缁樺埗3D璧拌璺嚎鍥�
drawRoadMap(e) {
this.factorDatas.refreshHeight(this.factorType);
-
Layer.drawRoadMap(this.factorDatas, e, this.merge, this.setCenter);
},
drawRoadLine(e) {
+ this.factorDatas.refreshHeight(this.factorType);
mapLine.drawLine(this.factorDatas, e);
},
drawMassMarks(e) {
--
Gitblit v1.9.3