Browse Source

fix():新增地图经纬度选择与回填组件,修改部分样式

tags/PMS_V1.0.0_Alpha7
zhugy 1 year ago
parent
commit
1684bef135
  1. 13
      src/components/SelectGaodeLngLat/index.jsx
  2. 3
      src/components/SelectGaodeLngLat/index.scss
  3. BIN
      src/components/SelectGaodeLngLat2/blue-point.png
  4. 231
      src/components/SelectGaodeLngLat2/index.jsx
  5. 29
      src/components/SelectGaodeLngLat2/index.scss
  6. 2
      src/components/index.jsx
  7. 47
      src/pages/InRoadMgm/RecordInquiry/ParkRecordTotal/loadable.jsx
  8. 4
      src/pages/NewEnergy/ChargeStationMgm/index.scss
  9. 43
      src/pages/NewEnergy/ChargeStationMgm/loadable.jsx

13
src/components/SelectGaodeLngLat/index.jsx

@ -13,7 +13,6 @@ function SelectGaodeLngLat(props) {
const {
getLntLat = () => { },
close,
hide,
lngLatVisible = false,
open,
onChange = () => { },
@ -136,7 +135,7 @@ function SelectGaodeLngLat(props) {
<Button
type="primary"
onClick={() => {
hide();
close();
getLocationMessage();
}}
>
@ -169,7 +168,7 @@ function ModalMap(props) {
const [map, setMap] = useState(null);
const [Marker, setMarker] = useState(null);
const mapRef = useRef(null);
const [latLng, setLatLng] = useState([])
const [point, setPoint] = useState([])
const initMap = () => {
// console.log(mapConfig);
// const _map = L.map("mapid", {
@ -208,19 +207,19 @@ function ModalMap(props) {
setLnglat([e.lnglat.lng.toFixed(4), e.lnglat.lat.toFixed(4)]);
getLntLat([e.lnglat.lng.toFixed(4), e.lnglat.lat.toFixed(4)]);
if (isClickMarker) {
setLatLng([e.lnglat.lng.toFixed(4), e.lnglat.lat.toFixed(4)])
setPoint([e.lnglat.lng.toFixed(4), e.lnglat.lat.toFixed(4)])
}
})
mapRef.current = map
};
useEffect(() => {
setLatLng(markerPoint)
setPoint(markerPoint)
}, [markerPoint]);
useEffect(() => {
if (map) {
addMarker(latLng); //
addMarker(point); //
}
}, [latLng]);
}, [point]);
const markerContent = `<div class="custom-content-marker">
<img src='${Rerm}' />
</div>`;

3
src/components/SelectGaodeLngLat/index.scss

@ -2,6 +2,9 @@
}
.map-modal {
.ant-modal-body {
border-radius: 4px;
}
.ant-modal-close-x {
width: 30px;
height: 30px;

BIN
src/components/SelectGaodeLngLat2/blue-point.png

After

Width: 48  |  Height: 54  |  Size: 2.3 KiB

231
src/components/SelectGaodeLngLat2/index.jsx

@ -0,0 +1,231 @@
import React, { useState, useEffect, useRef } from "react";
import { Button, Input, Modal, message, AutoComplete } from "antd";
import L from "leaflet";
import "leaflet/dist/leaflet.css";
import "leaflet.chinatmsproviders";
import ajax from "@/services";
import "./index.scss";
import Rerm from "./blue-point.png";
let timer = null;
function SelectGaodeLngLat(props) {
const {
getLntLat = () => { },
onChange = () => { },
_lngLat = [], //
_address = "", //
} = props;
const mapConfig = {
center: sysConfig.map.center,
zoom: sysConfig.map.zoom,
zooms: sysConfig.map.zooms,
maxZoom: sysConfig.map.zooms[1],
minZoom: sysConfig.map.zooms[0],
mapTileHost: sysConfig.map.mapTileHost,
zoomOffset: sysConfig.map.zoomOffset,
mapTileType: sysConfig.map.mapTileType,
};
const [visible, setVisible] = useState(false);
const [lnglat, setLnglat] = useState([]);
const [address, setAddress] = useState("");
const [searchLnglatValue, setSearchLnglatValue] = useState([]);
const [getLngLabel, setGetLngLabel] = useState([])
const [map, setMap] = useState(null);
const [markers, setMarkers] = useState(null);
const mapRef = useRef(null);
const searchLnglat = (values) => {
clearTimeout(timer);
timer = setTimeout(() => {
ajax.handleLng({
keywords: values,
}).then(
(res) => {
if (parseInt(res?.status) === 20000) {
setGetLngLabel(
res?.data.map((ele) => {
return {
...ele,
label: (
<div className="labds">
<span>{ele.label}</span>
</div>
),
value: ele.label,
values: ele.value
};
})
);
} else {
message.error(res?.message);
}
},
(err) => {
console.log(err);
}
);
}, 1000);
};
//
const onSelect = (data) => {
let add = getLngLabel.filter((ele) => ele.value == data)[0] || [];
setLnglat([add.lng, add.lat]);
};
function getLocationMessage(v) {
// const lat_lng = lnglat.reverse().join(",");
const lat_lng = v ? v.join(",") : lnglat.join(",");
ajax.getLocationNameByLngLat({ lat_lng }).then((res) => {
if (res.status === 20000) {
setAddress(res.data.address);
} else {
message.error(res.message);
}
});
}
//
const open = () => {
setVisible(true)
}
//
const save = () => {
setVisible(false)
onChange(address);
getLntLat(lnglat);
getLocationMessage();
}
//
const initMap = () => {
let _map = new AMap.Map("mapid", {
resizeEnable: true,
layers: [
new AMap.TileLayer.Satellite(),
new AMap.TileLayer.RoadNet()
]
});
_map.setCenter([mapConfig.center[1], mapConfig.center[0]], mapConfig.zoom);
setMap(_map)
if (_lngLat && _lngLat.length) {
let marker = new AMap.Marker({
position: new AMap.LngLat(parseFloat(_lngLat[0]), parseFloat(_lngLat[1])),
content: markerContent,
offset: new AMap.Pixel(-24, -45),
});
_map.add(marker);
setMarkers(marker);
setTimeout(() => {
_map.setCenter(new AMap.LngLat(parseFloat(_lngLat[0]), parseFloat(_lngLat[1])));
}, 800);
}
_map.on('click', function (e) {
setLnglat([e.lnglat.lng.toFixed(4), e.lnglat.lat.toFixed(4)]);
})
mapRef.current = map
};
const markerContent = `<div class="custom-content-marker">
<img src='${Rerm}' />
</div>`;
//
const addMarker = (data) => {
// console.log('marker',data);
if (markers) {
map.remove(markers);
}
if (data.length == 0) return
let marker = new AMap.Marker({
position: new AMap.LngLat(parseFloat(data[0]), parseFloat(data[1])),
content: markerContent,
offset: new AMap.Pixel(-24, -45),
});
map.add(marker);
setMarkers(marker);
setTimeout(() => {
map.setCenter(new AMap.LngLat(parseFloat(data[0]), parseFloat(data[1])));
}, 800);
};
useEffect(() => {
if (visible) {
setAddress(_address);
setLnglat(_lngLat);
setTimeout(() => {
initMap()
}, 500)
}
}, [visible]);
useEffect(() => {
lnglat?.length > 0 && getLocationMessage(lnglat)
if (map) {
addMarker(lnglat); //
}
}, [lnglat]);
useEffect(() => {
setTimeout(() => {
if (searchLnglatValue.length === 0) return;
mapRef.current.setView(searchLnglatValue, 13);
}, 800)
}, [searchLnglatValue]);
return (
<div className="SelectLnglat">
<Button
onClick={open}
type="primary"
>
打开
</Button>
<Modal
className="map-modal"
open={visible}
destroyOnClose
width={1000}
footer={false}
onCancel={() => { setVisible(false) }}
>
<div
style={{
width: "100%",
height: "500px",
}}
>
<div
id="mapid"
className="map"
style={{
height: "100%",
width: "100%",
}}
></div>
</div>
<div className="bottom-input">
<div className="input-search">
<AutoComplete
options={getLngLabel}
placeholder={address ? address : "请选择地址"}
onSearch={searchLnglat}
onSelect={onSelect}
// enterButton={""}
style={{ width: 300 }}
></AutoComplete>
</div>
<div className="result-search">
<label>已选择的经纬度:</label>
<Input value={lnglat} />
</div>
<div style={{ marginLeft: "40px" }}>
<Button
type="primary"
onClick={save}
>
保存
</Button>
</div>
</div>
</Modal>
</div>
);
}
export default SelectGaodeLngLat;

29
src/components/SelectGaodeLngLat2/index.scss

@ -0,0 +1,29 @@
.SelectLnglat {
}
.map-modal {
.ant-modal-body {
border-radius: 4px;
}
.ant-modal-close-x {
width: 30px;
height: 30px;
line-height: 30px;
}
}
.bottom-input {
display: flex;
margin: 10px 0 0 0;
.input-search {
margin: 0 10px 0 0;
width: 300px;
}
.result-search{
label{
width: 160px;
line-height: 32px;
height:32px;
}
display: flex;
}
}

2
src/components/index.jsx

@ -33,6 +33,7 @@ import TableModule from "./TableModule";
import TreeSelectGroup from "./TreeSelectGroup";
import SelectLntLat from "./SelectLngLat";
import SelectGaodeLngLat from "./SelectGaodeLngLat";
import SelectGaodeLngLat2 from "./SelectGaodeLngLat2";
import ImportBtn from './ImportBtn';
import QuickMenu from './QuickMenu';
import DataSelect from './DataSelect';
@ -82,6 +83,7 @@ export {
TreeSelectGroup,
SelectLntLat,
SelectGaodeLngLat,
SelectGaodeLngLat2,
ImportBtn,
QuickMenu,
DataSelect,

47
src/pages/InRoadMgm/RecordInquiry/ParkRecordTotal/loadable.jsx

@ -22,6 +22,7 @@ import ajax from "@/services";
import errorImg from '@/assets/images/error-img-new.png'
import { QuestionCircleOutlined } from '@ant-design/icons';
import { TableModule } from "@/components";
import { useSessionStorageState } from 'ahooks';
import "./index.scss";
import {
payRecordColumns,
@ -35,6 +36,23 @@ const { TextArea } = Input;
let array = [];
function ParkRecordTotal() {
const [sessionTabList, setSessionTabList] = useSessionStorageState("parkRecordTotal", {
value: {}
})
const sType = sessionTabList.type //
//
const [source, setSource] = useState(() => {
if (!sType || sType == 1) {
return sysConfig?.inSource
} else if (sType == 2) {
return sysConfig?.outSource
}
})
const valueChange = (v) => {
// console.log(v.type);
let _source = v.type == 1 ? sysConfig?.inSource : sysConfig?.outSource
setSource(_source)
}
const roadContent = (
<div>
<p>出场时间-入场时间的计算金额</p>
@ -303,7 +321,7 @@ function ParkRecordTotal() {
name: "region",
type: "TreeSelect",
label: "区域",
areaName:1
areaName: 1
},
{
name: "operator",
@ -311,14 +329,14 @@ function ParkRecordTotal() {
label: "商户名称",
defaultValue: "0",
placeholder: "请选择商户名称",
operatorName:1
operatorName: 1
},
{
name: "road",
type: "SearchSelect",
label: "路段名称",
placeholder: "请输入路段名称",
roadName:1
roadName: 1
},
{
name: "road_type",
@ -432,12 +450,12 @@ function ParkRecordTotal() {
// ],
},
{
name: "in_source",
name: "source",
type: "Select",
label: "操作来源",
placeholder: "请选择操作来源",
defaultValue: 0,
options: sysConfig?.inSource || [],
options: source,
},
{
name: "in_person",
@ -699,7 +717,7 @@ function ParkRecordTotal() {
<Descriptions.Item label="应收金额">
{item.receivable_amount}
</Descriptions.Item>
<Descriptions.Item label="优惠券">{item.coupon }</Descriptions.Item>
<Descriptions.Item label="优惠券">{item.coupon}</Descriptions.Item>
<Descriptions.Item label="优惠总额">
{item.preferential_amount}
</Descriptions.Item>
@ -725,17 +743,17 @@ function ParkRecordTotal() {
<Descriptions title="入场照片">
<Descriptions.Item label="车辆照片">
<div className="ltc-item ltc-item-img ">
<Image src={item.in_veh_pic || require("../../../../../src/assets/images/error-img-new.png")} onError={handleImgError}/>
<Image src={item.in_veh_pic || require("../../../../../src/assets/images/error-img-new.png")} onError={handleImgError} />
</div>
</Descriptions.Item>
<Descriptions.Item label="车牌照片">
<div className="ltc-item ltc-item-img ">
<Image src={item.in_plate_pic || require("../../../../../src/assets/images/error-img-new.png")} onError={handleImgError}/>
<Image src={item.in_plate_pic || require("../../../../../src/assets/images/error-img-new.png")} onError={handleImgError} />
</div>
</Descriptions.Item>
<Descriptions.Item label=" 残疾人证件">
<div className="ltc-item ltc-item-img ">
<Image src={item.cj_pic || require("../../../../../src/assets/images/error-img-new.png")} onError={handleImgError}/>
<Image src={item.cj_pic || require("../../../../../src/assets/images/error-img-new.png")} onError={handleImgError} />
</div>
</Descriptions.Item>
</Descriptions>
@ -744,7 +762,7 @@ function ParkRecordTotal() {
);
}
//
const [getHistoryData,setGetHistoryData]=useState({})
const [getHistoryData, setGetHistoryData] = useState({})
function checkHistoryDetail(record) {
setGetHistoryData(record);
setHistoryVisible(true);
@ -809,7 +827,7 @@ function ParkRecordTotal() {
if (res.status === 20000) {
setTableData(res.data.list);
setTotal(res.data.total);
}else{
} else {
message.error(res.message)
}
});
@ -826,7 +844,8 @@ function ParkRecordTotal() {
tableData={tableData}
formSearch={formSearch}
pagename="停车记录查询"
mandatory={['plate','berth_id']}
valueChange={valueChange}
mandatory={['plate', 'berth_id']}
mandatory_name={['车牌号或泊位号']}
pageName={'parkRecordTotal'}
initFormData={initFormData}
@ -1184,11 +1203,11 @@ function ParkRecordTotal() {
</div>
<div className="eae-modal-item">
<div>车辆照片</div>
<Image src={historyDataDetail.in_veh_pic} onError={handleImgError}/>
<Image src={historyDataDetail.in_veh_pic} onError={handleImgError} />
</div>
<div className="eae-modal-item">
<div>车牌照片</div>
<Image src={historyDataDetail.in_plate_pic} onError={handleImgError}/>
<Image src={historyDataDetail.in_plate_pic} onError={handleImgError} />
</div>
</div>
</Modal>

4
src/pages/NewEnergy/ChargeStationMgm/index.scss

@ -1,4 +1,7 @@
.add-station-modal {
.ant-modal-header {
border-radius: 4px 4px 0 0;
}
.add-station-body {
display: flex;
justify-content: space-between;
@ -62,6 +65,7 @@
.ant-modal-footer{
display: flex;
justify-content: center;
border-radius: 0 0 4px 4px;
.ant-btn{
width: 88px;
height: 35px;

43
src/pages/NewEnergy/ChargeStationMgm/loadable.jsx

@ -6,14 +6,14 @@ import {
Upload,
} from "antd";
import ajax from "@/services";
import { useSessionStorageState, useSetState } from "ahooks"
import { useSetState } from "ahooks"
import { LoadingOutlined, PlusOutlined } from '@ant-design/icons';
import { TableModule, FormInput, FormSelect, FormTreeSelectNew, ImgError, SelectGaodeLngLat } from "@/components";
import { TableModule, FormInput, FormSelect, FormTreeSelectNew, ImgError, SelectGaodeLngLat2 } from "@/components";
import "./index.scss";
function Appointment() {
const pattern = /^\d+$/; //
const pattern = /^[1-9][0-9]*$/; //
//
const [detailVisible, setDetailVisible] = useState(false);
//
@ -26,8 +26,7 @@ function Appointment() {
const [areaList, setAreaList] = useState([]);
//
const [operatorList, setOperatorList] = useState([]);
//
const [lngLatVisible, setLngLatVisible] = useState(false);
//
const initAdd = {
name: "",
@ -41,6 +40,10 @@ function Appointment() {
lng_lat: ""
}
const [addFormData, setAddFormData] = useSetState(initAdd);
const [lngLat, setLngLat] = useSetState({
lng_lat: "",
address: ""
});
//
const [formData, setFormData] = useSetState({});
// load
@ -200,6 +203,7 @@ function Appointment() {
//
const getAllOperator = () => {
ajax.getAllOperator().then((res) => {
console.log(res);
const { status, data } = res
if (status === 20000) {
if (data && data.length) {
@ -236,12 +240,8 @@ function Appointment() {
setLoading(false)
setDetailVisible(true)
}
const handelClose = () => {
setLngLatVisible(false)
setAddFormData({ lng_lat: "", address: "" })
}
const handelOk = () => {
// console.log(addFormData);
console.log(addFormData);
if (!addFormData.name) {
message.warn("请输入充电站名称")
return
@ -254,18 +254,10 @@ function Appointment() {
message.warn("请输入车位数量")
return
}
if (addFormData.count < 1) {
message.warn("请输入正确的车位数量")
return
}
if (!pattern.test(addFormData.count)) {
message.warn("请输入正整数的车位数量")
return
}
if (!addFormData.address) {
message.warn("请输入详细地址")
return
}
if (!addFormData.site_type) {
message.warn("请选择站点类型")
return
@ -282,6 +274,10 @@ function Appointment() {
message.warn("请选择经纬度")
return
}
if (!addFormData.address) {
message.warn("请输入详细地址")
return
}
if (!addFormData.img) {
message.warn("请上传充电站图片")
return
@ -468,20 +464,15 @@ function Appointment() {
disabled={true}
/>
<div className="latlng-box">
<SelectGaodeLngLat
isClickMarker
open={() => setLngLatVisible(true)}
lngLatVisible={lngLatVisible}
<SelectGaodeLngLat2
_lngLat={addFormData.lng_lat}
_address={addFormData.address}
getLntLat={(value) => {
setAddFormData({ lng_lat: value })
}}
onChange={(adress) => {
// console.log(adress);
setAddFormData({ address: adress })
}}
// close={handelClose}
close={() => setLngLatVisible(false)}
hide={() => setLngLatVisible(false)}
/>
</div>
</div>

Loading…
Cancel
Save