Browse Source

feat:fix bugs

dev
zhaobing’ 1 year ago
parent
commit
c675795190
  1. 4
      api/app/lib/controllers/analysis/network.js
  2. 5
      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) {
try {
const dataToIota = data
let iotaResponse = await ctx.app.fs.iotRequest.post(`/capabilities/invoke`, dataToIota)
rslt = JSON.parse(iotaResponse)
let iotaResponse = await ctx.app.fs.iotInvoke.post(`capabilities/invoke`, {data:dataToIota})
rslt = iotaResponse
error = null;
} catch (err) {
ctx.fs.logger.error(`path: ${ctx.path}, error: ${err}`);

5
api/config.js

@ -332,7 +332,10 @@ const product = {
name: 'iotRequest',
root: IOT_PROXY + '/_iota_api',
dataWord: 'text'
}, {
}, {
name: 'iotInvoke',
root: IOT_PROXY + '/_iota_api',
},{
name: 'godRequest',
root: GOD_URL,
params: {

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

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

Loading…
Cancel
Save