|
@@ -59,7 +59,7 @@
|
|
|
@del="handlePolysDel"
|
|
|
@edit="handlePolysEdit"
|
|
|
:data="boardData"
|
|
|
- v-if="isCurrentTab(1)"
|
|
|
+ v-if="boardData && isCurrentTab(1)"
|
|
|
>
|
|
|
</MapRightPoly>
|
|
|
</div>
|
|
@@ -93,10 +93,10 @@
|
|
|
import MapRight from "./map-right.vue";
|
|
|
import { router, setDocTitle } from "@/router";
|
|
|
import { Manage } from "./openlayer";
|
|
|
-import { ScenePoint, Scene, scenePoints, scenes } from "@/store/scene";
|
|
|
+import { ScenePoint, Scene, scenePoints, scenes, SceneStatus } from "@/store/scene";
|
|
|
import { initRelics, initSelfRelics, relics } from "@/store/relics";
|
|
|
import { onMounted, ref, watchEffect, watch, onUnmounted, computed } from "vue";
|
|
|
-import { createBoard, scenePosTransform } from "./board";
|
|
|
+import { createBoard, PolygonsPointAttrib } from "drawing-board";
|
|
|
import MapRightPoly from "./map-right-poly.vue";
|
|
|
import { Back } from "@element-plus/icons-vue";
|
|
|
import {
|
|
@@ -106,16 +106,32 @@ import {
|
|
|
DrawingDataType,
|
|
|
PolyDataType,
|
|
|
} from "@/request/drawing.ts";
|
|
|
-// import { relicsPolyginsFetch } from "@/request";
|
|
|
import { Grid, LocationInformation } from "@element-plus/icons-vue";
|
|
|
|
|
|
-import {
|
|
|
- mapManageInit,
|
|
|
- boardInit,
|
|
|
- flyUserCenter,
|
|
|
- tileOptions,
|
|
|
- tileType,
|
|
|
-} from "./map-flow";
|
|
|
+import { mapManageInit, flyUserCenter, tileOptions, tileType } from "./map-flow";
|
|
|
+
|
|
|
+const scenePosTransform = (scenes: Scene[]) => {
|
|
|
+ const points: PolygonsPointAttrib[] = [];
|
|
|
+
|
|
|
+ scenes.forEach((scene) => {
|
|
|
+ if (scene.calcStatus !== SceneStatus.SUCCESS) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ scene.scenePos.forEach((pos) => {
|
|
|
+ if (!pos.pos || pos.pos.length === 0) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ points.push({
|
|
|
+ x: pos.pos[0],
|
|
|
+ y: pos.pos[1],
|
|
|
+ title: pos.name,
|
|
|
+ id: pos.id.toString(),
|
|
|
+ rtk: true,
|
|
|
+ });
|
|
|
+ });
|
|
|
+ });
|
|
|
+ return points;
|
|
|
+};
|
|
|
|
|
|
const relicsId = computed(() => router.currentRoute.value.params.relicsId || "");
|
|
|
|
|
@@ -163,7 +179,7 @@ const flyScene = (scene: Scene) => {
|
|
|
|
|
|
const flyScenePoint = (point: ScenePoint) => {
|
|
|
flyPos(point.pos);
|
|
|
- board.polygon().activePointId.value = point.id.toString();
|
|
|
+ board.polygon.activePointId.value = point.id.toString();
|
|
|
};
|
|
|
|
|
|
watch(
|
|
@@ -191,7 +207,7 @@ watch(
|
|
|
// );
|
|
|
initCroodTabdata();
|
|
|
|
|
|
- board.polygon().bus.on("clickPoint", (bpoint) => {
|
|
|
+ board.polygon.bus.on("clickPoint", (bpoint) => {
|
|
|
const point =
|
|
|
bpoint.id &&
|
|
|
scenePoints.value.find((point) => point.id.toString() === bpoint.id);
|
|
@@ -201,7 +217,7 @@ watch(
|
|
|
// relicsPolyginsFetch().then((data) => {
|
|
|
// relics.value;
|
|
|
// board.setData(data, router.currentRoute.value.params.relicsId as string);
|
|
|
- // board.polygon().bus.on("clickPoint", (bpoint) => {
|
|
|
+ // board.polygon.bus.on("clickPoint", (bpoint) => {
|
|
|
// const point =
|
|
|
// bpoint.id &&
|
|
|
// scenePoints.value.find((point) => point.id.toString() === bpoint.id);
|
|
@@ -241,17 +257,19 @@ watchEffect(() => {
|
|
|
const mapContainer = ref<HTMLDivElement>();
|
|
|
const boardContainer = ref<HTMLDivElement>();
|
|
|
let mapManage: Manage;
|
|
|
-let board: ReturnType<typeof createBoard>;
|
|
|
+
|
|
|
+const board = createBoard();
|
|
|
const boardData = ref<DrawingDataType | null>(null);
|
|
|
let endEdithandler;
|
|
|
|
|
|
onMounted(async () => {
|
|
|
mapManage = mapManageInit(mapContainer.value!);
|
|
|
- board = (window as any).board = boardInit(boardContainer.value!, mapManage);
|
|
|
+ board.setProps({
|
|
|
+ dom: boardContainer.value!,
|
|
|
+ map: mapManage.map,
|
|
|
+ });
|
|
|
isMounted.value = true;
|
|
|
-
|
|
|
const borardPolyData = computed(() => board.getData());
|
|
|
-
|
|
|
watch(
|
|
|
borardPolyData,
|
|
|
(updater) => {
|
|
@@ -273,11 +291,11 @@ const handleTabs = (index: number) => {
|
|
|
};
|
|
|
|
|
|
const handleBoardDraw = () => {
|
|
|
- console.log("开始start draw", String(relicsId.value), board.polygon());
|
|
|
+ console.log("开始start draw", String(relicsId.value), board.polygon);
|
|
|
try {
|
|
|
- endEdithandler = board.polygon().editPolygon();
|
|
|
+ endEdithandler = board.polygon.editPolygon();
|
|
|
isEditDrawingMode.value = true;
|
|
|
- board.polygon().bus.on("penEndHandler", handleSyncDataToServer);
|
|
|
+ board.polygon.bus.on("penEndHandler", handleSyncDataToServer);
|
|
|
} catch (error) {
|
|
|
console.error("error", error);
|
|
|
}
|
|
@@ -286,6 +304,7 @@ const handleSyncDataToServer = () => {
|
|
|
setTimeout(async () => {
|
|
|
console.log("handleSyncDataToServer");
|
|
|
const data = (board.getData() as any) as DrawingDataType;
|
|
|
+ console.log(data);
|
|
|
boardData.value = data;
|
|
|
const param: DrawingParamsType = {
|
|
|
data: data,
|
|
@@ -296,7 +315,7 @@ const handleSyncDataToServer = () => {
|
|
|
await addOrUpdateDrawingFetch(param);
|
|
|
isEditDrawingMode.value = false;
|
|
|
|
|
|
- board.polygon().bus.off("penEndHandler");
|
|
|
+ board.polygon.bus.off("penEndHandler");
|
|
|
if (endEdithandler) {
|
|
|
console.log("end edit");
|
|
|
}
|
|
@@ -328,14 +347,12 @@ watch(
|
|
|
const initCroodTabdata = async () => {
|
|
|
const points = scenePosTransform(scenes.value);
|
|
|
console.log("initCroodTabdata", points, scenes.value);
|
|
|
- board.setData(
|
|
|
- {
|
|
|
- points: points,
|
|
|
- lines: [],
|
|
|
- polygons: [],
|
|
|
- },
|
|
|
- String(relicsId.value)
|
|
|
- );
|
|
|
+ board.setData({
|
|
|
+ id: String(relicsId.value),
|
|
|
+ points: points,
|
|
|
+ lines: [],
|
|
|
+ polygons: [],
|
|
|
+ });
|
|
|
};
|
|
|
|
|
|
const initPolyTabData = async () => {
|
|
@@ -347,7 +364,8 @@ const initPolyTabData = async () => {
|
|
|
if (res.data) {
|
|
|
boardData.value = res.data;
|
|
|
boardData.value.points = points.concat(res.data.points);
|
|
|
- board.setData(boardData.value, String(relicsId.value));
|
|
|
+ console.log(boardData.value);
|
|
|
+ board.setData({ ...boardData.value, id: String(relicsId.value) });
|
|
|
}
|
|
|
}, 500);
|
|
|
} catch (error) {}
|
|
@@ -355,7 +373,7 @@ const initPolyTabData = async () => {
|
|
|
|
|
|
const handlePolysDel = (id: string) => {
|
|
|
try {
|
|
|
- board.polygon().removePolygon(id);
|
|
|
+ board.polygon.removePolygon(id);
|
|
|
handleSyncDataToServer();
|
|
|
} catch (error) {
|
|
|
console.error("handlePolysDel", error);
|