mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-07-02 03:02: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,
|
fieldPath: dataIndex,
|
||||||
filterByTk: record.id,
|
filterByTk: record.id,
|
||||||
onSuccess: (values) => {
|
onSuccess: (values) => {
|
||||||
const oldData = this.resource.getData();
|
this.resource.setItem(recordIndex, {
|
||||||
const newData = oldData.slice(); // 浅拷贝
|
|
||||||
newData[recordIndex] = {
|
|
||||||
...record,
|
...record,
|
||||||
...values,
|
...values,
|
||||||
};
|
});
|
||||||
this.resource.setData(newData);
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
// await this.resource.refresh();
|
// await this.resource.refresh();
|
||||||
|
@ -139,6 +139,13 @@ export class MultiRecordResource<TDataItem = any> extends BaseRecordResource<TDa
|
|||||||
await this.refresh();
|
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> {
|
async refresh(): Promise<void> {
|
||||||
const { data, meta } = await this.runAction<TDataItem[], any>('list', {
|
const { data, meta } = await this.runAction<TDataItem[], any>('list', {
|
||||||
method: 'get',
|
method: 'get',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user