fix: pagination count not updating after deleting data in subtable (#5648)

* fix: pagination count not updating after deleting data in subtable

* fix: bug

* fix: bug
This commit is contained in:
Katherine 2024-11-15 12:58:57 +08:00 committed by GitHub
parent 514a63edbf
commit e4fd3679d5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 10 additions and 12 deletions

View File

@ -2,9 +2,7 @@
"version": "1.4.0-alpha.11", "version": "1.4.0-alpha.11",
"npmClient": "yarn", "npmClient": "yarn",
"useWorkspaces": true, "useWorkspaces": true,
"npmClientArgs": [ "npmClientArgs": ["--ignore-engines"],
"--ignore-engines"
],
"command": { "command": {
"version": { "version": {
"forcePublish": true, "forcePublish": true,

View File

@ -181,7 +181,7 @@ export const SubTable: any = observer(
return { return {
current: currentPage > page ? page : currentPage, current: currentPage > page ? page : currentPage,
pageSize: pageSize || 10, pageSize: pageSize || 10,
total: field?.value?.length, total: field?.value,
onChange: (page, pageSize) => { onChange: (page, pageSize) => {
setCurrentPage(page); setCurrentPage(page);
setPageSize(pageSize); setPageSize(pageSize);

View File

@ -200,23 +200,23 @@ const useTableColumns = (props: { showDel?: any; isSubTable?: boolean }, paginat
render: (v, record, index) => { render: (v, record, index) => {
if (props.showDel(record)) { if (props.showDel(record)) {
return ( return (
<CloseOutlined <div
style={{ cursor: 'pointer', color: 'gray' }}
onClick={() => { onClick={() => {
return action(() => { return action(() => {
const fieldIndex = (current - 1) * pageSize + index; const fieldIndex = (current - 1) * pageSize + index;
const deleteCount = field.value[fieldIndex] ? 1 : 2;
spliceArrayState(field, { spliceArrayState(field, {
startIndex: fieldIndex, startIndex: fieldIndex,
deleteCount: 1, deleteCount: deleteCount,
});
field.value.splice(fieldIndex, 1);
setTimeout(() => {
field.value[field.value.length] = null;
}); });
field.value.splice(fieldIndex, deleteCount);
field.setInitialValue(field.value);
return field.onInput(field.value); return field.onInput(field.value);
}); });
}} }}
/> >
<CloseOutlined style={{ cursor: 'pointer', color: 'gray' }} />
</div>
); );
} }
return; return;