bill 1 år sedan
förälder
incheckning
6d95015d7c
4 ändrade filer med 518 tillägg och 505 borttagningar
  1. 324 352
      pnpm-lock.yaml
  2. 1 1
      src/submodule
  3. 55 18
      src/view/map/map-board.vue
  4. 138 134
      src/view/map/map-right-poly.vue

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 324 - 352
pnpm-lock.yaml


+ 1 - 1
src/submodule

@@ -1 +1 @@
-Subproject commit e5b60b68a0bb8e2ba2d65f11848d21407d9e5a60
+Subproject commit 8ca62091d96f5a6ce509d7977507c2f4df02547e

+ 55 - 18
src/view/map/map-board.vue

@@ -6,13 +6,21 @@
           <el-button :icon="Back" circle type="default" @click="router.back()" />
         </div>
         <div class="nav_container">
-          <div class="nav_item" :class="{ active: isCurrentTab(0) }" @click="handleTabs(0)">
+          <div
+            class="nav_item"
+            :class="{ active: isCurrentTab(0) }"
+            @click="handleTabs(0)"
+          >
             <el-icon size="20">
               <LocationInformation />
             </el-icon>
             <span>坐标</span>
           </div>
-          <div class="nav_item" :class="{ active: isCurrentTab(1) }" @click="handleTabs(1)">
+          <div
+            class="nav_item"
+            :class="{ active: isCurrentTab(1) }"
+            @click="handleTabs(1)"
+          >
             <el-icon size="20">
               <Grid />
             </el-icon>
@@ -23,26 +31,57 @@
     </Teleport>
     <div id="map" class="map-container" ref="mapContainer" @click.stop>
       <div class="map-component">
-        <el-select v-model="tileType" placeholder="选择底图" style="width: 120px" class="tile-type-select">
-          <el-option v-for="item in tileOptions" :key="item" :label="item" :value="item" />
+        <el-select
+          v-model="tileType"
+          placeholder="选择底图"
+          style="width: 120px"
+          class="tile-type-select"
+        >
+          <el-option
+            v-for="item in tileOptions"
+            :key="item"
+            :label="item"
+            :value="item"
+          />
         </el-select>
       </div>
 
       <div class="board" ref="boardContainer"></div>
     </div>
     <div class="right-control">
-      <MapRight v-if="isCurrentTab(0)" @fly-point="flyScenePoint" @fly-scene="flyScene" @goto-point="gotoPointPage" />
-      <MapRightPoly @del="handlePolysDel" @edit="handlePolysEdit" :data="boardData" v-if="isCurrentTab(1)">
+      <MapRight
+        v-if="isCurrentTab(0)"
+        @fly-point="flyScenePoint"
+        @fly-scene="flyScene"
+        @goto-point="gotoPointPage"
+      />
+      <MapRightPoly
+        @del="handlePolysDel"
+        @edit="handlePolysEdit"
+        :data="boardData"
+        v-if="isCurrentTab(1)"
+      >
       </MapRightPoly>
     </div>
 
     <Teleport to="body" v-if="isMounted">
       <!-- <el-button class="temp_btn" @click="clearPolys">后端全清</el-button> -->
-      <div class="draw-global-icon" v-if="isCurrentTab(1) && !isEditDrawingMode" @click="handleBoardDraw">
+      <div
+        class="draw-global-icon"
+        v-if="isCurrentTab(1) && !isEditDrawingMode"
+        @click="handleBoardDraw"
+      >
         <el-icon size="30">
