Commit 155a3d61 authored by 卢均锐's avatar 卢均锐

Merge branch 'v2' of http://10.0.0.22:3000/lingxi/lingxi-business-paltform into v2

* 'v2' of http://10.0.0.22:3000/lingxi/lingxi-business-paltform: 🐞 fix(TableLayout 组件): 修改跨页多选的问题
parents e2ff0fdd ab54e95f
......@@ -9,6 +9,7 @@ import { createFormActions, FormEffectHooks } from '@formily/antd';
import { useStateFilterSearchLinkageEffect } from '@/formSchema/effects/useFilterSearch';
import { searchSelectGetSelectCategoryOptionEffect } from '@/pages/transaction/effect/index';
import { useLinkageUtils } from '@/utils/formEffectUtils';
import { useRowSelectionTable } from '@/hooks/useRowSelectionTable';
const { onFormMount$ } = FormEffectHooks
interface Iprops {
......@@ -58,7 +59,15 @@ const Table: React.FC<Iprops> = (props: any) => {
getCheckboxProps
} = props;
const tableRef = useRef<any>({});
const [selectRow, selectRowFns] = useRowSelectionTable({
customKey: rowKey || 'id',
extendsSelection: {
onChange: (_rowKeys: any) => {
fetchRowkeys(selectRowFns.selectedRowKeys)
},
getCheckboxProps: (record) => getCheckboxProps && getCheckboxProps(record)
}
});
/** 列表数据 */
const fetchData = (params?: any) => {
return new Promise((resolve, reject) => {
......@@ -77,20 +86,11 @@ const Table: React.FC<Iprops> = (props: any) => {
})
}
/**多选 */
const [selectedRowKeys, setSelectedRowKeys] = useState<Array<number>>([]);
const rowSelection: TableRowSelection<any> = {
selectedRowKeys: selectedRowKeys,
onChange: (rowKeys: any) => {
fetchRowkeys(rowKeys)
setSelectedRowKeys(rowKeys);
},
getCheckboxProps: (record) => getCheckboxProps && getCheckboxProps(record)
}
useImperativeHandle(reload, () => ({
reload: () => {
tableRef.current.reload();
selectRowFns.setSelectRow([])
selectRowFns.setSelectedRowKeys([])
}
}));
......@@ -129,7 +129,7 @@ const Table: React.FC<Iprops> = (props: any) => {
currentRef={tableRef}
columns={columns}
tableProps={{ rowKey: rowKey ? rowKey : 'id' }}
rowSelection={selectedRow && rowSelection}
rowSelection={selectedRow && selectRow}
fetchTableData={(params: any) => fetchData(params)}
controlRender={
<NiceForm
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment