diff --git a/front/src/components/FloorplanItem.vue b/front/src/components/FloorplanItem.vue index 2b1ebf4..0a058c5 100644 --- a/front/src/components/FloorplanItem.vue +++ b/front/src/components/FloorplanItem.vue @@ -47,11 +47,11 @@ const newDraw = async () => { const quantum_lines = plan.prepared_array + const chunkSize = plan.chunk_size || 8 quantum_lines.forEach((line, indexY) => { + const targetY = indexY * chunkSize line.forEach((point, indexX) => { - const chunkSize = plan.chunk_size || 8 const targetX = indexX * chunkSize - const targetY = indexY * chunkSize paths.value.push({ path: `M${targetX} ${targetY} ${targetX + chunkSize} ${targetY} ${targetX + chunkSize} ${targetY + chunkSize} ${targetX} ${targetY + chunkSize}Z`, unwalkable: !!point, @@ -76,8 +76,11 @@ const findPath = async () => { startToEndPath.value = localPath } -const setPointSvg = (item: PathItem) => { +const setPointSvg = (item: { x: number, y: number }) => { // startToEndPath.value = [] + const startP = floorplan.points.find(el => el.type === 'start') + if (!startP) return + startPoint.value = { x: startP.points.x, y: startP.points.y } endPoint.value = { x: item.x, y: item.y } findPath() } @@ -91,16 +94,25 @@ const ch = 800 \ No newline at end of file diff --git a/front/src/stores/floorplan.ts b/front/src/stores/floorplan.ts index 727a6b0..20c348b 100644 --- a/front/src/stores/floorplan.ts +++ b/front/src/stores/floorplan.ts @@ -11,6 +11,7 @@ export const useFloorplanStore = defineStore('floorplan', { prepared_array: [] as number[][], chunk_size: undefined as number | undefined, threshold: undefined as number | undefined, + points: [] as { type: string, title: string, points: { x: number, y: number } }[] } }, actions: { @@ -56,9 +57,20 @@ export const useFloorplanStore = defineStore('floorplan', { return el.filter(e => e > 0).length > (this.threshold as number) ? 1 : 0 }) }); + await this.getPoints(id) } catch (error) { console.log(error) } + }, + async getPoints(id: number) { + const res = await fetch(`${SERVER_URL}/api/floorplan/${id}/points`, { + headers: { + 'Content-Type': 'application/json', + 'Accept': 'application/json' + }, + }) + const data = await res.json() + this.points = data.points } } }) \ No newline at end of file