@ -126,7 +126,7 @@ const DetailList = (props) => {
dataIndex : 'userName' ,
align : 'center' ,
render : ( text , record ) => {
return record . user . name
return record ? . user ? . name || ''
}
} , {
title : '上报时间' ,
@ -254,6 +254,7 @@ const PatrolTable = (props) => {
const [ record , setRecord ] = useState ( ) ;
const [ dateRange , setDateRange ] = useState ( ) ;
const [ detailVisible , setDetailVisible ] = useState ( false )
const [ activeTabKey1 , setActiveTabKey1 ] = useState ( 'tab1' ) ;
const { RangePicker } = DatePicker ;
@ -265,15 +266,27 @@ const PatrolTable = (props) => {
useEffect ( ( ) => {
if ( record ) {
let query = { userId : record . id , reportType : 'patrol' }
if ( ( dateRange && dateRange instanceof Array ) ) {
query . startTime = moment ( dateRange [ 0 ] ) . startOf ( 'day' ) . format ( 'YYYY-MM-DD HH:mm:ss' )
query . endTime = moment ( dateRange [ 1 ] ) . endOf ( 'day' ) . format ( 'YYYY-MM-DD HH:mm:ss' )
}
dispatch ( getReportList ( query ) ) ;
queryData ( ) ;
}
} , [ record , dateRange ] )
const queryData = ( ) => {
let query = { userId : record . id , reportType : 'patrol' }
if ( ( dateRange && dateRange instanceof Array ) ) {
query . startTime = moment ( dateRange [ 0 ] ) . startOf ( 'day' ) . format ( 'YYYY-MM-DD HH:mm:ss' )
query . endTime = moment ( dateRange [ 1 ] ) . endOf ( 'day' ) . format ( 'YYYY-MM-DD HH:mm:ss' )
}
dispatch ( getReportList ( query ) ) ;
}
useEffect ( ( ) => {
if ( activeTabKey1 && activeTabKey1 == 'tab2' ) {
setRecord ( null ) ;
} else if ( activeTabKey1 && activeTabKey1 == 'tab1' ) {
setRecord ( userList [ 0 ] ) ;
}
} , [ activeTabKey1 ] )
const handelRefresh = ( ) => {
let query = { userId : record . id , reportType : 'patrol' }
dispatch ( getReportList ( query ) ) ;
@ -303,7 +316,6 @@ const PatrolTable = (props) => {
< / d i v > ] ,
tab2 : < PatrolGis userId = { ( record || { } ) . id } dispatch = { dispatch } reportList = { reportList } / >
} ;
const [ activeTabKey1 , setActiveTabKey1 ] = useState ( 'tab1' ) ;
const onTab1Change = ( key ) => {
setActiveTabKey1 ( key ) ;
} ;