Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

feat: input-table change事件data增加index #11523

Merged
merged 1 commit into from
Jan 21, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions packages/amis/src/renderers/Form/InputTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ export interface TableState {
filteredItems: Array<TableDataItem>;
columns: Array<any>;
editIndex: string;
rowIndex?: string;
isCreateMode?: boolean;
page?: number;
total?: number;
Expand Down Expand Up @@ -968,11 +969,12 @@ export default class FormTable<
*/
async dispatchEvent(eventName: string, eventData: any = {}) {
const {dispatchEvent} = this.props;
const {items} = this.state;
const {items, rowIndex} = this.state;
const rendererEvent = await dispatchEvent(
eventName,
resolveEventData(this.props, {
value: [...items],
rowIndex,
...eventData
})
);
Expand Down Expand Up @@ -1221,7 +1223,7 @@ export default class FormTable<

convertToRawPath(path: string, state?: Partial<TableState>) {
const {filteredItems, items} = {...this.state, ...state};
const list = path.split('.').map((item: any) => parseInt(item, 10));
const list = `${path}`.split('.').map((item: any) => parseInt(item, 10));
const firstRow = filteredItems[list[0]];
list[0] = items.findIndex(item => item === firstRow);
if (list[0] === -1) {
Expand Down Expand Up @@ -1777,6 +1779,7 @@ export default class FormTable<
filteredItems: state.filteredItems.map(a =>
a === origin ? value : a
),
rowIndex: editIndex,
/** 记录最近一次编辑记录,用于取消编辑数据回溯, */
...(lastModifiedRow?.index === editIndex
? {}
Expand Down Expand Up @@ -1804,6 +1807,7 @@ export default class FormTable<

Object.assign(newState, {
items,
rowIndex: rowIndexes as string,
...this.transformState(items, state)
});
callback = this.lazyEmitValue;
Expand Down
Loading