tangning 18 часов назад
Родитель
Сommit
12e0ba5e6b
4 измененных файлов с 31 добавлено и 13 удалено
  1. 27 10
      src/components/path/sign.vue
  2. 2 1
      src/sdk/cover/index.js
  3. 1 1
      src/sdk/sdk.ts
  4. 1 1
      src/views/guide/path/edit-path.vue

+ 27 - 10
src/components/path/sign.vue

@@ -80,13 +80,13 @@ path.bus.on("changeLineHeight", (val) => {
 });
 
 watchEffect(() => {
-  console.log('changePointDisplay', props.path)
   path.changeName(props.path.name);
 });
 
 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);
@@ -98,17 +98,34 @@ watch(
 );
 
 watchEffect(() => {
-  for (const point of props.path.points) {
-    watchEffect(() => {
-      const ndx = props.path.points.indexOf(point);
-      console.log(ndx, 'watchEffect', ~ndx, props.path);
-      if (~ndx) {
-        path.changePointName(ndx, point.name);
-        path.changePointDisplay && path.changePointDisplay(ndx, props.path.show || false);
-        currentPoints[ndx].name = point.name;
+    props.path.points.forEach((point, index) => {
+    // 监听 name 属性
+    watch(() => point.name, (newName) => {
+      path.changePointName(index, newName);
+      currentPoints[index].name = newName;
+    });
+    
+    // 监听 hide 属性
+    watch(() => point.hide, (newHide) => {
+      if (path.changePointDisplay) {
+        path.changePointDisplay(index, !newHide);
       }
     });
-  }
+  });
+  // for (const point of props.path.points) {
+  //   watchEffect(() => {
+  //     const ndx = props.path.points.indexOf(point);
+  //     console.log(ndx, 'watchEffect', ~ndx, 'point' ,point, props.path);
+  //     if (~ndx) {
+  //       path.changePointName(ndx, point.name);
+  //       path.changePointDisplay && path.changePointDisplay(ndx, !point.hide);
+  //       currentPoints[ndx].name = point.name;
+  //     }
+  //   });
+  // }
+},{ deep: true, flush: "post" });
+watchEffect(() => {
+  path.changeDirection(props.path.showDirection, props.path.reverseDirection);
 });
 
 let currentLine = getLineProps();

+ 2 - 1
src/sdk/cover/index.js

@@ -468,7 +468,8 @@ export const enter = ({ dom, mapDom, isLocal, lonlat, scenes, laserRoot, laserOS
                     bus.emit('changePoints', measure.dataset_points.map((p,i)=>{return {
                         position: (p || measure.points[i]).clone(), 
                         modelId: measure.points_datasets[i] == void 0 ? Id_noIntersect : measure.points_datasets[i], 
-                        name: measure.markerLabels[i].originText
+                        name: measure.markerLabels[i].originText,
+                        hide: false,
                     }}))
                     updatePathHideLine(measure)
                 }else{

+ 1 - 1
src/sdk/sdk.ts

@@ -300,7 +300,7 @@ export type Path = {
   // 更改标题气泡属性
   changeName: (name: string) => void;
   // 更改点位是否隐藏
-  changeHide: (hide: boolean) => void;
+  changePointDisplay: (index: number, hide: boolean) => void;
   // 线段销毁
   destroy: () => void;
 };

+ 1 - 1
src/views/guide/path/edit-path.vue

@@ -145,7 +145,7 @@
           <ui-group-option class="item">
             <span class="label">隐藏</span>
             <span class="oper">
-              <Switch v-model:checked="data.points[activePointNdx].show" />
+              <Switch v-model:checked="data.points[activePointNdx].hide" />
             </span>
           </ui-group-option>
         </ui-group>