|
@ -2,14 +2,14 @@ import React, { useEffect, useState, useRef } from 'react' |
|
|
import { push } from 'react-router-redux'; |
|
|
import { push } from 'react-router-redux'; |
|
|
import request from 'superagent'; |
|
|
import request from 'superagent'; |
|
|
import { connect } from 'react-redux'; |
|
|
import { connect } from 'react-redux'; |
|
|
import { editCrane } from '../actions' |
|
|
import { editCrane, getCrane } from '../actions' |
|
|
import { |
|
|
import { |
|
|
BorderlessTableOutlined, BlockOutlined, RollbackOutlined, SaveOutlined |
|
|
BorderlessTableOutlined, BlockOutlined, RollbackOutlined, SaveOutlined |
|
|
} from '@ant-design/icons'; |
|
|
} from '@ant-design/icons'; |
|
|
import { Col, Row, Button, Modal, Form, Input, InputNumber, message } from 'antd'; |
|
|
import { Col, Row, Button, Modal, Form, Input, InputNumber, message, Switch } from 'antd'; |
|
|
import '../style.less' |
|
|
import '../style.less' |
|
|
|
|
|
|
|
|
function SetUp ({ dispatch }) { |
|
|
function SetUp ({ dispatch, craneData }) { |
|
|
const [form] = Form.useForm(); |
|
|
const [form] = Form.useForm(); |
|
|
const [renderMenu, setRenderMenu] = useState([]) |
|
|
const [renderMenu, setRenderMenu] = useState([]) |
|
|
const [renderForm, setRenderForm] = useState(false) |
|
|
const [renderForm, setRenderForm] = useState(false) |
|
@ -24,7 +24,40 @@ function SetUp ({ dispatch }) { |
|
|
} |
|
|
} |
|
|
}, { |
|
|
}, { |
|
|
n: '限位告警参数', |
|
|
n: '限位告警参数', |
|
|
ic: <BorderlessTableOutlined className='setup-icon' /> |
|
|
ic: <BorderlessTableOutlined className='setup-icon' />, |
|
|
|
|
|
click: () => { |
|
|
|
|
|
setRenderForm(true) |
|
|
|
|
|
setFormIndex(1) |
|
|
|
|
|
setFormItems([ |
|
|
|
|
|
{ |
|
|
|
|
|
label: '设备编号', |
|
|
|
|
|
name: 'device_no', |
|
|
|
|
|
type: 'string', |
|
|
|
|
|
disabled: true, |
|
|
|
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
label: '1级碰撞距离', |
|
|
|
|
|
name: 'dis_level_1', |
|
|
|
|
|
type: 'number', |
|
|
|
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
label: '3级碰撞距离', |
|
|
|
|
|
name: 'dis_level_3', |
|
|
|
|
|
type: 'number', |
|
|
|
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
label: '是否静音', |
|
|
|
|
|
name: 'mute', |
|
|
|
|
|
type: 'boolean', |
|
|
|
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
label: '2级碰撞距离', |
|
|
|
|
|
name: 'dis_level_2', |
|
|
|
|
|
type: 'number', |
|
|
|
|
|
}, |
|
|
|
|
|
]) |
|
|
|
|
|
initData() |
|
|
|
|
|
} |
|
|
}, { |
|
|
}, { |
|
|
n: '返回', |
|
|
n: '返回', |
|
|
ic: <RollbackOutlined className='setup-icon' />, |
|
|
ic: <RollbackOutlined className='setup-icon' />, |
|
@ -48,6 +81,7 @@ function SetUp ({ dispatch }) { |
|
|
label: '设备编号', |
|
|
label: '设备编号', |
|
|
name: 'device_no', |
|
|
name: 'device_no', |
|
|
type: 'string', |
|
|
type: 'string', |
|
|
|
|
|
disabled: true, |
|
|
}, |
|
|
}, |
|
|
{ |
|
|
{ |
|
|
label: '经度', |
|
|
label: '经度', |
|
@ -115,6 +149,7 @@ function SetUp ({ dispatch }) { |
|
|
type: 'number', |
|
|
type: 'number', |
|
|
}, |
|
|
}, |
|
|
]) |
|
|
]) |
|
|
|
|
|
initData() |
|
|
} |
|
|
} |
|
|
}, { |
|
|
}, { |
|
|
n: '返回', |
|
|
n: '返回', |
|
@ -141,6 +176,19 @@ function SetUp ({ dispatch }) { |
|
|
) |
|
|
) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const initData = () => { |
|
|
|
|
|
console.log(craneData); |
|
|
|
|
|
setTimeout(() => { |
|
|
|
|
|
form.setFieldsValue({ |
|
|
|
|
|
...craneData |
|
|
|
|
|
}) |
|
|
|
|
|
}, 0) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
|
initData() |
|
|
|
|
|
}, [craneData]) |
|
|
|
|
|
|
|
|
return ( |
|
|
return ( |
|
|
<div style={{ height: '100vh', background: '#000' }}> |
|
|
<div style={{ height: '100vh', background: '#000' }}> |
|
|
{ |
|
|
{ |
|
@ -162,7 +210,7 @@ function SetUp ({ dispatch }) { |
|
|
wrapperCol: { |
|
|
wrapperCol: { |
|
|
span: 18, |
|
|
span: 18, |
|
|
}, |
|
|
}, |
|
|
}} name="control-hooks" size='large'> |
|
|
}} name="control-hooks" size='large' style={{ display: 'flex', flexDirection: 'column', height: '95%', justifyContent: 'space-between', }}> |
|
|
<Row style={{ padding: '8% 12% 0' }}> |
|
|
<Row style={{ padding: '8% 12% 0' }}> |
|
|
{ |
|
|
{ |
|
|
(() => { |
|
|
(() => { |
|
@ -183,8 +231,12 @@ function SetUp ({ dispatch }) { |
|
|
> |
|
|
> |
|
|
{ |
|
|
{ |
|
|
item.type === 'number' ? |
|
|
item.type === 'number' ? |
|
|
<InputNumber style={{ width: '100%' }} /> : |
|
|
<InputNumber style={{ width: '100%' }} disabled={item.disabled} /> |
|
|
<Input /> |
|
|
: |
|
|
|
|
|
item.type == 'boolean' ? |
|
|
|
|
|
<Switch checkedChildren="开启" unCheckedChildren="关闭" defaultChecked size={'large'} disabled={item.disabled} /> |
|
|
|
|
|
: |
|
|
|
|
|
<Input disabled={item.disabled} /> |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
</Form.Item> |
|
|
</Form.Item> |
|
@ -210,10 +262,11 @@ function SetUp ({ dispatch }) { |
|
|
ic: <SaveOutlined className='setup-icon' />, |
|
|
ic: <SaveOutlined className='setup-icon' />, |
|
|
click: () => { |
|
|
click: () => { |
|
|
if (formIndex == 1) { |
|
|
if (formIndex == 1) { |
|
|
const values = form.getFieldsValue() |
|
|
let values = form.getFieldsValue() |
|
|
dispatch(editCrane(values)).then(res => { |
|
|
dispatch(editCrane({ ...craneData, ...values })).then(res => { |
|
|
if (res.success) { |
|
|
if (res.success) { |
|
|
message.success('修改配置信息成功') |
|
|
message.success('修改配置信息成功') |
|
|
|
|
|
dispatch(getCrane()) |
|
|
} else { |
|
|
} else { |
|
|
message.error('修改配置信息失败') |
|
|
message.error('修改配置信息失败') |
|
|
} |
|
|
} |
|
@ -238,15 +291,14 @@ function SetUp ({ dispatch }) { |
|
|
<div> |
|
|
<div> |
|
|
|
|
|
|
|
|
</div> |
|
|
</div> |
|
|
|
|
|
|
|
|
</div> |
|
|
</div> |
|
|
) |
|
|
) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function mapStateToProps (state) { |
|
|
function mapStateToProps (state) { |
|
|
const { auth } = state; |
|
|
const { crane } = state; |
|
|
return { |
|
|
return { |
|
|
|
|
|
craneData: crane.data || {} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|