|
|
@@ -3,7 +3,7 @@ import { Component, AfterViewInit, inject } from '@angular/core';
|
|
3
|
3
|
import { ConfigMetaService } from '../../services/config-meta.service';
|
|
4
|
4
|
import { AuthService } from '../../services/auth.service';
|
|
5
|
5
|
import { TabulatorMapper } from '../../utils/tabulator-mapper.util';
|
|
6
|
|
-import { ConfigService, StickyHeaderComponent } from 'base-core';
|
|
|
6
|
+import { ConfigService, StickyHeaderComponent, StickyHeaderButton } from 'base-core';
|
|
7
|
7
|
import { CommonModule } from '@angular/common';
|
|
8
|
8
|
|
|
9
|
9
|
// 声明全局类型
|
|
|
@@ -23,9 +23,13 @@ export class ServiceRegisterConfigComponent implements AfterViewInit {
|
|
23
|
23
|
private config = inject(ConfigService);
|
|
24
|
24
|
private authService = inject(AuthService);
|
|
25
|
25
|
|
|
26
|
|
- title = '注册服务配置';
|
|
27
|
|
- hintText = '点击"注册"按钮将同步所有配置元信息到数据库,并显示配置列表。';
|
|
28
|
|
- registering = false;
|
|
|
26
|
+ title = '注册服务配置';
|
|
|
27
|
+ hintText = '点击"注册"按钮将同步所有配置元信息到数据库,并显示配置列表。';
|
|
|
28
|
+ headerButtons: StickyHeaderButton[] = [
|
|
|
29
|
+ { title: '注册', name: 'register', icon: 'add', color: 'primary' },
|
|
|
30
|
+ { title: '刷新', name: 'refresh', icon: 'refresh', color: 'accent' }
|
|
|
31
|
+ ];
|
|
|
32
|
+ registering = false;
|
|
29
|
33
|
|
|
30
|
34
|
ngAfterViewInit(): void {
|
|
31
|
35
|
console.log('ServiceRegisterConfigComponent ngAfterViewInit');
|
|
|
@@ -207,40 +211,65 @@ export class ServiceRegisterConfigComponent implements AfterViewInit {
|
|
207
|
211
|
}
|
|
208
|
212
|
|
|
209
|
213
|
|
|
210
|
|
- onRegister() {
|
|
211
|
|
- console.log('注册按钮被点击');
|
|
212
|
|
- this.registering = true;
|
|
213
|
|
-
|
|
214
|
|
- this.configMetaService.initConfigMeta().subscribe({
|
|
215
|
|
- next: (result: any) => {
|
|
216
|
|
- this.registering = false;
|
|
217
|
|
- //this.errorMessage = null;
|
|
218
|
|
- if (result.success) {
|
|
219
|
|
- console.log('注册完成:', result.data);
|
|
220
|
|
-
|
|
221
|
|
- // 注册后切换到真实API数据
|
|
222
|
|
- //this.debugInfo.useMockData = false;
|
|
223
|
|
- //this.updateDataConfig();
|
|
224
|
|
-
|
|
225
|
|
- // 重新加载数据
|
|
226
|
|
- //this.loadData(1);
|
|
227
|
|
-
|
|
228
|
|
- console.log('注册成功,数据已重新加载');
|
|
229
|
|
- } else {
|
|
230
|
|
- console.error('注册失败:', result);
|
|
231
|
|
- }
|
|
232
|
|
- },
|
|
|
214
|
+ onRegister() {
|
|
|
215
|
+ console.log('注册按钮被点击');
|
|
|
216
|
+ this.registering = true;
|
|
|
217
|
+ this.headerButtons[0].loading = true;
|
|
233
|
218
|
|
|
234
|
|
- });
|
|
235
|
|
- }
|
|
236
|
|
- /**
|
|
237
|
|
- * 刷新表格 - 重新加载数据
|
|
238
|
|
- */
|
|
239
|
|
- refresh(): void {
|
|
240
|
|
- if (this.tabulator) {
|
|
241
|
|
- this.tabulator.replaceData();
|
|
|
219
|
+ this.configMetaService.initConfigMeta().subscribe({
|
|
|
220
|
+ next: (result: any) => {
|
|
|
221
|
+ this.registering = false;
|
|
|
222
|
+ this.headerButtons[0].loading = false;
|
|
|
223
|
+ //this.errorMessage = null;
|
|
|
224
|
+ if (result.success) {
|
|
|
225
|
+ console.log('注册完成:', result.data);
|
|
|
226
|
+
|
|
|
227
|
+ // 注册后切换到真实API数据
|
|
|
228
|
+ //this.debugInfo.useMockData = false;
|
|
|
229
|
+ //this.updateDataConfig();
|
|
|
230
|
+
|
|
|
231
|
+ // 重新加载数据
|
|
|
232
|
+ //this.loadData(1);
|
|
|
233
|
+
|
|
|
234
|
+ console.log('注册成功,数据已重新加载');
|
|
|
235
|
+ } else {
|
|
|
236
|
+ console.error('注册失败:', result);
|
|
|
237
|
+ }
|
|
|
238
|
+ },
|
|
|
239
|
+ error: (error) => {
|
|
|
240
|
+ this.registering = false;
|
|
|
241
|
+ this.headerButtons[0].loading = false;
|
|
|
242
|
+ console.error('注册请求失败:', error);
|
|
|
243
|
+ }
|
|
|
244
|
+ });
|
|
242
|
245
|
}
|
|
243
|
|
- }
|
|
|
246
|
+
|
|
|
247
|
+ onHeaderButtonAction(name: string) {
|
|
|
248
|
+ console.log(`头部按钮点击: ${name}`);
|
|
|
249
|
+ switch (name) {
|
|
|
250
|
+ case 'register':
|
|
|
251
|
+ this.onRegister();
|
|
|
252
|
+ break;
|
|
|
253
|
+ case 'refresh':
|
|
|
254
|
+ this.refresh();
|
|
|
255
|
+ break;
|
|
|
256
|
+ default:
|
|
|
257
|
+ console.warn(`未知按钮操作: ${name}`);
|
|
|
258
|
+ }
|
|
|
259
|
+ }
|
|
|
260
|
+ /**
|
|
|
261
|
+ * 刷新表格 - 重新加载数据
|
|
|
262
|
+ */
|
|
|
263
|
+ refresh(): void {
|
|
|
264
|
+ if (this.tabulator) {
|
|
|
265
|
+ this.headerButtons[1].loading = true;
|
|
|
266
|
+ this.tabulator.replaceData();
|
|
|
267
|
+ // 简单延迟后清除loading状态
|
|
|
268
|
+ setTimeout(() => {
|
|
|
269
|
+ this.headerButtons[1].loading = false;
|
|
|
270
|
+ }, 500);
|
|
|
271
|
+ }
|
|
|
272
|
+ }
|
|
244
|
273
|
|
|
245
|
274
|
/**
|
|
246
|
275
|
* 重置筛选和排序
|