6 changed files with 506 additions and 71 deletions
-
2src/components/TableModule/index.jsx
-
156src/pages/OutRoadMgm/OutDeviceMgm/OutMonitorMgm/HistoryTable.jsx
-
13src/pages/OutRoadMgm/OutDeviceMgm/OutMonitorMgm/index.scss
-
189src/pages/OutRoadMgm/OutDeviceMgm/OutMonitorMgm/loadable.jsx
-
106src/pages/OutRoadMgm/OutDeviceMgm/OutNvrMgm/loadable.jsx
-
23src/services/search.js
@ -0,0 +1,156 @@ |
|||||
|
import React, { useEffect, useState, useRef } from "react" |
||||
|
import { Button, message , Input, Modal ,Table ,DatePicker } from "antd" |
||||
|
import { IconPda ,VideoPlay } from '@/components' |
||||
|
import { useNavigate } from "react-router-dom" |
||||
|
import './index.scss' |
||||
|
import ajax from "@/services" |
||||
|
import { useDispatch,useSelector } from "react-redux" |
||||
|
import { setFirstPageMap } from "@/store/common.js" |
||||
|
import axios from 'axios' |
||||
|
import { dictionary } from "@/config/common"; |
||||
|
import moment from "moment"; |
||||
|
|
||||
|
export default function HistoryTable(props) { |
||||
|
const {id} = props |
||||
|
const [tableData, setTableData] = useState([ ]) |
||||
|
const [total, setTotal] = useState(0) |
||||
|
const [pageData, setPageData] = useState({ |
||||
|
pn: 1, |
||||
|
page_size: dictionary?.pageSizeOptions[0] ? dictionary.pageSizeOptions[0] : 15 |
||||
|
}) |
||||
|
const [visible, setVisible]= useState(false) |
||||
|
|
||||
|
const [timeRange, setTimeRange] = useState([moment(new Date(new Date().getTime() - 365*86400*1000)), moment()]) |
||||
|
const videoRef = useRef() |
||||
|
const [videoUrl, setVideoUrl] = useState('') |
||||
|
const intervalPlayRef = useRef() |
||||
|
const columns = [ |
||||
|
{ |
||||
|
title: '序号', |
||||
|
width: 150, |
||||
|
dataIndex: 'name', |
||||
|
key: 'name', |
||||
|
align: "center", |
||||
|
render: (va, record,index) => <span>{index + 1}</span>, |
||||
|
}, |
||||
|
{ |
||||
|
title: '开始时间', |
||||
|
dataIndex: 'start_time', |
||||
|
key: 'start_time', |
||||
|
align: "center" |
||||
|
}, |
||||
|
{ |
||||
|
title: '结束时间', |
||||
|
dataIndex: 'end_time', |
||||
|
key: 'end_time', |
||||
|
align: "center" |
||||
|
}, |
||||
|
{ |
||||
|
title: '操作', |
||||
|
key: 'operation', |
||||
|
width: 150, |
||||
|
align: "center", |
||||
|
render: (va, record) => <a onClick={()=>{getOneVideoPlay(record.start_time, record.end_time)}}>查看回放</a>, |
||||
|
}, |
||||
|
]; |
||||
|
|
||||
|
const getHistoryVideoList = ()=>{ |
||||
|
let start_time = timeRange[0].format('YYYY-MM-DD HH:mm:ss'), |
||||
|
end_time = timeRange[1].format('YYYY-MM-DD HH:mm:ss'); |
||||
|
ajax.getHistoryVideoList({...pageData, start_time, end_time}).then( |
||||
|
res=>{ |
||||
|
if(res.status == 20000){ |
||||
|
setTableData(res.data) |
||||
|
setTotal(res.total ? res.total: 1000) |
||||
|
}else{ |
||||
|
setTableData([]) |
||||
|
setTotal(0) |
||||
|
} |
||||
|
} |
||||
|
).catch(err=>{ |
||||
|
setTableData([]) |
||||
|
setTotal(0) |
||||
|
}) |
||||
|
} |
||||
|
|
||||
|
const getOneVideoPlay =(time1, time2)=>{ |
||||
|
ajax.getOneVideoPlay({id: id, start_time: time1, end_time: time2, type: 2}).then( |
||||
|
res=>{ |
||||
|
if(res.status == 20000){ |
||||
|
setVisible(true) |
||||
|
setVideoUrl(res.data.url) |
||||
|
} |
||||
|
} |
||||
|
).catch(err=>{ |
||||
|
|
||||
|
}) |
||||
|
} |
||||
|
|
||||
|
// const stopIntervalToClose = ()=>{ |
||||
|
// if(intervalPlayRef.current){ |
||||
|
// clearInterval(intervalPlayRef.current) |
||||
|
// intervalPlayRef.current = null |
||||
|
// } |
||||
|
// } |
||||
|
|
||||
|
useEffect(()=>{ |
||||
|
getHistoryVideoList() |
||||
|
},[pageData]) |
||||
|
|
||||
|
useEffect(()=>{ |
||||
|
getHistoryVideoList() |
||||
|
},[]) |
||||
|
|
||||
|
return ( |
||||
|
<div className="table-block"> |
||||
|
<div className="search-part" style={{display: "flex",justifyContent:"space-between",marginBottom: '10px'}}> |
||||
|
<div className="time-item" style={{width: '400px',display: 'flex', alignItems:"center"}}> |
||||
|
<span style={{display: "block", width: '90px'}}>回放时间</span> |
||||
|
<DatePicker.RangePicker value={timeRange} onChange={(e)=>{setTimeRange(e)}} showTime allowClear={false} /> |
||||
|
</div> |
||||
|
<Button type="primary" onClick={getHistoryVideoList}>查询</Button> |
||||
|
</div> |
||||
|
<div className="table-part"> |
||||
|
<Table |
||||
|
columns={columns} |
||||
|
dataSource={tableData} |
||||
|
rowKey={(row)=>row.start_time} |
||||
|
scroll={{ |
||||
|
y: 450, |
||||
|
}} |
||||
|
pagination={{ |
||||
|
total: total, |
||||
|
pageSizeOptions: dictionary?.pageSizeOptions, |
||||
|
current: pageData.pn, |
||||
|
pageSize: pageData.page_size, |
||||
|
onChange:(targetPn, targetSize)=>{ |
||||
|
if(pageData.page_size != targetSize){ |
||||
|
setPageData({ |
||||
|
pn:1, page_size: targetSize |
||||
|
}) |
||||
|
}else{ |
||||
|
setPageData({ |
||||
|
pn:targetPn, page_size: targetSize |
||||
|
}) |
||||
|
} |
||||
|
} |
||||
|
}} |
||||
|
/> |
||||
|
</div> |
||||
|
<Modal |
||||
|
open={visible} |
||||
|
width={1200} |
||||
|
title="" |
||||
|
onCancel={()=>{setVisible(false);}} |
||||
|
footer={null} |
||||
|
> |
||||
|
<div> |
||||
|
{ |
||||
|
videoUrl ? <VideoPlay videoType="mp4" ref={videoRef} videoUrl={videoUrl} ></VideoPlay> : null |
||||
|
} |
||||
|
</div> |
||||
|
</Modal> |
||||
|
</div> |
||||
|
|
||||
|
) |
||||
|
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue