mirror of
https://github.com/t8y2/dbx.git
synced 2026-10-31 00:22:30 +00:00
Fix: DataGrid数据集和工具栏的修复及加强 (#157)
* fix: 修复结果集内的数据过滤功能 * add: 将原先误删的WHERE查询加回 * add: 合并事务栏和搜索栏,并且在结果集中不启用搜索功能 * add: 修复在表数据和结果集模式下,DataGrid刷新时未保留查询条件的问题,将表数据和结果集的处理逻辑进行拆分 * add: 与主分支合并,解决冲突 * add: 恢复i18n * add: 恢复useDataGridActions.ts * add: 恢复ContentArea.vue * add: 恢复DataGrid.vue * fix: 修复括号自动配对的bug * add: 将DDL按钮移到表数据编辑的第一行尾,并且不在DataGrid中显示
This commit is contained in:
@@ -13,7 +13,10 @@ export function useDataGridActions(activeTab: ComputedRef<QueryTab | undefined>)
|
||||
return quoteTableIdentifier(config?.db_type, name);
|
||||
}
|
||||
|
||||
function buildTableSql(tab: QueryTab, options: { orderBy?: string; limit?: number; offset?: number } = {}): string {
|
||||
function buildTableSql(
|
||||
tab: QueryTab,
|
||||
options: { orderBy?: string; limit?: number; offset?: number; whereInput?: string } = {},
|
||||
): string {
|
||||
const config = connectionStore.getConfig(tab.connectionId);
|
||||
const fallbackOrderColumns =
|
||||
config?.db_type === "sqlserver" && !tab.tableMeta?.primaryKeys?.length
|
||||
@@ -36,28 +39,33 @@ export function useDataGridActions(activeTab: ComputedRef<QueryTab | undefined>)
|
||||
await queryStore.executeTabSql(tab.id, sql);
|
||||
}
|
||||
|
||||
async function onReloadData() {
|
||||
async function onReloadData(sql?: string, whereInput?: string) {
|
||||
const tab = activeTab.value;
|
||||
if (!tab) return;
|
||||
if (tab.mode === "data" && tab.tableMeta) {
|
||||
queryStore.updateSql(tab.id, buildTableSql(tab));
|
||||
queryStore.updateSql(tab.id, buildTableSql(tab, { whereInput }));
|
||||
return queryStore.executeCurrentTab();
|
||||
}
|
||||
queryStore.executeCurrentTab();
|
||||
// Results mode: re-run only the SQL that produced the current result set
|
||||
if (sql?.trim()) {
|
||||
return queryStore.executeTabSql(tab.id, sql);
|
||||
}
|
||||
return queryStore.executeCurrentTab();
|
||||
}
|
||||
|
||||
async function onPaginate(offset: number, limit: number, orderBy?: string) {
|
||||
async function onPaginate(offset: number, limit: number, whereInput?: string, orderBy?: string) {
|
||||
const tab = activeTab.value;
|
||||
if (!tab?.tableMeta) return;
|
||||
const sql = buildTableSql(tab, { limit, offset, orderBy });
|
||||
const sql = buildTableSql(tab, { limit, offset, whereInput, orderBy });
|
||||
queryStore.updateSql(tab.id, sql);
|
||||
await queryStore.executeCurrentTab();
|
||||
}
|
||||
|
||||
async function onSort(column: string, direction: "asc" | "desc" | null) {
|
||||
async function onSort(column: string, direction: "asc" | "desc" | null, whereInput?: string) {
|
||||
const tab = activeTab.value;
|
||||
if (!tab?.tableMeta) return;
|
||||
const orderBy = direction ? `${quoteIdent(tab, column)} ${direction.toUpperCase()}` : undefined;
|
||||
const sql = buildTableSql(tab, { orderBy });
|
||||
const sql = buildTableSql(tab, { orderBy, whereInput });
|
||||
queryStore.updateSql(tab.id, sql);
|
||||
await queryStore.executeCurrentTab();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user