|
@@ -31,19 +31,51 @@ import {
|
|
|
} from "../../store";
|
|
|
import { ImageData } from "@/core/components/image";
|
|
|
import { TextData } from "@/core/components/text";
|
|
|
-import { getCoverPaperScale, getRealPixel, setCoverPaperScale } from "./gen-tab";
|
|
|
-import { defaultTableStyle } from "@/core/components/serial";
|
|
|
+import {
|
|
|
+ genTabulationData,
|
|
|
+ getCoverPaperScale,
|
|
|
+ getRealPixel,
|
|
|
+ repTabulationStore,
|
|
|
+ setCoverPaperScale,
|
|
|
+} from "./gen-tab";
|
|
|
import { IconData } from "@/core/components/icon";
|
|
|
import { Transform } from "konva/lib/Util";
|
|
|
import { MathUtils } from "three";
|
|
|
import { components } from "@/core/components";
|
|
|
import { ShapeType } from "@/index";
|
|
|
import { round } from "@/utils/shared";
|
|
|
+import { PaperKey } from "@/example/components/slide/actions";
|
|
|
+import { StoreData } from "@/core/store/store";
|
|
|
+import { getImageSize } from "@/utils/shape";
|
|
|
+import { tabCustomStyle } from "./defStyle";
|
|
|
+import { defaultLayer } from "@/constant";
|
|
|
|
|
|
const uploadResourse = window.platform.uploadResourse;
|
|
|
const full = ref(false);
|
|
|
const draw = ref<Draw>();
|
|
|
|
|
|
+const setMap = async (paperKey: PaperKey, compass: number, store: StoreData) => {
|
|
|
+ const data = tabulationData.value;
|
|
|
+
|
|
|
+ if (data.mapUrl && data.high && data.width) {
|
|
|
+ const size = await getImageSize(data.mapUrl);
|
|
|
+ const cover = {
|
|
|
+ url: data.mapUrl,
|
|
|
+ ...size,
|
|
|
+ proportion: {
|
|
|
+ scale: (data.width / size.width) * 1000,
|
|
|
+ unit: "mm",
|
|
|
+ },
|
|
|
+ };
|
|
|
+ if (!data.store.config) {
|
|
|
+ const layer = await genTabulationData(paperKey, compass, cover);
|
|
|
+ data.store.layers[defaultLayer] = layer;
|
|
|
+ } else {
|
|
|
+ await repTabulationStore(paperKey, compass, cover, store);
|
|
|
+ }
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
const inited = ref(false);
|
|
|
const init = async (draw: Draw) => {
|
|
|
await refreshTabulationData();
|
|
@@ -51,7 +83,10 @@ const init = async (draw: Draw) => {
|
|
|
draw.config.showGrid = false;
|
|
|
draw.config.showLabelLine = false;
|
|
|
draw.config.showComponentSize = false;
|
|
|
+
|
|
|
const config: any = tabulationData.value.store.config || {};
|
|
|
+ const p = tabulationData.value.paperKey;
|
|
|
+ await setMap(p, 0, tabulationData.value.store);
|
|
|
draw.store.setStore({
|
|
|
...tabulationData.value.store,
|
|
|
config: {
|
|
@@ -61,25 +96,35 @@ const init = async (draw: Draw) => {
|
|
|
...(config.compass || {}),
|
|
|
url: "./icons/compass.svg",
|
|
|
},
|
|
|
+ proportion: {
|
|
|
+ scale: 1 / getRealPixel(1, p),
|
|
|
+ unit: "mm",
|
|
|
+ },
|
|
|
},
|
|
|
});
|
|
|
inited.value = true;
|
|
|
-
|
|
|
- const p = tabulationData.value.paperKey;
|
|
|
- defaultTableStyle.nameColWidth = defaultTableStyle.valueColWidth = getRealPixel(20, p);
|
|
|
- defaultTableStyle.fontSize = getRealPixel(4, p);
|
|
|
- defaultTableStyle.padding = getRealPixel(2, p);
|
|
|
- defaultTableStyle.colHeight = getRealPixel(8, p);
|
|
|
- defaultTableStyle.repColCount = 2;
|
|
|
+ return tabCustomStyle(p);
|
|
|
};
|
|
|
-watch(draw, (draw) => {
|
|
|
+watch(draw, (draw, _, onCleanup) => {
|
|
|
if (draw) {
|
|
|
- init(draw);
|
|
|
for (const type in components) {
|
|
|
draw.menusFilter.setMenusFilter(type as ShapeType, (items) => {
|
|
|
return items.filter((item) => item.label !== "隐藏");
|
|
|
});
|
|
|
}
|
|
|
+ let des = false;
|
|
|
+ let unInit: () => void;
|
|
|
+ init(draw).then((_unInit) => {
|
|
|
+ if (!des) {
|
|
|
+ unInit = _unInit;
|
|
|
+ } else {
|
|
|
+ _unInit();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ onCleanup(() => {
|
|
|
+ unInit && unInit();
|
|
|
+ des = true;
|
|
|
+ });
|
|
|
}
|
|
|
});
|
|
|
|