Browse Source

feat:fix bugs

dev
zhaobing’ 1 year ago
parent
commit
c675795190
  1. 4
      api/app/lib/controllers/analysis/network.js
  2. 3
      api/config.js
  3. 25
      web-network/client/src/sections/network/containers/tableShow.js

4
api/app/lib/controllers/analysis/network.js

@ -430,8 +430,8 @@ async function createInvoke (ctx, next) {
if (data) { if (data) {
try { try {
const dataToIota = data const dataToIota = data
let iotaResponse = await ctx.app.fs.iotRequest.post(`/capabilities/invoke`, dataToIota) let iotaResponse = await ctx.app.fs.iotInvoke.post(`capabilities/invoke`, {data:dataToIota})
rslt = JSON.parse(iotaResponse) rslt = iotaResponse
error = null; error = null;
} catch (err) { } catch (err) {
ctx.fs.logger.error(`path: ${ctx.path}, error: ${err}`); ctx.fs.logger.error(`path: ${ctx.path}, error: ${err}`);

3
api/config.js

@ -333,6 +333,9 @@ const product = {
root: IOT_PROXY + '/_iota_api', root: IOT_PROXY + '/_iota_api',
dataWord: 'text' dataWord: 'text'
}, { }, {
name: 'iotInvoke',
root: IOT_PROXY + '/_iota_api',
},{
name: 'godRequest', name: 'godRequest',
root: GOD_URL, root: GOD_URL,
params: { params: {

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

@ -7,7 +7,8 @@ import moment from 'moment'
const Network = props => { const Network = props => {
const { dispatch, actions, user, clientHeight, thingId, deviceListAlarms, devicesCardStatusList, project, token,thingStatus } = props const { dispatch, actions, user, clientHeight, thingId, deviceListAlarms, devicesCardStatusList, project, token,thingStatus } = props
const { analysis } = actions const { analysis } = actions
const form = useRef() //表单 // const form = useRef() //表单
const [form] = Form.useForm();
const [deployData, setDeployData] = useState([]) const [deployData, setDeployData] = useState([])
const [deviceData, setDeviceData] = useState([]) const [deviceData, setDeviceData] = useState([])
const [deviceMetasDeployed, setDeviceMetasDeployed] = useState([]) const [deviceMetasDeployed, setDeviceMetasDeployed] = useState([])
@ -26,6 +27,7 @@ const Network = props => {
const [controlId,setControlId]=useState('') const [controlId,setControlId]=useState('')
const [id,setId]=useState('')//设计设备的id const [id,setId]=useState('')//设计设备的id
const [param,setParam]=useState('')//开与关 const [param,setParam]=useState('')//开与关
const [text,setText]=useState('')
const DeviceTypes = { const DeviceTypes = {
'DTU': 'DTU', 'DTU': 'DTU',
'gateway': '网关', 'gateway': '网关',
@ -267,8 +269,9 @@ const Network = props => {
}; };
const res= await dispatch(analysis.invokeCapability(values,token)) const res= await dispatch(analysis.invokeCapability(values,token))
setStatus(res?.payload?.data?.data?.info?.includes('离线')?false:true) setStatus(res?.payload?.data?.data?.data?.info?.includes('离线')?false:true)
} form.setFieldValue('status', res?.payload?.data?.data?.data?.info)
}
const columns = [ const columns = [
{ {
title: '设备名称', title: '设备名称',
@ -406,18 +409,24 @@ const Network = props => {
dataSource={lastData}></Table> dataSource={lastData}></Table>
<Modal <Modal
title='开关' title='开关'
footer={[ <Button key="back" onClick={()=>{setModalVis(false)}}>
取消
</Button>,
<Button key="submit" type="primary" disabled={!status} onClick={okHandler}>
下发指令
</Button>]}
visible={modalVis} visible={modalVis}
onCancel={()=>{setModalVis(false)}}
// sensorId={sensorId} // sensorId={sensorId}
onOk={okHandler}
okText='升级' okText='升级'
> >
<Form> <Form
form={form}
>
<Form.Item label='状态' name='status'> <Form.Item label='状态' name='status'>
<Input disabled/> <Input disabled />
</Form.Item> </Form.Item>
<Form.Item label='开关' name='open'> <Form.Item label='开关' name='open'>
<Switch disabled={status} onChange={switchChange}></Switch> <Switch disabled={!status} onChange={switchChange}></Switch>
</Form.Item> </Form.Item>
</Form> </Form>
</Modal> </Modal>

Loading…
Cancel
Save