Skip to content

fix(grid): 批量/行级自定义 action 执行成功后列表不刷新 #2159

Description

@baozhoutao

问题

列表勾选多行后,点击底部 BulkActionBar 的批处理按钮(如「下推」「派工」等字符串型 `batchActions`),操作在服务端成功执行后,列表页不刷新,仍停留在旧数据。用户以为没生效或需要手动刷新。

同样的问题也存在于单行的自定义 action(RowActionMenu 的 `onAction`/`onActionDef`)。

根因

`ObjectGrid` 自取数据的 effect 只依赖 `refreshKey`(packages/plugin-grid/src/ObjectGrid.tsx:589),且全文没有订阅 `dataSource.onMutation`。而批处理有三条执行路径,只有两条会触发刷新:

路径 刷新?
富定义批量(BulkActionDialog)→ handleBulkDialogClose(result)setRefreshKey(k+1)
字符串 delete 分支 → onBulkDelete(外层负责刷新)
字符串非 delete 分支executeAction({type, params:{records}})(ObjectGrid.tsx:1629) ❌ 不刷新、不清选中
行级自定义 actionexecuteAction(...)(ObjectGrid.tsx:1494 / 1507) ❌ 不刷新

executeAction(ActionRunner)执行成功后不发任何 mutation/刷新信号,且批处理常走自定义 API(不经过 `dataSource.update`),连 adapter 的 mutation 事件都不会发 → grid 永远看不到变化。

方案(精准修复)

executeAction 返回 `Promise`(含 `.success`)。在这两条路径上 await 结果,成功后 `setRefreshKey(k+1)`(批量路径同时 `setSelectedRows([])` + `setSelectAllMatching(false)`),与现有 `handleBulkDialogClose` / delete 分支的刷新写法保持一致。

不改动 ActionRunner 底层,避免对导航/导出等非写 action 造成多余 refetch。

验证

  • objectui 加 ObjectGrid 回归测试:字符串型 batchAction 执行成功后必须 refetch 且清空选中。
  • framework app-showcase 加一个 batchAction 示例,live 复现 + 回归。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions