|
|
@@ -132,39 +132,88 @@ export class ConfigMetaService {
|
|
132
|
132
|
* @param params Tabulator格式的请求参数 {page, size, sort, filter}
|
|
133
|
133
|
* @returns Tabulator期望的响应格式 {last_page, data}
|
|
134
|
134
|
*/
|
|
135
|
|
- listForTabulator(params: any): Observable<any> {
|
|
136
|
|
- console.debug('[配置元服务] Tabulator请求参数:', params);
|
|
137
|
|
-
|
|
138
|
|
- // 转换参数:Tabulator格式 → ConfigMetaQueryRequest
|
|
139
|
|
- const request: ConfigMetaQueryRequest = TabulatorMapper.buildServerRequest(
|
|
140
|
|
- params.page || 1,
|
|
141
|
|
- params.size || 20,
|
|
142
|
|
- params.sort || [],
|
|
143
|
|
- params.filter || []
|
|
144
|
|
- );
|
|
145
|
|
-
|
|
146
|
|
- console.debug('[配置元服务] 转换后的请求参数:', request);
|
|
147
|
|
-
|
|
148
|
|
- // 调用现有分页方法
|
|
149
|
|
- return this.listConfigMetaPaginated(request).pipe(
|
|
150
|
|
- map(response => {
|
|
151
|
|
- console.debug('[配置元服务] 原始响应:', response);
|
|
152
|
|
-
|
|
153
|
|
- // 计算总页数
|
|
154
|
|
- const pageSize = params.size || 20;
|
|
155
|
|
- const totalCount = response.totalCount || 0;
|
|
156
|
|
- const lastPage = Math.ceil(totalCount / pageSize) || 1;
|
|
157
|
|
-
|
|
158
|
|
- // 返回Tabulator期望的格式
|
|
159
|
|
- const tabulatorResponse = {
|
|
160
|
|
- last_page: lastPage,
|
|
161
|
|
- data: response.data || []
|
|
162
|
|
- };
|
|
163
|
|
-
|
|
164
|
|
- console.debug('[配置元服务] Tabulator格式响应:', tabulatorResponse);
|
|
165
|
|
- return tabulatorResponse;
|
|
166
|
|
- })
|
|
167
|
|
- );
|
|
|
135
|
+ listForTabulator(params: any): Observable<any> {
|
|
|
136
|
+ console.group('[配置元服务] Tabulator参数处理流程');
|
|
|
137
|
+ console.debug('[配置元服务] 原始Tabulator请求参数:', params);
|
|
|
138
|
+
|
|
|
139
|
+ // 详细分析参数结构
|
|
|
140
|
+ console.debug('[配置元服务] 参数结构分析:', {
|
|
|
141
|
+ paramsType: typeof params,
|
|
|
142
|
+ isObject: params && typeof params === 'object',
|
|
|
143
|
+ keys: params ? Object.keys(params) : [],
|
|
|
144
|
+ page: params?.page,
|
|
|
145
|
+ size: params?.size,
|
|
|
146
|
+ sizeValue: params?.size,
|
|
|
147
|
+ sizeType: typeof params?.size,
|
|
|
148
|
+ hasFilter: 'filter' in params,
|
|
|
149
|
+ hasSort: 'sort' in params,
|
|
|
150
|
+ filterType: typeof params?.filter,
|
|
|
151
|
+ filterIsArray: Array.isArray(params?.filter),
|
|
|
152
|
+ filterLength: Array.isArray(params?.filter) ? params.filter.length : 0,
|
|
|
153
|
+ filterSample: Array.isArray(params?.filter) && params.filter.length > 0 ? params.filter.slice(0, 2) : '空',
|
|
|
154
|
+ sortType: typeof params?.sort,
|
|
|
155
|
+ sortIsArray: Array.isArray(params?.sort),
|
|
|
156
|
+ sortLength: Array.isArray(params?.sort) ? params.sort.length : 0,
|
|
|
157
|
+ sortSample: Array.isArray(params?.sort) && params.sort.length > 0 ? params.sort.slice(0, 2) : '空'
|
|
|
158
|
+ });
|
|
|
159
|
+
|
|
|
160
|
+ // 直接使用Tabulator原始参数,后端期望TabulatorRequest格式
|
|
|
161
|
+ const pageNum = params.page || 1;
|
|
|
162
|
+ const pageSize = params.size || 20;
|
|
|
163
|
+ console.debug('[配置元服务] 直接使用Tabulator参数:', { pageNum, pageSize, sort: params?.sort, filter: params?.filter });
|
|
|
164
|
+
|
|
|
165
|
+ // 构建Tabulator格式请求(与Go TabulatorRequest结构匹配)
|
|
|
166
|
+ const tabulatorRequest = {
|
|
|
167
|
+ page: pageNum, // 页码(从1开始)
|
|
|
168
|
+ size: pageSize, // 每页大小
|
|
|
169
|
+ sort: params.sort || [],
|
|
|
170
|
+ filter: params.filter || []
|
|
|
171
|
+ };
|
|
|
172
|
+
|
|
|
173
|
+ console.debug('[配置元服务] Tabulator格式请求:', tabulatorRequest);
|
|
|
174
|
+ console.debug('[配置元服务] 请求参数详情:', {
|
|
|
175
|
+ page: tabulatorRequest.page,
|
|
|
176
|
+ size: tabulatorRequest.size,
|
|
|
177
|
+ sortCount: tabulatorRequest.sort?.length || 0,
|
|
|
178
|
+ filterCount: tabulatorRequest.filter?.length || 0,
|
|
|
179
|
+ sort: tabulatorRequest.sort,
|
|
|
180
|
+ filter: tabulatorRequest.filter
|
|
|
181
|
+ });
|
|
|
182
|
+
|
|
|
183
|
+ // 直接调用API,使用Tabulator原生格式
|
|
|
184
|
+ const url = `${this.config.apiBaseUrl}${this.listApiPath}`;
|
|
|
185
|
+ console.debug(`[配置元服务] 直接调用Tabulator API: ${url}`);
|
|
|
186
|
+
|
|
|
187
|
+ return this.http.post<any>(url, tabulatorRequest).pipe(
|
|
|
188
|
+ map(response => {
|
|
|
189
|
+ console.debug('[配置元服务] 原始API响应:', response);
|
|
|
190
|
+
|
|
|
191
|
+ // 计算总页数(如果响应未包含last_page)
|
|
|
192
|
+ const pageSize = params.size || 20;
|
|
|
193
|
+ const totalCount = response.totalCount || 0;
|
|
|
194
|
+ let lastPage = response.last_page;
|
|
|
195
|
+ if (!lastPage && totalCount > 0) {
|
|
|
196
|
+ lastPage = Math.ceil(totalCount / pageSize) || 1;
|
|
|
197
|
+ }
|
|
|
198
|
+
|
|
|
199
|
+ // 返回Tabulator期望的格式
|
|
|
200
|
+ const tabulatorResponse = {
|
|
|
201
|
+ last_page: lastPage || 1,
|
|
|
202
|
+ data: response.data || []
|
|
|
203
|
+ };
|
|
|
204
|
+
|
|
|
205
|
+ console.debug('[配置元服务] Tabulator格式响应:', tabulatorResponse);
|
|
|
206
|
+ console.debug('[配置元服务] 响应详情:', {
|
|
|
207
|
+ last_page: tabulatorResponse.last_page,
|
|
|
208
|
+ data_count: tabulatorResponse.data?.length || 0,
|
|
|
209
|
+ totalCount: totalCount,
|
|
|
210
|
+ pageSize: pageSize
|
|
|
211
|
+ });
|
|
|
212
|
+
|
|
|
213
|
+ console.groupEnd();
|
|
|
214
|
+ return tabulatorResponse;
|
|
|
215
|
+ })
|
|
|
216
|
+ );
|
|
168
|
217
|
}
|
|
169
|
218
|
|
|
170
|
219
|
private generateMockConfigMetaList(): ConfigMeta[] {
|