Browse Source

组网鉴权

dev
wenlele 1 year ago
parent
commit
616516863f
  1. 24
      api/config.js
  2. 2
      web-network/client/src/index.js
  3. 79
      web-network/client/src/sections/auth/containers/login.js
  4. 40
      web-network/client/src/sections/network/actions/network.js
  5. 6
      web-network/client/src/sections/network/components/device-tree/equipment-option.js
  6. 6
      web-network/client/src/sections/network/components/device-tree/index.js
  7. 18
      web-network/client/src/sections/network/components/device-tree/zuwang-main.js
  8. 32
      web-network/client/src/sections/network/containers/device-monitor.js
  9. 28
      web-network/client/src/sections/network/containers/tableShow.js
  10. 4
      web/client/src/sections/analysis/containers/network.jsx

24
api/config.js

@ -240,17 +240,19 @@ const product = {
{ p: '/project/group/:groupId/detail', o: 'GET' }, { p: '/project/group/:groupId/detail', o: 'GET' },
{ p: '/project/workOrders/repairRank', o: 'GET' }, { p: '/project/workOrders/repairRank', o: 'GET' },
{ p: '/project/workOrders', o: 'GET' }, { p: '/project/workOrders', o: 'GET' },
{ p: '/organizations/:pepProjectId/struc', o: 'GET' },
{ p: '/things/:iotaThingId/deploys', o: 'GET' },
{ p: '/meta/things/:iotaThingId/devices', o: 'GET' }, // { p: '/organizations/:pepProjectId/struc', o: 'GET' },
{ p: '/metrics/things/:iotaThingId/devices/link_status', o: 'GET' }, // { p: '/things/:iotaThingId/deploys', o: 'GET' },
{ p: '/things/:iotaThingId/deploy', o: 'GET' }, // { p: '/meta/things/:iotaThingId/devices', o: 'GET' },
{ p: '/sensors/last/data', o: 'POST' }, // { p: '/metrics/things/:iotaThingId/devices/link_status', o: 'GET' },
{ p: '/meta/things/:iotaThingId/devices', o: 'GET' }, // { p: '/things/:iotaThingId/deploy', o: 'GET' },
{ p: '/devices/alarms', o: 'POST' }, // { p: '/sensors/last/data', o: 'POST' },
{ p: '/devices/cardStatus', o: 'POST' }, // { p: '/meta/things/:iotaThingId/devices', o: 'GET' },
{ p: '/metrics/devices/:deviceId/link_status', o: 'GET' }, // { p: '/devices/alarms', o: 'POST' },
{ p: '/device/:deviceId/alarms', o: 'GET' }, // { p: '/devices/cardStatus', o: 'POST' },
// { p: '/metrics/devices/:deviceId/link_status', o: 'GET' },
// { p: '/device/:deviceId/alarms', o: 'GET' },
], // 不做认证的路由,也可以使用 exclude: ["*"] 跳过所有路由 ], // 不做认证的路由,也可以使用 exclude: ["*"] 跳过所有路由

2
web-network/client/src/index.js

@ -4,4 +4,4 @@ import React from 'react';
import { render } from 'react-dom'; import { render } from 'react-dom';
import App from './app'; import App from './app';
render((<App projectName="南昌县智慧交通监管系统" />), document.getElementById('App')); render((<App projectName="运维组网" />), document.getElementById('App'));

79
web-network/client/src/sections/auth/containers/login.js

