|
|
@@ -1,15 +1,13 @@
|
|
|
-import {deleteMenu} from '@apis';
|
|
|
import {MenuListData} from '@models';
|
|
|
import {Button} from 'antd';
|
|
|
import {ColumnsType} from 'antd/es/table';
|
|
|
import {
|
|
|
- DOUBLE_BTN_WIDTH,
|
|
|
HUGE_TABLE_WIDTH,
|
|
|
MIDDLE_TABLE_WIDTH,
|
|
|
NORMAL_TABLE_WIDTH,
|
|
|
SMALL_TABLE_WIDTH,
|
|
|
} from '@utils';
|
|
|
-import {useTableModalEvent, useTableDeleteEvent} from '@hooks';
|
|
|
+import {useTableModalEvent} from '@hooks';
|
|
|
|
|
|
const tableColumns: ColumnsType<MenuListData> = [
|
|
|
{
|
|
|
@@ -45,12 +43,9 @@ const tableColumns: ColumnsType<MenuListData> = [
|
|
|
},
|
|
|
];
|
|
|
|
|
|
-export function useHandle(refetch: () => void) {
|
|
|
+export function useHandle() {
|
|
|
const [{visible, editId}, {onAdd, onEdit, onClose: onModalClose}] =
|
|
|
useTableModalEvent();
|
|
|
- const [pendingId, onDelete] = useTableDeleteEvent(deleteMenu, refetch, {
|
|
|
- label: 'PDA菜单',
|
|
|
- });
|
|
|
|
|
|
const columns: ColumnsType<MenuListData> = [
|
|
|
...tableColumns,
|
|
|
@@ -59,26 +54,17 @@ export function useHandle(refetch: () => void) {
|
|
|
dataIndex: 'id',
|
|
|
key: 'id',
|
|
|
fixed: 'right',
|
|
|
- width: DOUBLE_BTN_WIDTH,
|
|
|
- render(_, {id, name}) {
|
|
|
+ width: SMALL_TABLE_WIDTH,
|
|
|
+ render(_, {id}) {
|
|
|
return (
|
|
|
<>
|
|
|
<Button
|
|
|
type='text'
|
|
|
className='ant-text-btn-color-primary'
|
|
|
- disabled={pendingId === id}
|
|
|
onClick={onEdit(id)}
|
|
|
>
|
|
|
修改
|
|
|
</Button>
|
|
|
- <Button
|
|
|
- type='text'
|
|
|
- danger
|
|
|
- loading={pendingId === id}
|
|
|
- onClick={onDelete(id, name)}
|
|
|
- >
|
|
|
- 删除
|
|
|
- </Button>
|
|
|
</>
|
|
|
);
|
|
|
},
|