Skip to content

Commit afa0f3b

Browse files
committed
fix: 修复打开移动组织弹窗时无法拉取最新数据
1 parent c7eca06 commit afa0f3b

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/pages/Organization/Tree/MoveTree.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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) {

src/pages/Organization/Tree/_hooks.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Key, useEffect, useState } from 'react';
1+
import { DependencyList, Key, useEffect, useState } from 'react';
22
import { App } from 'antd';
33
import { useActive } from '@/hooks';
44
import { BASIC_INTL } from '@/constant';
@@ -13,12 +13,13 @@ import {
1313
} from '@/services/organization';
1414

1515
export type Props = {
16+
initDeps?: DependencyList;
1617
currentKey?: string;
1718
onSelect?: (id: string, name: string) => void;
1819
};
1920

2021
export 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,

0 commit comments

Comments
 (0)