@ -73,45 +73,48 @@ const Login = props => {
return ( return (
<div className='login'> <div>
{/* <div className='left'></div> */} {"{ token : 未生效,请刷新页面}"}
<div className='right'>
<div className='loginBox'>
<h1>南昌县智慧交通监管系统</h1>
<Form onKeyDown={enterHandler}>
<FormItem>
<div className='loginFormTit'>用户名</div>
<Input
className='loginInp'
type="text"
value={username}
maxlength={11}
onChange={e => {
//('e.target.value', e.target.value)
setUserName(e.target.value)
setInputChanged(true)
}}
/>
</FormItem>
<div className='loginFormTit'>密码</div>
<FormItem>
<Input
className='loginInp'
type="password"
value={password}
onChange={e => {
//console.log('setPassword', e.target.value)
setPassword(e.target.value)
setInputChanged(true)
}}
/>
</FormItem>
</Form>
<Button type="primary" className='loginBtn' loading={isRequesting} onClick={handleLogin}>登录</Button>
</div>
</div>
</div> </div>
// <div className='login'>
// {/* <div className='left'></div> */}
// <div className='right'>
// <div className='loginBox'>
// <h1>南昌县智慧交通监管系统</h1>
// <Form onKeyDown={enterHandler}>
// <FormItem>
// <div className='loginFormTit'>用户名</div>
// <Input
// className='loginInp'
// type="text"
// value={username}
// maxlength={11}
// onChange={e => {
// //('e.target.value', e.target.value)
// setUserName(e.target.value)
// setInputChanged(true)
// }}
// />
// </FormItem>
// <div className='loginFormTit'>密码</div>
// <FormItem>
// <Input
// className='loginInp'
// type="password"
// value={password}
// onChange={e => {
// //console.log('setPassword', e.target.value)
// setPassword(e.target.value)
// setInputChanged(true)
// }}
// />
// </FormItem>
// </Form>
// <Button type="primary" className='loginBtn' loading={isRequesting} onClick={handleLogin}>登录</Button>
// </div>
// </div>
// </div>
); );
} }

40
web-network/client/src/sections/network/actions/network.js

