mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 08:26:21 +00:00
fix: issue with adding data to sub-table after deletion (#5568)
This commit is contained in:
parent
0b762cf89f
commit
14f843ef79
@ -165,7 +165,7 @@ export const SubTable: any = observer(
|
|||||||
};
|
};
|
||||||
const getFilter = () => {
|
const getFilter = () => {
|
||||||
const targetKey = collectionField?.targetKey || 'id';
|
const targetKey = collectionField?.targetKey || 'id';
|
||||||
const list = (field.value || []).map((option) => option[targetKey]).filter(Boolean);
|
const list = (field.value || []).map((option) => option?.[targetKey]).filter(Boolean);
|
||||||
const filter = list.length ? { $and: [{ [`${targetKey}.$ne`]: list }] } : {};
|
const filter = list.length ? { $and: [{ [`${targetKey}.$ne`]: list }] } : {};
|
||||||
return filter;
|
return filter;
|
||||||
};
|
};
|
||||||
@ -235,6 +235,7 @@ export const SubTable: any = observer(
|
|||||||
// 计算总页数,并跳转到最后一页
|
// 计算总页数,并跳转到最后一页
|
||||||
const totalPages = Math.ceil(field.value.length / (field.componentProps?.pageSize || 10));
|
const totalPages = Math.ceil(field.value.length / (field.componentProps?.pageSize || 10));
|
||||||
setCurrentPage(totalPages);
|
setCurrentPage(totalPages);
|
||||||
|
return field.onInput(field.value);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{t('Add new')}
|
{t('Add new')}
|
||||||
|
@ -191,10 +191,15 @@ const useTableColumns = (props: { showDel?: any; isSubTable?: boolean }, paginat
|
|||||||
onClick={() => {
|
onClick={() => {
|
||||||
return action(() => {
|
return action(() => {
|
||||||
const fieldIndex = (current - 1) * pageSize + index;
|
const fieldIndex = (current - 1) * pageSize + index;
|
||||||
const updatedValue = [...field.value];
|
spliceArrayState(field, {
|
||||||
updatedValue.splice(fieldIndex, 1);
|
startIndex: fieldIndex,
|
||||||
field.value = updatedValue;
|
deleteCount: 1,
|
||||||
field.onInput(field.value);
|
});
|
||||||
|
field.value.splice(fieldIndex, 1);
|
||||||
|
setTimeout(() => {
|
||||||
|
field.value[field.value.length] = null;
|
||||||
|
});
|
||||||
|
return field.onInput(field.value);
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
Loading…
Reference in New Issue
Block a user