瀏覽代碼

修改需求

bill 2 年之前
父節點
當前提交
3826eaaff3
共有 4 個文件被更改,包括 142 次插入118 次删除
  1. 21 21
      src/views/graphic/geos/roadEdge.vue
  2. 1 1
      src/views/scene/TrackMeasure.vue
  3. 108 94
      src/views/scene/menus/actions.ts
  4. 12 2
      src/views/scene/mode.vue

+ 21 - 21
src/views/graphic/geos/roadEdge.vue

@@ -35,27 +35,27 @@ const lineTypeMenu = [
     text: "单虚线",
     onClick: clickHandlerFactory(VectorStyle.SingleDashedLine),
   },
-  {
-    hide: props.geo.type === VectorType.CurveRoadEdge,
-    key: VectorStyle.DoubleSolidLine,
-    icon: "line_df",
-    text: "双实线",
-    onClick: clickHandlerFactory(VectorStyle.DoubleSolidLine),
-  },
-  {
-    hide: props.geo.type === VectorType.CurveRoadEdge,
-    key: VectorStyle.DoubleDashedLine,
-    icon: "line_dd",
-    text: "双虚线",
-    onClick: clickHandlerFactory(VectorStyle.DoubleDashedLine),
-  },
-  {
-    hide: props.geo.type === VectorType.CurveRoadEdge,
-    key: VectorStyle.BrokenLine,
-    icon: "line_broken",
-    text: "折线",
-    onClick: clickHandlerFactory(VectorStyle.BrokenLine),
-  },
+  // {
+  //   hide: props.geo.type === VectorType.CurveRoadEdge,
+  //   key: VectorStyle.DoubleSolidLine,
+  //   icon: "line_df",
+  //   text: "双实线",
+  //   onClick: clickHandlerFactory(VectorStyle.DoubleSolidLine),
+  // },
+  // {
+  //   hide: props.geo.type === VectorType.CurveRoadEdge,
+  //   key: VectorStyle.DoubleDashedLine,
+  //   icon: "line_dd",
+  //   text: "双虚线",
+  //   onClick: clickHandlerFactory(VectorStyle.DoubleDashedLine),
+  // },
+  // {
+  //   hide: props.geo.type === VectorType.CurveRoadEdge,
+  //   key: VectorStyle.BrokenLine,
+  //   icon: "line_broken",
+  //   text: "折线",
+  //   onClick: clickHandlerFactory(VectorStyle.BrokenLine),
+  // },
   {
     key: VectorStyle.PointDrawLine,
     icon: "line_dot",

+ 1 - 1
src/views/scene/TrackMeasure.vue

@@ -1,7 +1,7 @@
 <template>
   <div class="photo-btn">
     <ButtonPane class="item fun-ctrl" :size="80" @click="callback">
-      <ui-icon type="affirm" class="icon" />
+      <ui-icon type="return" class="icon" />
     </ButtonPane>
     <ButtonPane class="item fun-ctrl" :size="80" @click="active = !active">
       <ui-icon type="line_h" class="icon" :class="{ active }" />

+ 108 - 94
src/views/scene/menus/actions.ts

@@ -1,41 +1,54 @@
-import {findMenuByKey, menuEnum, MenuRaw} from "@/views/scene/menus/menus";
-import {continuedMeasure, startMeasure, stopMeasure as stopMeasureRaw} from "@/views/scene/linkage/measure";
-import {list, MeasureAtom, MeasureType} from "@/store/measure";
-import {baseLines} from '@/store/baseLine'
-import {basePoints} from "@/store/basePoint";
-import {Ref, watch} from "vue";
-import {activeBasePointStack, activeFixPointStack, customMap} from "@/hook";
-import {getCoverPos} from '../linkage/cover'
-import {Pos3D} from "@/sdk";
-import {fixPoints} from "@/store/fixPoint";
+import { findMenuByKey, menuEnum, MenuRaw } from "@/views/scene/menus/menus";
+import {
+  continuedMeasure,
+  startMeasure,
+  stopMeasure as stopMeasureRaw,
+} from "@/views/scene/linkage/measure";
+import { list, MeasureAtom, MeasureType } from "@/store/measure";
+import { baseLines } from "@/store/baseLine";
+import { basePoints } from "@/store/basePoint";
+import { Ref, watch } from "vue";
+import {
+  activeBasePointStack,
+  activeFixPointStack,
+  customMap,
+  useConfirm,
+} from "@/hook";
+import { getCoverPos } from "../linkage/cover";
+import { Pos3D } from "@/sdk";
+import { fixPoints } from "@/store/fixPoint";
 import Message from "@/components/base/components/message/message.vue";
-import { getId } from '@/utils'
+import { getId } from "@/utils";
 
-const trackPosMenuAction = (onComplete: () => void, onAddStore: (pos: Pos3D) => void, continued = false) => {
-  let onCleanup
-  let stop = false
+const trackPosMenuAction = (
+  onComplete: () => void,
+  onAddStore: (pos: Pos3D) => void,
+  continued = false
+) => {
+  let onCleanup;
+  let stop = false;
   const trackCoverPos = () => {
-    onCleanup && onCleanup()
-    onCleanup = getCoverPos(pos => {
-      onAddStore(pos)
+    onCleanup && onCleanup();
+    onCleanup = getCoverPos((pos) => {
+      onAddStore(pos);
       if (!continued) {
-        onComplete()
+        onComplete();
       } else if (!stop) {
-        trackCoverPos()
+        trackCoverPos();
       }
-    })
-  }
-  trackCoverPos()
+    });
+  };
+  trackCoverPos();
   return () => {
-    stop = true
-    onCleanup()
-  }
-}
+    stop = true;
+    onCleanup();
+  };
+};
 
 const stopMeasure = () => {
-  stopMeasureRaw()
+  stopMeasureRaw();
   // customMap.magnifier = false
-}
+};
 const trackMeasureMenuAction = (
   measureType: MeasureType,
   menu: MenuRaw,
@@ -44,156 +57,157 @@ const trackMeasureMenuAction = (
   name: string,
   color = "#3290ff"
 ) => {
-  let hide
-  let startTipEd = false
-  let endTipEd = false
+  let hide;
+  let startTipEd = false;
+  let endTipEd = false;
   const startTip = () => {
-    hide && hide()
+    hide && hide();
     if (!startTipEd) {
-      hide = Message.success({msg: `请绘制${name}`})
+      hide = Message.success({ msg: `请绘制${name}` });
       // 请选择一个位置单击,确定${name}的起点
-      startTipEd = true
+      startTipEd = true;
     }
-  }
+  };
   const firstTip = () => {
-    hide && hide()
+    hide && hide();
     if (!endTipEd) {
-      endTipEd = true
+      endTipEd = true;
       // hide = Message.success({msg: `再选择一个位置单击,确定${name}的终点`})
     }
-  }
-  startTip()
+  };
+  startTip();
   // customMap.magnifier = true
   const onAddMeasure = (data: MeasureAtom) => {
     if (data) {
       data.id = getId();
-      onAddStore(data)
-      onComplete()
+      onAddStore(data);
+      onComplete();
     }
     if (menu.continued) {
-      startTip()
+      startTip();
     }
-  }
-
+  };
 
   if (menu.continued) {
-    continuedMeasure(measureType as any, color, onAddMeasure, firstTip)
+    continuedMeasure(measureType as any, color, onAddMeasure, firstTip);
   } else {
-    startMeasure(measureType as any, color,  firstTip).then(onAddMeasure)
+    startMeasure(measureType as any, color, firstTip).then(onAddMeasure);
   }
 
   return () => {
-    stopMeasure()
-    hide()
-  }
-}
+    stopMeasure();
+    hide();
+  };
+};
 
 const menuActions = {
   [menuEnum.BASE_POINT]: (_, onComplete) => {
-    let hide = Message.success({ msg: "请单击选择基准点位置" })
+    let hide = Message.success({ msg: "请单击选择基准点位置" });
     const onDestroy = trackPosMenuAction(
       () => {
-        hide && hide()
-        onComplete()
+        hide && hide();
+        onComplete();
       },
-      pos => {
-        const len = basePoints.value.push({ id: getId(), pos })
-        activeBasePointStack.current.value.value = basePoints.value[len - 1]
+      (pos) => {
+        const len = basePoints.value.push({ id: getId(), pos });
+        activeBasePointStack.current.value.value = basePoints.value[len - 1];
         if (hide) {
-          hide()
-          hide = null
+          hide();
+          hide = null;
         }
       },
       true
-    )
+    );
     return () => {
-      onDestroy()
-      hide && hide()
-    }
+      onDestroy();
+      hide && hide();
+    };
   },
