|
@@ -7,14 +7,19 @@
|
|
重做
|
|
重做
|
|
</ElButton>
|
|
</ElButton>
|
|
<ElButton @click="getData">获取数据</ElButton>
|
|
<ElButton @click="getData">获取数据</ElButton>
|
|
|
|
+
|
|
<ElButton v-if="!drawing" @click="drawHandler"> 绘画 </ElButton>
|
|
<ElButton v-if="!drawing" @click="drawHandler"> 绘画 </ElButton>
|
|
<ElButton v-if="drawing" @click="drawing.cancel()"> 停止 </ElButton>
|
|
<ElButton v-if="drawing" @click="drawing.cancel()"> 停止 </ElButton>
|
|
<ElButton v-if="drawing" @click="drawing.submit()"> 提交 </ElButton>
|
|
<ElButton v-if="drawing" @click="drawing.submit()"> 提交 </ElButton>
|
|
|
|
+
|
|
<template v-if="activeEntity">
|
|
<template v-if="activeEntity">
|
|
- <ElButton @click="board.copy({ entity: activeEntity, count: 5 })">
|
|
|
|
- 向右复制5个
|
|
|
|
- </ElButton>
|
|
|
|
- <ElButton @click="board.del(activeEntity)"> 删除 </ElButton>
|
|
|
|
|
|
+ <ElButton @click="activeEntity.copy({ count: 5 })"> 向右复制5个 </ElButton>
|
|
|
|
+ <ElButton @click="activeEntity.del()"> 删除 </ElButton>
|
|
|
|
+ </template>
|
|
|
|
+
|
|
|
|
+ <ElButton v-if="!addPoiState" @click="addPoiHandler('bzjg')">添加poi</ElButton>
|
|
|
|
+ <template v-if="addPoiState">
|
|
|
|
+ <ElButton @click="addPoiState.cancel()"> 停止添加poi </ElButton>
|
|
</template>
|
|
</template>
|
|
</div>
|
|
</div>
|
|
<div
|
|
<div
|
|
@@ -25,20 +30,20 @@
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts">
|
|
<script setup lang="ts">
|
|
-import { ref, watch } from "vue";
|
|
|
|
|
|
+import { shallowRef, watch } from "vue";
|
|
import { EditWholeLine } from "../../board/packages";
|
|
import { EditWholeLine } from "../../board/packages";
|
|
import storeData from "./storeData.json";
|
|
import storeData from "./storeData.json";
|
|
import { ElButton } from "element-plus";
|
|
import { ElButton } from "element-plus";
|
|
-import { createBoard } from "../../app/liantong";
|
|
|
|
-import { Entity } from "../../board";
|
|
|
|
|
|
+import { createBoard, EditPoi } from "../../app/liantong";
|
|
|
|
|
|
withDefaults(defineProps<{ width?: number; height?: number; pixelRation?: number }>(), {
|
|
withDefaults(defineProps<{ width?: number; height?: number; pixelRation?: number }>(), {
|
|
width: 320,
|
|
width: 320,
|
|
height: 150,
|
|
height: 150,
|
|
pixelRation: 1,
|
|
pixelRation: 1,
|
|
});
|
|
});
|
|
|
|
+type Board = ReturnType<typeof createBoard>;
|
|
|
|
|
|
-const drawing = ref<ReturnType<EditWholeLine["createPolygon"]>>();
|
|
|
|
|
|
+const drawing = shallowRef<ReturnType<EditWholeLine["createPolygon"]>>();
|
|
const drawHandler = () => {
|
|
const drawHandler = () => {
|
|
drawing.value = board.value.room.createPolygon();
|
|
drawing.value = board.value.room.createPolygon();
|
|
drawing.value.promise.then((result) => {
|
|
drawing.value.promise.then((result) => {
|
|
@@ -47,9 +52,17 @@ const drawHandler = () => {
|
|
});
|
|
});
|
|
};
|
|
};
|
|
|
|
|
|
-const board = ref<ReturnType<typeof createBoard>>();
|
|
|
|
-const containerRef = ref<HTMLDivElement>();
|
|
|
|
-const activeEntity = ref<Entity>();
|
|
|
|
|
|
+const addPoiState = shallowRef<ReturnType<Board["addPoi"]>>();
|
|
|
|
+const addPoiHandler = (type: string) => {
|
|
|
|
+ addPoiState.value = board.value.addPoi(type);
|
|
|
|
+ addPoiState.value.promise.finally(() => {
|
|
|
|
+ addPoiState.value = null;
|
|
|
|
+ });
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+const board = shallowRef<Board>();
|
|
|
|
+const containerRef = shallowRef<HTMLDivElement>();
|
|
|
|
+const activeEntity = shallowRef<EditPoi>();
|
|
|
|
|
|
watch(containerRef, (container, _, onClanup) => {
|
|
watch(containerRef, (container, _, onClanup) => {
|
|
if (container) {
|
|
if (container) {
|
|
@@ -58,7 +71,7 @@ watch(containerRef, (container, _, onClanup) => {
|
|
board.value.getData();
|
|
board.value.getData();
|
|
onClanup(() => board.value.destory);
|
|
onClanup(() => board.value.destory);
|
|
|
|
|
|
- board.value.bus.on("active", (entity) => {
|
|
|
|
|
|
+ board.value.bus.on("activePoi", (entity) => {
|
|
activeEntity.value = entity;
|
|
activeEntity.value = entity;
|
|
});
|
|
});
|
|
}
|
|
}
|