From eb6f5dd06c71f85b48d7c845a68d9f80a8c261c1 Mon Sep 17 00:00:00 2001 From: Cmen <1176967590@qq.com> Date: Sun, 6 Mar 2022 10:01:13 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=8D=E8=83=BD=E5=A4=9A?= =?UTF-8?q?=E6=AC=A1=E9=80=89=E4=B8=AD=E5=88=A0=E9=99=A4=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/map/MapEditor.ts | 1 + src/map/editors/BaseOverlayEditor.ts | 2 +- src/map/editors/CircleEditor.ts | 2 +- src/map/editors/PolygonEditor.ts | 2 +- src/map/editors/PolylineEditor.ts | 2 +- src/map/editors/RectangleEditor.ts | 2 +- src/map/type.ts | 1 + src/store/actions/index.ts | 7 ++++--- src/store/reducers/map/index.ts | 7 ++----- 9 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/map/MapEditor.ts b/src/map/MapEditor.ts index 1228cfe..c3d79c8 100644 --- a/src/map/MapEditor.ts +++ b/src/map/MapEditor.ts @@ -171,6 +171,7 @@ export class MapEditor extends Emitter implements IMapEditor { this.map.remove(target); delete this.overlayMap[id]; }); + this.selectedIds = []; } finishEditOverlay() { diff --git a/src/map/editors/BaseOverlayEditor.ts b/src/map/editors/BaseOverlayEditor.ts index e44a1f6..c0ddeb2 100644 --- a/src/map/editors/BaseOverlayEditor.ts +++ b/src/map/editors/BaseOverlayEditor.ts @@ -1,5 +1,5 @@ import { OverlayTypes } from "@types"; -import { IOverlay } from "../../store/type"; +import { IOverlay } from "../type"; export abstract class BaseOverlayEditor { map: AMap.Map; diff --git a/src/map/editors/CircleEditor.ts b/src/map/editors/CircleEditor.ts index 193aa7a..16345c9 100644 --- a/src/map/editors/CircleEditor.ts +++ b/src/map/editors/CircleEditor.ts @@ -1,5 +1,5 @@ import { OverlayTypes } from "@types"; -import { IOverlay } from "@store"; +import { IOverlay } from "../type"; import { BaseOverlayEditor } from "./BaseOverlayEditor"; export class CircleEditor extends BaseOverlayEditor { diff --git a/src/map/editors/PolygonEditor.ts b/src/map/editors/PolygonEditor.ts index 89e461d..cee4aa4 100644 --- a/src/map/editors/PolygonEditor.ts +++ b/src/map/editors/PolygonEditor.ts @@ -1,5 +1,5 @@ import { OverlayTypes } from "@types"; -import { IOverlay } from "../../store/type"; +import { IOverlay } from "../type"; import { BaseOverlayEditor } from "./BaseOverlayEditor"; export class PolygonEditor extends BaseOverlayEditor { diff --git a/src/map/editors/PolylineEditor.ts b/src/map/editors/PolylineEditor.ts index 538ca1f..cd9374e 100644 --- a/src/map/editors/PolylineEditor.ts +++ b/src/map/editors/PolylineEditor.ts @@ -1,5 +1,5 @@ import { OverlayTypes } from "@types"; -import { IOverlay } from "@store"; +import { IOverlay } from "../type"; import { BaseOverlayEditor } from "./BaseOverlayEditor"; export class PolylineEditor extends BaseOverlayEditor { diff --git a/src/map/editors/RectangleEditor.ts b/src/map/editors/RectangleEditor.ts index 4e655ee..be57c81 100644 --- a/src/map/editors/RectangleEditor.ts +++ b/src/map/editors/RectangleEditor.ts @@ -1,5 +1,5 @@ import { OverlayTypes } from "@types"; -import { IOverlay } from "../../store/type"; +import { IOverlay } from "../type"; import { BaseOverlayEditor } from "./BaseOverlayEditor"; export class RectangleEditor extends BaseOverlayEditor { diff --git a/src/map/type.ts b/src/map/type.ts index 0b5c122..c498a6d 100644 --- a/src/map/type.ts +++ b/src/map/type.ts @@ -7,6 +7,7 @@ export interface IMapEditor { importProject(options: IMapOptions): void; importGeoJSON(geojson: GeoJSON.FeatureCollection): void; selectOverlays(ids?: string[]): void; + deleteOverlays(): void; } export interface IOverlay { diff --git a/src/store/actions/index.ts b/src/store/actions/index.ts index 4a747d9..605e2f3 100644 --- a/src/store/actions/index.ts +++ b/src/store/actions/index.ts @@ -73,12 +73,13 @@ export class EditorAction { } deleteOverlays() { - const { selectedIds } = this.mapOptions; - if (selectedIds?.length == 0) return; + const { selectedIds } = this.store.getState(); + if (selectedIds?.length === 0) return; Modal.confirm({ title: "确定删除覆盖物吗?", onOk: () => { - // this.store.dispatch(EditorAction.deleteOverlays()); + this.mapEditor?.deleteOverlays(); + this.store.dispatch(StoreAction.deleteOverlays()); }, }); } diff --git a/src/store/reducers/map/index.ts b/src/store/reducers/map/index.ts index 4a7000b..f1d8011 100644 --- a/src/store/reducers/map/index.ts +++ b/src/store/reducers/map/index.ts @@ -12,18 +12,15 @@ export function createOverlay(state = initState, payload: OverlayTypes) { } export function deleteOverlays(state = initState, payload: any) { - const { selectedIds } = state.map; + const { selectedIds } = state; const [id] = selectedIds!; const filterFunc = (overlay: IOverlay) => overlay.id !== id; return produce(state, (draft) => { - // draft.map.status = Status.CreateOverlay; - // draft.map.command = Command.DeleteOverlays; draft.map.rectangles = draft.map.rectangles.filter(filterFunc); draft.map.polygons = draft.map.polygons.filter(filterFunc); draft.map.polylines = draft.map.polylines.filter(filterFunc); draft.map.circles = draft.map.circles.filter(filterFunc); - draft.map.selectedIds = []; - // draft.map.overlayType = payload as OverlayTypes; + draft.selectedIds = []; }); }