|
@ -1,9 +1,12 @@ |
|
|
import React, { useState ,useRef} from 'react' |
|
|
import React, { useState ,useRef} from 'react' |
|
|
|
|
|
import { connect } from "react-redux"; |
|
|
import { Modal,Form,Row,Col,Spin,Notification } from '@douyinfe/semi-ui'; |
|
|
import { Modal,Form,Row,Col,Spin,Notification } from '@douyinfe/semi-ui'; |
|
|
import { IconTickCircle } from '@douyinfe/semi-icons'; |
|
|
import { IconTickCircle } from '@douyinfe/semi-icons'; |
|
|
function nvrModal(props){ |
|
|
function nvrModal(props){ |
|
|
const {modalName}=props |
|
|
const {modalName}=props |
|
|
const nvrData = props.nvrData||{} |
|
|
const { dispatch, actions, user, loading } = props; |
|
|
|
|
|
const venderList=props.venderList||[]//设备厂家 |
|
|
|
|
|
const nvrData = props.nvrData||{}//修改时传来的值 |
|
|
const form = useRef(); |
|
|
const form = useRef(); |
|
|
const [visible, setVisible] = useState(false);//是否显示弹框 |
|
|
const [visible, setVisible] = useState(false);//是否显示弹框 |
|
|
const [isloading,setloading] = useState(false);//是否显示loading |
|
|
const [isloading,setloading] = useState(false);//是否显示loading |
|
@ -11,6 +14,7 @@ function nvrModal(props){ |
|
|
const [step,setstep] = useState(0)//第几步 |
|
|
const [step,setstep] = useState(0)//第几步 |
|
|
const [okText,setokText] = useState('测试校验')//ok弹框text 右边 |
|
|
const [okText,setokText] = useState('测试校验')//ok弹框text 右边 |
|
|
const [cancelText,setcancelText] = useState('取消')//取消弹框text 左边 |
|
|
const [cancelText,setcancelText] = useState('取消')//取消弹框text 左边 |
|
|
|
|
|
const [formObj,setformObj] = useState()//接口入参 |
|
|
const opts ={//添加完成确认后通知 |
|
|
const opts ={//添加完成确认后通知 |
|
|
title:'Hi', |
|
|
title:'Hi', |
|
|
content:'添加成功', |
|
|
content:'添加成功', |
|
@ -19,10 +23,32 @@ function nvrModal(props){ |
|
|
function showDialog() {//打开弹框 |
|
|
function showDialog() {//打开弹框 |
|
|
setVisible(true); |
|
|
setVisible(true); |
|
|
} |
|
|
} |
|
|
|
|
|
function positionForm(val){ |
|
|
|
|
|
let zz = /^(-?\d+)(\.\d+)?$/ |
|
|
|
|
|
if(!val){ |
|
|
|
|
|
return '请输入或拾取高德经纬度坐标' |
|
|
|
|
|
} |
|
|
|
|
|
else if(val.split(',').length!=2){ |
|
|
|
|
|
return '请输入格式为116.354169,39.835452的经纬度坐标' |
|
|
|
|
|
} |
|
|
|
|
|
else if(!zz.test(val.split(',')[0])){ |
|
|
|
|
|
return '只能填写数字' |
|
|
|
|
|
} |
|
|
|
|
|
else if(!zz.test(val.split(',')[1])){ |
|
|
|
|
|
return '只能填写数字' |
|
|
|
|
|
} |
|
|
|
|
|
else{ |
|
|
|
|
|
return '' |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
function handleOk() {//点击弹框确定 右边按钮 |
|
|
function handleOk() {//点击弹框确定 右边按钮 |
|
|
if(step==0){ |
|
|
if(step==0){ |
|
|
form.current.validate() |
|
|
form.current.validate() |
|
|
.then(values=>{//表单校验成功 |
|
|
.then(values=>{//表单校验成功 |
|
|
|
|
|
let valuesObj=JSON.parse(JSON.stringify(values)) |
|
|
|
|
|
valuesObj.longitude=values.position.split(',')[0] |
|
|
|
|
|
valuesObj.latitude=values.position.split(',')[1] |
|
|
|
|
|
setformObj(valuesObj) |
|
|
setloading(true); |
|
|
setloading(true); |
|
|
setTimeout(() => { |
|
|
setTimeout(() => { |
|
|
setloadingTip('...接受成功') |
|
|
setloadingTip('...接受成功') |
|
@ -43,8 +69,10 @@ function nvrModal(props){ |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
else{ |
|
|
else{ |
|
|
Notification.success(opts) |
|
|
dispatch(actions.equipmentWarehouse.addchangeNvr(formObj)).then(res => { |
|
|
setVisible(false); |
|
|
Notification.success(opts) |
|
|
|
|
|
setVisible(false); |
|
|
|
|
|
}) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
function handleAfterClose(){//在关闭之后 |
|
|
function handleAfterClose(){//在关闭之后 |
|
@ -63,7 +91,7 @@ function nvrModal(props){ |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
function handleLocation(){//高德经纬度 |
|
|
function handleLocation(){//高德经纬度 |
|
|
console.log('handleLocationhandleLocation'); |
|
|
window.open('https://lbs.amap.com/tools/picker','_blank') |
|
|
} |
|
|
} |
|
|
return ( |
|
|
return ( |
|
|
<> |
|
|
<> |
|
@ -88,29 +116,30 @@ function nvrModal(props){ |
|
|
getFormApi={formApi => form.current = formApi}> |
|
|
getFormApi={formApi => form.current = formApi}> |
|
|
<Row> |
|
|
<Row> |
|
|
<Col span={12}> |
|
|
<Col span={12}> |
|
|
<Form.Input field='UserName' label='设备编号:' initValue={nvrData.name||''} placeholder='请输入设备编号' style={{ width:149 }} |
|
|
<Form.Input maxLength='39' field='serialNo' label='设备编号:' initValue={nvrData.name||''} placeholder='请输入设备编号' style={{ width:149 }} |
|
|
rules={[ |
|
|
rules={[ |
|
|
{ required: true, message: '请输入设备编号' } |
|
|
{ required: true, message: '请输入设备编号' } |
|
|
]}/> |
|
|
]}/> |
|
|
</Col> |
|
|
</Col> |
|
|
<Col span={12}> |
|
|
<Col span={12}> |
|
|
<Form.Input field='Use11rName' label='行政区区码:' placeholder='请输入行政区区码' style={{ width:149 }}/> |
|
|
<Form.Input maxLength='15' field='regionCode' label='行政区区码:' placeholder='请输入行政区区码' style={{ width:149 }}/> |
|
|
</Col> |
|
|
</Col> |
|
|
<Col span={24}> |
|
|
<Col span={24}> |
|
|
<Form.Input field='Use11rName11' label='设备名称:' placeholder='请输入设备名称、常用项目或位置定义' style={{ width:421 }} |
|
|
<Form.Input maxLength='36' field='name' label='设备名称:' placeholder='请输入设备名称、常用项目或位置定义' style={{ width:421 }} |
|
|
rules={[ |
|
|
rules={[ |
|
|
{ required: true, message: '请输入设备名称、常用项目或位置定义' } |
|
|
{ required: true, message: '请输入设备名称、常用项目或位置定义' } |
|
|
]}/> |
|
|
]}/> |
|
|
</Col> |
|
|
</Col> |
|
|
<Col span={24}> |
|
|
<Col span={24}> |
|
|
<Form.Select label="设备厂家:" field='business2' placeholder='请选择设备厂家' style={{ width: 421 }}> |
|
|
<Form.Select label="设备厂家:" field='venderId' placeholder='请选择设备厂家' style={{ width: 421 }}> |
|
|
<Form.Select.Option value="abc">Semi</Form.Select.Option> |
|
|
{venderList.map((item,index)=>( |
|
|
<Form.Select.Option value="ulikeCam">轻颜相机</Form.Select.Option> |
|
|
<Form.Select.Option key={index} value={item.id}>{item.name}</Form.Select.Option> |
|
|
<Form.Select.Option value="toutiao">今日头条</Form.Select.Option> |
|
|
))} |
|
|
</Form.Select> |
|
|
</Form.Select> |
|
|
</Col> |
|
|
</Col> |
|
|
<Col span={24} style={{display:'flex'}}> |
|
|
<Col span={24} style={{display:'flex'}}> |
|
|
<Form.Input field='Use11rName131' label='安装位置:' placeholder='请输入或拾取高德经纬度坐标' style={{ width:386 }} |
|
|
<Form.Input maxLength='39' field='position' label='安装位置:' placeholder='请输入或拾取高德经纬度坐标' style={{ width:386 }} |
|
|
|
|
|
validate={positionForm} |
|
|
rules={[ |
|
|
rules={[ |
|
|
{ required: true, message: '请输入或拾取高德经纬度坐标' } |
|
|
{ required: true, message: '请输入或拾取高德经纬度坐标' } |
|
|
]}/> |
|
|
]}/> |
|
@ -148,4 +177,14 @@ function nvrModal(props){ |
|
|
); |
|
|
); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
export default nvrModal |
|
|
function mapStateToProps(state) { |
|
|
|
|
|
const { auth, global, members } = state; |
|
|
|
|
|
return { |
|
|
|
|
|
loading: members.isRequesting, |
|
|
|
|
|
user: auth.user, |
|
|
|
|
|
actions: global.actions, |
|
|
|
|
|
members: members.data, |
|
|
|
|
|
}; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export default connect(mapStateToProps)(nvrModal); |