|
|
@@ -1,14 +1,16 @@
|
|
|
import {FC} from 'react';
|
|
|
import {useDicionaryType} from '../hooks';
|
|
|
-import {Card} from 'antd';
|
|
|
+import {Button, Card, message} from 'antd';
|
|
|
import {Table, TableTools} from '@components';
|
|
|
import {context, pageContext, searchContext} from '../context';
|
|
|
import PutModal from './modal';
|
|
|
-import {getDictionaryList} from '@apis';
|
|
|
+import {getDictionaryList, syncDepartment} from '@apis';
|
|
|
import {useContextSection, useQueryTableList, useSupertube} from '@hooks';
|
|
|
import {OriginalListParams, GetDictionaryListParams} from '@models';
|
|
|
import StorageModal from './type-modal';
|
|
|
import {useHandle} from './hooks';
|
|
|
+import {useMutation} from '@tanstack/react-query';
|
|
|
+import {Sync} from '@icon-park/react';
|
|
|
|
|
|
const TableList: FC = function() {
|
|
|
const type = useDicionaryType();
|
|
|
@@ -34,6 +36,17 @@ const TableList: FC = function() {
|
|
|
{onAdd, onClose, onEditStoreClose},
|
|
|
] = useHandle(refetch);
|
|
|
const isSuper = useSupertube();
|
|
|
+
|
|
|
+ const {isLoading, mutate} = useMutation({
|
|
|
+ mutationFn: syncDepartment,
|
|
|
+ onSuccess({msg}) {
|
|
|
+ if (msg === '200') {
|
|
|
+ refetch();
|
|
|
+ message.success('同步完成');
|
|
|
+ }
|
|
|
+ },
|
|
|
+ });
|
|
|
+
|
|
|
return (
|
|
|
<>
|
|
|
<Card className="table-wrapper">
|
|
|
@@ -42,7 +55,15 @@ const TableList: FC = function() {
|
|
|
onAdd={isSuper ? onAdd : void 0}
|
|
|
pageContext={pageContext}
|
|
|
searchContext={searchContext}
|
|
|
- />
|
|
|
+ >
|
|
|
+ {type === '部门字典' && <Button
|
|
|
+ icon={<Sync theme="outline" className="anticon" />}
|
|
|
+ loading={isLoading}
|
|
|
+ onClick={() => mutate()}
|
|
|
+ >
|
|
|
+ 同步
|
|
|
+ </Button>}
|
|
|
+ </TableTools>
|
|
|
|
|
|
<Table
|
|
|
columns={columns}
|