type RecordId = number | string;
|
|
interface BatchSavedRow {
|
clientRowId: string;
|
id: RecordId;
|
}
|
|
/** ID 仅传入本次后置事件,不改变表单的新增/编辑状态或原参数引用。 */
|
export function buildAfterSubmitParameter<T extends { formData?: { id?: RecordId } }>(parameter: T, id?: RecordId) {
|
return { ...parameter, id: id ?? parameter.formData?.id ?? '' };
|
}
|
|
/** 批量响应按客户端行标识关联,不依赖服务端返回顺序。 */
|
export function getBatchSubmitRecordIds(rows: { __batchRowId?: string; id?: RecordId; jnpfId?: string }[], savedRows: BatchSavedRow[] = [], isEdit = false) {
|
const ids = new Map(savedRows.map((row) => [row.clientRowId, row.id]));
|
return rows.map((row) => ids.get(row.__batchRowId || row.jnpfId || '') ?? (isEdit ? (row.id ?? '') : ''));
|
}
|