diff --git a/web/client/src/sections/fillion/components/patrolTable.js b/web/client/src/sections/fillion/components/patrolTable.js index 39cdcbb3..e8a79935 100644 --- a/web/client/src/sections/fillion/components/patrolTable.js +++ b/web/client/src/sections/fillion/components/patrolTable.js @@ -211,15 +211,21 @@ const DetailList = (props) => { const PatrolNameList = (props) => { const [users, setUsers] = useState([]); - const { onChange, record, userList, loading } = props; + const { onChange, record, userList, loading, activeTabKey1 } = props; const [selectRoad, setSelectRoad] = useState(); + useEffect(() => { - if (userList && userList instanceof Array && userList.length) { - setSelectRoad(userList[0].id) - // onChange(userList[0]); - } - }, [userList]) + + if (userList && userList instanceof Array && userList.length) { + setSelectRoad(userList[0].id) + // onChange(userList[0]); + } + if(activeTabKey1 == 'tab2'){ + setSelectRoad(null) + } + + }, [userList, activeTabKey1]) const columns = [ { @@ -271,7 +277,11 @@ const PatrolNameList = (props) => { onClick: () => { if (record) { // console.log('record:', record) - setSelectRoad(record.id); + let id = record.id + if(selectRoad == record.id){ + id = null + } + setSelectRoad(id); onChange(record); } }, @@ -376,6 +386,7 @@ const PatrolTable = (props) => { handleChangeRecord(record)} record={record} + activeTabKey1={activeTabKey1} userList={userList} loading={userLoading} />