✨ feat(dataGrid): 增加复制逐行插入语句的功能

This commit is contained in:
二丫讲梵 authored and GitHub committed 2026-07-07 16:39:38 +08:00
1 parent b74e97d530
commit 326c4f5495
13 files changed
+166 -38

No files matched your search

+34 -6
View File
@@ -7335,8 +7335,14 @@ function onRowContext(rowId: number, rowIndex: number) {
async function prefetchCopyStatements() {
await prefetchRowAsInsertStatement(false);
if (isMultiRow.value) {
await prefetchRowAsInsertStatement(false, "row-by-row");
}
if (canCopyRowAsInsertWithoutPrimaryKeys.value) {
await prefetchRowAsInsertStatement(true);
if (isMultiRow.value) {
await prefetchRowAsInsertStatement(true, "row-by-row");
}
}
if (canCopyRowAsUpdate.value) {
await prefetchRowAsUpdateStatement();
@@ -7945,7 +7951,11 @@ function copyRowLabels() {
return {
row: isMultiRow.value ? t("grid.copyRows", { count }) : t("grid.copyRow"),
insert: isMultiRow.value ? t("grid.copyRowsInsert", { count }) : t("grid.copyRowInsert"),
insertMerged: t("grid.copyRowsInsertMerged", { count }),
insertRowByRow: t("grid.copyRowsInsertRowByRow", { count }),
insertNoPk: isMultiRow.value ? t("grid.copyRowsInsertWithoutPrimaryKeys", { count }) : t("grid.copyRowInsertWithoutPrimaryKeys"),
insertNoPkMerged: t("grid.copyRowsInsertWithoutPrimaryKeysMerged", { count }),
insertNoPkRowByRow: t("grid.copyRowsInsertWithoutPrimaryKeysRowByRow", { count }),
update: isMultiRow.value ? t("grid.copyRowsUpdate", { count }) : t("grid.copyRowUpdate"),
};
}
@@ -7977,13 +7987,31 @@ function copySubmenu(): ContextMenuItem {
items.push({ label: t("grid.copyCell"), action: copyCell });
}
items.push({ label: labels.row, action: copyRow });
items.push({ label: labels.insert, action: copyRowAsInsert, disabled: !canCopyPreparedInsert(false) });
if (isMultiRow.value) {
items.push({ label: labels.insertMerged, action: () => copyRowAsInsert("merged"), disabled: !canCopyPreparedInsert(false, "merged") });
items.push({ label: labels.insertRowByRow, action: () => copyRowAsInsert("row-by-row"), disabled: !canCopyPreparedInsert(false, "row-by-row") });
} else {
items.push({ label: labels.insert, action: () => copyRowAsInsert(), disabled: !canCopyPreparedInsert(false) });
}
if (canCopyRowAsInsertWithoutPrimaryKeys.value) {
items.push({
label: labels.insertNoPk,
action: copyRowAsInsertWithoutPrimaryKeys,
disabled: !canCopyPreparedInsert(true),
});
if (isMultiRow.value) {
items.push({
label: labels.insertNoPkMerged,
action: () => copyRowAsInsertWithoutPrimaryKeys("merged"),
disabled: !canCopyPreparedInsert(true, "merged"),
});
items.push({
label: labels.insertNoPkRowByRow,
action: () => copyRowAsInsertWithoutPrimaryKeys("row-by-row"),
disabled: !canCopyPreparedInsert(true, "row-by-row"),
});
} else {
items.push({
label: labels.insertNoPk,
action: () => copyRowAsInsertWithoutPrimaryKeys(),
disabled: !canCopyPreparedInsert(true),
});
}
}
if (canCopyRowAsUpdate.value) {
items.push({ label: labels.update, action: copyRowAsUpdate, disabled: !canCopyPreparedUpdate() });