|
@ -1,168 +1,282 @@ |
|
|
import React, { useState ,useRef,useEffect,useImperativeHandle} from 'react' |
|
|
import React, { useState, useRef, useEffect, useImperativeHandle } from "react"; |
|
|
import { connect } from "react-redux"; |
|
|
import { connect } from "react-redux"; |
|
|
import { Form,Row,Col,Button,CheckboxGroup, Checkbox,Radio,Input } from '@douyinfe/semi-ui'; |
|
|
import { |
|
|
import { IconEdit,IconPlayCircle } from '@douyinfe/semi-icons'; |
|
|
Form, |
|
|
|
|
|
Row, |
|
|
|
|
|
Col, |
|
|
|
|
|
Button, |
|
|
|
|
|
CheckboxGroup, |
|
|
|
|
|
Checkbox, |
|
|
|
|
|
Radio, |
|
|
|
|
|
Input, |
|
|
|
|
|
} from "@douyinfe/semi-ui"; |
|
|
|
|
|
import { IconEdit, IconPlayCircle } from "@douyinfe/semi-icons"; |
|
|
import "./cameraModal.less"; |
|
|
import "./cameraModal.less"; |
|
|
function nvrCamera({cRef}){ |
|
|
import PerfectScrollbar from "perfect-scrollbar"; |
|
|
|
|
|
|
|
|
|
|
|
let equipmentScrollbar; |
|
|
|
|
|
function nvrCamera({ dispatch, actions, nvrRef }) { |
|
|
|
|
|
const { equipmentWarehouse } = actions; |
|
|
const form = useRef(); |
|
|
const form = useRef(); |
|
|
const [nvrCheckList, setNvrCheckList] = useState([]);//nvr视频流多选 |
|
|
const [nvrCheckList, setNvrCheckList] = useState([]); //nvr视频流多选 |
|
|
const [NVRcameraList,setNVRcameraList]=useState([])//nvr视频流列表 |
|
|
const [NVRcameraList, setNVRcameraList] = useState([]); //nvr视频流列表 |
|
|
const [isAllChoose,setIsAllChoose]=useState(false)//全选 |
|
|
const [isAllChoose, setIsAllChoose] = useState(false); //全选 |
|
|
const [equipmentNum,setEquipmentNum]=useState('')//nvr视频编号 |
|
|
const [equipmentNum, setEquipmentNum] = useState(""); //nvr视频编号 |
|
|
function NvrChangeName(e,index){//nvr摄像头视频流获取修改名称 |
|
|
|
|
|
let NvrchangeList = JSON.parse(JSON.stringify(NVRcameraList)) |
|
|
useEffect(() => { |
|
|
NvrchangeList[index].change=true |
|
|
NVRcameraList |
|
|
setNVRcameraList(NvrchangeList) |
|
|
? (equipmentScrollbar = new PerfectScrollbar("#video_streaming", { |
|
|
e.stopPropagation() |
|
|
suppressScrollX: true, |
|
|
|
|
|
})) |
|
|
|
|
|
: ""; |
|
|
|
|
|
}, [NVRcameraList]); |
|
|
|
|
|
useEffect(() => { |
|
|
|
|
|
const videoStreaming = document.getElementById("video_streaming"); |
|
|
|
|
|
if (videoStreaming && equipmentScrollbar) { |
|
|
|
|
|
equipmentScrollbar.update(); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
function NvrChangeName(e, index) { |
|
|
|
|
|
//nvr摄像头视频流获取修改名称 |
|
|
|
|
|
let NvrchangeList = JSON.parse(JSON.stringify(NVRcameraList)); |
|
|
|
|
|
NvrchangeList[index].change = true; |
|
|
|
|
|
setNVRcameraList(NvrchangeList); |
|
|
|
|
|
e.stopPropagation(); |
|
|
} |
|
|
} |
|
|
function nvronBlur(index){//nvr摄像头名称修改失去焦点 |
|
|
function nvronBlur(index) { |
|
|
let NvrchangeList = JSON.parse(JSON.stringify(NVRcameraList)) |
|
|
//nvr摄像头名称修改失去焦点 |
|
|
NvrchangeList[index].change=false |
|
|
let NvrchangeList = JSON.parse(JSON.stringify(NVRcameraList)); |
|
|
setNVRcameraList(NvrchangeList) |
|
|
NvrchangeList[index].change = false; |
|
|
|
|
|
setNVRcameraList(NvrchangeList); |
|
|
} |
|
|
} |
|
|
function inputchange(e,index){//nvr摄像头名称修改 |
|
|
function inputchange(e, index) { |
|
|
let NvrchangeList = JSON.parse(JSON.stringify(NVRcameraList)) |
|
|
//nvr摄像头名称修改 |
|
|
NvrchangeList[index].name=e |
|
|
let NvrchangeList = JSON.parse(JSON.stringify(NVRcameraList)); |
|
|
setNVRcameraList(NvrchangeList) |
|
|
console.log(e); |
|
|
|
|
|
NvrchangeList[index].name = e; |
|
|
|
|
|
setNVRcameraList(NvrchangeList); |
|
|
} |
|
|
} |
|
|
function toggle(e,index){//nvr云台支持 |
|
|
function toggle(e, index) { |
|
|
let NvrchangeList = JSON.parse(JSON.stringify(NVRcameraList)) |
|
|
//nvr云台支持 |
|
|
NvrchangeList[index].support=e.target.checked |
|
|
let NvrchangeList = JSON.parse(JSON.stringify(NVRcameraList)); |
|
|
setNVRcameraList(NvrchangeList) |
|
|
NvrchangeList[index].support = e.target.checked; |
|
|
e.stopPropagation() |
|
|
setNVRcameraList(NvrchangeList); |
|
|
|
|
|
e.stopPropagation(); |
|
|
} |
|
|
} |
|
|
function getVideoList(){ |
|
|
function getVideoList() { |
|
|
form.current.validate().then(values=>{//表单校验成功 |
|
|
form.current |
|
|
let chooseList=[] |
|
|
.validate() |
|
|
let nvrCameraList=[{ |
|
|
.then((values) => { |
|
|
id:10, |
|
|
//表单校验成功 |
|
|
name:'南昌县1', |
|
|
let chooseList = []; |
|
|
number:'111111111111111111', |
|
|
let valuess = JSON.parse(JSON.stringify(values)); |
|
|
support:false, |
|
|
valuess.streamId = values.serialNo; |
|
|
change:false, |
|
|
delete valuess.serialNo; |
|
|
},{ |
|
|
dispatch(equipmentWarehouse.getVideoStreaming(valuess)).then((res) => { |
|
|
id:20, |
|
|
let data = res.payload.data.map((item) => { |
|
|
name:'南昌县2', |
|
|
item.change = false; |
|
|
number:'222222222222222222', |
|
|
item.support = false; |
|
|
support:false, |
|
|
return item; |
|
|
change:false, |
|
|
}); |
|
|
},{ |
|
|
console.log(data); |
|
|
id:30, |
|
|
setNVRcameraList(data); |
|
|
name:'南昌县3', |
|
|
for (let index = 0; index < data.length; index++) { |
|
|
number:'333333333333333333', |
|
|
chooseList.push(data[index].id); |
|
|
support:false, |
|
|
} |
|
|
change:false, |
|
|
console.log(chooseList); |
|
|
},{ |
|
|
setNvrCheckList(chooseList); |
|
|
id:40, |
|
|
setIsAllChoose(true); |
|
|
name:'南昌县4', |
|
|
}); |
|
|
number:'444444444444444444', |
|
|
}) |
|
|
support:false, |
|
|
.catch((errors) => { |
|
|
change:false, |
|
|
//表单校验失败 |
|
|
}] |
|
|
console.log("errors", errors); |
|
|
setNVRcameraList(nvrCameraList) |
|
|
}); |
|
|
for (let index = 0; index < nvrCameraList.length; index++) { |
|
|
|
|
|
chooseList.push(nvrCameraList[index].id) |
|
|
|
|
|
} |
|
|
|
|
|
setNvrCheckList(chooseList) |
|
|
|
|
|
setIsAllChoose(true) |
|
|
|
|
|
}) |
|
|
|
|
|
.catch(errors=>{//表单校验失败 |
|
|
|
|
|
console.log('errors',errors); |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
} |
|
|
function allChoose(e){//全选/全不选 |
|
|
function allChoose(e) { |
|
|
let chooseList=[] |
|
|
//全选/全不选 |
|
|
if(NVRcameraList.length==nvrCheckList.length){ |
|
|
let chooseList = []; |
|
|
setNvrCheckList([]) |
|
|
if (NVRcameraList.length == nvrCheckList.length) { |
|
|
setIsAllChoose(false) |
|
|
setNvrCheckList([]); |
|
|
} |
|
|
setIsAllChoose(false); |
|
|
else{ |
|
|
} else { |
|
|
for (let index = 0; index < NVRcameraList.length; index++) { |
|
|
for (let index = 0; index < NVRcameraList.length; index++) { |
|
|
chooseList.push(NVRcameraList[index].id) |
|
|
chooseList.push(NVRcameraList[index].id); |
|
|
} |
|
|
} |
|
|
setNvrCheckList(chooseList) |
|
|
setNvrCheckList(chooseList); |
|
|
setIsAllChoose(true) |
|
|
setIsAllChoose(true); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
function playVideo(e) {//nvr播放视频 |
|
|
function playVideo(e) { |
|
|
console.log('22222222222222222'); |
|
|
//nvr播放视频 |
|
|
e.stopPropagation() |
|
|
console.log("22222222222222222"); |
|
|
|
|
|
e.stopPropagation(); |
|
|
} |
|
|
} |
|
|
// useImperativeHandle(cRef,() => ({//传给父组件方法 |
|
|
useImperativeHandle(nvrRef, () => ({ |
|
|
// //aa即为子组件暴露给父组件的方法 |
|
|
//传给父组件方法 |
|
|
// getDate : form.current.validate, |
|
|
//aa即为子组件暴露给父组件的方法 |
|
|
// // resetFluoriteCamera : form.current.reset |
|
|
resetFluoriteCamera: form.current.reset, |
|
|
// })) |
|
|
equipmentNum: equipmentNum, |
|
|
|
|
|
NVRcameraList: NVRcameraList.filter((v) => |
|
|
|
|
|
nvrCheckList.some((e) => e == v.id) |
|
|
|
|
|
), |
|
|
|
|
|
})); |
|
|
return ( |
|
|
return ( |
|
|
<> |
|
|
<> |
|
|
<Form |
|
|
<Form |
|
|
allowEmpty |
|
|
allowEmpty |
|
|
labelPosition='left' |
|
|
labelPosition="left" |
|
|
labelAlign='left' |
|
|
labelAlign="left" |
|
|
labelWidth= '115px' |
|
|
labelWidth="115px" |
|
|
onValueChange={values=>{setEquipmentNum(values.equipmentNum)}} |
|
|
onValueChange={(values) => { |
|
|
getFormApi={formApi => form.current = formApi}> |
|
|
setEquipmentNum(values.serialNo); |
|
|
<div style={{display:'flex'}}> |
|
|
}} |
|
|
<Form.Input field='equipmentNum' maxLength='39' label='设备编号:' initValue={''} placeholder='请输入设备编号' style={{ width:307 }} |
|
|
getFormApi={(formApi) => (form.current = formApi)} |
|
|
rules={[ |
|
|
> |
|
|
{ required: true, message: '请输入设备编号' }, |
|
|
<div style={{ display: "flex" }}> |
|
|
{ pattern: '^[A-Za-z0-9]+$', message: '只能输入数字或者字母' } |
|
|
<Form.Input |
|
|
]}/> |
|
|
field="serialNo" |
|
|
<Button disabled={!equipmentNum.length>0} theme='solid' type='primary' onClick={()=>{getVideoList()}} style={{ marginLeft: 8,marginTop:12 }}>视频流获取</Button> |
|
|
maxLength="39" |
|
|
{NVRcameraList.length>0?<div style={{display: 'flex',alignItems: 'center',marginLeft: 211}}> |
|
|
label="设备编号:" |
|
|
|
|
|
initValue={""} |
|
|
|
|
|
placeholder="请输入设备编号" |
|
|
|
|
|
style={{ width: 307 }} |
|
|
|
|
|
rules={[ |
|
|
|
|
|
{ required: true, message: "请输入设备编号" }, |
|
|
|
|
|
{ pattern: "^[A-Za-z0-9]+$", message: "只能输入数字或者字母" }, |
|
|
|
|
|
]} |
|
|
|
|
|
/> |
|
|
|
|
|
<Button |
|
|
|
|
|
disabled={!equipmentNum.length > 0} |
|
|
|
|
|
theme="solid" |
|
|
|
|
|
type="primary" |
|
|
|
|
|
onClick={() => { |
|
|
|
|
|
getVideoList(); |
|
|
|
|
|
}} |
|
|
|
|
|
style={{ marginLeft: 8, marginTop: 12 }} |
|
|
|
|
|
> |
|
|
|
|
|
视频流获取 |
|
|
|
|
|
</Button> |
|
|
|
|
|
{NVRcameraList.length > 0 ? ( |
|
|
|
|
|
<div |
|
|
|
|
|
style={{ display: "flex", alignItems: "center", marginLeft: 211 }} |
|
|
|
|
|
> |
|
|
<Radio |
|
|
<Radio |
|
|
checked={isAllChoose} |
|
|
checked={isAllChoose} |
|
|
mode="advanced" |
|
|
mode="advanced" |
|
|
onChange={e=>allChoose(e)} |
|
|
onChange={(e) => allChoose(e)} |
|
|
aria-label="全选"> |
|
|
aria-label="全选" |
|
|
|
|
|
> |
|
|
全选 |
|
|
全选 |
|
|
</Radio> |
|
|
</Radio> |
|
|
</div>:''} |
|
|
</div> |
|
|
</div> |
|
|
) : ( |
|
|
|
|
|
"" |
|
|
|
|
|
)} |
|
|
|
|
|
</div> |
|
|
<Row> |
|
|
<Row> |
|
|
<CheckboxGroup type='pureCard' direction='vertical' aria-label="视频流获取" |
|
|
<CheckboxGroup |
|
|
value={nvrCheckList} |
|
|
type="pureCard" |
|
|
|
|
|
direction="vertical" |
|
|
|
|
|
aria-label="视频流获取" |
|
|
|
|
|
value={nvrCheckList} |
|
|
onChange={(nvrCheck) => { |
|
|
onChange={(nvrCheck) => { |
|
|
setNvrCheckList(nvrCheck); |
|
|
setNvrCheckList(nvrCheck); |
|
|
// console.log('11111111111',nvrCheck); |
|
|
if (NVRcameraList.length == nvrCheck.length) { |
|
|
if(NVRcameraList.length==nvrCheck.length){ |
|
|
setIsAllChoose(true); |
|
|
setIsAllChoose(true) |
|
|
} else { |
|
|
} |
|
|
setIsAllChoose(false); |
|
|
else{ |
|
|
|
|
|
setIsAllChoose(false) |
|
|
|
|
|
} |
|
|
} |
|
|
}}> |
|
|
}} |
|
|
{NVRcameraList.length>0?NVRcameraList.map((item,index)=>( |
|
|
> |
|
|
<Col key={index} span={12} style={{display:'flex',justifyContent:'center',marginTop:12}}> |
|
|
<div id="video_streaming" style={{ maxHeight: 300,position: "relative"}}> |
|
|
<Checkbox value={item.id} |
|
|
{NVRcameraList.length > 0 |
|
|
extra={ |
|
|
? NVRcameraList.map((item, index) => ( |
|
|
<div> |
|
|
<Col |
|
|
<div style={{display:'flex',alignItems:'center',justifyContent:'space-between',height:30}}> |
|
|
key={index} |
|
|
<div>通道名称:{item.change?<Input autofocus style={{width:100}} value={item.name} onChange={e=>inputchange(e,index)} onBlur={()=>nvronBlur(index)}></Input>:item.name}</div> |
|
|
span={12} |
|
|
<div style={{display:'flex',alignItems:'center'}}> |
|
|
style={{ |
|
|
<IconEdit |
|
|
display: "flex", |
|
|
style={{fontSize:16,marginLeft:18,cursor: "pointer",color:'#1859C1'}} |
|
|
justifyContent: "center", |
|
|
onClick={e=>NvrChangeName(e,index)}/> |
|
|
marginTop: 12, |
|
|
</div> |
|
|
}} |
|
|
</div> |
|
|
> |
|
|
<div style={{marginTop:8,width:246}}>设备编号:{item.number}</div> |
|
|
<Checkbox |
|
|
<div style={{marginTop:12,display:'flex',justifyContent:'space-between',alignItems:'center'}}> |
|
|
value={item.id} |
|
|
<IconPlayCircle size='extra-large' style={{color:'#1859C1',}} onClick={e=>playVideo(e)}/> |
|
|
extra={ |
|
|
<Radio |
|
|
<div> |
|
|
checked={item.support} |
|
|
<div |
|
|
mode="advanced" |
|
|
style={{ |
|
|
onChange={e=>toggle(e,index)} |
|
|
display: "flex", |
|
|
aria-label="单选" |
|
|
alignItems: "center", |
|
|
> |
|
|
justifyContent: "space-between", |
|
|
云台支持 |
|
|
height: 30, |
|
|
</Radio> |
|
|
}} |
|
|
</div> |
|
|
> |
|
|
</div> |
|
|
<div> |
|
|
} |
|
|
通道名称: |
|
|
style={{width:280,border:'1px solid #F9F9F9',}}> |
|
|
{item.change ? ( |
|
|
</Checkbox> |
|
|
<Input |
|
|
</Col> |
|
|
autofocus |
|
|
)):''} |
|
|
style={{ width: 100 }} |
|
|
|
|
|
value={item.name} |
|
|
|
|
|
onChange={(e) => inputchange(e, index)} |
|
|
|
|
|
onBlur={() => nvronBlur(index)} |
|
|
|
|
|
></Input> |
|
|
|
|
|
) : ( |
|
|
|
|
|
item.name |
|
|
|
|
|
)} |
|
|
|
|
|
</div> |
|
|
|
|
|
<div |
|
|
|
|
|
style={{ |
|
|
|
|
|
display: "flex", |
|
|
|
|
|
alignItems: "center", |
|
|
|
|
|
}} |
|
|
|
|
|
> |
|
|
|
|
|
<IconEdit |
|
|
|
|
|
style={{ |
|
|
|
|
|
fontSize: 16, |
|
|
|
|
|
marginLeft: 18, |
|
|
|
|
|
cursor: "pointer", |
|
|
|
|
|
color: "#1859C1", |
|
|
|
|
|
}} |
|
|
|
|
|
onClick={(e) => NvrChangeName(e, index)} |
|
|
|
|
|
/> |
|
|
|
|
|
</div> |
|
|
|
|
|
</div> |
|
|
|
|
|
<div style={{ marginTop: 8, width: 246 }}> |
|
|
|
|
|
设备编号:{item.parent} |
|
|
|
|
|
</div> |
|
|
|
|
|
<div |
|
|
|
|
|
style={{ |
|
|
|
|
|
marginTop: 12, |
|
|
|
|
|
display: "flex", |
|
|
|
|
|
justifyContent: "space-between", |
|
|
|
|
|
alignItems: "center", |
|
|
|
|
|
}} |
|
|
|
|
|
> |
|
|
|
|
|
<IconPlayCircle |
|
|
|
|
|
size="extra-large" |
|
|
|
|
|
style={{ color: "#1859C1" }} |
|
|
|
|
|
onClick={(e) => playVideo(e)} |
|
|
|
|
|
/> |
|
|
|
|
|
<Radio |
|
|
|
|
|
checked={item.support} |
|
|
|
|
|
mode="advanced" |
|
|
|
|
|
onChange={(e) => toggle(e, index)} |
|
|
|
|
|
aria-label="单选" |
|
|
|
|
|
> |
|
|
|
|
|
云台支持 |
|
|
|
|
|
</Radio> |
|
|
|
|
|
</div> |
|
|
|
|
|
</div> |
|
|
|
|
|
} |
|
|
|
|
|
style={{ width: 280, border: "1px solid #F9F9F9" }} |
|
|
|
|
|
></Checkbox> |
|
|
|
|
|
</Col> |
|
|
|
|
|
)) |
|
|
|
|
|
: ""} |
|
|
|
|
|
</div> |
|
|
</CheckboxGroup> |
|
|
</CheckboxGroup> |
|
|
</Row> |
|
|
</Row> |
|
|
</Form> |
|
|
</Form> |
|
|