-          <svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24">
-            <path fill="currentColor"
-              d="M2 4.621a.5.5 0 0 1 .854-.353l6.01 6.01c.126.126.17.31.15.487a2 2 0 1 0 1.751-1.751a.586.586 0 0 1-.487-.15l-6.01-6.01A.5.5 0 0 1 4.62 2H11a9 9 0 0 1 8.468 12.054l2.24 2.239a1 1 0 0 1 0 1.414l-4 4a1 1 0 0 1-1.415 0l-2.239-2.239A9 9 0 0 1 2 11z" />
+          <svg
+            xmlns="http://www.w3.org/2000/svg"
+            width="1em"
+            height="1em"
+            viewBox="0 0 24 24"
+          >
+            <path
+              fill="currentColor"
+              d="M2 4.621a.5.5 0 0 1 .854-.353l6.01 6.01c.126.126.17.31.15.487a2 2 0 1 0 1.751-1.751a.586.586 0 0 1-.487-.15l-6.01-6.01A.5.5 0 0 1 4.62 2H11a9 9 0 0 1 8.468 12.054l2.24 2.239a1 1 0 0 1 0 1.414l-4 4a1 1 0 0 1-1.415 0l-2.239-2.239A9 9 0 0 1 2 11z"
+            />
           </svg>
         </el-icon>
       </div>
@@ -156,7 +195,7 @@ watch(
           const point =
             bpoint.id &&
             scenePoints.value.find((point) => point.id.toString() === bpoint.id);
-          point && gotoPointPage(point);
+          // point && gotoPointPage(point);
         });
 
         // relicsPolyginsFetch().then((data) => {
@@ -297,8 +336,7 @@ const initCroodTabdata = async () => {
     },
     String(relicsId.value)
   );
