import React, {useMemo, useState} from "react"; import {Badge, Button, Col, ConfigProvider, Modal, Row, Select, Table,} from "antd" export default function getGisSbleData(props: { height: string }) { // 添加设备类型筛选状态 const [typeFilter, setTypeFilter] = useState('all'); // 添加导航按钮状态管理 const [activeNavButton, setActiveNavButton] = useState("realtime"); // 设备列表状态 const [GISdeviceModalVisible, setGISDeviceModalVisible] = useState(false) const [GISselectedDevice, setGISSelectedDevice] = useState(null) // 添加图片预览相关状态 const [previewImage, setPreviewImage] = useState(null); const [previewVisible, setPreviewVisible] = useState(false); //gis设备列表 const EquipmentListData = { columns: [ { title: () => (
设备名称
), dataIndex: "name", width: 100, ellipsis: true, render: (text, record) => ( // 添加record参数获取行数据
{ // 设置选中设备并打开弹窗 setGISSelectedDevice(record); setGISDeviceModalVisible(true); }} onMouseOver={(e) => { e.currentTarget.style.backgroundColor = '#3b2e50'; // 鼠标悬停效果 }} onMouseOut={(e) => { e.currentTarget.style.backgroundColor = 'transparent'; // 恢复原背景色 }} > {text}
), }, { title: () => (
设备类型
{/* 添加下拉筛选器 */}
), dataIndex: "type", width: 150, ellipsis: true, render: (text, record) => ( // 添加record参数获取行数据
{ // 设置选中设备并打开弹窗 setGISSelectedDevice(record); setGISDeviceModalVisible(true); }} onMouseOver={(e) => { e.currentTarget.style.backgroundColor = '#3b2e50'; }} onMouseOut={(e) => { e.currentTarget.style.backgroundColor = 'transparent'; }} > {text}
), }, { title: () => ( // 将标题改为函数组件,自定义表头样式
设备电量
), dataIndex: "electricity", width: 100, render: (text) => { // 根据电量值设置背景色和文字色 const bgColor = text < '30' ? '#fff1f0' : // 低电量:浅红背景 text < '50' ? '#fffbe6' : // 中电量:浅黄背景 '#f6ffed'; // 高电量:浅绿背景 const textColor = text < '30' ? '#f5222d' : // 低电量:红色文字 text < '50' ? '#faad14' : // 中电量:橙色文字 '#52c41a'; // 高电量:绿色文字 return (
{text}%
); }, } ], data: [{ id: '1', name: '井盖一', type: '电用井盖', electricity: '80', facilityCode: '5001110103009062', region: '东三路米香街道', regionGrade: '暂无', locationDescription: '东三路A地铁口向西方向300米', competentDepartment: '东三路社区服务中心', ownershipUnit: 'A市住房和城乡建设委员会', maintenanceUnit: 'A市住房和城乡建设委员会', nameOfPersonInCharge: '张三', PhoneOfPersonInCharge: '15399665548', status: '1', manholeType: '1', manholeCover: '暂无', manholeShape: '圆形', constructionTime: '2025-09-15 20:57:42', longitude: '110.22252454', latitude: '27.1148554', manholeImage: 'manholeimg.png', QRCode: '/QRCode.jpg', }, { id: '2', name: '井盖二', type: '供水井盖', electricity: '80', facilityCode: '5001110103009062', region: '东三路米香街道', regionGrade: '暂无', locationDescription: '东三路A地铁口向西方向300米', competentDepartment: '东三路社区服务中心', ownershipUnit: 'A市住房和城乡建设委员会', maintenanceUnit: 'A市住房和城乡建设委员会', nameOfPersonInCharge: '张三', PhoneOfPersonInCharge: '15399665548', status: '0', manholeType: '1', manholeCover: '暂无', manholeShape: '圆形', constructionTime: '2025-09-15 20:57:42', longitude: '110.22252454', latitude: '27.1148554', manholeImage: 'manholeimg.png', QRCode: '/QRCode.jpg', }, { id: '3', name: '井盖三', type: '通信井盖', electricity: '80', facilityCode: '5001110103009062', region: '东三路米香街道', regionGrade: '暂无', locationDescription: '东三路A地铁口向西方向300米', competentDepartment: '东三路社区服务中心', ownershipUnit: 'A市住房和城乡建设委员会', maintenanceUnit: 'A市住房和城乡建设委员会', nameOfPersonInCharge: '张三', PhoneOfPersonInCharge: '15399665548', status: '1', manholeType: '1', manholeCover: '暂无', manholeShape: '圆形', constructionTime: '2025-09-15 20:57:42', longitude: '110.22252454', latitude: '27.1148554', manholeImage: 'manholeimg.png', QRCode: '/QRCode.jpg', }, { id: '4', name: '井盖四', type: '污水井盖', electricity: '80', facilityCode: '5001110103009062', region: '东三路米香街道', regionGrade: '暂无', locationDescription: '东三路A地铁口向西方向300米', competentDepartment: '东三路社区服务中心', ownershipUnit: 'A市住房和城乡建设委员会', maintenanceUnit: 'A市住房和城乡建设委员会', nameOfPersonInCharge: '张三', PhoneOfPersonInCharge: '15399665548', status: '1', manholeType: '1', manholeCover: '暂无', manholeShape: '圆形', constructionTime: '2025-09-15 20:57:42', longitude: '110.22252454', latitude: '27.1148554', manholeImage: 'manholeimg.png', QRCode: '/QRCode.jpg', }, { id: '5', name: '井盖五', type: '污水井盖', electricity: '80', facilityCode: '5001110103009062', region: '东三路米香街道', regionGrade: '暂无', locationDescription: '东三路A地铁口向西方向300米', competentDepartment: '东三路社区服务中心', ownershipUnit: 'A市住房和城乡建设委员会', maintenanceUnit: 'A市住房和城乡建设委员会', nameOfPersonInCharge: '张三', PhoneOfPersonInCharge: '15399665548', status: '1', manholeType: '1', manholeCover: '暂无', manholeShape: '圆形', constructionTime: '2025-09-15 20:57:42', longitude: '110.22252454', latitude: '27.1148554', manholeImage: 'manholeimg.png', QRCode: '/QRCode.jpg', }, { id: '6', name: '井盖六', type: '污水井盖', electricity: '80', facilityCode: '5001110103009062', region: '东三路米香街道', regionGrade: '暂无', locationDescription: '东三路A地铁口向西方向300米', competentDepartment: '东三路社区服务中心', ownershipUnit: 'A市住房和城乡建设委员会', maintenanceUnit: 'A市住房和城乡建设委员会', nameOfPersonInCharge: '张三', PhoneOfPersonInCharge: '15399665548', status: '1', manholeType: '1', manholeCover: '暂无', manholeShape: '圆形', constructionTime: '2025-09-15 20:57:42', longitude: '110.22252454', latitude: '27.1148554', manholeImage: 'manholeimg.png', QRCode: '/QRCode.jpg', }, { id: '7', name: '井盖七', type: '通信井盖', electricity: '80', facilityCode: '5001110103009062', region: '东三路米香街道', regionGrade: '暂无', locationDescription: '东三路A地铁口向西方向300米', competentDepartment: '东三路社区服务中心', ownershipUnit: 'A市住房和城乡建设委员会', maintenanceUnit: 'A市住房和城乡建设委员会', nameOfPersonInCharge: '张三', PhoneOfPersonInCharge: '15399665548', status: '1', manholeType: '1', manholeCover: '暂无', manholeShape: '圆形', constructionTime: '2025-09-15 20:57:42', longitude: '110.22252454', latitude: '27.1148554', manholeImage: 'manholeimg.png', QRCode: '/QRCode.jpg', }, , { id: '8', name: '井盖八', type: '通信井盖', electricity: '80', facilityCode: '5001110103009062', region: '东三路米香街道', regionGrade: '暂无', locationDescription: '东三路A地铁口向西方向300米', competentDepartment: '东三路社区服务中心', ownershipUnit: 'A市住房和城乡建设委员会', maintenanceUnit: 'A市住房和城乡建设委员会', nameOfPersonInCharge: '张三', PhoneOfPersonInCharge: '15399665548', status: '1', manholeType: '1', manholeCover: '暂无', manholeShape: '圆形', constructionTime: '2025-09-15 20:57:42', longitude: '110.22252454', latitude: '27.1148554', manholeImage: 'manholeimg.png', QRCode: '/QRCode.jpg', }, { id: '9', name: '井盖九', type: '通信井盖', electricity: '80', facilityCode: '5001110103009062', region: '东三路米香街道', regionGrade: '暂无', locationDescription: '东三路A地铁口向西方向300米', competentDepartment: '东三路社区服务中心', ownershipUnit: 'A市住房和城乡建设委员会', maintenanceUnit: 'A市住房和城乡建设委员会', nameOfPersonInCharge: '张三', PhoneOfPersonInCharge: '15399665548', status: '1', manholeType: '1', manholeCover: '暂无', manholeShape: '圆形', constructionTime: '2025-09-15 20:57:42', longitude: '110.22252454', latitude: '27.1148554', manholeImage: 'manholeimg.png', QRCode: '/QRCode.jpg', }, { id: '10', name: '井盖十', type: '通信井盖', electricity: '80', facilityCode: '5001110103009062', region: '东三路米香街道', regionGrade: '暂无', locationDescription: '东三路A地铁口向西方向300米', competentDepartment: '东三路社区服务中心', ownershipUnit: 'A市住房和城乡建设委员会', maintenanceUnit: 'A市住房和城乡建设委员会', nameOfPersonInCharge: '张三', PhoneOfPersonInCharge: '15399665548', status: '1', manholeType: '1', manholeCover: '暂无', manholeShape: '圆形', constructionTime: '2025-09-15 20:57:42', longitude: '110.22252454', latitude: '27.1148554', manholeImage: 'manholeimg.png', QRCode: '/QRCode.jpg', }, { id: '11', name: '井盖十一', type: '通信井盖', electricity: '80', facilityCode: '5001110103009062', region: '东三路米香街道', regionGrade: '暂无', locationDescription: '东三路A地铁口向西方向300米', competentDepartment: '东三路社区服务中心', ownershipUnit: 'A市住房和城乡建设委员会', maintenanceUnit: 'A市住房和城乡建设委员会', nameOfPersonInCharge: '张三', PhoneOfPersonInCharge: '15399665548', status: '1', manholeType: '1', manholeCover: '暂无', manholeShape: '圆形', constructionTime: '2025-09-15 20:57:42', longitude: '110.22252454', latitude: '27.1148554', manholeImage: 'manholeimg.png', QRCode: '/QRCode.jpg', }, { id: '12', name: '井盖十二', type: '通信井盖', electricity: '80', facilityCode: '5001110103009062', region: '东三路米香街道', regionGrade: '暂无', locationDescription: '东三路A地铁口向西方向300米', competentDepartment: '东三路社区服务中心', ownershipUnit: 'A市住房和城乡建设委员会', maintenanceUnit: 'A市住房和城乡建设委员会', nameOfPersonInCharge: '张三', PhoneOfPersonInCharge: '15399665548', status: '1', manholeType: '1', manholeCover: '暂无', manholeShape: '圆形', constructionTime: '2025-09-15 20:57:42', longitude: '110.22252454', latitude: '27.1148554', manholeImage: 'manholeimg.png', QRCode: '/QRCode.jpg', }], } // 使用 useMemo 动态计算筛选数据,依赖 typeFilter 和 EquipmentListData.data const filteredData = useMemo(() => { return typeFilter === 'all' ? EquipmentListData.data : EquipmentListData.data.filter(item => item.type === typeFilter); }, [typeFilter, EquipmentListData.data]); // 当筛选条件或原始数据变化时重新计算 const popUpdata = { columns: [ { title: () => (
设备ID
), dataIndex: "codeID", width: 150, ellipsis: true, render: (text, record) => ( // 添加record参数获取行数据
{text}
), }, { title: () => (
检测时间
), dataIndex: "date", ellipsis: true, render: (text, record) => ( // 添加record参数获取行数据
{text}
), }, { title: () => (
温度(℃)
), dataIndex: "temperature", ellipsis: true, render: (text, record) => ( // 添加record参数获取行数据
{text}
), }, { title: () => (
角度(°)
), dataIndex: "angle", ellipsis: true, render: (text, record) => ( // 添加record参数获取行数据
{text}
), }, { title: () => (
电压(V)
), dataIndex: "voltage", ellipsis: true, render: (text, record) => ( // 添加record参数获取行数据
{text}
), } ], data: [{ id: '1', // 添加唯一 id 作为 rowKey date: '2016-05-02', codeID: '5001110103009062', temperature: '29', angle: '4', voltage: '3.6' }, { id: '1', // 添加唯一 id 作为 rowKey date: '2016-05-02', codeID: '5001110103009062', temperature: '29', angle: '4', voltage: '3.6' }, { id: '1', // 添加唯一 id 作为 rowKey date: '2016-05-02', codeID: '5001110103009062', temperature: '29', angle: '4', voltage: '3.6' }, { id: '1', // 添加唯一 id 作为 rowKey date: '2016-05-02', codeID: '5001110103009062', temperature: '29', angle: '4', voltage: '3.6' }, { id: '1', // 添加唯一 id 作为 rowKey date: '2016-05-02', codeID: '5001110103009062', temperature: '29', angle: '4', voltage: '3.6' }, { id: '1', // 添加唯一 id 作为 rowKey date: '2016-05-02', codeID: '5001110103009062', temperature: '29', angle: '4', voltage: '3.6' }, { id: '1', // 添加唯一 id 作为 rowKey date: '2016-05-02', codeID: '5001110103009062', temperature: '29', angle: '4', voltage: '3.6' }, { id: '1', // 添加唯一 id 作为 rowKey date: '2016-05-02', codeID: '5001110103009062', temperature: '29', angle: '4', voltage: '3.6' }, { id: '1', // 添加唯一 id 作为 rowKey date: '2016-05-02', codeID: '5001110103009062', temperature: '29', angle: '4', voltage: '3.6' }, { id: '1', // 添加唯一 id 作为 rowKey date: '2016-05-02', codeID: '5001110103009062', temperature: '29', angle: '4', voltage: '3.6' }, { id: '1', // 添加唯一 id 作为 rowKey date: '2016-05-02', codeID: '5001110103009062', temperature: '29', angle: '4', voltage: '3.6' }, { id: '1', // 添加唯一 id 作为 rowKey date: '2016-05-02', codeID: '5001110103009062', temperature: '29', angle: '4', voltage: '3.6' }, { id: '1', // 添加唯一 id 作为 rowKey date: '2016-05-02', codeID: '5001110103009062', temperature: '29', angle: '4', voltage: '3.6' }, { id: '1', // 添加唯一 id 作为 rowKey date: '2016-05-02', codeID: '5001110103009062', temperature: '29', angle: '4', voltage: '3.6' },] } return (
{ // return 'bg-[#3a3899]'; }} columns={EquipmentListData.columns} dataSource={filteredData} pagination={false} rowKey="id" size="small" scroll={{x: 200, y: 420}} /> {/* GIS设备详情弹窗 */} setGISDeviceModalVisible(false)} // footer={null} width={1200} className="custom-modal" style={{ textAlign: 'center' }} > {GISselectedDevice && (
设备名称: {GISselectedDevice.name}
设备类型: {GISselectedDevice.type}
设备电量: {GISselectedDevice.electricity}%
设备编号:{GISselectedDevice.facilityCode}
所属区域: {GISselectedDevice.region}
道路等级: {GISselectedDevice.regionGrade}
位置描述: {GISselectedDevice.locationDescription}
主管部门: {GISselectedDevice.competentDepartment}
权属单位: {GISselectedDevice.ownershipUnit}
养护单位: {GISselectedDevice.maintenanceUnit}
负责人姓名: {GISselectedDevice.nameOfPersonInCharge}
负责人电话: {GISselectedDevice.PhoneOfPersonInCharge}
设施状态: {GISselectedDevice.status === "1" ? "正常" : "异常"} } />
是否智能井盖:
井盖材质: {GISselectedDevice.manholeCover}
井身形状: {GISselectedDevice.manholeShape}
建设时问: {GISselectedDevice.constructionTime}
经纬度: {GISselectedDevice.longitude}°N, {GISselectedDevice.latitude}°E
井盖图片: 井盖图片 { setPreviewImage(GISselectedDevice.manholeImage); setPreviewVisible(true); }} />
二维码: {/* 二维码图片也添加点击放大功能 */} 二维码 { setPreviewImage(GISselectedDevice.QRCode); setPreviewVisible(true); }} />
{/*GIS井盖详情第二模块*/} {/*GIS井盖详情第二模块 - 修改为按钮式导航*/}
{/* 按钮式导航 */}
近15日数据
{/* 内容区域 */}
{activeNavButton === "realtime" && (
)} {activeNavButton === "history" && (
历史事件记录展示区域
)} {activeNavButton === "inspection" && (
日常巡查信息展示区域
)} )} {/* 添加图片预览弹窗 */} setPreviewVisible(false)} maskClosable={true} width="800px" height="500px" bodyStyle={{padding: 0}} closable={true} zIndex={10000} > {previewImage && ( 预览图片 )} {/* 添加全局样式覆盖表头背景色 */} ) }