import React, { useEffect, useState, useRef } from 'react'; import { connect } from 'react-redux'; import ReactECharts from 'echarts-for-react'; import echarts from 'echarts'; import { Spin, Card, RadioGroup, Radio, Form, Button } from '@douyinfe/semi-ui'; import TableShow from './tableShow'; import TreeShow from './treeShow'; const Network = ({ dispatch, actions, user, clientHeight, networkWeb, projectPoms, pepProjectId, organizationsStruc }) => { const { analysis } = actions const [show, setShow] = useState('tree') const [projectList, setProjectList] = useState([]) //项目列表 const [projectValue, setProjectValue] = useState() //选中的项目 const [thingId, setThingId] = useState() //结构物thingId const [spinning, setSpinning] = useState(true) const form = useRef();//表单 useEffect(() => { setSpinning(true) let projectData = [] let project = projectPoms.filter(v => v.pepProjectIsDelete != 1) if (projectPoms?.length) { if (pepProjectId) { if (pepProjectId?.length) { let projectId = pepProjectId + ',-1' projectData = project?.filter(d => projectId?.includes(d.id?.toString())) } else { projectData = project?.filter(d => d.id == pepProjectId) } } else { projectData = [...project] } } setProjectList(projectData?.map(d => ({ value: d.id, label: d.name || d.pepProjectName }))) setProjectValue(projectData[0]?.id) form.current.setValue('projectId', projectData[0]?.id) }, [projectPoms, pepProjectId]) useEffect(() => { //获取当前选中项目的结构物列表 if (projectValue) dispatch(analysis.getOrganizationsStruc(projectValue)) }, [projectValue]) useEffect(() => { //获取当前选中项目的结构物列表 if (organizationsStruc?.length) { setThingId(organizationsStruc[0]?.thingId) form.current.setValue('thingId', organizationsStruc[0]?.thingId) } else { setThingId("") form.current.setValue('thingId', "") } }, [organizationsStruc]) useEffect(() => { // 获取iframe元素 const iframe = document.getElementById('myIframe'); if (iframe) { // 监听iframe的load事件 iframe.addEventListener('load', function () { console.log('IFrame is loaded'); setSpinning(false) // 在这里可以执行一些处理,表示iframe加载完毕 }); } }, []) return ( <>
一图统揽
PICTURE CENTRALIZE
(form.current = formApi)} layout="horizontal" style={{ position: "relative", width: "100%", flex: 1, display: 'flex', margin: "16px 0" }} > { if (projectValue != v) { setProjectValue(v) setSpinning(true) form.current.setValue('projectId', v) } }} /> ({ value: d.thingId, label: d.strucName })) || []} onSelect={v => { if (thingId != v) { setSpinning(true) setThingId(v) form.current.setValue('thingId', v) } }} />
{/*
设备总数: 222 个; 异常设备:0 个; 正常设备:222 个
{ setShow(e.target?.value) }} > 树状展示 表格展示
{show == 'tree' && } {show == 'table' && }
*/}
) } function mapStateToProps (state) { const { auth, global, ProjectPoms, organizationsStruc } = state; return { user: auth.user, actions: global.actions, clientHeight: global.clientHeight, projectPoms: ProjectPoms?.data?.rows || [], pepProjectId: global.pepProjectId, organizationsStruc: organizationsStruc?.data || [], //结构物选择列表 networkWeb: global.networkWeb, }; } export default connect(mapStateToProps)(Network);