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 ( <>