@ -4,84 +4,84 @@ import { basicAction } from '@peace/utils';
import { ApiTable } from '$utils'; import { ApiTable } from '$utils';
export function getOrganizationsStruc (id) { export function getOrganizationsStruc (id, token) {
return dispatch => basicAction({ return dispatch => basicAction({
type: 'get', type: 'get',
dispatch: dispatch, dispatch: dispatch,
actionType: 'GET_ORGANIZATIONS_STRUC', actionType: 'GET_ORGANIZATIONS_STRUC',
url: `${ApiTable.organizationsStruc.replace('{pepProjectId}', id)}`, url: `${ApiTable.organizationsStruc.replace('{pepProjectId}', id)}?token=${token}`,
msg: { error: '获取项目下的结构物信息失败' }, msg: { error: '获取项目下的结构物信息失败' },
reducer: { name: 'organizationsStruc' } reducer: { name: 'organizationsStruc' }
}) })
} }
export function getThingsDeploy (id) { export function getThingsDeploy (id, token) {
return dispatch => basicAction({ return dispatch => basicAction({
type: 'get', type: 'get',
dispatch: dispatch, dispatch: dispatch,
actionType: 'GET_THINGS_DEPLOY', actionType: 'GET_THINGS_DEPLOY',
url: `${ApiTable.thingsDeploy.replace('{iotaThingId}', id)}`, url: `${ApiTable.thingsDeploy.replace('{iotaThingId}', id)}?token=${token}`,
msg: { error: '获取设备部署信息失败' }, msg: { error: '获取设备部署信息失败' },
reducer: { name: 'deviceList' } reducer: { name: 'deviceList' }
}) })
} }
export function getDeviceMetaDeployed (id) { export function getDeviceMetaDeployed (id, token) {
return dispatch => basicAction({ return dispatch => basicAction({
type: 'get', type: 'get',
dispatch: dispatch, dispatch: dispatch,
actionType: 'GET_DEVIC_META_DEPLOYED', actionType: 'GET_DEVIC_META_DEPLOYED',
url: `${ApiTable.deviceMetaDeployed.replace('{iotaThingId}', id)}`, url: `${ApiTable.deviceMetaDeployed.replace('{iotaThingId}', id)}?token=${token}`,
msg: { error: '获取部署设备原型失败' }, msg: { error: '获取部署设备原型失败' },
reducer: { name: 'deviceMeta' } reducer: { name: 'deviceMeta' }
}) })
} }
export function getIotaThingsLlinkStatus (id) { export function getIotaThingsLlinkStatus (id, token) {
return dispatch => basicAction({ return dispatch => basicAction({
type: 'get', type: 'get',
dispatch: dispatch, dispatch: dispatch,
actionType: 'GET_IOTA_ThINGS_LINK_STATUS', actionType: 'GET_IOTA_ThINGS_LINK_STATUS',
url: `${ApiTable.getIotaThingsLlinkStatus.replace('{iotaThingId}', id)}`, url: `${ApiTable.getIotaThingsLlinkStatus.replace('{iotaThingId}', id)}?token=${token}`,
msg: { error: '获取设备在线状态/以结构物id集体获取失败' }, msg: { error: '获取设备在线状态/以结构物id集体获取失败' },
reducer: { name: '' } reducer: { name: '' }
}) })
} }
export function findDeviceMetaDeployed (id) { export function findDeviceMetaDeployed (id, token) {
return dispatch => basicAction({ return dispatch => basicAction({
type: 'get', type: 'get',
dispatch: dispatch, dispatch: dispatch,
actionType: 'FIND_DEVICE_META_DEPLOYED', actionType: 'FIND_DEVICE_META_DEPLOYED',
url: `${ApiTable.findDeviceMetaDeployed.replace('{iotaThingId}', id)}`, url: `${ApiTable.findDeviceMetaDeployed.replace('{iotaThingId}', id)}?token=${token}`,
msg: { error: '获取单个结构物的设备信息失败' }, msg: { error: '获取单个结构物的设备信息失败' },
reducer: { name: 'deviceMetaDeployed', params: { noClear: true } }, reducer: { name: 'deviceMetaDeployed', params: { noClear: true } },
}) })
} }
export function findSensorLastData (data) { export function findSensorLastData (data, token) {
return dispatch => basicAction({ return dispatch => basicAction({
type: 'post', type: 'post',
data, data,
dispatch: dispatch, dispatch: dispatch,
actionType: 'FIND_SENSOR_LAST_DATA', actionType: 'FIND_SENSOR_LAST_DATA',
url: `${ApiTable.findSensorLastData}`, url: `${ApiTable.findSensorLastData}?token=${token}`,
msg: { error: '原始数据查询失败' }, msg: { error: '原始数据查询失败' },
reducer: { name: 'sensorLastData' } reducer: { name: 'sensorLastData' }
}) })
} }
export function getDevicesAlarms (deviceIds, query) { export function getDevicesAlarms (deviceIds, query, token) {
return dispatch => basicAction({ return dispatch => basicAction({
type: 'post', type: 'post',
dispatch: dispatch, dispatch: dispatch,
data: deviceIds, data: deviceIds,
query: query, query: query,
actionType: 'REQUEST_POST_DEVICES_ALARMS', actionType: 'REQUEST_POST_DEVICES_ALARMS',
url: `${ApiTable.getDevicesAlarms}?state=new`, url: `${ApiTable.getDevicesAlarms}?state=new&token=${token}`,
msg: { msg: {
error: '获取设备告警信息失败' error: '获取设备告警信息失败'
}, },
@ -92,13 +92,13 @@ export function getDevicesAlarms (deviceIds, query) {
} }
export function findDevicesCardStatus (deviceIds) { export function findDevicesCardStatus (deviceIds, token) {
return dispatch => basicAction({ return dispatch => basicAction({
type: 'post', type: 'post',
dispatch: dispatch, dispatch: dispatch,
data: deviceIds, data: deviceIds,
actionType: 'FIND_DEVICES_CARD_STATUS', actionType: 'FIND_DEVICES_CARD_STATUS',
url: `${ApiTable.findDevicesCardStatus}`, url: `${ApiTable.findDevicesCardStatus}?token=${token}`,
msg: { msg: {
error: '获取物联网卡信息失败' error: '获取物联网卡信息失败'
}, },
@ -108,25 +108,25 @@ export function findDevicesCardStatus (deviceIds) {
}); });
} }
export function getDevicesLlinkStatus (id) { export function getDevicesLlinkStatus (id, token) {
return dispatch => basicAction({ return dispatch => basicAction({
type: 'get', type: 'get',
dispatch: dispatch, dispatch: dispatch,
actionType: 'GET_DEVICES_LINK_STATUS', actionType: 'GET_DEVICES_LINK_STATUS',
url: `${ApiTable.getDevicesLlinkStatus.replace('{deviceId}', id)}`, url: `${ApiTable.getDevicesLlinkStatus.replace('{deviceId}', id)}?token=${token}`,
msg: { error: '获取设备在线状态/以设备id单个获取' }, msg: { error: '获取设备在线状态/以设备id单个获取' },
reducer: { name: '' } reducer: { name: '' }
}) })
} }
export function findAlarmsDevice (deviceIds, query) { export function findAlarmsDevice (deviceIds, query, token) {
return dispatch => basicAction({ return dispatch => basicAction({
type: 'get', type: 'get',
dispatch: dispatch, dispatch: dispatch,
query: query, query: query,
actionType: 'GET_FIND_ALARM_DEVICES', actionType: 'GET_FIND_ALARM_DEVICES',
url: `device/${deviceIds}/alarms`, url: `device/${deviceIds}/alarms?token=${token}`,
msg: { msg: {
error: '获取设备告警信息失败' error: '获取设备告警信息失败'
}, },

6
web-network/client/src/sections/network/components/device-tree/equipment-option.js

@ -13,7 +13,7 @@ import { Request } from '@peace/utils'
const TabPane = Tabs.TabPane; const TabPane = Tabs.TabPane;
export default ({ ...props }) => { export default ({ ...props }) => {
const { isEdit, devices, info, parentNode, dimensions, height, deviceMetas, dispatch, actions } = props; const { isEdit, devices, info, parentNode, dimensions, height, deviceMetas, dispatch, actions, token } = props;
const { analysis } = actions const { analysis } = actions
const [linkState, setLinkState] = useSafeState(null); const [linkState, setLinkState] = useSafeState(null);
@ -31,14 +31,14 @@ export default ({ ...props }) => {
if (info?.device?.id && info.device.id != currentDeviceId) { if (info?.device?.id && info.device.id != currentDeviceId) {
setCurrentDeviceId(info.device.id); setCurrentDeviceId(info.device.id);
setActiveKey('1'); setActiveKey('1');
dispatch(analysis.getDevicesLlinkStatus(info?.device?.id)).then(res => { dispatch(analysis.getDevicesLlinkStatus(info?.device?.id, token)).then(res => {
if (res.success) { if (res.success) {
setLinkState(res.payload?.data?.status) setLinkState(res.payload?.data?.status)
} }
}) })
dispatch(analysis.findAlarmsDevice(info?.device?.id, { limit: 5 })).then(res => { dispatch(analysis.findAlarmsDevice(info?.device?.id, { limit: 5 }, token)).then(res => {
if (res.success) { if (res.success) {
setAlarmMsg({ new: res.payload?.data?.new || [], history: res.payload?.data?.history || [] }) setAlarmMsg({ new: res.payload?.data?.new || [], history: res.payload?.data?.history || [] })
} }

6
web-network/client/src/sections/network/components/device-tree/index.js

@ -17,7 +17,7 @@ const { ModifyEquipmentNetworking } = AuthorizationCode;
export default function ({ ...props }) { export default function ({ ...props }) {
const { const {
dispatch,actions, clientHeight, deviceMetasWithFollow, deviceList, dimensionlist, struct, dispatch, actions, clientHeight, deviceMetasWithFollow, deviceList, dimensionlist, struct, token
} = props; } = props;
const [g6TreeDirection, setG6TreeDirection] = useSafeState('TB'); const [g6TreeDirection, setG6TreeDirection] = useSafeState('TB');
const [devices, setDevices] = useSafeState(null); const [devices, setDevices] = useSafeState(null);
@ -279,6 +279,9 @@ export default function ({ ...props }) {
foldAllG6ToCenter={foldAllG6ToCenter} foldAllG6ToCenter={foldAllG6ToCenter}
resetFoldAllG6ToCenter={resetFoldAllG6ToCenter} resetFoldAllG6ToCenter={resetFoldAllG6ToCenter}
g6TreeDirection={g6TreeDirection} g6TreeDirection={g6TreeDirection}
token={token}
dispatch={dispatch}
actions={actions}
/> />
) )
} }
@ -306,6 +309,7 @@ export default function ({ ...props }) {
height={containerHeight} height={containerHeight}
dispatch={dispatch} dispatch={dispatch}
actions={actions} actions={actions}
token={token}
/> />
</Drawer> </Drawer>
</div> </div>

18
web-network/client/src/sections/network/components/device-tree/zuwang-main.js

@ -19,7 +19,7 @@ export default function ({ ...props }) {
const { const {
struct, data, resetFoldAllG6ToCenter, foldAllG6ToCenter, g6TreeDirection, emitChange, emitDataChange_, struct, data, resetFoldAllG6ToCenter, foldAllG6ToCenter, g6TreeDirection, emitChange, emitDataChange_,
width, height, collapseAll, collapsed, expanded, expandAll, changeFinish, targetNode, inputSearching, setInputSearching, width, height, collapseAll, collapsed, expanded, expandAll, changeFinish, targetNode, inputSearching, setInputSearching,
onCollapse, handleNodeEnter, handelNodeClick, onCollapse, handleNodeEnter, handelNodeClick, token, dispatch, actions
} = props; } = props;
const [isGetLinkStateDone, { setTrue, setFalse }] = useBoolean(false); const [isGetLinkStateDone, { setTrue, setFalse }] = useBoolean(false);
const [devicesLinkState, setDevicesLinkState] = useSafeState(null); const [devicesLinkState, setDevicesLinkState] = useSafeState(null);
@ -30,28 +30,28 @@ export default function ({ ...props }) {
const [lastClickNodeKey, setLastClickNodeKey] = useSafeState(null); const [lastClickNodeKey, setLastClickNodeKey] = useSafeState(null);
const [disCheckedKeys, setDisCheckedKeys] = useSafeState([]); const [disCheckedKeys, setDisCheckedKeys] = useSafeState([]);
let intervalLinkStatus = null; let intervalLinkStatus = null;
const { analysis } = actions
// const da = useThingsLinkStatus(struct?.iotaThingId); // const da = useThingsLinkStatus(struct?.iotaThingId);
const getThingsLinkStatus = (isCycle = false) => { const getThingsLinkStatus = (isCycle = false) => {
const iotaThingId = struct?.thingId; const iotaThingId = struct?.thingId;
if (iotaThingId) { if (iotaThingId) {
const url = ApiTable.getIotaThingsLlinkStatus.replace('{iotaThingId}', iotaThingId); dispatch(analysis.getIotaThingsLlinkStatus(iotaThingId, token)).then((res) => {
Request.get(url).then((res) => { if (res.payload?.data?.devices.length >= 0) {
if (res.devices.length >= 0) { setDevicesLinkState(res.payload?.data?.devices || []);
setDevicesLinkState(res.devices);
} else { } else {
intervalLinkStatus && clearInterval(intervalLinkStatus); intervalLinkStatus && clearInterval(intervalLinkStatus);
} }
if (!isCycle) { if (!isCycle) {
setTrue(); setTrue(true);
} }
}, (error) => { }, (error) => {
if (!isCycle) { if (!isCycle) {
message.warning('设备在线状态获取失败'); message.warning('设备在线状态获取失败')
setTrue(); setTrue(true);
} }
}); })
} }
}; };
useEffect(() => { useEffect(() => {

32
web-network/client/src/sections/network/containers/device-monitor.js

@ -31,41 +31,23 @@ function DeviceMonitor ({ ...props }) {
let strucParam = JSON.parse((qs.parse(props.location?.search.slice(1)) || {})?.strucData) let strucParam = JSON.parse((qs.parse(props.location?.search.slice(1)) || {})?.strucData)
const token = qs.parse(props.location?.search.slice(1))?.key
useEffect(() => { useEffect(() => {
if (strucParam?.thingId) { if (strucParam?.thingId) {
dispatch(analysis.getThingsDeploy(strucParam?.thingId)).then(res => { dispatch(analysis.getThingsDeploy(strucParam?.thingId, token)).then(res => {
console.log(3213, res);
if (res.success) { if (res.success) {
const instances = res?.payload?.data?.instances; const instances = res?.payload?.data?.instances;
if (instances) { if (instances) {
const deviceIds = Object.keys(instances).filter((k) => instances[k]?.type == 's.d'); const deviceIds = Object.keys(instances).filter((k) => instances[k]?.type == 's.d');
dispatch(analysis.getDevicesAlarms(deviceIds, { limit: 5 })); dispatch(analysis.getDevicesAlarms(deviceIds, { limit: 5 }, token));
} }
} }
}) })
dispatch(analysis.getDeviceMetaDeployed(strucParam?.thingId)) dispatch(analysis.getDeviceMetaDeployed(strucParam?.thingId, token))
} }
}, []); }, []);
useEffect(() => {
if (selectStructure && myStructList?.length > 0) {
const curStructure = myStructList.find((v) => v.id === selectStructure);
if (curStructure) {
// dispatch(actions.dataMonitor.getStationList(curStructure?.id));
// dispatch(actions.dataMonitor.getDeviceList(curStructure?.iotaThingId)).then((res) => {
// if (res.success) {
// const instances = res?.payload?.data?.instances;
// if (instances) {
// const deviceIds = Object.keys(instances).filter((k) => instances[k]?.type == 's.d');
// dispatch(actions.dataMonitor.getDevicesAlarms(deviceIds, { limit: 5 }));
// }
// }
// });
// dispatch(actions.dataMonitor.getDimensionsList(curStructure?.iotaThingId));
}
}
}, [selectStructure]);
// 展示切换 // 展示切换
const onExtraChange = (e) => { const onExtraChange = (e) => {
@ -149,10 +131,12 @@ function DeviceMonitor ({ ...props }) {
struct={strucParam} struct={strucParam}
clientHeight={clientHeight} clientHeight={clientHeight}
clientWidth={clientWidth} clientWidth={clientWidth}
token={token}
/> />
) : <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} /> ) : <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />
: ( : (
<TableShow thingId={strucParam.thingId} project={strucParam.projectId} /> <TableShow thingId={strucParam.thingId} project={strucParam.projectId} token={token} />
) )
} }
</ProCard> </ProCard>

28
web-network/client/src/sections/network/containers/tableShow.js

@ -1,11 +1,11 @@
import React, { useEffect, useState, useRef, useMemo } from 'react' import React, { useEffect, useState, useRef, useMemo } from 'react'
import { connect } from 'react-redux' import { connect } from 'react-redux'
import { Spin, Card, CardGroup, Form,Select ,Input, Button, Table, Pagination, Tooltip } from 'antd' import { Spin, Card, CardGroup, Form, Select, Input, Button, Table, Pagination, Tooltip } from 'antd'
import ExportData from '../components/export-data' import ExportData from '../components/export-data'
import moment from 'moment' import moment from 'moment'
const Network = props => { const Network = props => {
const { dispatch, actions, user, clientHeight, thingId, deviceListAlarms, devicesCardStatusList, project } = props const { dispatch, actions, user, clientHeight, thingId, deviceListAlarms, devicesCardStatusList, project, token } = props
const { analysis } = actions const { analysis } = actions
const form = useRef() //表单 const form = useRef() //表单
const [deployData, setDeployData] = useState([]) const [deployData, setDeployData] = useState([])
@ -39,7 +39,7 @@ const Network = props => {
useEffect(() => { useEffect(() => {
if (thingId) { if (thingId) {
let dataList = [] let dataList = []
dispatch(analysis.getThingsDeploy(thingId)).then(rs => { dispatch(analysis.getThingsDeploy(thingId, token)).then(rs => {
if (rs.success) { if (rs.success) {
setDeployData(rs.payload.data) setDeployData(rs.payload.data)
dataList = rs.payload.data dataList = rs.payload.data
@ -62,7 +62,7 @@ const Network = props => {
}) })
} }
dispatch(analysis.findDeviceMetaDeployed(thingId)).then(res => { dispatch(analysis.findDeviceMetaDeployed(thingId, token)).then(res => {
if (res.success) { if (res.success) {
setDeviceMetasDeployed(res.payload.data) setDeviceMetasDeployed(res.payload.data)
const deviceMetaDeployed = res.payload.data const deviceMetaDeployed = res.payload.data
@ -91,8 +91,8 @@ const Network = props => {
sensorsId.push(id) sensorsId.push(id)
} }
} }
dispatch(analysis.getDevicesAlarms(deviceIds , { limit: 5 })) dispatch(analysis.getDevicesAlarms(deviceIds, { limit: 5 }, token))
dispatch(analysis.findDevicesCardStatus({ deviceIds: alarmSensorId })) dispatch(analysis.findDevicesCardStatus({ deviceIds: alarmSensorId }, token))
setSensorsDataItems(sensorsDataItems) setSensorsDataItems(sensorsDataItems)
setSensorId(sensorsId) setSensorId(sensorsId)
setDeviceData(da) setDeviceData(da)
@ -105,7 +105,7 @@ const Network = props => {
}, [thingId]) }, [thingId])
useEffect(async () => { useEffect(async () => {
if (sensorId && sensorId.length && sensorsDataItems) { if (sensorId && sensorId.length && sensorsDataItems) {
const rs = await dispatch(analysis.findSensorLastData(sensorId)) const rs = await dispatch(analysis.findSensorLastData(sensorId, token))
const tableData = [] const tableData = []
if (rs.success) { if (rs.success) {
rs.payload.data.forEach(sd => { rs.payload.data.forEach(sd => {
@ -149,7 +149,7 @@ const Network = props => {
} }
}, [sensorId]) }, [sensorId])
useEffect(() => { useEffect(() => {
if (deviceData && deviceData.length ) { if (deviceData && deviceData.length) {
const dataD = deviceData?.map(p => { const dataD = deviceData?.map(p => {
const objRslt = tableData?.find(q => q.sensorId == p.sensorId) const objRslt = tableData?.find(q => q.sensorId == p.sensorId)
return { return {
@ -190,15 +190,15 @@ const Network = props => {
// const lastDataCopy=useMemo(()=>{ // const lastDataCopy=useMemo(()=>{
// return lastData // return lastData
// },[thingId]) // },[thingId])
const scroll = useMemo(() => ({ y:clientHeight-600+175+175 }), []) const scroll = useMemo(() => ({ y: clientHeight - 600 + 175 + 175 }), [])
//名称回调事件 //名称回调事件
const inputChange = e => { const inputChange = e => {
setSearchName(e.target.value) setSearchName(e.target.value)
} }
//选择设备类型下拉框回调 //选择设备类型下拉框回调
const selectChange = e => { const selectChange = e => {
let rslt=typeList.find(f => f.value == e) let rslt = typeList.find(f => f.value == e)
setSearchType(rslt?rslt.label:undefined) setSearchType(rslt ? rslt.label : undefined)
} }
//查询事件回调 //查询事件回调
@ -206,7 +206,7 @@ const Network = props => {
setLastData( setLastData(
lastDataCopy.filter(f => lastDataCopy.filter(f =>
(!searchName || f.sensorName.includes(searchName)) && (!searchName || f.sensorName.includes(searchName)) &&
(!searchType|| f.deviceType===searchType) (!searchType || f.deviceType === searchType)
) )
) )
} }
@ -283,7 +283,7 @@ const Network = props => {
pure pure
allowClear allowClear
style={{ width: 260, marginRight: 12 }} style={{ width: 260, marginRight: 12 }}
onChange={inputChange}/> onChange={inputChange} />
<Select options={typeList} label='设备类型' <Select options={typeList} label='设备类型'
pure pure
allowClear allowClear
@ -318,7 +318,7 @@ const Network = props => {
) )
} }
function mapStateToProps(state) { function mapStateToProps (state) {
const { auth, global, members, webSocket, deviceListAlarms, devicesCardStatus } = state const { auth, global, members, webSocket, deviceListAlarms, devicesCardStatus } = state
return { return {
user: auth.user, user: auth.user,

4
web/client/src/sections/analysis/containers/network.jsx

@ -62,7 +62,6 @@ const Network = ({
useEffect(() => { useEffect(() => {
// iframe // iframe
const iframe = document.getElementById('myIframe'); const iframe = document.getElementById('myIframe');
console.log(4324, iframe);
if (iframe) { if (iframe) {
// iframeload // iframeload
iframe.addEventListener('load', function () { iframe.addEventListener('load', function () {
@ -128,7 +127,6 @@ const Network = ({
<Spin <Spin
// style={{ }}
childStyle={{ width: "100%", height: clientHeight - 188 }} childStyle={{ width: "100%", height: clientHeight - 188 }}
spinning={spinning}> spinning={spinning}>
<div id='show' style={{ width: "100%", height: "100%" }}> <div id='show' style={{ width: "100%", height: "100%" }}>
@ -139,7 +137,7 @@ const Network = ({
height: '100%', height: '100%',
zIndex: 7, border: 0 zIndex: 7, border: 0
}} }}
src={`${networkWeb}/network?strucData=${JSON.stringify(organizationsStruc?.find(v => v.thingId == thingId) || {})}`} src={`${networkWeb}/network?key=${user?.token}&strucData=${JSON.stringify(organizationsStruc?.find(v => v.thingId == thingId) || {})}`}
allowFullScreen allowFullScreen
> >
<p>你的浏览器不支持 iframe </p> <p>你的浏览器不支持 iframe </p>

Loading…
Cancel
Save