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'; ...@@ -9,6 +9,7 @@ import { createFormActions, FormEffectHooks } from '@formily/antd';
import { useStateFilterSearchLinkageEffect } from '@/formSchema/effects/useFilterSearch'; import { useStateFilterSearchLinkageEffect } from '@/formSchema/effects/useFilterSearch';
import { searchSelectGetSelectCategoryOptionEffect } from '@/pages/transaction/effect/index'; import { searchSelectGetSelectCategoryOptionEffect } from '@/pages/transaction/effect/index';
import { useLinkageUtils } from '@/utils/formEffectUtils'; import { useLinkageUtils } from '@/utils/formEffectUtils';
import { useRowSelectionTable } from '@/hooks/useRowSelectionTable';
const { onFormMount$ } = FormEffectHooks const { onFormMount$ } = FormEffectHooks
interface Iprops { interface Iprops {
...@@ -58,7 +59,15 @@ const Table: React.FC<Iprops> = (props: any) => { ...@@ -58,7 +59,15 @@ const Table: React.FC<Iprops> = (props: any) => {
getCheckboxProps getCheckboxProps
} = props; } = props;
const tableRef = useRef<any>({}); 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) => { const fetchData = (params?: any) => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
...@@ -77,20 +86,11 @@ const Table: React.FC<Iprops> = (props: any) => { ...@@ -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, () => ({ useImperativeHandle(reload, () => ({
reload: () => { reload: () => {
tableRef.current.reload(); tableRef.current.reload();
selectRowFns.setSelectRow([])
selectRowFns.setSelectedRowKeys([])
} }
})); }));
...@@ -129,7 +129,7 @@ const Table: React.FC<Iprops> = (props: any) => { ...@@ -129,7 +129,7 @@ const Table: React.FC<Iprops> = (props: any) => {
currentRef={tableRef} currentRef={tableRef}
columns={columns} columns={columns}
tableProps={{ rowKey: rowKey ? rowKey : 'id' }} tableProps={{ rowKey: rowKey ? rowKey : 'id' }}
rowSelection={selectedRow && rowSelection} rowSelection={selectedRow && selectRow}
fetchTableData={(params: any) => fetchData(params)} fetchTableData={(params: any) => fetchData(params)}
controlRender={ controlRender={
<NiceForm <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