bill 1 년 전
부모
커밋
104ced3e40
3개의 변경된 파일47개의 추가작업 그리고 24개의 파일을 삭제
  1. 42 22
      src/util/pc4xlsl.ts
  2. 3 1
      src/view/map/map.vue
  3. 2 1
      src/view/scene-select.vue

+ 42 - 22
src/util/pc4xlsl.ts

@@ -3,27 +3,47 @@ import { round, toDegrees } from "./";
 import { saveAs } from "./file-serve";
 
 const genXLSLByTemp = (data: ArrayBuffer, tabs: any[][], name: string) => {
-  const workbook = XLSX.read(data);
+  const workbook = XLSX.read(data, {
+    type: "binary",
+    cellStyles: true,
+
+    cellNF: true,
+    cellDates: true,
+    sheetStubs: true,
+    raw: true,
+    bookDeps: true,
+    bookVBA: true,
+    // bookProps: true,
+    // bookSheets: true,
+    WTF: true,
+    PRN: true,
+    xlfn: true,
+  });
   const sheetName = workbook.SheetNames[0];
   const worksheet = workbook.Sheets[sheetName];
-  XLSX.utils.sheet_add_aoa(worksheet, tabs, { origin: "A2" });
 
-  const wbout = XLSX.write(workbook, {
-    // 要生成的文件类型
-    bookType: "xlsx",
-    type: "binary",
-  });
+  console.log(worksheet);
+  XLSX.utils.sheet_add_aoa(worksheet, tabs, { origin: "A2" });
+  const wbout = XLSX.writeFile(workbook, `${name}.xlsx`);
+  // const wbout = URL.createObjectURL(new Blob([data]));
+  // const wbout = XLSX.write(workbook, {
+  //   // 要生成的文件类型
+  //   bookType: "xlsx",
+  //   type: "binary",
+  // });
   // 将字符串转ArrayBuffer
-  function s2ab(s: string) {
-    const buf = new ArrayBuffer(s.length);
-    const view = new Uint8Array(buf);
-    for (let i = 0; i !== s.length; ++i) view[i] = s.charCodeAt(i) & 0xff;
-    return buf;
-  }
-  const blob = new Blob([s2ab(wbout)], {
-    type: "application/octet-stream",
-  });
-  return saveAs(blob, `${name}.xls`);
+
+  // console.log(wbout);
+  // function s2ab(s: string) {
+  //   const buf = new ArrayBuffer(s.length);
+  //   const view = new Uint8Array(buf);
+  //   for (let i = 0; i !== s.length; ++i) view[i] = s.charCodeAt(i) & 0xff;
+  //   return buf;
+  // }
+  // const blob = new Blob([s2ab(wbout)], {
+  //   type: "application/octet-stream",
+  // });
+  return saveAs(wbout, `${name}.xls`);
 };
 
 export const downloadPointsXLSL1 = async (
@@ -51,14 +71,14 @@ export const downloadPointsXLSL2 = async (
   const tabs = points.map((point, i) => {
     const des = desc[i] || { title: "无", desc: "无" };
     return [
-      toDegrees(point[1], 4),
-      toDegrees(point[0], 4),
-      round(point[2], 4),
+      { v: toDegrees(point[1], 4), t: "s", z: "@" },
+      { v: toDegrees(point[0], 4), t: "s", z: "@" },
+      { v: round(point[2], 4), t: "s", z: "@" },
       des.title,
       des.desc,
-    ].map((i) => i.toString());
+    ];
   });
-
+  console.log("data", tabs);
   await genXLSLByTemp(temp, tabs, name);
 };
 

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

@@ -50,7 +50,7 @@ import { router, setDocTitle } from "@/router";
 import { TileType, createMap } from "./";
 import { ScenePoint, Scene, scenePoints, scenes } from "@/store/scene";
 import { initRelics, initSelfRelics, relics } from "@/store/relics";
-import { computed, onMounted, ref, watchEffect, watch } from "vue";
+import { computed, onMounted, ref, watchEffect, watch, onUnmounted } from "vue";
 import { Manage } from "./manage";
 import ScaleLine from "ol/control/ScaleLine";
 
@@ -240,6 +240,8 @@ watchEffect(() => {
     setDocTitle(relics.value.name);
   }
 });
+
+onUnmounted(() => mapManage.map.dispose());
 </script>
 
 <style lang="scss">

+ 2 - 1
src/view/scene-select.vue

@@ -1,5 +1,5 @@
 <template>
-  <div style="height: 550px">
+  <div style="height: 550px" v-loading="!loaded">
     <SceneTable :tableProps="tableProps" simple>
       <template v-slot:table>
         <el-table-column type="selection" width="55" />
@@ -47,6 +47,7 @@ const tableProps = {
       ...val
         .filter((scene) => {
           if (scene.calcStatus !== SceneStatus.SUCCESS) {
+            console.log("fff", scene);
             tableProps.tableRef.value!.toggleRowSelection(scene, false);
             tip || ElMessage.error({ message: "计算中场景无法添加", repeatNum: 1 });
             tip = true;