mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-07-01 10:42:19 +08:00
feat: resource setItem
This commit is contained in:
parent
090ee6df4c
commit
bb3d9a78ec
@ -170,13 +170,10 @@ export class TableModel extends DataBlockModel<TableModelStructure> {
|
||||
fieldPath: dataIndex,
|
||||
filterByTk: record.id,
|
||||
onSuccess: (values) => {
|
||||
const oldData = this.resource.getData();
|
||||
const newData = oldData.slice(); // 浅拷贝
|
||||
newData[recordIndex] = {
|
||||
this.resource.setItem(recordIndex, {
|
||||
...record,
|
||||
...values,
|
||||
};
|
||||
this.resource.setData(newData);
|
||||
});
|
||||
},
|
||||
});
|
||||
// await this.resource.refresh();
|
||||
|
@ -139,6 +139,13 @@ export class MultiRecordResource<TDataItem = any> extends BaseRecordResource<TDa
|
||||
await this.refresh();
|
||||
}
|
||||
|
||||
setItem(index: number, newDataItem: TDataItem) {
|
||||
const oldData = this.getData();
|
||||
const newData = oldData.slice(); // 浅拷贝
|
||||
newData[index] = { ...newDataItem };
|
||||
this.setData(newData);
|
||||
}
|
||||
|
||||
async refresh(): Promise<void> {
|
||||
const { data, meta } = await this.runAction<TDataItem[], any>('list', {
|
||||
method: 'get',
|
||||
|
Loading…
x
Reference in New Issue
Block a user