Browse Source

feat:新增loading效果

dev
zhaobing’ 1 year ago
parent
commit
37f68fab81
  1. 38
      web-network/client/src/sections/network/containers/tableShow.js

38
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,Modal } 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, token } = 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([])
@ -21,6 +21,8 @@ const Network = props => {
const [typeList, setTypeList] = useState([]) const [typeList, setTypeList] = useState([])
const [query, setQuery] = useState({ limit: 10, page: 0 }) //页码信息 const [query, setQuery] = useState({ limit: 10, page: 0 }) //页码信息
const [deviceId,setDeviceId] = useState([]) const [deviceId,setDeviceId] = useState([])
const [modalVis,setModalVis]=useState(false)
const [loading,setLoading]=useState(true)
const DeviceTypes = { const DeviceTypes = {
'DTU': 'DTU', 'DTU': 'DTU',
'gateway': '网关', 'gateway': '网关',
@ -52,6 +54,7 @@ const Network = props => {
sensorId: i, sensorId: i,
sensorName: dataList.instances[i]?.name, sensorName: dataList.instances[i]?.name,
deviceType: dataList?.instances[i]?.instance?.properties?.deviceType, deviceType: dataList?.instances[i]?.instance?.properties?.deviceType,
model:dataList?.instances[i]?.instance?.properties?.productType,
collectTime: '--', collectTime: '--',
data: '--', data: '--',
iotCardStatus: '--', iotCardStatus: '--',
@ -73,12 +76,12 @@ const Network = props => {
for (const id in dataList.instances) { for (const id in dataList.instances) {
deviceIds.push(id) deviceIds.push(id)
const instances = dataList.instances[id] const instances = dataList.instances[id]
if (instances.type == 's.d' && instances.instance.properties.deviceType == 'sensor') { if (instances.type == 's.d' && instances.instance.properties.deviceType == 'sensor') {
const meta = deviceMetaDeployed.devices.find(m => m.id == instances.instance.deviceMetaId) const meta = deviceMetaDeployed.devices.find(m => m.id == instances.instance.deviceMetaId)
sensorsDataItems[id] = { sensorsDataItems[id] = {
items: {}, items: {},
deviceName: instances.name, deviceName: instances.name,
model:instances.instance.properties.productType
} }
if (meta) { if (meta) {
sensorsDataItems[id].items = meta.capabilities[0].properties.reduce((p, n) => { sensorsDataItems[id].items = meta.capabilities[0].properties.reduce((p, n) => {
@ -136,6 +139,7 @@ const Network = props => {
sensorId: sd.sensorId, sensorId: sd.sensorId,
sensorName: sensorName, sensorName: sensorName,
collectTime: collectTime, collectTime: collectTime,
model:sensorsDataItems[sd.sensorId]?.model,
data: dataStr, data: dataStr,
deviceType: 'sensor', //传感器 deviceType: 'sensor', //传感器
iotCardStatus: '--', iotCardStatus: '--',
@ -162,14 +166,13 @@ const Network = props => {
collectTime: objRslt ? objRslt.collectTime : p.collectTime, collectTime: objRslt ? objRslt.collectTime : p.collectTime,
data: objRslt ? objRslt.data : p.data, data: objRslt ? objRslt.data : p.data,
deviceType: DeviceTypes[objRslt ? objRslt.deviceType : p.deviceType], deviceType: DeviceTypes[objRslt ? objRslt.deviceType : p.deviceType],
model:objRslt?objRslt?.model:p.model,
iotCardStatus: iotCardStatus:
res.payload.data && res.payload.data.length res.payload.data && res.payload.data.length&&res.payload.data.find(v => v.deviceId == p.sensorId)?.status === 0
? res.payload.data.find(v => v.deviceId == p.sensorId)?.status === 0
? '正常' ? '正常'
: res.payload.data.find(v => v.deviceId == p.sensorId)?.status === 1 : res.payload.data.find(v => v.deviceId == p.sensorId)?.status === 1
? '未激活' ? '未激活':res.payload.data.find(v => v.deviceId == p.sensorId)?.status === 2?'停机'
: '停机' : '--',
: '--',
status: status:
deviceListAlarms && deviceListAlarms.length deviceListAlarms && deviceListAlarms.length
? deviceListAlarms?.find(v => v.deviceId == p.sensorId) ? deviceListAlarms?.find(v => v.deviceId == p.sensorId)
@ -188,6 +191,7 @@ const Network = props => {
}, []) }, [])
setTypeList(typeList) setTypeList(typeList)
setLastData(dataD) setLastData(dataD)
setLoading(false)
setLastDataCopy(dataD) setLastDataCopy(dataD)
} }
} }
@ -280,12 +284,19 @@ const Network = props => {
{ {
title: '操作', title: '操作',
width: '10%', width: '10%',
dataIndex: 'option', // dataIndex: 'option',
key: 'option', key: 'option',
render: (_, r) => {
return (
<div> {r.model==='FS-WSD-01M'?<Button onClick={()=>{setModalVis(true)}}>查询</Button>: '--'}</div>
)
}
}, },
] ]
console.log('modalVis',modalVis)
return ( return (
<> <>
<Spin spinning={loading}>
<div style={{ marginBottom: 12, display: 'flex' }}> <div style={{ marginBottom: 12, display: 'flex' }}>
<div> <div>
<Input // suffix={<IconSearch />} <Input // suffix={<IconSearch />}
@ -325,6 +336,11 @@ const Network = props => {
// scroll={scroll} // scroll={scroll}
columns={columns} columns={columns}
dataSource={lastData}></Table> dataSource={lastData}></Table>
<Modal
title='开关'
visible={modalVis}
></Modal>
</Spin>
</> </>
) )
} }
@ -336,7 +352,9 @@ function mapStateToProps (state) {
actions: global.actions, actions: global.actions,
clientHeight: global.clientHeight, clientHeight: global.clientHeight,
deviceListAlarms: deviceListAlarms?.data || [], deviceListAlarms: deviceListAlarms?.data || [],
devicesCardStatusList: devicesCardStatus?.data || [], devicesCardStatusList: devicesCardStatus?.data || [],
} }
} }

Loading…
Cancel
Save