Forráskód Böngészése

feat: fixing typo

gemercheung 1 éve
szülő
commit
820fc30954
3 módosított fájl, 38 hozzáadás és 6 törlés
  1. 33 0
      src/util/pc4xlsl.ts
  2. 1 1
      src/view/map/map-board.vue
  3. 4 5
      src/view/map/map-right-poly.vue

+ 33 - 0
src/util/pc4xlsl.ts

@@ -85,3 +85,36 @@ export const downloadPointsXLSL = async (
   downloadPointsXLSL1(points, desc, name);
   downloadPointsXLSL2(points, desc, name + "本体边界坐标");
 };
+
+
+export const downloadPointsPolys = async (
+  points: {
+    x: number
+    y: number
+    rtk: false
+    title: string
+    id: string
+  }[],
+  desc: { title: string; desc: string }[] = [],
+  name: string
+) => {
+  const tabs = points.map((point, i) => {
+    const des = desc[i] || { title: "无", desc: "无" };
+    return {
+      // fid: i.toString(),
+      title: des.title,
+      rtk: point.rtk,
+      id: point.id,
+      x: point.x,
+      y: point.y,
+    };
+  });
+
+  const data = await fetch(basePath + URL.exportCoordinateData, {
+    headers: gHeaders,
+    method: "post",
+    body: JSON.stringify(tabs),
+  }).then((res) => res.blob());
+
+  return saveAs(data, `${name}.xls`);
+};

+ 1 - 1
src/view/map/map-board.vue

@@ -311,7 +311,7 @@ const handlePolysDel = (id: string) => {
       });
       new Set(points).forEach((_, i) => {
         const pIndex = obj.points.findIndex(p => p.id === i);
-        console.log('pIndex', pIndex, obj.points)
+        // console.log('pIndex', pIndex, obj.points)
         obj.points.splice(pIndex, 1)
       })
       console.log('points', new Set(points))

+ 4 - 5
src/view/map/map-right-poly.vue

@@ -36,7 +36,7 @@
 </template>
 
 <script setup lang="ts">
-import { ref, unref, watchEffect } from "vue";
+import { ref, watchEffect } from "vue";
 import type { PolyDataType, DrawingDataType } from '@/request/drawing.ts'
 import {
     Delete,
@@ -44,7 +44,7 @@ import {
     Edit,
 } from "@element-plus/icons-vue";
 import SingleInput from "@/components/single-input.vue";
-
+import { downloadPointsPolys } from "@/util/pc4xlsl";
 import { relics } from "@/store/relics";
 import { ElMessageBox } from "element-plus";
 
@@ -87,7 +87,7 @@ const del = async (id: string) => {
         emit('del', id)
     }
 }
-const handleDownload = () => {
+const handleDownload = async () => {
     const points = []
     props.data.polygons.forEach(poly => {
         poly.lineIds.forEach(line => {
@@ -100,9 +100,8 @@ const handleDownload = () => {
         })
     });
     console.log('points', points)
-
-
     console.log('handleDownload');
+    await downloadPointsPolys(points, [{ title: "xx", desc: "xxxx" }], 'xx');
 } 
 </script>