瀏覽代碼

很重要-筛选带上默认查询参数

qdy 1 月之前
父節點
當前提交
6445312e53
共有 1 個檔案被更改,包括 92 行新增76 行删除
  1. 92
    76
      src/app/pages/service-register-config/service-register-config.component.ts

+ 92
- 76
src/app/pages/service-register-config/service-register-config.component.ts 查看文件

@@ -28,8 +28,11 @@ export class ServiceRegisterConfigComponent implements AfterViewInit {
28 28
    headerButtons: StickyHeaderButton[] = [
29 29
      { title: '注册', name: 'register', icon: 'add', color: 'primary' },
30 30
      { title: '刷新', name: 'refresh', icon: 'refresh', color: 'accent' }
31
-   ];
32
-   //registering = false;
31
+    ];
32
+    //registering = false;
33
+    
34
+    // 外部查询条件预留字段(用于将来扩展)
35
+    externalFilters: any = {};
33 36
 
34 37
   ngAfterViewInit(): void {
35 38
     console.log('ServiceRegisterConfigComponent ngAfterViewInit');
@@ -61,46 +64,13 @@ export class ServiceRegisterConfigComponent implements AfterViewInit {
61 64
     this.tabulator = new Tabulator('#tabulator-table', {
62 65
      
63 66
       // 列定义 - 使用现有列配置
64
-      columns: [
65
-        { 
66
-          title: 'ID', 
67
-          field: 'id', 
68
-          sorter: 'number', 
69
-          headerFilter: 'input',
70
-          width: 80
71
-        },
72
-        { 
73
-          title: '配置名称', 
74
-          field: 'configName', 
75
-          sorter: 'string', 
76
-          headerFilter: 'input',
77
-          headerFilterFunc: 'like'
78
-        },
79
-        { 
80
-          title: '字段名', 
81
-          field: 'fieldName', 
82
-          sorter: 'string', 
83
-          headerFilter: 'input',
84
-          headerFilterFunc: 'like'
85
-        },
86
-        { 
87
-          title: '字段类型', 
88
-          field: 'fieldType', 
89
-          sorter: 'string', 
90
-          headerFilter: 'input',
91
-          headerFilterParams: {
92
-            values: ['string', 'number', 'boolean', 'array', 'object']
93
-          }
94
-        },
95
-        { 
96
-          title: '描述', 
97
-          field: 'fieldDesc', 
98
-          sorter: 'string', 
99
-          headerFilter: 'input',
100
-          headerFilterFunc: 'like',
101
-          width: 300
102
-        }
103
-      ],
67
+    columns: [
68
+      { title: 'ID', field: 'id', sorter: 'number', headerFilter: 'input', width: 220 },
69
+      { title: '配置名称', field: 'configName', sorter: 'string', headerFilter: 'input', headerFilterFunc: 'like',width: 110 },
70
+      { title: '字段名', field: 'fieldName', sorter: 'string', headerFilter: 'input', headerFilterFunc: 'like' ,width: 130},
71
+      { title: '字段类型', field: 'fieldType', sorter: 'string', headerFilter: 'input',width: 120, headerFilterParams: { values: ['string', 'number', 'boolean', 'array', 'object'] } },
72
+      { title: '描述', field: 'fieldDesc', sorter: 'string', headerFilter: 'input', headerFilterFunc: 'like' }
73
+    ],
104 74
       
105 75
       // 标准远程分页配置
106 76
       pagination: true,
@@ -121,44 +91,90 @@ export class ServiceRegisterConfigComponent implements AfterViewInit {
121 91
       },
122 92
       ajaxContentType: 'json',
123 93
       
124
-      // // 参数生成器,将Tabulator参数转换为后端期望格式
125
-      // ajaxParamsGenerator: (url: string, config: any, params: any) => {
126
-      //   console.log('Tabulator AJAX参数生成器被调用', { url, config });
127
-      //   console.log('原始params类型:', typeof params);
128
-      //   console.log('原始params完整结构:', params);
94
+      ajaxParams: function() {
95
+        // 获取调用时的上下文信息
96
+        const callTime = new Date().toISOString();
97
+        const stack = new Error().stack; // 获取调用堆栈
129 98
         
130
-      //   // 详细分析params对象
131
-      //   if (params) {
132
-      //     console.log('params所有键:', Object.keys(params));
133
-      //     console.log('page:', params.page);
134
-      //     console.log('size:', params.size);
135
-      //     console.log('sort类型:', typeof params.sort);
136
-      //     console.log('sort值:', params.sort);
137
-      //     console.log('filter类型:', typeof params.filter);
138
-      //     console.log('filter值:', params.filter);
139
-          
140
-      //     // 检查可能的别名
141
-      //     console.log('sorters存在?:', 'sorters' in params);
142
-      //     console.log('filters存在?:', 'filters' in params);
143
-      //   }
99
+        console.group("=== ajaxParams被调用 ===");
100
+        console.log("调用时间:", callTime);
101
+        console.log("当前页码:", this.getPage());
102
+        console.log("筛选条件:", this.getFilters(true));
103
+        console.log("排序条件:", this.getSorters());
104
+       // console.log("调用来源:", stack.split('\n')[2]?.trim() || "未知");
105
+        console.groupEnd();
144 106
         
145
-      //   // 处理params为undefined的情况
146
-      //   if (!params) {
147
-      //     params = {};
148
-      //   }
107
+        return {
108
+            page: this.getPage() || 1,
109
+            size: this.getPageSize() || 20,
110
+            filter: this.getFilters(true) || [],
111
+            sort: this.getSorters() || []
112
+        };
113
+    },
114
+      //       参数生成器,将Tabulator参数转换为后端期望格式
115
+      ajaxURLGenerator:function(url: string, config: any, params: any){
116
+      //ajaxParamsGenerator: (url: string, config: any, params: any) => {
117
+        console.log('=== Tabulator AJAX参数生成器被调用 ===');
118
+        console.log('请求URL:', url);
119
+        console.log('请求配置:', config);
120
+        console.log('原始params类型:', typeof params);
121
+        console.log('原始params完整结构:', JSON.stringify(params, null, 2));
149 122
         
150
-      //   // 构建请求参数,使用TabulatorMapper转换为后端期望格式
151
-      //   // Tabulator 6.x发送的是 sort/filter(单数),但后端期望 sorters/filters(复数)
152
-      //   const request = TabulatorMapper.buildServerRequest(
153
-      //     params.page || 1,
154
-      //     params.size || 20,
155
-      //     params.sorts || [],      // Tabulator使用单数'sort'
156
-      //     params.filters || []     // Tabulator使用单数'filter'
157
-      //   );
123
+        // 详细分析params对象
124
+        if (params) {
125
+          console.log('params所有键:', Object.keys(params));
126
+          console.log('page:', params.page);
127
+          console.log('size:', params.size);
128
+          console.log('sort类型:', typeof params.sort);
129
+          console.log('sort值:', params.sort);
130
+          console.log('filter类型:', typeof params.filter);
131
+          console.log('filter值:', params.filter);
132
+          
133
+          // 检查可能的别名
134
+          console.log('sorters存在?:', 'sorters' in params);
135
+          console.log('filters存在?:', 'filters' in params);
136
+          
137
+          // 检查是否有外部查询条件的预留字段
138
+          console.log('当前外部查询条件预留字段:', this.externalFilters || '未定义');
139
+        } else {
140
+          console.log('params为undefined或null');
141
+          params = {};
142
+        }
158 143
         
159
-      //   console.log('生成的请求参数:', request);
160
-      //   return request;
161
-      // },
144
+        // 构建请求参数,使用TabulatorMapper转换为后端期望格式
145
+        // Tabulator 6.x发送的是 sort/filter(单数),但后端期望 sorters/filters(复数)
146
+       // const request = TabulatorMapper.buildServerRequest(
147
+         // params.page || 1,
148
+          //params.size || 20,
149
+          //params.sorts || [],      // Tabulator使用单数'sort'
150
+          //params.filters || []     // Tabulator使用单数'filter'
151
+        //);
152
+        
153
+       // console.log('生成的请求参数:', JSON.stringify(request, null, 2));
154
+       
155
+         const fullUrl = url + '?params=' + encodeURIComponent(JSON.stringify(params));
156
+
157
+         console.log('完整URL:', fullUrl);
158
+          console.log('=== 参数生成器执行结束 ===');
159
+  
160
+        return fullUrl;
161
+    
162
+        // 返回完整的请求配置对象
163
+  // return {
164
+  //   method: 'POST',  // 使用POST方法
165
+  //   headers: {
166
+  //     'Content-Type': 'application/json',
167
+  //     'Authorization': 'Basic YWRtaW46MTIz',  // 你的认证信息
168
+  //     // 可以添加其他需要的headers
169
+  //   },
170
+  //   body: JSON.stringify({
171
+  //     filter: params.filter || [],  // 根据后端期望的字段名调整
172
+  //     page: params.page || 1,
173
+  //     size: params.size || 20,
174
+  //     sort: params.sorter || []     // 根据后端期望的字段名调整
175
+   //  })
176
+  //};
177
+      },
162 178
       
163 179
       // 响应处理,将后端响应转换为Tabulator期望格式
164 180
       // ajaxResponse: (url: string, params: any, response: any) => {

Loading…
取消
儲存