From bb46e7c37ddbdf44e4a7b729b608b39a3561f1e4 Mon Sep 17 00:00:00 2001
From: schangxiang@126.com <schangxiang@126.com>
Date: 周二, 20 5月 2025 11:46:40 +0800
Subject: [PATCH] 高级查询过滤优化了,不再用这种方式了

---
 Weben_CMS专用代码生成器/Code/Templete/Web/Controllers/EntityModeQueryDrawer模板.txt |   58 +++++++++++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 49 insertions(+), 9 deletions(-)

diff --git "a/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Templete/Web/Controllers/EntityModeQueryDrawer\346\250\241\346\235\277.txt" "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Templete/Web/Controllers/EntityModeQueryDrawer\346\250\241\346\235\277.txt"
index 54c1878..e874b09 100644
--- "a/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Templete/Web/Controllers/EntityModeQueryDrawer\346\250\241\346\235\277.txt"
+++ "b/Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/Code/Templete/Web/Controllers/EntityModeQueryDrawer\346\250\241\346\235\277.txt"
@@ -14,6 +14,15 @@
 import isEqual from 'lodash/isEqual'
 import { ConfirmBox } from '@/components/ConfirmBox/ConfirmBox'
 import { cloneDeep } from 'lodash'
+// 引入公共选项配置
+import { 
+  FILTER_MODE_OPTIONS_STRING, 
+  FILTER_MODE_OPTIONS_NUM,
+  FILTER_MODE_OPTIONS_BOOL
+} from '@/components/DyFormForHighQuery/DyFormForHighQueryOptions';
+import { 
+  BOOLEAN_OPTIONS
+} from '@/utils/commonOptionConstants';
 
 export const use$EntityName$QueryDrawer = (props: any, ctx?: any) => {
   const $PageMenuInstanceName$Drawer = injectModel<$EntityName$Drawer>('$EntityName$Drawer')
@@ -110,15 +119,45 @@
     const data =commonGetFormData();
     ctx.emit('confirmQuery', data)
   }
-  /**
-   * 重置查询
-   */
-  const onReset = async () => {
-    formData.value = {}
-    $Save_PageAddFormAttributes_Query_Clear$
-    //向父组件发送自定义事件
-    ctx.emit('restQuery');
-  }
+  /** 
+   * 重置公共select查询 
+   */ 
+  const onResetForHighSelect = () => {  
+      // 遍历所有表单字段  
+      formItems.forEach(item => {  
+        // 检查字段是否有高级查询的过滤模式配置  
+        if (item.highSelectAttrs && item.highSelectAttrs.prop) {  
+          const filterModeProp = item.highSelectAttrs.prop;  
+          const options = item.highSelectAttrs.options || [];  
+      
+          // 如果存在选项,则设置为第一个选项的值  
+          if (options.length > 0) {  
+            // 假设选项格式为 { value, label } 或类似结构  
+            const firstValue = options[0].value !== undefined ? options[0].value : options[0];  
+            formData.value[filterModeProp] = firstValue;  
+          }  
+        }  
+      });  
+  }  
+    /**
+    * 重置查询 - 优化版
+    */
+    const onReset = async () => {
+        // 1. 清空所有基础字段(不包含过滤模式字段)
+        const baseFields = formItems.reduce((acc, item) => {
+        acc[item.prop] = '';
+        return acc;
+        }, {});
+  
+        // 2. 应用基础字段初始值
+        formData.value = { ...baseFields };
+  
+        // 3. 使用原有方法重置过滤模式字段
+        onResetForHighSelect(); // 保留原有方法调用
+  
+        // 4. 向父组件发送自定义事件
+        ctx.emit('restQuery');
+    }
 
   const updateCheckData = () => {
     initiateData.value = {
@@ -143,6 +182,7 @@
     $CommonQueryEnumForFrom$
   }
   commonQueryEnumForFrom()
+  onResetForHighSelect();//重置公共select查询 
   /**
    * 弹窗打开获取详情
    */

--
Gitblit v1.9.3