From 2b29780c76cacd619c36f80822300f4d723f69cf Mon Sep 17 00:00:00 2001 From: runstone Date: Wed, 13 May 2026 18:12:01 +0800 Subject: [PATCH] feat(grid): add export selected rows and batch restore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 背景说明 恢复导出选中行的功能,并新增批量恢复行功能。用户现在可以在多行选中时, 通过右键菜单或工具栏导出选中的行,同时支持批量恢复已删除的行。 ## 修改内容 - exportCsv/exportJson/exportMarkdown/exportXlsx 支持可选 rowIds 参数 - 新增 rowsToExport 辅助函数,根据 rowIds 筛选要导出的行 - 右键菜单和工具栏新增"导出选中行"选项(CSV/XLSX/JSON/Markdown) - 新增 restoreRows 函数支持批量恢复已删除行 - 更新上下文菜单中恢复行的文案,支持单数/复数切换 - 补充 en/es/zh-CN 三语言国际化文案 ## 测试 - 建议补充:导出函数传入特定 rowIds 的筛选逻辑测试 - 建议补充:批量恢复已删除行的单元测试 - 建议补充:多选时状态栏显示边界测试 --- src/components/grid/DataGrid.vue | 45 ++++++++++++++++++++++++++-- src/composables/useDataGridEditor.ts | 7 +++++ src/composables/useDataGridExport.ts | 22 +++++++++----- src/i18n/locales/en.ts | 5 ++++ src/i18n/locales/es.ts | 5 ++++ src/i18n/locales/zh-CN.ts | 5 ++++ 6 files changed, 78 insertions(+), 11 deletions(-) diff --git a/src/components/grid/DataGrid.vue b/src/components/grid/DataGrid.vue index 9e436f97e..a851b97aa 100644 --- a/src/components/grid/DataGrid.vue +++ b/src/components/grid/DataGrid.vue @@ -927,6 +927,7 @@ const { requestDeleteRow, confirmDeleteRow, restoreRow, + restoreRows, pendingDeleteRowIds, requestDeleteRows, cloneRows, @@ -1111,6 +1112,22 @@ function affectedRowIds(): number[] { return []; } +function exportSelectedRowsCsv() { + return exportCsv(affectedRowIds()); +} + +function exportSelectedRowsXlsx() { + return exportXlsx(affectedRowIds()); +} + +function exportSelectedRowsJson() { + return exportJson(affectedRowIds()); +} + +function exportSelectedRowsMarkdown() { + return exportMarkdown(affectedRowIds()); +} + function isRowActive(index: number): boolean { const item = displayItems.value[index]; if (item && isRowSelected(item.id)) return true; @@ -2620,8 +2637,12 @@ defineExpose({ {{ isMultiRow ? t("grid.cloneRows", { count: multiRowCount }) : t("grid.cloneRow") }} - - {{ t("grid.restoreRow") }} + + + {{ isMultiRow ? t("grid.restoreRows", { count: multiRowCount }) : t("grid.restoreRow") }} {{ t("grid.exportXlsx") }} {{ t("grid.exportJson") }} {{ t("grid.exportMarkdown") }} + @@ -2664,7 +2694,7 @@ defineExpose({ (truncated) {{ t("grid.rowsAffected", { count: result.affected_rows }) }} {{ result.execution_time_ms }}ms - {{ selectionSummary }} + {{ selectionSummary }}