|
@@ -2,31 +2,40 @@ import {FC} from 'react';
|
|
|
import {ColumnsType} from 'antd/es/table';
|
|
|
import {ReserveWarningListData} from '@models';
|
|
|
import {Card} from 'antd';
|
|
|
-import {Table} from '@components';
|
|
|
-import {context, contextStateSelector, pageContext, searchContext} from '../context';
|
|
|
+import {Table, TableTools} from '@components';
|
|
|
+import {context, pageContext, searchContext} from '../context';
|
|
|
import {HUGE_TABLE_WIDTH, NORMAL_TABLE_WIDTH, SMALL_TABLE_WIDTH} from '@utils';
|
|
|
-import {getReserveWarningList} from '@apis';
|
|
|
-import {useContextSection, useQueryTableList} from '@hooks';
|
|
|
+import {exportWarning, getReserveWarningList} from '@apis';
|
|
|
+import {useContextSection, useQueryTableList, useTableExportEvent} from '@hooks';
|
|
|
|
|
|
const columns: ColumnsType<ReserveWarningListData> = [
|
|
|
- {title: '物料名称', dataIndex: 'materialName', key: 'materialName', width: HUGE_TABLE_WIDTH},
|
|
|
{title: '物料编号', dataIndex: 'wllbCode', key: 'wllbCode', width: NORMAL_TABLE_WIDTH},
|
|
|
- {title: '数量', dataIndex: 'amount', key: 'amount', width: SMALL_TABLE_WIDTH},
|
|
|
- {title: '最小数量', dataIndex: 'minNum', key: 'minNum', width: SMALL_TABLE_WIDTH},
|
|
|
- {title: '最大数量', dataIndex: 'maxNum', key: 'maxNum', width: SMALL_TABLE_WIDTH},
|
|
|
+ {title: '物料名称', dataIndex: 'materialName', key: 'materialName', width: HUGE_TABLE_WIDTH},
|
|
|
+ {title: '数量', dataIndex: 'amount', key: 'amount', width: SMALL_TABLE_WIDTH, align: 'right'},
|
|
|
+ {title: '最小数量', dataIndex: 'minNum', key: 'minNum', width: SMALL_TABLE_WIDTH, align: 'right'},
|
|
|
+ {title: '最大数量', dataIndex: 'maxNum', key: 'maxNum', width: SMALL_TABLE_WIDTH, align: 'right'},
|
|
|
];
|
|
|
|
|
|
const TableList: FC = function () {
|
|
|
- const params = useContextSection(context, contextStateSelector);
|
|
|
- const [{data, count}] = useQueryTableList({
|
|
|
+ const params = useContextSection(context, state => state[0]);
|
|
|
+ const [{data, count, isFetching}, {refetch}] = useQueryTableList({
|
|
|
queryFn: getReserveWarningList,
|
|
|
params,
|
|
|
pageContext,
|
|
|
searchContext,
|
|
|
});
|
|
|
|
|
|
+ const [isExporting, onExport] = useTableExportEvent({pageContext, context, fn: exportWarning});
|
|
|
+
|
|
|
return (
|
|
|
<Card className='table-wrapper'>
|
|
|
+ <TableTools
|
|
|
+ onRefresh={refetch}
|
|
|
+ isRefreshing={isFetching}
|
|
|
+ onExport={onExport}
|
|
|
+ isExporting={isExporting}
|
|
|
+ />
|
|
|
+
|
|
|
<Table
|
|
|
data={data}
|
|
|
count={count}
|