File tree Expand file tree Collapse file tree 2 files changed +5
-4
lines changed
src/pages/Organization/Tree Expand file tree Collapse file tree 2 files changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -47,7 +47,7 @@ const MoveTree: React.FC<Props> = (props) => {
4747 setSelectedKeys,
4848 handleUpdateDepartment,
4949 } ,
50- } = useOrgTreeHook ( { currentKey : currentNode . id } ) ;
50+ } = useOrgTreeHook ( { currentKey : currentNode . id , initDeps : [ currentNode ] } ) ;
5151
5252 const handleSubmit = async ( ) => {
5353 if ( selectedKeys && selectedKeys . length > 0 ) {
Original file line number Diff line number Diff line change 1- import { Key , useEffect , useState } from 'react' ;
1+ import { DependencyList , Key , useEffect , useState } from 'react' ;
22import { App } from 'antd' ;
33import { useActive } from '@/hooks' ;
44import { BASIC_INTL } from '@/constant' ;
@@ -13,12 +13,13 @@ import {
1313} from '@/services/organization' ;
1414
1515export type Props = {
16+ initDeps ?: DependencyList ;
1617 currentKey ?: string ;
1718 onSelect ?: ( id : string , name : string ) => void ;
1819} ;
1920
2021export default function useOrgTreeHook ( props : Props ) {
21- const { onSelect, currentKey } = props ;
22+ const { initDeps = [ ] , onSelect, currentKey } = props ;
2223 const intl = useIntl ( ) ;
2324 const { message } = App . useApp ( ) ;
2425
@@ -93,7 +94,7 @@ export default function useOrgTreeHook(props: Props) {
9394 useEffect ( ( ) => {
9495 showInitLoading ( ) ;
9596 getRootOrganizationData ( { } ) ;
96- } , [ ] ) ;
97+ } , initDeps ) ;
9798
9899 const { run : doDelete } = useRequest ( deleteDepartment , {
99100 manual : true ,
You can’t perform that action at this time.
0 commit comments