import React, { useState } from 'react'; import { Card, Table, Button, Typography, Space, Modal, Form, Input, Popconfirm, Select, Switch, Divider, Upload, message, Row, Col, Tag } from 'antd'; import { PlusOutlined, EditOutlined, DeleteOutlined, BgColorsOutlined, UserOutlined, SettingOutlined } from '@ant-design/icons'; const { Title } = Typography; const { Option } = Select; // 模拟场站数据 const stationData = [ { id: 1, name: '上海浦东光伏场站', code: 'PD001', address: '上海市浦东新区光伏大道', status: 0, contact: '张三', phone: '13800138000', maintainCompany: '上海新能源运维公司', areaCount: 3, hasMap: true, }, { id: 2, name: '苏州昆山储能电站', code: 'KS001', address: '苏州市昆山市能源路', status: 1, contact: '李四', phone: '13900139000', maintainCompany: '苏州智慧运维有限公司', areaCount: 2, hasMap: false, }, ]; // 场站分区模拟 const areaData = [ { id: 1, stationId: 1, name: 'A区', type: '清扫区', status: 0 }, { id: 2, stationId: 1, name: 'B区', type: '巡检区', status: 0 }, { id: 3, stationId: 1, name: 'C区', type: '禁飞区', status: 1 }, ]; export default function StationManage() { const [stationList, setStationList] = useState(stationData); const [currentStation, setCurrentStation] = useState(null); // 主弹窗 const [modalVisible, setModalVisible] = useState(false); const [form] = Form.useForm(); const [editRecord, setEditRecord] = useState(null); // 分区弹窗 const [areaVisible, setAreaVisible] = useState(false); // 边界绘制弹窗 const [mapVisible, setMapVisible] = useState(false); // 打开新增 const handleAdd = () => { form.resetFields(); setEditRecord(null); setModalVisible(true); }; // 打开编辑 const handleEdit = (record) => { form.setFieldsValue(record); setEditRecord(record); setModalVisible(true); }; // 删除场站 const handleDelete = (id) => { setStationList(stationList.filter(s => s.id !== id)); message.success('删除成功'); }; // 保存场站 const handleSave = () => { form.validateFields().then(values => { const data = { ...values, id: editRecord?.id || Date.now() }; if (editRecord) { setStationList(stationList.map(s => s.id === editRecord.id ? data : s)); message.success('编辑成功'); } else { setStationList([...stationList, data]); message.success('新增场站成功'); } setModalVisible(false); }); }; // 打开分区 const handleOpenArea = (record) => { setCurrentStation(record); setAreaVisible(true); }; // 打开地图边界 const handleOpenMap = (record) => { setCurrentStation(record); setMapVisible(true); }; const columns = [ { title: '场站名称', dataIndex: 'name' }, { title: '场站编号', dataIndex: 'code' }, { title: '地址', dataIndex: 'address' }, { title: '状态', dataIndex: 'status', render: (s) => s === 0 ? 启用 : 停用 }, { title: '负责人', dataIndex: 'contact' }, { title: '运维单位', dataIndex: 'maintainCompany' }, { title: '分区数量', dataIndex: 'areaCount', }, { title: '地图数据', render: (_, r) => r.hasMap ? 已维护 : 未维护 }, { title: '操作', width: 400, render: (_, record) => ( handleDelete(record.id)}> ) } ]; return (
场站管理
{/* ====================== 1. 新增/编辑场站 ====================== */} setModalVisible(false)} onOk={handleSave} width={700} destroyOnClose >
联系人与运维单位 {/* ====================== 2. 场站分区设置 ====================== */} setAreaVisible(false)} footer={null} >
r.status === 0 ? '正常' : '禁用' }, { title: '操作', render: () => ( ) } ]} dataSource={areaData.filter(a => a.stationId === currentStation?.id)} /> {/* ====================== 3. 场站边界绘制 & 地图维护 ====================== */} setMapVisible(false)} footer={null} >
{/**/}
地图组件 / 百度地图 / 高德地图 区域绘制
支持:边界点绘制、电子围栏、导入KML、保存GeoJSON
); }