-  [menuEnum.FIX_POINT]:  (_, onComplete) => {
-    let hide = Message.success({ msg: "请单击选择固定点位置" })
+  [menuEnum.FIX_POINT]: (_, onComplete) => {
+    let hide = Message.success({ msg: "请单击选择固定点位置" });
     const onDestroy = trackPosMenuAction(
       () => {
-        hide && hide()
-        onComplete()
+        hide && hide();
+        onComplete();
       },
-      pos => {
-        const len = fixPoints.value.push({ id: getId(), pos, text: "固定点" })
-        activeFixPointStack.current.value.value = fixPoints.value[len - 1]
+      (pos) => {
+        const len = fixPoints.value.push({ id: getId(), pos, text: "固定点" });
+        activeFixPointStack.current.value.value = fixPoints.value[len - 1];
         if (hide) {
-          hide()
-          hide = null
+          hide();
+          hide = null;
         }
       },
       true
-    )
+    );
     return () => {
-      onDestroy()
-      hide && hide()
-    }
+      onDestroy();
+      hide && hide();
+    };
   },
   [menuEnum.MEASURE_ROW]: (menu, onComplete) => {
     return trackMeasureMenuAction(
-      'L_LINE',
+      "L_LINE",
       menu,
       (data) => list.value.push(data),
       onComplete,
       "测量线"
-    )
+    );
   },
   [menuEnum.MEASURE_COLUMN]: (menu, onComplete) => {
     return trackMeasureMenuAction(
-      'V_LINE',
+      "V_LINE",
       menu,
       (data) => list.value.push(data),
       onComplete,
       "测量线"
-    )
+    );
   },
   [menuEnum.MEASURE_FREE]: (menu, onComplete) => {
     return trackMeasureMenuAction(
-      'LINE',
+      "LINE",
       menu,
       (data) => list.value.push(data),
       onComplete,
       "测量线"
-    )
+    );
   },
   [menuEnum.BASE_LINE]: (menu, onComplete) => {
     return trackMeasureMenuAction(
-      'BASE_LINE',
+      "BASE_LINE",
       menu,
       (data) => baseLines.value.push(data),
       onComplete,
       "基准线",
       "#ED1C24"
-    )
+    );
   },
