Browse Source

重置已修改为保存的path数据

tangning 1 ngày trước cách đây
mục cha
commit
23e009d5ed
2 tập tin đã thay đổi với 19 bổ sung14 xóa
  1. 15 12
      src/components/path/list.vue
  2. 4 2
      src/components/path/sign.vue

+ 15 - 12
src/components/path/list.vue

@@ -1,27 +1,30 @@
 <template>
   <!-- <template v-for="(path, index) in paths" :key="path.id">
     v-if="getPathIsShow(path)" -->
-  <Sign
-    v-for="(path, index) in paths"
-    @delete="deletePath(path)"
-    @updatePoints="(data) => updatePosition(index, data)"
-    @updateLinePosition="(data) => updateLinePosition(index, data)"
-    @updateLineHeight="(data) => (paths[index].lineAltitudeAboveGround = data)"
-    :ref="(node: any) => nodeHandler(index, node)"
-    :path="path"
-    :key="path.id"
-  />
+  <div class="pathList">
+      <Sign
+        v-for="(path, index) in paths"
+        @delete="deletePath(path)"
+        @updatePoints="(data) => updatePosition(index, data)"
+        @updateLinePosition="(data) => updateLinePosition(index, data)"
+        @updateLineHeight="(data) => (paths[index].lineAltitudeAboveGround = data)"
+        :ref="(node: any) => nodeHandler(index, node)"
+        @updateId="(id) => refreshId = id"
+        :path="path"
+        :key="path.id == refreshId ? Date.now() : path.id"
+      />
+  </div>
   <!-- </template> -->
 </template>
 
 <script lang="ts" setup>
-import { reactive, watchEffect } from "vue";
+import { reactive, watchEffect, ref } from "vue";
 import Sign from "./sign.vue";
 import { getPathIsShow, Path } from "@/store";
 import { PathsNode } from "@/sdk/association/path";
 const props = defineProps<{ paths: Path[] }>();
 const nodes = reactive([]) as PathsNode;
-
+const refreshId = ref(null as any);
 watchEffect(() => (nodes.length = props.paths.length));
 
 const deletePath = (path: Path) => {

+ 4 - 2
src/components/path/sign.vue

@@ -16,6 +16,7 @@ import { computed, onUnmounted, ref, watch, watchEffect } from "vue";
 import { sdk } from "@/sdk";
 
 import type { Path } from "@/store";
+import { initialPaths, recoverPaths } from "@/store";
 import { inRevise } from "bill/utils";
 
 export type SignProps = { path: Path };
@@ -25,6 +26,7 @@ const emit = defineEmits<{
   (e: "delete"): void;
   (e: "updateLinePosition", val: Path["linePosition"]): void;
   (e: "updatePoints", val: Path["points"]): void;
+  (e: "updateId"): void;
   (e: "updateLineHeight", val: Path["lineAltitudeAboveGround"]): void;
 }>();
 
@@ -86,11 +88,11 @@ watchEffect(() => {
 watch(
   () => props.path.points.map((i) => ({ modelId: i.modelId, position: i.position })),
   (p) => {
-    console.log(p, 'watchEffect0', props.path.points);
     changPointsTimeout = setTimeout(() => {
       if (inRevise(props.path.points, currentPoints)) {
         path.changePathPoints(p);
-        currentPoints = props.path.points;
+        emit("updateId", props.path.id);//重置已修改为保存的数据
+        // currentPoints = props.path.points;
       }
     }, 16);
   },