-
-}
+};
 
 const initPolyTabData = async () => {
   try {
@@ -308,18 +346,17 @@ const initPolyTabData = async () => {
       // console.log("res", points, res.data);
       if (res.data) {
         boardData.value = res.data;
-        boardData.value.points = points.concat(res.data.points)
+        boardData.value.points = points.concat(res.data.points);
         board.setData(boardData.value, String(relicsId.value));
       }
     }, 500);
-  } catch (error) { }
+  } catch (error) {}
 };
 
 const handlePolysDel = (id: string) => {
   try {
     board.polygon().removePolygon(id);
     handleSyncDataToServer();
-
   } catch (error) {
     console.error("handlePolysDel", error);
   }
@@ -424,7 +461,7 @@ const handlePolysEdit = (item: PolyDataType) => {
   &.light {
     --color: #fff;
 
-    >div {
+    > div {
       text-shadow: 0 0 2px #000;
     }
   }
@@ -432,7 +469,7 @@ const handlePolysEdit = (item: PolyDataType) => {
   &.dark {
     --color: #000;
 
-    >div {
+    > div {
       text-shadow: 0 0 2px #fff;
     }
   }

+ 138 - 134
src/view/map/map-right-poly.vue

@@ -1,192 +1,196 @@
 <template>
-    <div class="right-layout">
-        <div class="right-content">
-            <div class="tree-layout">
-                <p>全部数据</p>
-                <div class="poly-list">
-                    <template v-if="data.polygons.length > 0" v-for=" item in data.polygons">
-                        <div class="poly-list-item">
-                            <div class="left">
-                                <span>{{ item.name ? item.name : '本体边界' + item.id }}</span>
-                            </div>
-                            <div class="right">
-                                <el-icon class="icon">
-                                    <Delete @click="del(item.id)" />
-                                </el-icon>
-                                <el-icon class="icon">
-                                    <Edit @click="handleShowEditModel(item)" />
-                                </el-icon>
-                                <el-icon class="icon">
-                                    <Download @click="handleDownload" />
-                                </el-icon>
-                            </div>
-                        </div>
-                    </template>
-                    <template v-else>
-                        <div class="empty">
-                            暂没数据
-                        </div>
-                    </template>
-                </div>
+  <div class="right-layout">
+    <div class="right-content">
+      <div class="tree-layout">
+        <p>全部数据</p>
+        <div class="poly-list">
+          <template v-if="data.polygons.length > 0" v-for="item in data.polygons">
+            <div class="poly-list-item">
+              <div class="left">
+                <span>{{ item.name ? item.name : "本体边界" + item.id }}</span>
+              </div>
+              <div class="right">
+                <el-icon class="icon">
+                  <Delete @click="del(item.id)" />
+                </el-icon>
+                <el-icon class="icon">
+                  <Edit @click="handleShowEditModel(item)" />
+                </el-icon>
+                <el-icon class="icon">
+                  <Download @click="handleDownload(item)" />
+                </el-icon>
+              </div>
             </div>
+          </template>
+          <template v-else>
+            <div class="empty">暂没数据</div>
+          </template>
         </div>
-        <SingleInput :visible="isShowPolyEditName" @update:visible="isShowPolyEditName = false"
-            :value="currentPoly.name" :update-value="updatePolyName" title="修改边界名称" />
+      </div>
     </div>
+    <SingleInput
+      :visible="isShowPolyEditName"
+      @update:visible="isShowPolyEditName = false"
+      :value="currentPoly.name"
+      :update-value="updatePolyName"
+      title="修改边界名称"
+    />
+  </div>
 </template>
 
 <script setup lang="ts">
 import { ref, watchEffect } from "vue";
-import type { PolyDataType, DrawingDataType } from '@/request/drawing.ts'
-import {
-    Delete,
-    Download,
-    Edit,
-} from "@element-plus/icons-vue";
+import type { PolyDataType, DrawingDataType } from "@/request/drawing.ts";
+import { Delete, Download, Edit } from "@element-plus/icons-vue";
 import SingleInput from "@/components/single-input.vue";
 import { scenePosTransform } from "./board";
 import { downloadPointsXLSL2 } from "@/util/pc4xlsl";
-import { scenes } from "@/store/scene";
+import { scenePoints, scenes } from "@/store/scene";
 
 import { relics } from "@/store/relics";
 import { ElMessageBox } from "element-plus";
+import { getWholeLinePolygonPoints } from "@/submodule/src/board";
 
 const props = defineProps<{
-    data: DrawingDataType | null;
+  data: DrawingDataType | null;
 }>();
 
 const emit = defineEmits<{
-    (e: "del", id: string): void;
-    (e: "edit", data: PolyDataType): void;
-    // (e: "edit", id: string): void;
+  (e: "del", id: string): void;
+  (e: "edit", data: PolyDataType): void;
+  // (e: "edit", id: string): void;
 }>();
 
 const relicsName = ref("");
 
 const currentPoly = ref<PolyDataType>({
-    id: '',
-    name: '',
-    lineIds: []
+  id: "",
+  name: "",
+  lineIds: [],
 });
 const isShowPolyEditName = ref(false);
 watchEffect(() => {
-    relicsName.value = relics.value?.name || "";
-    console.log('props', props.data)
+  relicsName.value = relics.value?.name || "";
+  console.log("props", props.data);
 });
 const updatePolyName = (name: string) => {
-    currentPoly.value.name = name;
-    emit('edit', currentPoly.value);
-}
+  currentPoly.value.name = name;
+  emit("edit", currentPoly.value);
+};
 const handleShowEditModel = (item: PolyDataType) => {
-    isShowPolyEditName.value = true;
-    currentPoly.value = item;
-}
+  isShowPolyEditName.value = true;
+  currentPoly.value = item;
+};
 
 const del = async (id: string) => {
-    const ok = await ElMessageBox.confirm("确定要删除吗", {
-        type: "warning",
-    });
-    if (ok) {
-        emit('del', id)
+  const ok = await ElMessageBox.confirm("确定要删除吗", {
+    type: "warning",
+  });
+  if (ok) {
+    emit("del", id);
+  }
+};
+const handleDownload = async (item: any) => {
+  const polygonPoints: any[] = getWholeLinePolygonPoints(props.data as any, item.id);
+
+  const points = polygonPoints.map((p) => {
+    const pos = [p.x, p.y, 0];
+    if (p.rtk) {
+      const sPoint = scenePoints.value.find(({ id }) => id.toString() === p.title);
+      if (sPoint) {
+        pos[2] = sPoint.pos[2];
+      }
     }
-}
-const handleDownload = async () => {
-    const points = []
-    props.data.polygons.forEach(poly => {
-        poly.lineIds.forEach(line => {
-            const targetLine = props.data.lines.find(l => l.id === line)
-            targetLine && targetLine.pointIds.forEach(point => {
-                const targetPoint = props.data.points.find(p => p.id === point)
-                targetPoint && points.push(targetPoint)
-            })
-        })
-    });
-
-    points.map(item => (item.rtk = true))
-    const transPoints = scenePosTransform(scenes.value);
-    console.log('handleDownload', points, transPoints);
-    await downloadPointsXLSL2(points, [{ title: "", desc: "" }], "本体边界坐标");
-    // await downloadPointsXLSL2(points, [{ title: "xx", desc: "xxxx" }], 'xx');
-} 
+    return pos;
+  });
+  const dists = polygonPoints.map((p) => ({
+    title: p.id,
+    desc: p.title || p.id,
+  }));
+  await downloadPointsXLSL2(
+    points,
+    dists,
+    `${item.name ? item.name : "本体边界" + item.id}`
+  );
+};
 </script>
 
 <style lang="scss" scoped>
 .tree-item {
-    display: flex;
-    width: calc(100% - 50px);
-    align-items: center;
-    justify-content: space-between;
-
-    .title {
-        flex: 1;
-        overflow: hidden;
-        text-overflow: ellipsis; //文本溢出显示省略号
-        white-space: nowrap; //文本不会换行
-    }
-
-    .oper {
-        flex: none;
-    }
+  display: flex;
+  width: calc(100% - 50px);
+  align-items: center;
+  justify-content: space-between;
+
+  .title {
+    flex: 1;
+    overflow: hidden;
+    text-overflow: ellipsis; //文本溢出显示省略号
+    white-space: nowrap; //文本不会换行
+  }
+
+  .oper {
+    flex: none;
+  }
 }
 
 .disable {
-    pointer-events: all;
+  pointer-events: all;
 }
 
 .tree-layout {
-    p {
-        color: #303133;
-        font-size: 14px;
-    }
+  p {
+    color: #303133;
+    font-size: 14px;
+  }
 }
 
 .right-layout {
-    display: flex;
-    height: 100%;
-    flex-direction: column;
-
-    .right-content {
-        flex: 1;
-        overflow-y: auto;
-    }
+  display: flex;
+  height: 100%;
+  flex-direction: column;
+
+  .right-content {
+    flex: 1;
+    overflow-y: auto;
+  }
 }
 
 .tree-layout .tree-scene-name {
-    font-size: 10px;
-    margin: 0;
-    color: #999;
+  font-size: 10px;
+  margin: 0;
+  color: #999;
 }
 
 .poly-list {
+  width: 100%;
+  display: flex;
+  flex-direction: column;
+  font-size: 14px;
+  user-select: none;
+
+  .poly-list-item {
     width: 100%;
     display: flex;
-    flex-direction: column;
-    font-size: 14px;
-    user-select: none;
-
-    .poly-list-item {
-        width: 100%;
-        display: flex;
-        flex-direction: row;
-        justify-content: space-between;
-        align-items: center;
-        margin-bottom: 10px;
-
-        .icon {
-            margin-left: 8px;
-            color: #409EFF;
-            cursor: pointer;
-        }
-    }
-
-    .empty {
-        display: flex;
-        align-items: center;
-        justify-content: center;
-        font-size: 13px;
-        color: gray;
-        padding-top: 40px;
+    flex-direction: row;
+    justify-content: space-between;
+    align-items: center;
+    margin-bottom: 10px;
 
+    .icon {
+      margin-left: 8px;
+      color: #409eff;
+      cursor: pointer;
     }
+  }
+
+  .empty {
+    display: flex;
+    align-items: center;
+    justify-content: center;
+    font-size: 13px;
+    color: gray;
+    padding-top: 40px;
+  }
 }
 </style>