Cmen
3 years ago
7 changed files with 103 additions and 7 deletions
@ -1,10 +1,75 @@ |
|||||||
import { useSelector } from "react-redux"; |
import { useDispatch, useSelector } from "react-redux"; |
||||||
import { selectedIdsSelector, mapOptionsSelector } from "@store"; |
import { Form, Input, Select } from "antd"; |
||||||
|
import { selectedIdsSelector, mapOptionsSelector, StoreAction } from "@store"; |
||||||
|
import { OverlayCategory, IOverlay } from "@map"; |
||||||
|
|
||||||
|
import "./index.less"; |
||||||
|
import { OverlayTypes } from "@types"; |
||||||
|
|
||||||
|
type CategoryItem = { |
||||||
|
title: string; |
||||||
|
value: OverlayCategory; |
||||||
|
}; |
||||||
|
|
||||||
|
const { Option } = Select; |
||||||
|
|
||||||
const Property = () => { |
const Property = () => { |
||||||
const selectedIds = useSelector(selectedIdsSelector); |
const selectedIds = useSelector(selectedIdsSelector); |
||||||
// const { } = useSelector(mapOptionsSelector);
|
const { overlays } = useSelector(mapOptionsSelector); |
||||||
return <h1>属性区域</h1>; |
const dispatch = useDispatch(); |
||||||
|
if (!selectedIds?.length) return <></>; |
||||||
|
const [id] = selectedIds; |
||||||
|
const overlay = overlays.find((overlay) => overlay.id === id)!; |
||||||
|
|
||||||
|
const updateOverlayProps = (props: Partial<IOverlay>) => { |
||||||
|
dispatch(StoreAction.updateOverlayProps(props)); |
||||||
|
}; |
||||||
|
|
||||||
|
const categorys: CategoryItem[] = []; |
||||||
|
if (overlay.type === OverlayTypes.Polyline) { |
||||||
|
categorys.push({ title: "道路", value: OverlayCategory.Road }); |
||||||
|
} else { |
||||||
|
categorys.push( |
||||||
|
{ title: "建筑", value: OverlayCategory.Building }, |
||||||
|
{ title: "河流", value: OverlayCategory.Water }, |
||||||
|
{ title: "草地", value: OverlayCategory.Grass } |
||||||
|
); |
||||||
|
} |
||||||
|
|
||||||
|
return ( |
||||||
|
<div className="property-area"> |
||||||
|
<Form size="small"> |
||||||
|
<Form.Item label="名称"> |
||||||
|
<Input |
||||||
|
value={overlay.name} |
||||||
|
onChange={(e) => |
||||||
|
updateOverlayProps({ |
||||||
|
id: overlay.id, |
||||||
|
name: e.target.value, |
||||||
|
}) |
||||||
|
} |
||||||
|
/> |
||||||
|
</Form.Item> |
||||||
|
<Form.Item label="类型"> |
||||||
|
<Select |
||||||
|
value={overlay.category} |
||||||
|
onChange={(category) => |
||||||
|
updateOverlayProps({ |
||||||
|
id: overlay.id, |
||||||
|
category, |
||||||
|
}) |
||||||
|
} |
||||||
|
> |
||||||
|
{categorys.map((item) => ( |
||||||
|
<Option key={item.title} value={item.value}> |
||||||
|
{item.title} |
||||||
|
</Option> |
||||||
|
))} |
||||||
|
</Select> |
||||||
|
</Form.Item> |
||||||
|
</Form> |
||||||
|
</div> |
||||||
|
); |
||||||
}; |
}; |
||||||
|
|
||||||
export default Property; |
export default Property; |
||||||
|
Loading…
Reference in new issue