Browse Source

fix: 修复切换选中覆盖物名称不变的问题

master
Cmen 3 years ago
parent
commit
c6c9af7099
  1. 47
      src/editor/Catalog/index.tsx
  2. 2
      src/editor/Catalog/style.less
  3. 8
      src/editor/Property/FineInput.tsx
  4. 62
      src/editor/Property/index.tsx
  5. 6
      src/editor/index.less
  6. 9
      src/store/actions/index.ts

47
src/editor/Catalog/index.tsx

@ -63,28 +63,31 @@ const Catalog = () => {
}); });
return ( return (
<div className="catalog-wrapper"> <>
<Collapse <div className="pane-title"></div>
defaultActiveKey={["1", "2", "3", "4", "5"]} <div className="catalog-wrapper">
expandIconPosition="right" <Collapse
> defaultActiveKey={["1", "2", "3", "4", "5"]}
<Panel header="矩形" key={1}> expandIconPosition="right"
<OverlayList overlays={rectangles} /> >
</Panel> <Panel header="矩形" key={1}>
<Panel header="多边形" key={2}> <OverlayList overlays={rectangles} />
<OverlayList overlays={polygons} /> </Panel>
</Panel> <Panel header="多边形" key={2}>
<Panel header="多段线" key={3}> <OverlayList overlays={polygons} />
<OverlayList overlays={polylines} /> </Panel>
</Panel> <Panel header="多段线" key={3}>
<Panel header="圆形" key={4}> <OverlayList overlays={polylines} />
<OverlayList overlays={circles} /> </Panel>
</Panel> <Panel header="圆形" key={4}>
<Panel header="标记点" key={5}> <OverlayList overlays={circles} />
<OverlayList overlays={points} /> </Panel>
</Panel> <Panel header="标记点" key={5}>
</Collapse> <OverlayList overlays={points} />
</div> </Panel>
</Collapse>
</div>
</>
); );
}; };

2
src/editor/Catalog/style.less

@ -19,6 +19,6 @@
background-color: #e5e6e7; background-color: #e5e6e7;
} }
.catalog-wrapper{ .catalog-wrapper{
height: 100%; height: calc(100% - 36px);
overflow-y: scroll; overflow-y: scroll;
} }

8
src/editor/Property/FineInput.tsx

@ -1,5 +1,5 @@
import { Input } from "antd"; import { Input } from "antd";
import { useState } from "react"; import { useEffect, useState } from "react";
export type FineInputProps = { export type FineInputProps = {
value: string | number; value: string | number;
@ -7,7 +7,11 @@ export type FineInputProps = {
}; };
export const FineInput = (props: FineInputProps) => { export const FineInput = (props: FineInputProps) => {
const [value, setValue] = useState(props.value); const [value, setValue] = useState<string | number>("");
useEffect(() => {
setValue(props.value);
}, [props]);
return ( return (
<Input <Input

62
src/editor/Property/index.tsx

@ -18,7 +18,12 @@ const { Option } = Select;
const Property = () => { const Property = () => {
const selectedIds = useSelector(selectedIdsSelector); const selectedIds = useSelector(selectedIdsSelector);
const { overlays } = useSelector(mapOptionsSelector); const { overlays } = useSelector(mapOptionsSelector);
if (!selectedIds?.length) return <></>; if (!selectedIds?.length)
return (
<>
<div className="pane-title"></div>
</>
);
const [id] = selectedIds; const [id] = selectedIds;
const overlay = overlays.find((overlay) => overlay.id === id)!; const overlay = overlays.find((overlay) => overlay.id === id)!;
const { lngLat = [0, 0] } = overlay; const { lngLat = [0, 0] } = overlay;
@ -69,40 +74,43 @@ const Property = () => {
); );
return ( return (
<div className="property-area"> <>
<Form size="small"> <div className="pane-title"></div>
<Form.Item label="名称"> <div className="property-area">
<FineInput <Form size="small">
value={overlay.name} <Form.Item label="名称">
onChange={(value) =>
updateOverlayProps({
id: overlay.id,
name: value,
})
}
/>
</Form.Item>
{overlay.type === OverlayTypes.Point ? positionPane : categoryPane}
{overlay.category === OverlayCategory.Building ? (
<Form.Item label="高度">
<FineInput <FineInput
value={overlay.height || 0} value={overlay.name}
onChange={(value) => onChange={(value) =>
updateOverlayProps({ updateOverlayProps({
id: overlay.id, id: overlay.id,
height: +value, name: value,
}) })
} }
/> />
</Form.Item> </Form.Item>
) : null} {overlay.type === OverlayTypes.Point ? positionPane : categoryPane}
{overlay.type === OverlayTypes.Rectangle ? ( {overlay.category === OverlayCategory.Building ? (
<Form.Item label="背景"> <Form.Item label="高度">
<OverlayBackground overlay={overlay} /> <FineInput
</Form.Item> value={overlay.height || 0}
) : null} onChange={(value) =>
</Form> updateOverlayProps({
</div> id: overlay.id,
height: +value,
})
}
/>
</Form.Item>
) : null}
{overlay.type === OverlayTypes.Rectangle ? (
<Form.Item label="背景">
<OverlayBackground overlay={overlay} />
</Form.Item>
) : null}
</Form>
</div>
</>
); );
}; };

6
src/editor/index.less

@ -66,6 +66,12 @@ body ::-webkit-scrollbar-thumb {
body ::-webkit-scrollbar-corner { body ::-webkit-scrollbar-corner {
background-color: #eee; background-color: #eee;
} }
.pane-title{
line-height: 24px;
padding:6px 12px;
background-color: #dbd8d8;
// color: #fff;
}
/* stylelint-disable no-duplicate-selectors */ /* stylelint-disable no-duplicate-selectors */
/* stylelint-disable */ /* stylelint-disable */
/* stylelint-disable declaration-bang-space-before,no-duplicate-selectors,string-no-newline */ /* stylelint-disable declaration-bang-space-before,no-duplicate-selectors,string-no-newline */

9
src/store/actions/index.ts

@ -115,11 +115,16 @@ export class EditorAction {
selectOverlay(id: string, reset = true) { selectOverlay(id: string, reset = true) {
const { selectedIds } = this.store.getState(); const { selectedIds } = this.store.getState();
if (selectedIds.indexOf(id) >= 0 && reset) { if (selectedIds.indexOf(id) >= 0 && reset) {
this.mapEditor?.selectOverlays(); if (reset) {
this.mapEditor?.selectOverlays();
this.dispatch(StoreAction.selectOverlay());
} else {
this.dispatch(StoreAction.selectOverlay(id));
}
} else { } else {
this.mapEditor?.selectOverlays([id]); this.mapEditor?.selectOverlays([id]);
this.dispatch(StoreAction.selectOverlay(id));
} }
this.dispatch(StoreAction.selectOverlay(id));
} }
updateOverlay(props: Partial<IOverlay>) { updateOverlay(props: Partial<IOverlay>) {

Loading…
Cancel
Save