22
schangxiang@126.com
2025-05-20 5b189017d143be6366f56ffcdd3c3699a381e034
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
 
//表单工具文件
/**
 * 通用高级查询表单数据收集函数
 * @param {Array} formItems - 表单配置项数组
 * @param {Object} formData - 表单数据对象
 * @returns {Object} - 收集的表单数据
 */
export const collectFormDataForHighQuery = (formItems, formData) => {
     const data = {}; 
   
  // 遍历表单配置收集数据 
  formItems.forEach(item => { 
    // 收集基础字段 
    data[item.prop] = formData.value[item.prop] || ''; 
     
    // 收集过滤模式字段 
    if (item.highSelectAttrs && item.highSelectAttrs.prop) { 
      const filterModeProp = item.highSelectAttrs.prop; 
      data[filterModeProp] = formData.value[filterModeProp] || ''; 
    } 
  }); 
   
  return data; 
  }
 
 /**
 * 重置高级查询的过滤模式
 * @param formItems - 表单配置项数组
 * @param formData - 表单数据对象
 */
 export const onResetForHighSelect = (formItems, formData) => {   
    // 遍历所有表单字段   
    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;   
        }   
      }   
    });   
}   
 
/**
 * 重置高级查询
 * @param formItems - 表单配置项数组
 * @param formData - 表单数据对象
 */
export const onResetForHighQuery = (formItems, formData) => {   
    // 1. 清空所有基础字段(不包含过滤模式字段) 
    const baseFields = formItems.reduce((acc, item) => { 
        acc[item.prop] = ''; 
        return acc; 
        }, {}); 
   
        // 2. 应用基础字段初始值 
        formData.value = { ...baseFields }; 
}