From 8a249a21942751afaeb59e82677857a5b27f0ee7 Mon Sep 17 00:00:00 2001 From: rarnu Date: Fri, 8 May 2026 18:33:59 +0800 Subject: [PATCH] =?UTF-8?q?add:=20=E5=9C=A8=E7=BB=93=E6=9E=9C=E9=9B=86?= =?UTF-8?q?=E4=B8=AD=E5=A2=9E=E5=8A=A0=E6=95=B0=E6=8D=AE=E8=BF=87=E6=BB=A4?= =?UTF-8?q?=E7=9A=84=E5=8A=9F=E8=83=BD=20(#163)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * add: 在结果集中增加数据过滤的功能 * 1. 提取 isResultsContext — 新增具名计算属性,替代魔法字符串 results,模板和逻辑中统一使用。 2. wherePredicate 在 results 场景下短路 — 加了 canUseWhereSearch.value ? ... : undefined 守卫,避免在结果集界面无意义地调用 normalizeWhereInput()。在 results 上下文下: - wherePredicate → undefined - isWhereSearch → false(因为 canUseWhereSearch 为 false) - activeWhereInput → undefined - 搜索框 placeholder 切换为纯 search(由 canUseWhereSearch 控制,已存在) - 应用按钮隐藏(v-if=isWhereSearch,已存在) 逻辑链现在是一致的:canUseWhereSearch === false 时,所有 where 相关功能(解析、建议、按钮、回车提交)全部失效 --- src/components/grid/DataGrid.vue | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/src/components/grid/DataGrid.vue b/src/components/grid/DataGrid.vue index 831fe975f..c42c9f1aa 100644 --- a/src/components/grid/DataGrid.vue +++ b/src/components/grid/DataGrid.vue @@ -424,9 +424,10 @@ watch(() => props.result.columns.length, initColumnWidths); const pageSize = ref(100); const currentPage = ref(1); const isFullPage = computed(() => props.result.rows.length >= pageSize.value); -const canUseWhereSearch = computed(() => !!props.tableMeta && !!props.onExecuteSql); +const isResultsContext = computed(() => props.context === "results"); +const canUseWhereSearch = computed(() => !!props.tableMeta && !!props.onExecuteSql && !isResultsContext.value); const isWhereSearch = computed(() => canUseWhereSearch.value && /^\s*where\b/i.test(searchText.value)); -const wherePredicate = computed(() => normalizeWhereInput(searchText.value)); +const wherePredicate = computed(() => (canUseWhereSearch.value ? normalizeWhereInput(searchText.value) : undefined)); const activeWhereInput = computed(() => (isWhereSearch.value && wherePredicate.value ? searchText.value : undefined)); const clientSearchText = computed(() => (isWhereSearch.value ? "" : searchText.value)); @@ -1285,14 +1286,8 @@ defineExpose({
-
- +
+