riku
2025-02-21 c35074e0e33054bb6c5ada22f8104422ae953b17
1. 新增默认加载时先判断各选项是否获取完成逻辑
已修改6个文件
46 ■■■■ 文件已修改
src/api/index.js 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/search/OptionDevice.vue 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/search/OptionMission.vue 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/search/OptionType.vue 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/search/SearchBar.vue 33 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/historymode/HistoryMode.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/index.js
@@ -15,7 +15,7 @@
const $http = axios.create({
  baseURL: ip1,
  timeout: 20000
  timeout: 30000
});
//添加拦截器
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');
        }
      });
    },
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');
        }
      });
    },
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);
  }
};
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,6 +64,7 @@
    },
    mission(nV, oV) {
      if (nV != oV) {
        this.onInit(() => {
        this.formSearch.timeArray = [
          new Date(nV.startTime),
          new Date(nV.endTime)
@@ -68,10 +79,28 @@
            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 });
    }
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) {