|
|
@ -21,9 +21,10 @@ export default function HistoryTable(props) { |
|
|
|
const [visible, setVisible]= useState(false) |
|
|
|
|
|
|
|
const [timeRange, setTimeRange] = useState([moment(new Date(new Date().getTime() - 7*86400*1000)), moment()]) |
|
|
|
const videoRef = useRef() |
|
|
|
const modalVideoRef = useRef() |
|
|
|
const [videoUrl, setVideoUrl] = useState('') |
|
|
|
const intervalPlayRef = useRef() |
|
|
|
const recordRef = useRef() |
|
|
|
const columns = [ |
|
|
|
{ |
|
|
|
title: '序号', |
|
|
@ -50,7 +51,7 @@ export default function HistoryTable(props) { |
|
|
|
key: 'operation', |
|
|
|
width: 150, |
|
|
|
align: "center", |
|
|
|
render: (va, record) => <a onClick={()=>{getOneVideoPlay(record.start_time, record.end_time)}}>查看回放</a>, |
|
|
|
render: (va, record) => <a onClick={()=>{getOneVideoPlay(record)}}>查看回放</a>, |
|
|
|
}, |
|
|
|
]; |
|
|
|
|
|
|
@ -73,25 +74,47 @@ export default function HistoryTable(props) { |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
const getOneVideoPlay =(time1, time2)=>{ |
|
|
|
ajax.getOneVideoPlay({id: id, start_time: time1, end_time: time2, type: 2}).then( |
|
|
|
const getOneVideoPlay =(record)=>{ |
|
|
|
recordRef.current = record |
|
|
|
ajax.getOneVideoPlay({id: id, start_time: record.start_time, end_time: record.end_time, type: 2}).then( |
|
|
|
res=>{ |
|
|
|
if(res.status == 20000){ |
|
|
|
setVisible(true) |
|
|
|
setVideoUrl(res.data.url) |
|
|
|
setTimeout(() => { |
|
|
|
modalVideoRef.current.changeUrl(res.data.url) |
|
|
|
}, 300); |
|
|
|
startIntervalToPlay() |
|
|
|
} |
|
|
|
} |
|
|
|
).catch(err=>{ |
|
|
|
|
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
const startIntervalToPlay = ()=>{ |
|
|
|
if(!intervalPlayRef.current){ |
|
|
|
intervalPlayRef.current = setInterval(() => { |
|
|
|
ajax.getOutRoadVideoPlaying({id: id, start_time: recordRef.current.start_time, end_time: recordRef.current.end_time, type:2}).then((res)=>{ |
|
|
|
if(res.status == 20000){ |
|
|
|
|
|
|
|
} |
|
|
|
}) |
|
|
|
}, 5000); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
const stopIntervalToClose = ()=>{ |
|
|
|
if(modalVideoRef.current){ |
|
|
|
modalVideoRef.current.closeVideo() |
|
|
|
// videoRef.current = null |
|
|
|
} |
|
|
|
if(intervalPlayRef.current){ |
|
|
|
clearInterval(intervalPlayRef.current) |
|
|
|
intervalPlayRef.current = null |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// const stopIntervalToClose = ()=>{ |
|
|
|
// if(intervalPlayRef.current){ |
|
|
|
// clearInterval(intervalPlayRef.current) |
|
|
|
// intervalPlayRef.current = null |
|
|
|
// } |
|
|
|
// } |
|
|
|
|
|
|
|
useEffect(()=>{ |
|
|
|
getHistoryVideoList() |
|
|
@ -99,6 +122,9 @@ export default function HistoryTable(props) { |
|
|
|
|
|
|
|
useEffect(()=>{ |
|
|
|
getHistoryVideoList() |
|
|
|
return ()=>{ |
|
|
|
stopIntervalToClose() |
|
|
|
} |
|
|
|
},[]) |
|
|
|
|
|
|
|
return ( |
|
|
@ -141,13 +167,11 @@ export default function HistoryTable(props) { |
|
|
|
open={visible} |
|
|
|
width={1200} |
|
|
|
title="" |
|
|
|
onCancel={()=>{setVisible(false);}} |
|
|
|
onCancel={()=>{setVisible(false);stopIntervalToClose(); }} |
|
|
|
footer={null} |
|
|
|
> |
|
|
|
<div> |
|
|
|
{ |
|
|
|
videoUrl ? <VideoPlay videoType="mp4" ref={videoRef} videoUrl={videoUrl} ></VideoPlay> : null |
|
|
|
} |
|
|
|
<VideoPlay videoType="mp4" ref={modalVideoRef} ></VideoPlay> |
|
|
|
</div> |
|
|
|
</Modal> |
|
|
|
</div> |
|
|
|