feat(export): add streaming TXT data export
This commit is contained in:
1 parent
99b84cbc92
commit
78b3bb1ba1
17 files changed
+471
-81
No files matched your search
@@ -296,7 +296,7 @@ interface DataGridProps {
|
||||
cacheKey?: string;
|
||||
onExecuteSql?: (sql: string) => Promise<void>;
|
||||
fullExportResult?: (onProgress?: (info: { rowsExported: number; totalRows: number | null }) => void) => Promise<QueryResult | undefined>;
|
||||
queryResultExportRequest?: (options: { exportId: string; filePath: string; format: "csv" | "xlsx" }) => Promise<api.QueryResultExportRequest | undefined>;
|
||||
queryResultExportRequest?: (options: { exportId: string; filePath: string; format: "csv" | "xlsx" | "txt" }) => Promise<api.QueryResultExportRequest | undefined>;
|
||||
allExportResults?: Array<{ sheetName: string; result: QueryResult }>;
|
||||
exportFileBaseName?: string;
|
||||
customSaveHandler?: import("@/composables/useDataGridEditor").CustomSaveHandler;
|
||||
@@ -4870,6 +4870,12 @@ function exportSelectedRowsSql() {
|
||||
return exportSql(rowIds);
|
||||
}
|
||||
|
||||
function exportSelectedRowsTxt() {
|
||||
const rowIds = affectedRowIds();
|
||||
if (rowIds.length === 0) return;
|
||||
return exportTxt(rowIds);
|
||||
}
|
||||
|
||||
function executePreviewAction(action: { execute: (ctx: any) => any }) {
|
||||
const config = action.execute({
|
||||
result: props.result,
|
||||
@@ -6546,6 +6552,8 @@ const {
|
||||
exportAllResultsXlsx,
|
||||
exportSql,
|
||||
exportCurrentPageSql,
|
||||
exportTxt,
|
||||
exportCurrentPageTxt,
|
||||
copySql,
|
||||
} = useDataGridExport({
|
||||
columns: visibleColumns,
|
||||
@@ -6601,11 +6609,21 @@ const exportMenuItems = computed(() => {
|
||||
{ value: "selected-json", label: t("grid.exportSelectedRowsJson") },
|
||||
{ value: "selected-markdown", label: t("grid.exportSelectedRowsMarkdown") },
|
||||
{ value: "selected-sql", label: t("grid.exportSelectedRowsSql") },
|
||||
{ value: "selected-txt", label: t("grid.exportSelectedRowsTxt") },
|
||||
]
|
||||
: [];
|
||||
|
||||
if (!hasFullResultExport) {
|
||||
return [{ value: "csv", label: t("grid.exportCsv") }, { value: "xlsx", label: t("grid.exportXlsx") }, { value: "json", label: t("grid.exportJson") }, { value: "markdown", label: t("grid.exportMarkdown") }, { value: "sql", label: t("grid.exportSql") }, ...allResultItems, ...selectedItems];
|
||||
return [
|
||||
{ value: "csv", label: t("grid.exportCsv") },
|
||||
{ value: "xlsx", label: t("grid.exportXlsx") },
|
||||
{ value: "json", label: t("grid.exportJson") },
|
||||
{ value: "markdown", label: t("grid.exportMarkdown") },
|
||||
{ value: "sql", label: t("grid.exportSql") },
|
||||
{ value: "txt", label: t("grid.exportTxt") },
|
||||
...allResultItems,
|
||||
...selectedItems,
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
@@ -6614,11 +6632,13 @@ const exportMenuItems = computed(() => {
|
||||
{ value: "page-json", label: t("grid.exportCurrentPageJson") },
|
||||
{ value: "page-markdown", label: t("grid.exportCurrentPageMarkdown") },
|
||||
{ value: "page-sql", label: t("grid.exportCurrentPageSql") },
|
||||
{ value: "page-txt", label: t("grid.exportCurrentPageTxt") },
|
||||
{ value: "csv", label: t("grid.exportCurrentResultCsv"), separatorBefore: true },
|
||||
{ value: "xlsx", label: t("grid.exportCurrentResultXlsx") },
|
||||
{ value: "json", label: t("grid.exportCurrentResultJson") },
|
||||
{ value: "markdown", label: t("grid.exportCurrentResultMarkdown") },
|
||||
{ value: "sql", label: t("grid.exportCurrentResultSql") },
|
||||
{ value: "txt", label: t("grid.exportCurrentResultTxt") },
|
||||
...allResultItems,
|
||||
...selectedItems,
|
||||
];
|
||||
@@ -6635,17 +6655,20 @@ function selectExportMenuItem(value: string) {
|
||||
"page-json": exportCurrentPageJson,
|
||||
"page-markdown": exportCurrentPageMarkdown,
|
||||
"page-sql": exportCurrentPageSql,
|
||||
"page-txt": exportCurrentPageTxt,
|
||||
csv: exportCsv,
|
||||
xlsx: exportXlsx,
|
||||
"all-results-xlsx": exportAllResultsXlsx,
|
||||
json: exportJson,
|
||||
markdown: exportMarkdown,
|
||||
sql: exportSql,
|
||||
txt: exportTxt,
|
||||
"selected-csv": exportSelectedRowsCsv,
|
||||
"selected-xlsx": exportSelectedRowsXlsx,
|
||||
"selected-json": exportSelectedRowsJson,
|
||||
"selected-markdown": exportSelectedRowsMarkdown,
|
||||
"selected-sql": exportSelectedRowsSql,
|
||||
"selected-txt": exportSelectedRowsTxt,
|
||||
};
|
||||
actions[value]?.();
|
||||
}
|
||||
@@ -8670,6 +8693,7 @@ defineExpose({
|
||||
exportJson,
|
||||
exportSql,
|
||||
exportXlsx,
|
||||
exportTxt,
|
||||
});
|
||||
|
||||
// ---- CustomContextMenu ----
|
||||
@@ -8782,6 +8806,7 @@ function exportSubmenu(): ContextMenuItem {
|
||||
{ label: t("grid.exportJson"), action: exportJson },
|
||||
{ label: t("grid.exportMarkdown"), action: exportMarkdown },
|
||||
{ label: t("grid.exportSql"), action: exportSql },
|
||||
{ label: t("grid.exportTxt"), action: exportTxt },
|
||||
];
|
||||
if (isMultiRow.value) {
|
||||
items.push(
|
||||
@@ -8791,6 +8816,7 @@ function exportSubmenu(): ContextMenuItem {
|
||||
{ label: t("grid.exportSelectedRowsJson"), action: exportSelectedRowsJson },
|
||||
{ label: t("grid.exportSelectedRowsMarkdown"), action: exportSelectedRowsMarkdown },
|
||||
{ label: t("grid.exportSelectedRowsSql"), action: exportSelectedRowsSql },
|
||||
{ label: t("grid.exportSelectedRowsTxt"), action: exportSelectedRowsTxt },
|
||||
);
|
||||
}
|
||||
return { label: t("grid.export"), icon: Upload, children: items };
|
||||
|
||||
@@ -1127,7 +1127,7 @@ defineExpose({ focusSearch, refreshData, handleModRTarget, requestQueryEditorExe
|
||||
:total-row-count-loading="activeTab.resultTotalRowCountLoading"
|
||||
:on-execute-sql="async (sql: string) => emit('executeSql', sql)"
|
||||
:full-export-result="(onProgress?: (info: { rowsExported: number; totalRows: number | null }) => void) => queryStore.fetchTabResultForExport(activeTab.id, onProgress)"
|
||||
:query-result-export-request="(options: { exportId: string; filePath: string; format: 'csv' | 'xlsx' }) => queryStore.buildQueryResultExportRequest(activeTab.id, options)"
|
||||
:query-result-export-request="(options: { exportId: string; filePath: string; format: 'csv' | 'xlsx' | 'txt' }) => queryStore.buildQueryResultExportRequest(activeTab.id, options)"
|
||||
:all-export-results="allResultExportSheets"
|
||||
:export-file-base-name="activeTab.title"
|
||||
@update:order-by-input="(v: string) => (activeTab.orderByInput = v)"
|
||||
|
||||
Reference in new issue
Block a user