-  [menuEnum.CLEAR]: (menu, onComplete) => {
-    list.value = []
-    baseLines.value = []
-    basePoints.value = []
-    fixPoints.value = []
-    onComplete()
+  [menuEnum.CLEAR]: async (menu, onComplete) => {
+    if (await useConfirm("确认情况?该操作无法撤销")) {
+      list.value = [];
+      baseLines.value = [];
+      basePoints.value = [];
+      fixPoints.value = [];
+    }
+    onComplete();
   },
-}
+};
 
 export const joinActions = (activeKey: Ref<string>) => {
   return watch(
     () => activeKey.value,
     (key, oldKey, onCleanup) => {
       if (key && menuActions[key]) {
-        const menu = findMenuByKey(key as any)
+        const menu = findMenuByKey(key as any);
         const cleanup = menuActions[key](menu, () => {
           if (!menu.continued) {
             activeKey.value = null;
           }
         });
-        if (typeof cleanup === 'function') {
+        if (typeof cleanup === "function") {
           onCleanup(cleanup);
         }
       }
     }
-  )
-}
+  );
+};

+ 12 - 2
src/views/scene/mode.vue

@@ -12,6 +12,7 @@ import GroupButton from "@/components/group-button/index.vue";
 import { Mode } from "@/sdk";
 import { computed, ref, watch, watchEffect } from "vue";
 import { customMap, disabledMap } from "@/hook/custom/index";
+import { params } from "@/hook";
 
 const tabs = [
   {
@@ -26,7 +27,9 @@ const tabs = [
   },
 ];
 
-const activeKey = ref(tabs[0].mode);
+const key = params.m + "model";
+
+const activeKey = ref(Number(localStorage.getItem(key) || 0));
 const menus = computed(() =>
   tabs.map((tab) => ({
     icon: tab.mode === activeKey.value ? tab.activeIcon : tab.icon,
@@ -35,7 +38,14 @@ const menus = computed(() =>
   }))
 );
 
-watch(activeKey, () => (customMap.mode = activeKey.value));
+watch(
+  activeKey,
+  () => {
+    customMap.mode = activeKey.value;
+    localStorage.setItem(key, activeKey.value.toString());
+  },
+  { immediate: true }
+);
 </script>
 
 <style lang="scss" scoped>