|
@@ -1,6 +1,5 @@
|
|
|
<template>
|
|
|
<Teleport to="#right-pano">
|
|
|
- {{ activeEntity?.attrib }}
|
|
|
<ElButton @click="board.clear()"> 清除 </ElButton>
|
|
|
<ElButton :disabled="!board.history.state.hasUndo" @click="board.history.undo()">
|
|
|
撤销
|
|
@@ -19,7 +18,10 @@
|
|
|
<ElButton @click="activeEntity.del()"> 删除 </ElButton>
|
|
|
</template>
|
|
|
|
|
|
- <ElButton v-if="!addPoiState" @click="addPoiHandler('bzjg')">添加poi</ElButton>
|
|
|
+ <ElSelect v-model="poiType">
|
|
|
+ <ElOption v-for="key in Object.keys(svgs)" :value="key" :label="key" />
|
|
|
+ </ElSelect>
|
|
|
+ <ElButton v-if="!addPoiState" @click="addPoiHandler(poiType)">添加poi</ElButton>
|
|
|
<template v-if="addPoiState">
|
|
|
<ElButton @click="addPoiState.cancel()"> 停止添加poi </ElButton>
|
|
|
</template>
|
|
@@ -38,29 +40,18 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
-import { shallowRef, watch } from "vue";
|
|
|
-import { EditWholeLine, createBoard, EditPoi, changeEnv } from "../";
|
|
|
-import storeData from "./storeData.json";
|
|
|
+import { shallowRef, watch, ref } from "vue";
|
|
|
+import { EditWholeLine, createBoard, EditPoi, changeEnv, floorDataTransform } from "../";
|
|
|
+// import storeData from "./storeData.json";
|
|
|
import floor from "./floorplan_cad.json";
|
|
|
-import { ElButton } from "element-plus";
|
|
|
+import { ElButton, ElSelect, ElOption } from "element-plus";
|
|
|
+import "element-plus/dist/index.css";
|
|
|
+import { svgs } from "../icon";
|
|
|
|
|
|
-const rooms = floor.floors.map((item) => {
|
|
|
- return {
|
|
|
- id: item.id.toString(),
|
|
|
- points: item["vertex-xy"].map((p) => ({ ...p, id: p.id.toString() })),
|
|
|
- lines: item["segment"].map((l) => ({
|
|
|
- id: l.id.toString(),
|
|
|
- pointIds: [l.a.toString(), l.b.toString()],
|
|
|
- })),
|
|
|
- polygons: item["segment"].map((l) => ({
|
|
|
- id: l.id.toString(),
|
|
|
- lineIds: [l.id.toString()],
|
|
|
- })),
|
|
|
- };
|
|
|
-});
|
|
|
+const poiType = ref(Object.keys(svgs)[0]);
|
|
|
+const rooms = floorDataTransform(floor);
|
|
|
console.log(rooms);
|
|
|
-
|
|
|
-changeEnv(true);
|
|
|
+changeEnv(false);
|
|
|
withDefaults(defineProps<{ width?: number; height?: number; pixelRation?: number }>(), {
|
|
|
width: 320,
|
|
|
height: 150,
|
|
@@ -72,8 +63,8 @@ const board = createBoard();
|
|
|
board.bound.setRetainScale(true);
|
|
|
|
|
|
setTimeout(() => {
|
|
|
- // board.setData({ rooms: rooms });
|
|
|
- board.setData(storeData);
|
|
|
+ board.setData({ rooms: rooms });
|
|
|
+ // board.setData(storeData);
|
|
|
board.bound.autoBound(20);
|
|
|
}, 500);
|
|
|
|
|
@@ -94,6 +85,7 @@ const drawHandler = () => {
|
|
|
});
|
|
|
};
|
|
|
|
|
|
+window.board = board;
|
|
|
const addPoiState = shallowRef<ReturnType<Board["addPoi"]>>();
|
|
|
const addPoiHandler = (type: string) => {
|
|
|
addPoiState.value = board.addPoi(type);
|
|
@@ -115,6 +107,7 @@ const getData = () => {
|
|
|
<style lang="scss" scoped>
|
|
|
.board-layout {
|
|
|
position: absolute;
|
|
|
+ background: rgba(0, 0, 0, 0.3);
|
|
|
|
|
|
canvas {
|
|
|
display: block;
|