|
@@ -8,7 +8,7 @@
|
|
|
<Header v-if="inited" :title="title" />
|
|
|
</template>
|
|
|
<template #slide>
|
|
|
- <Slide v-if="inited" />
|
|
|
+ <Slide v-if="inited" @update-map-image="setMapHandler" />
|
|
|
</template>
|
|
|
</Container>
|
|
|
|
|
@@ -44,38 +44,82 @@ import { MathUtils } from "three";
|
|
|
import { components } from "@/core/components";
|
|
|
import { ShapeType } from "@/index";
|
|
|
import { mergeFuns, 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";
|
|
|
+import { Size } from "@/utils/math";
|
|
|
|
|
|
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;
|
|
|
+const setMap = async (config: { url: string; size: Size }) => {
|
|
|
+ const store = tabulationData.value.store;
|
|
|
+ const paperKey = tabulationData.value.paperKey;
|
|
|
+ const compass = 0;
|
|
|
|
|
|
- if (data.mapUrl && data.high && data.width) {
|
|
|
- const size = await getImageSize(data.mapUrl);
|
|
|
+ if (config.url && config.size.height && config.size.width) {
|
|
|
+ const size = await getImageSize(config.url);
|
|
|
const cover = {
|
|
|
- url: data.mapUrl,
|
|
|
+ url: config.url,
|
|
|
...size,
|
|
|
proportion: {
|
|
|
- scale: (data.width / size.width) * 1000,
|
|
|
+ scale: (config.size.width / size.width) * 1000,
|
|
|
unit: "mm",
|
|
|
},
|
|
|
};
|
|
|
- if (!data.store.config) {
|
|
|
+ if (!tabulationData.value.store.config) {
|
|
|
const layer = await genTabulationData(paperKey, compass, cover);
|
|
|
- data.store.layers[defaultLayer] = layer;
|
|
|
+ tabulationData.value.store.layers[defaultLayer] = layer;
|
|
|
} else {
|
|
|
await repTabulationStore(paperKey, compass, cover, store);
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
|
|
|
+const setMapHandler = async (config: { url: string; size: Size }) => {
|
|
|
+ const size = await getImageSize(config.url);
|
|
|
+ const cover = {
|
|
|
+ url: config.url,
|
|
|
+ ...size,
|
|
|
+ proportion: {
|
|
|
+ scale: (config.size.width / size.width) * 1000,
|
|
|
+ unit: "mm",
|
|
|
+ },
|
|
|
+ };
|
|
|
+ const data = await genTabulationData(tabulationData.value.paperKey, undefined, cover);
|
|
|
+ const store = draw.value!.store;
|
|
|
+ const img = data.image?.find((item) => item.key === tableCoverKey);
|
|
|
+ const text = data.text?.find((item) => item.key === tableCoverScaleKey);
|
|
|
+
|
|
|
+ if (img && text) {
|
|
|
+ const sImage = store.getTypeItems("image").find((item) => item.key === tableCoverKey);
|
|
|
+ const sText = store
|
|
|
+ .getTypeItems("text")
|
|
|
+ .find((item) => item.key === tableCoverScaleKey);
|
|
|
+
|
|
|
+ draw.value!.history.onceTrack(() => {
|
|
|
+ if (sImage) {
|
|
|
+ store.setItem("image", {
|
|
|
+ id: sImage.id,
|
|
|
+ value: { ...sImage, ...img, id: sImage.id },
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ store.addItem("image", img);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (sText) {
|
|
|
+ store.setItem("text", {
|
|
|
+ id: text.id,
|
|
|
+ value: { ...sText, ...text, id: sText.id },
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ store.addItem("text", text);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
const inited = ref(false);
|
|
|
const init = async (draw: Draw) => {
|
|
|
const quitMerges: Array<() => void> = [];
|
|
@@ -86,8 +130,9 @@ const init = async (draw: Draw) => {
|
|
|
draw.config.showComponentSize = false;
|
|
|
|
|
|
const config: any = tabulationData.value.store.config || {};
|
|
|
+ const data = tabulationData.value;
|
|
|
const p = tabulationData.value.paperKey;
|
|
|
- await setMap(p, 0, tabulationData.value.store);
|
|
|
+ await setMap({ url: data.mapUrl!, size: { width: data.width!, height: data.high! } });
|
|
|
draw.store.setStore({
|
|
|
...tabulationData.value.store,
|
|
|
config: {
|