cmat 0.0.111 → 0.0.112
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fesm2022/cmat-components-adapter.mjs +531 -536
- package/fesm2022/cmat-components-adapter.mjs.map +1 -1
- package/fesm2022/cmat-components-breadcrumb.mjs +521 -356
- package/fesm2022/cmat-components-breadcrumb.mjs.map +1 -1
- package/fesm2022/cmat-components-card.mjs +150 -42
- package/fesm2022/cmat-components-card.mjs.map +1 -1
- package/fesm2022/cmat-components-carousel.mjs +1120 -629
- package/fesm2022/cmat-components-carousel.mjs.map +1 -1
- package/fesm2022/cmat-components-cascade.mjs +861 -441
- package/fesm2022/cmat-components-cascade.mjs.map +1 -1
- package/fesm2022/cmat-components-chip-input.mjs +580 -335
- package/fesm2022/cmat-components-chip-input.mjs.map +1 -1
- package/fesm2022/cmat-components-code-editor.mjs +197 -105
- package/fesm2022/cmat-components-code-editor.mjs.map +1 -1
- package/fesm2022/cmat-components-color-picker.mjs +1762 -825
- package/fesm2022/cmat-components-color-picker.mjs.map +1 -1
- package/fesm2022/cmat-components-custom-formly.mjs +5196 -2531
- package/fesm2022/cmat-components-custom-formly.mjs.map +1 -1
- package/fesm2022/cmat-components-data-picker.mjs +1901 -1073
- package/fesm2022/cmat-components-data-picker.mjs.map +1 -1
- package/fesm2022/cmat-components-date-range.mjs +701 -456
- package/fesm2022/cmat-components-date-range.mjs.map +1 -1
- package/fesm2022/cmat-components-date-time-display.mjs +137 -30
- package/fesm2022/cmat-components-date-time-display.mjs.map +1 -1
- package/fesm2022/cmat-components-drawer.mjs +410 -258
- package/fesm2022/cmat-components-drawer.mjs.map +1 -1
- package/fesm2022/cmat-components-empty-state.mjs +201 -41
- package/fesm2022/cmat-components-empty-state.mjs.map +1 -1
- package/fesm2022/cmat-components-file-preview.mjs +198 -35
- package/fesm2022/cmat-components-file-preview.mjs.map +1 -1
- package/fesm2022/cmat-components-filter-toolbar.mjs +320 -72
- package/fesm2022/cmat-components-filter-toolbar.mjs.map +1 -1
- package/fesm2022/cmat-components-form-actions.mjs +102 -26
- package/fesm2022/cmat-components-form-actions.mjs.map +1 -1
- package/fesm2022/cmat-components-fullscreen.mjs +167 -47
- package/fesm2022/cmat-components-fullscreen.mjs.map +1 -1
- package/fesm2022/cmat-components-highlight.mjs +203 -112
- package/fesm2022/cmat-components-highlight.mjs.map +1 -1
- package/fesm2022/cmat-components-image-viewer.mjs +489 -215
- package/fesm2022/cmat-components-image-viewer.mjs.map +1 -1
- package/fesm2022/cmat-components-inline-loading.mjs +117 -27
- package/fesm2022/cmat-components-inline-loading.mjs.map +1 -1
- package/fesm2022/cmat-components-json-editor.mjs +276 -230
- package/fesm2022/cmat-components-json-editor.mjs.map +1 -1
- package/fesm2022/cmat-components-knob-input.mjs +615 -420
- package/fesm2022/cmat-components-knob-input.mjs.map +1 -1
- package/fesm2022/cmat-components-loading-overlay.mjs +53 -25
- package/fesm2022/cmat-components-loading-overlay.mjs.map +1 -1
- package/fesm2022/cmat-components-masonry.mjs +120 -40
- package/fesm2022/cmat-components-masonry.mjs.map +1 -1
- package/fesm2022/cmat-components-material-color-picker.mjs +332 -155
- package/fesm2022/cmat-components-material-color-picker.mjs.map +1 -1
- package/fesm2022/cmat-components-material-datetimepicker.mjs +4283 -2504
- package/fesm2022/cmat-components-material-datetimepicker.mjs.map +1 -1
- package/fesm2022/cmat-components-navigation.mjs +3080 -1404
- package/fesm2022/cmat-components-navigation.mjs.map +1 -1
- package/fesm2022/cmat-components-opt-input.mjs +540 -466
- package/fesm2022/cmat-components-opt-input.mjs.map +1 -1
- package/fesm2022/cmat-components-org-chart.mjs +528 -125
- package/fesm2022/cmat-components-org-chart.mjs.map +1 -1
- package/fesm2022/cmat-components-page-header.mjs +141 -32
- package/fesm2022/cmat-components-page-header.mjs.map +1 -1
- package/fesm2022/cmat-components-pagination.mjs +866 -534
- package/fesm2022/cmat-components-pagination.mjs.map +1 -1
- package/fesm2022/cmat-components-password-strength.mjs +873 -434
- package/fesm2022/cmat-components-password-strength.mjs.map +1 -1
- package/fesm2022/cmat-components-popover.mjs +1012 -731
- package/fesm2022/cmat-components-popover.mjs.map +1 -1
- package/fesm2022/cmat-components-progress-bar.mjs +98 -35
- package/fesm2022/cmat-components-progress-bar.mjs.map +1 -1
- package/fesm2022/cmat-components-qrcode.mjs +463 -287
- package/fesm2022/cmat-components-qrcode.mjs.map +1 -1
- package/fesm2022/cmat-components-rating.mjs +377 -203
- package/fesm2022/cmat-components-rating.mjs.map +1 -1
- package/fesm2022/cmat-components-rich-text-editor.mjs +153 -39
- package/fesm2022/cmat-components-rich-text-editor.mjs.map +1 -1
- package/fesm2022/cmat-components-select-search.mjs +926 -496
- package/fesm2022/cmat-components-select-search.mjs.map +1 -1
- package/fesm2022/cmat-components-select-table.mjs +1280 -842
- package/fesm2022/cmat-components-select-table.mjs.map +1 -1
- package/fesm2022/cmat-components-select-tree.mjs +998 -690
- package/fesm2022/cmat-components-select-tree.mjs.map +1 -1
- package/fesm2022/cmat-components-skeleton.mjs +143 -57
- package/fesm2022/cmat-components-skeleton.mjs.map +1 -1
- package/fesm2022/cmat-components-speed-dial.mjs +457 -303
- package/fesm2022/cmat-components-speed-dial.mjs.map +1 -1
- package/fesm2022/cmat-components-status-tag.mjs +136 -44
- package/fesm2022/cmat-components-status-tag.mjs.map +1 -1
- package/fesm2022/cmat-components-table-toolbar.mjs +120 -28
- package/fesm2022/cmat-components-table-toolbar.mjs.map +1 -1
- package/fesm2022/cmat-components-timeline.mjs +464 -168
- package/fesm2022/cmat-components-timeline.mjs.map +1 -1
- package/fesm2022/cmat-components-toast.mjs +346 -262
- package/fesm2022/cmat-components-toast.mjs.map +1 -1
- package/fesm2022/cmat-components-transfer-picker.mjs +1427 -593
- package/fesm2022/cmat-components-transfer-picker.mjs.map +1 -1
- package/fesm2022/cmat-components-treetable.mjs +372 -112
- package/fesm2022/cmat-components-treetable.mjs.map +1 -1
- package/fesm2022/cmat-components-upload.mjs +904 -410
- package/fesm2022/cmat-components-upload.mjs.map +1 -1
- package/fesm2022/cmat-components-x6-angular-shape.mjs +153 -170
- package/fesm2022/cmat-components-x6-angular-shape.mjs.map +1 -1
- package/fesm2022/cmat-directives-animate-on-scroll.mjs +220 -138
- package/fesm2022/cmat-directives-animate-on-scroll.mjs.map +1 -1
- package/fesm2022/cmat-directives-arrow-cursor.mjs +246 -193
- package/fesm2022/cmat-directives-arrow-cursor.mjs.map +1 -1
- package/fesm2022/cmat-directives-autofocus.mjs +43 -25
- package/fesm2022/cmat-directives-autofocus.mjs.map +1 -1
- package/fesm2022/cmat-directives-data-exporter.mjs +537 -338
- package/fesm2022/cmat-directives-data-exporter.mjs.map +1 -1
- package/fesm2022/cmat-directives-debounce.mjs +162 -76
- package/fesm2022/cmat-directives-debounce.mjs.map +1 -1
- package/fesm2022/cmat-directives-digit-only.mjs +457 -356
- package/fesm2022/cmat-directives-digit-only.mjs.map +1 -1
- package/fesm2022/cmat-directives-equal-validator.mjs +70 -53
- package/fesm2022/cmat-directives-equal-validator.mjs.map +1 -1
- package/fesm2022/cmat-directives-seamless-auto-scroll.mjs +180 -132
- package/fesm2022/cmat-directives-seamless-auto-scroll.mjs.map +1 -1
- package/fesm2022/cmat-lib-mock-api.mjs +207 -195
- package/fesm2022/cmat-lib-mock-api.mjs.map +1 -1
- package/fesm2022/cmat-pipes-bytes.mjs +50 -30
- package/fesm2022/cmat-pipes-bytes.mjs.map +1 -1
- package/fesm2022/cmat-pipes-date-format.mjs +41 -25
- package/fesm2022/cmat-pipes-date-format.mjs.map +1 -1
- package/fesm2022/cmat-pipes-find-by-key.mjs +44 -26
- package/fesm2022/cmat-pipes-find-by-key.mjs.map +1 -1
- package/fesm2022/cmat-pipes-group-by.mjs +50 -38
- package/fesm2022/cmat-pipes-group-by.mjs.map +1 -1
- package/fesm2022/cmat-pipes-keys.mjs +44 -31
- package/fesm2022/cmat-pipes-keys.mjs.map +1 -1
- package/fesm2022/cmat-pipes-secure.mjs +60 -49
- package/fesm2022/cmat-pipes-secure.mjs.map +1 -1
- package/fesm2022/cmat-pipes-uppercase.mjs +39 -22
- package/fesm2022/cmat-pipes-uppercase.mjs.map +1 -1
- package/fesm2022/cmat-reports.mjs +2751 -0
- package/fesm2022/cmat-reports.mjs.map +1 -0
- package/fesm2022/cmat-services-alert.mjs +249 -277
- package/fesm2022/cmat-services-alert.mjs.map +1 -1
- package/fesm2022/cmat-services-config.mjs +110 -81
- package/fesm2022/cmat-services-config.mjs.map +1 -1
- package/fesm2022/cmat-services-confirmation.mjs +184 -73
- package/fesm2022/cmat-services-confirmation.mjs.map +1 -1
- package/fesm2022/cmat-services-data.mjs +136 -125
- package/fesm2022/cmat-services-data.mjs.map +1 -1
- package/fesm2022/cmat-services-export-as.mjs +165 -183
- package/fesm2022/cmat-services-export-as.mjs.map +1 -1
- package/fesm2022/cmat-services-loading.mjs +116 -95
- package/fesm2022/cmat-services-loading.mjs.map +1 -1
- package/fesm2022/cmat-services-local-storage.mjs +75 -66
- package/fesm2022/cmat-services-local-storage.mjs.map +1 -1
- package/fesm2022/cmat-services-media-watcher.mjs +69 -64
- package/fesm2022/cmat-services-media-watcher.mjs.map +1 -1
- package/fesm2022/cmat-services-platform.mjs +48 -45
- package/fesm2022/cmat-services-platform.mjs.map +1 -1
- package/fesm2022/cmat-services-print.mjs +984 -1109
- package/fesm2022/cmat-services-print.mjs.map +1 -1
- package/fesm2022/cmat-services-splash-screen.mjs +53 -38
- package/fesm2022/cmat-services-splash-screen.mjs.map +1 -1
- package/fesm2022/cmat-services-title.mjs +57 -47
- package/fesm2022/cmat-services-title.mjs.map +1 -1
- package/fesm2022/cmat-services-translation.mjs +79 -68
- package/fesm2022/cmat-services-translation.mjs.map +1 -1
- package/fesm2022/cmat-services-utils.mjs +424 -517
- package/fesm2022/cmat-services-utils.mjs.map +1 -1
- package/fesm2022/cmat-validators.mjs +23 -33
- package/fesm2022/cmat-validators.mjs.map +1 -1
- package/fesm2022/cmat-version.mjs +12 -16
- package/fesm2022/cmat-version.mjs.map +1 -1
- package/fesm2022/cmat.mjs +39805 -22511
- package/fesm2022/cmat.mjs.map +1 -1
- package/package.json +5 -1
- package/types/cmat-components-adapter.d.ts +145 -156
- package/types/cmat-components-breadcrumb.d.ts +108 -86
- package/types/cmat-components-card.d.ts +34 -18
- package/types/cmat-components-carousel.d.ts +251 -134
- package/types/cmat-components-cascade.d.ts +158 -117
- package/types/cmat-components-chip-input.d.ts +105 -71
- package/types/cmat-components-code-editor.d.ts +59 -34
- package/types/cmat-components-color-picker.d.ts +378 -236
- package/types/cmat-components-custom-formly.d.ts +776 -814
- package/types/cmat-components-data-picker.d.ts +502 -360
- package/types/cmat-components-date-range.d.ts +106 -77
- package/types/cmat-components-date-time-display.d.ts +36 -13
- package/types/cmat-components-drawer.d.ts +91 -61
- package/types/cmat-components-empty-state.d.ts +47 -17
- package/types/cmat-components-file-preview.d.ts +42 -14
- package/types/cmat-components-filter-toolbar.d.ts +57 -25
- package/types/cmat-components-form-actions.d.ts +18 -10
- package/types/cmat-components-fullscreen.d.ts +21 -13
- package/types/cmat-components-highlight.d.ts +33 -26
- package/types/cmat-components-image-viewer.d.ts +119 -58
- package/types/cmat-components-inline-loading.d.ts +24 -11
- package/types/cmat-components-json-editor.d.ts +39 -28
- package/types/cmat-components-knob-input.d.ts +172 -101
- package/types/cmat-components-loading-overlay.d.ts +8 -11
- package/types/cmat-components-masonry.d.ts +27 -14
- package/types/cmat-components-material-color-picker.d.ts +56 -42
- package/types/cmat-components-material-datetimepicker.d.ts +817 -454
- package/types/cmat-components-navigation.d.ts +295 -221
- package/types/cmat-components-opt-input.d.ts +111 -90
- package/types/cmat-components-org-chart.d.ts +53 -35
- package/types/cmat-components-page-header.d.ts +37 -14
- package/types/cmat-components-pagination.d.ts +144 -107
- package/types/cmat-components-password-strength.d.ts +197 -86
- package/types/cmat-components-popover.d.ts +264 -166
- package/types/cmat-components-progress-bar.d.ts +17 -14
- package/types/cmat-components-qrcode.d.ts +111 -42
- package/types/cmat-components-rating.d.ts +105 -59
- package/types/cmat-components-rich-text-editor.d.ts +39 -16
- package/types/cmat-components-select-search.d.ts +195 -99
- package/types/cmat-components-select-table.d.ts +241 -142
- package/types/cmat-components-select-tree.d.ts +185 -118
- package/types/cmat-components-skeleton.d.ts +55 -32
- package/types/cmat-components-speed-dial.d.ts +86 -61
- package/types/cmat-components-status-tag.d.ts +42 -24
- package/types/cmat-components-table-toolbar.d.ts +30 -12
- package/types/cmat-components-timeline.d.ts +83 -51
- package/types/cmat-components-toast.d.ts +84 -85
- package/types/cmat-components-transfer-picker.d.ts +228 -181
- package/types/cmat-components-treetable.d.ts +63 -39
- package/types/cmat-components-upload.d.ts +205 -106
- package/types/cmat-components-x6-angular-shape.d.ts +29 -37
- package/types/cmat-directives-animate-on-scroll.d.ts +48 -30
- package/types/cmat-directives-arrow-cursor.d.ts +55 -35
- package/types/cmat-directives-autofocus.d.ts +8 -11
- package/types/cmat-directives-data-exporter.d.ts +71 -40
- package/types/cmat-directives-debounce.d.ts +31 -28
- package/types/cmat-directives-digit-only.d.ts +90 -53
- package/types/cmat-directives-equal-validator.d.ts +11 -14
- package/types/cmat-directives-seamless-auto-scroll.d.ts +42 -29
- package/types/cmat-lib-mock-api.d.ts +46 -55
- package/types/cmat-pipes-bytes.d.ts +7 -10
- package/types/cmat-pipes-date-format.d.ts +7 -10
- package/types/cmat-pipes-find-by-key.d.ts +8 -12
- package/types/cmat-pipes-group-by.d.ts +11 -15
- package/types/cmat-pipes-keys.d.ts +10 -13
- package/types/cmat-pipes-secure.d.ts +14 -17
- package/types/cmat-pipes-uppercase.d.ts +7 -10
- package/types/cmat-reports.d.ts +1131 -0
- package/types/cmat-services-alert.d.ts +80 -87
- package/types/cmat-services-config.d.ts +37 -43
- package/types/cmat-services-confirmation.d.ts +31 -37
- package/types/cmat-services-data.d.ts +18 -21
- package/types/cmat-services-export-as.d.ts +28 -33
- package/types/cmat-services-loading.d.ts +27 -31
- package/types/cmat-services-local-storage.d.ts +17 -21
- package/types/cmat-services-media-watcher.d.ts +14 -18
- package/types/cmat-services-platform.d.ts +8 -11
- package/types/cmat-services-print.d.ts +97 -102
- package/types/cmat-services-splash-screen.d.ts +11 -14
- package/types/cmat-services-title.d.ts +9 -12
- package/types/cmat-services-translation.d.ts +19 -22
- package/types/cmat-services-utils.d.ts +76 -80
- package/types/cmat-validators.d.ts +5 -8
- package/types/cmat-version.d.ts +8 -10
- package/types/cmat.d.ts +7551 -5204
|
@@ -0,0 +1,2751 @@
|
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
import { ChangeDetectionStrategy, Component, Inject, Injectable, InjectionToken, Injector, computed, effect, inject, input, runInInjectionContext, signal, untracked, viewChild } from "@angular/core";
|
|
3
|
+
import { catchError, firstValueFrom, map, of, retry, shareReplay, take, tap, throwError, timeout } from "rxjs";
|
|
4
|
+
import { HttpClient, HttpHeaders } from "@angular/common/http";
|
|
5
|
+
import { CmatDataService } from "cmat/services/data";
|
|
6
|
+
import { MatDialog } from "@angular/material/dialog";
|
|
7
|
+
import { ActivatedRoute, Router } from "@angular/router";
|
|
8
|
+
import * as i1 from "@angular/common";
|
|
9
|
+
import { CommonModule, NgClass, NgStyle } from "@angular/common";
|
|
10
|
+
import * as i4 from "@angular/material/button";
|
|
11
|
+
import { MatButtonModule } from "@angular/material/button";
|
|
12
|
+
import * as i8 from "@angular/material/checkbox";
|
|
13
|
+
import { MatCheckboxModule } from "@angular/material/checkbox";
|
|
14
|
+
import * as i6 from "@angular/material/icon";
|
|
15
|
+
import { MatIconModule } from "@angular/material/icon";
|
|
16
|
+
import * as i5 from "@angular/material/menu";
|
|
17
|
+
import { MatMenuModule } from "@angular/material/menu";
|
|
18
|
+
import * as i3 from "@angular/material/progress-bar";
|
|
19
|
+
import { MatProgressBarModule } from "@angular/material/progress-bar";
|
|
20
|
+
import * as i2 from "@angular/material/table";
|
|
21
|
+
import { MatTableModule } from "@angular/material/table";
|
|
22
|
+
import * as i7 from "@angular/material/tooltip";
|
|
23
|
+
import { MatTooltipModule } from "@angular/material/tooltip";
|
|
24
|
+
import { CmatPaginationComponent, CmatPaginationService } from "cmat/components/pagination";
|
|
25
|
+
import { CmatMediaWatcherService } from "cmat/services/media-watcher";
|
|
26
|
+
import { map as map$1 } from "rxjs/operators";
|
|
27
|
+
import { CmatConfigService } from "cmat/services/config";
|
|
28
|
+
import * as echarts from "echarts";
|
|
29
|
+
const REPORT_BFF_CONFIG = new InjectionToken("REPORT_BFF_CONFIG");
|
|
30
|
+
var ApiProvider = class ApiProvider {
|
|
31
|
+
constructor(config) {
|
|
32
|
+
this.type = "api";
|
|
33
|
+
this._http = inject(HttpClient);
|
|
34
|
+
this._cmatDataService = inject(CmatDataService);
|
|
35
|
+
this._bffConfig = inject(REPORT_BFF_CONFIG);
|
|
36
|
+
this.id = config.id;
|
|
37
|
+
this.config = config.api;
|
|
38
|
+
}
|
|
39
|
+
getSchema() {
|
|
40
|
+
const relativeUrl = `${this.config.url}/${this.id}/schema`;
|
|
41
|
+
const headers = this._buildHeaders();
|
|
42
|
+
const mapResponse = (response) => {
|
|
43
|
+
const data = response?.success !== void 0 ? response.data : response;
|
|
44
|
+
return Array.isArray(data) ? data : [];
|
|
45
|
+
};
|
|
46
|
+
if (this._bffConfig.enableMock) return this._http.get(relativeUrl, { headers }).pipe(map(mapResponse), catchError((error) => {
|
|
47
|
+
console.error("[ApiProvider] Schema request error:", error);
|
|
48
|
+
return throwError(() => /* @__PURE__ */ new Error(`Failed to fetch schema: ${error.message}`));
|
|
49
|
+
}));
|
|
50
|
+
else {
|
|
51
|
+
const bffUrl = this._resolveUrl(relativeUrl);
|
|
52
|
+
return this._cmatDataService.get(bffUrl).pipe(map(mapResponse), catchError((error) => {
|
|
53
|
+
console.error("[ApiProvider] Schema request error:", error);
|
|
54
|
+
return throwError(() => /* @__PURE__ */ new Error(`Failed to fetch schema: ${error.message}`));
|
|
55
|
+
}));
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
fetchList(query) {
|
|
59
|
+
const relativeUrl = "api/reports/data";
|
|
60
|
+
const headers = this._buildHeaders();
|
|
61
|
+
const requestBody = {
|
|
62
|
+
providerName: this.id,
|
|
63
|
+
parameters: this._buildParameters(query)
|
|
64
|
+
};
|
|
65
|
+
const mapResponse = (response) => {
|
|
66
|
+
return {
|
|
67
|
+
data: response.data ?? [],
|
|
68
|
+
total: response.total ?? 0,
|
|
69
|
+
page: response.page ?? query.pagination?.page ?? 1,
|
|
70
|
+
pageSize: response.pageSize ?? query.pagination?.size ?? 10,
|
|
71
|
+
totalPages: response.totalPages ?? 0
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
const handleError = (error) => {
|
|
75
|
+
console.error("[ApiProvider] List query error:", error);
|
|
76
|
+
return throwError(() => /* @__PURE__ */ new Error(`Failed to fetch list: ${error.message}`));
|
|
77
|
+
};
|
|
78
|
+
if (this._bffConfig.enableMock) return this._http.post(relativeUrl, requestBody, { headers }).pipe(map(mapResponse), catchError(handleError));
|
|
79
|
+
else {
|
|
80
|
+
const bffUrl = this._resolveUrl(relativeUrl);
|
|
81
|
+
return this._cmatDataService.post(bffUrl, requestBody).pipe(map(mapResponse), catchError(handleError));
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
fetchOne(id) {
|
|
85
|
+
const relativeUrl = `${this.config.url}/one`;
|
|
86
|
+
const headers = this._buildHeaders();
|
|
87
|
+
const params = { id: String(id) };
|
|
88
|
+
const mapResponse = (response) => {
|
|
89
|
+
return response?.success !== void 0 ? response.data : response;
|
|
90
|
+
};
|
|
91
|
+
const handleError = (error) => {
|
|
92
|
+
console.error("[ApiProvider] One query error:", error);
|
|
93
|
+
return throwError(() => /* @__PURE__ */ new Error(`Failed to fetch record: ${error.message}`));
|
|
94
|
+
};
|
|
95
|
+
if (this._bffConfig.enableMock) return this._http.get(relativeUrl, {
|
|
96
|
+
headers,
|
|
97
|
+
params
|
|
98
|
+
}).pipe(map(mapResponse), catchError(handleError));
|
|
99
|
+
else {
|
|
100
|
+
const bffUrl = this._resolveUrl(relativeUrl);
|
|
101
|
+
return this._cmatDataService.get(bffUrl, params).pipe(map(mapResponse), catchError(handleError));
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
fetchMetric(aggregation) {
|
|
105
|
+
const relativeUrl = `${this.config.url}/metric`;
|
|
106
|
+
const headers = this._buildHeaders();
|
|
107
|
+
const requestBody = { aggregation: {
|
|
108
|
+
operation: aggregation.operation,
|
|
109
|
+
field: aggregation.field
|
|
110
|
+
} };
|
|
111
|
+
const mapResponse = (response) => {
|
|
112
|
+
return (response?.success !== void 0 ? response.data : response) ?? 0;
|
|
113
|
+
};
|
|
114
|
+
const handleError = (error) => {
|
|
115
|
+
console.error("[ApiProvider] Metric query error:", error);
|
|
116
|
+
return throwError(() => /* @__PURE__ */ new Error(`Failed to calculate metric: ${error.message}`));
|
|
117
|
+
};
|
|
118
|
+
if (this._bffConfig.enableMock) return this._http.post(relativeUrl, requestBody, { headers }).pipe(map(mapResponse), catchError(handleError));
|
|
119
|
+
else {
|
|
120
|
+
const bffUrl = this._resolveUrl(relativeUrl);
|
|
121
|
+
return this._cmatDataService.post(bffUrl, requestBody).pipe(map(mapResponse), catchError(handleError));
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
healthCheck() {
|
|
125
|
+
const relativeUrl = `${this.config.url}/health`;
|
|
126
|
+
const headers = this._buildHeaders();
|
|
127
|
+
const mapResponse = (response) => {
|
|
128
|
+
return response?.success !== void 0 ? response.data : response;
|
|
129
|
+
};
|
|
130
|
+
const handleError = (error) => {
|
|
131
|
+
console.error("[ApiProvider] Health check error:", error);
|
|
132
|
+
return throwError(() => /* @__PURE__ */ new Error(`Health check failed: ${error.message}`));
|
|
133
|
+
};
|
|
134
|
+
if (this._bffConfig.enableMock) return this._http.get(relativeUrl, { headers }).pipe(map(mapResponse), catchError(handleError));
|
|
135
|
+
else {
|
|
136
|
+
const bffUrl = this._resolveUrl(relativeUrl);
|
|
137
|
+
return this._cmatDataService.get(bffUrl).pipe(map(mapResponse), catchError(handleError));
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
dispose() {}
|
|
141
|
+
_resolveUrl(target) {
|
|
142
|
+
if (/^https?:\/\//i.test(target)) return target;
|
|
143
|
+
return `${this._bffConfig.bffUrl}/${target}`;
|
|
144
|
+
}
|
|
145
|
+
_buildHeaders() {
|
|
146
|
+
let headers = new HttpHeaders({ "Content-Type": "application/json" });
|
|
147
|
+
if (this.config.headers) Object.entries(this.config.headers).forEach(([key, value]) => {
|
|
148
|
+
headers = headers.set(key, value);
|
|
149
|
+
});
|
|
150
|
+
return headers;
|
|
151
|
+
}
|
|
152
|
+
_buildParameters(query) {
|
|
153
|
+
const parameters = {};
|
|
154
|
+
if (query.pagination) parameters.pagination = {
|
|
155
|
+
page: query.pagination.page,
|
|
156
|
+
size: query.pagination.size
|
|
157
|
+
};
|
|
158
|
+
if (query.filters && query.filters.length > 0) {
|
|
159
|
+
parameters.filters = query.filters.map((filter) => ({
|
|
160
|
+
field: filter.field,
|
|
161
|
+
operator: filter.operator,
|
|
162
|
+
value: filter.value
|
|
163
|
+
}));
|
|
164
|
+
if (query.filterLogic) parameters.filterLogic = query.filterLogic;
|
|
165
|
+
}
|
|
166
|
+
if (query.sorting && query.sorting.length > 0) parameters.sorting = query.sorting.map((rule) => ({
|
|
167
|
+
field: rule.field,
|
|
168
|
+
order: rule.order
|
|
169
|
+
}));
|
|
170
|
+
if (query.params) Object.assign(parameters, query.params);
|
|
171
|
+
return parameters;
|
|
172
|
+
}
|
|
173
|
+
static {
|
|
174
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
175
|
+
minVersion: "12.0.0",
|
|
176
|
+
version: "22.2.3",
|
|
177
|
+
ngImport: i0,
|
|
178
|
+
type: ApiProvider,
|
|
179
|
+
deps: [{ token: "API_PROVIDER_CONFIG" }],
|
|
180
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
static {
|
|
184
|
+
this.ɵprov = i0.ɵɵngDeclareInjectable({
|
|
185
|
+
minVersion: "12.0.0",
|
|
186
|
+
version: "22.2.3",
|
|
187
|
+
ngImport: i0,
|
|
188
|
+
type: ApiProvider
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
193
|
+
minVersion: "12.0.0",
|
|
194
|
+
version: "22.2.3",
|
|
195
|
+
ngImport: i0,
|
|
196
|
+
type: ApiProvider,
|
|
197
|
+
decorators: [{ type: Injectable }],
|
|
198
|
+
ctorParameters: () => [{
|
|
199
|
+
type: void 0,
|
|
200
|
+
decorators: [{
|
|
201
|
+
type: Inject,
|
|
202
|
+
args: ["API_PROVIDER_CONFIG"]
|
|
203
|
+
}]
|
|
204
|
+
}]
|
|
205
|
+
});
|
|
206
|
+
var ApiProviderFactory = class {
|
|
207
|
+
constructor() {
|
|
208
|
+
this._injector = inject(Injector);
|
|
209
|
+
}
|
|
210
|
+
create(config) {
|
|
211
|
+
return runInInjectionContext(this._injector, () => new ApiProvider(config));
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
var MockProvider = class MockProvider {
|
|
215
|
+
constructor(config) {
|
|
216
|
+
this.type = "mock";
|
|
217
|
+
this.dataCache = [];
|
|
218
|
+
this.id = config.id;
|
|
219
|
+
this.config = config.mock;
|
|
220
|
+
this.generateData();
|
|
221
|
+
}
|
|
222
|
+
getSchema() {
|
|
223
|
+
return of(this.config.schema);
|
|
224
|
+
}
|
|
225
|
+
fetchList(query) {
|
|
226
|
+
let data = [...this.dataCache];
|
|
227
|
+
if (query.filters && query.filters.length > 0) data = this._applyFilters(data, query.filters);
|
|
228
|
+
if (query.sorting && query.sorting.length > 0) data = this.applySorting(data, query.sorting);
|
|
229
|
+
const total = data.length;
|
|
230
|
+
if (query.pagination) {
|
|
231
|
+
const start = (query.pagination.page - 1) * query.pagination.size;
|
|
232
|
+
const end = start + query.pagination.size;
|
|
233
|
+
data = data.slice(start, end);
|
|
234
|
+
}
|
|
235
|
+
return of({
|
|
236
|
+
data,
|
|
237
|
+
total,
|
|
238
|
+
page: query.pagination?.page ?? 1,
|
|
239
|
+
pageSize: query.pagination?.size ?? data.length,
|
|
240
|
+
totalPages: query.pagination ? Math.ceil(total / query.pagination.size) : 1
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
fetchOne(id) {
|
|
244
|
+
const item = this.dataCache.find((r) => r.id === id);
|
|
245
|
+
return of(item);
|
|
246
|
+
}
|
|
247
|
+
fetchMetric(aggregation) {
|
|
248
|
+
const data = [...this.dataCache];
|
|
249
|
+
const values = data.map((r) => Number(r[aggregation.field]) || 0);
|
|
250
|
+
let result = 0;
|
|
251
|
+
switch (aggregation.operation) {
|
|
252
|
+
case "sum":
|
|
253
|
+
result = values.reduce((s, v) => s + v, 0);
|
|
254
|
+
break;
|
|
255
|
+
case "avg":
|
|
256
|
+
result = values.length > 0 ? values.reduce((s, v) => s + v, 0) / values.length : 0;
|
|
257
|
+
break;
|
|
258
|
+
case "min":
|
|
259
|
+
result = values.length > 0 ? Math.min(...values) : 0;
|
|
260
|
+
break;
|
|
261
|
+
case "max":
|
|
262
|
+
result = values.length > 0 ? Math.max(...values) : 0;
|
|
263
|
+
break;
|
|
264
|
+
case "count": result = data.length;
|
|
265
|
+
}
|
|
266
|
+
return of(result);
|
|
267
|
+
}
|
|
268
|
+
healthCheck() {
|
|
269
|
+
return of({
|
|
270
|
+
status: "healthy",
|
|
271
|
+
message: "Mock provider is ready",
|
|
272
|
+
latency: 0
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
dispose() {
|
|
276
|
+
this.dataCache = [];
|
|
277
|
+
}
|
|
278
|
+
generateData() {
|
|
279
|
+
if (this.config.fixedData && this.config.fixedData.length > 0) {
|
|
280
|
+
this.dataCache = this.config.fixedData;
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
const generator = this.config.dataGenerator ?? "random";
|
|
284
|
+
const count = this.config.rowCount;
|
|
285
|
+
for (let i = 1; i <= count; i++) {
|
|
286
|
+
const row = { id: i };
|
|
287
|
+
for (const field of this.config.schema) switch (field.type) {
|
|
288
|
+
case "number":
|
|
289
|
+
row[field.name] = generator === "sequential" ? i : Math.floor(Math.random() * 1e3);
|
|
290
|
+
break;
|
|
291
|
+
case "string":
|
|
292
|
+
row[field.name] = `${field.name}_${i}`;
|
|
293
|
+
break;
|
|
294
|
+
case "date":
|
|
295
|
+
row[field.name] = (/* @__PURE__ */ new Date(Date.now() - Math.random() * 365 * 24 * 60 * 60 * 1e3)).toISOString();
|
|
296
|
+
break;
|
|
297
|
+
case "boolean":
|
|
298
|
+
row[field.name] = Math.random() > .5;
|
|
299
|
+
break;
|
|
300
|
+
default: row[field.name] = null;
|
|
301
|
+
}
|
|
302
|
+
this.dataCache.push(row);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
_applyFilters(data, filters) {
|
|
306
|
+
return data.filter((row) => {
|
|
307
|
+
return filters.every((filter) => {
|
|
308
|
+
const value = row[filter.field];
|
|
309
|
+
let result;
|
|
310
|
+
switch (filter.operator) {
|
|
311
|
+
case "=":
|
|
312
|
+
result = value === filter.value;
|
|
313
|
+
break;
|
|
314
|
+
case "!=":
|
|
315
|
+
result = value !== filter.value;
|
|
316
|
+
break;
|
|
317
|
+
case ">":
|
|
318
|
+
result = value > filter.value;
|
|
319
|
+
break;
|
|
320
|
+
case "<":
|
|
321
|
+
result = value < filter.value;
|
|
322
|
+
break;
|
|
323
|
+
case ">=":
|
|
324
|
+
result = value >= filter.value;
|
|
325
|
+
break;
|
|
326
|
+
case "<=":
|
|
327
|
+
result = value <= filter.value;
|
|
328
|
+
break;
|
|
329
|
+
case "in":
|
|
330
|
+
result = Array.isArray(filter.value) && filter.value.includes(value);
|
|
331
|
+
break;
|
|
332
|
+
case "like":
|
|
333
|
+
result = String(value).includes(filter.value);
|
|
334
|
+
break;
|
|
335
|
+
default: result = true;
|
|
336
|
+
}
|
|
337
|
+
return result;
|
|
338
|
+
});
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
applySorting(data, rules) {
|
|
342
|
+
return [...data].sort((a, b) => {
|
|
343
|
+
for (const rule of rules) {
|
|
344
|
+
const aVal = a[rule.field];
|
|
345
|
+
const bVal = b[rule.field];
|
|
346
|
+
if (aVal == null && bVal == null) continue;
|
|
347
|
+
if (aVal == null) return 1;
|
|
348
|
+
if (bVal == null) return -1;
|
|
349
|
+
let comparison;
|
|
350
|
+
if (typeof aVal === "number" && typeof bVal === "number") comparison = aVal - bVal;
|
|
351
|
+
else if (aVal instanceof Date && bVal instanceof Date) comparison = aVal.getTime() - bVal.getTime();
|
|
352
|
+
else {
|
|
353
|
+
const aStr = aVal;
|
|
354
|
+
const bStr = bVal;
|
|
355
|
+
comparison = aStr.localeCompare(bStr, void 0, {
|
|
356
|
+
numeric: true,
|
|
357
|
+
sensitivity: "base"
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
if (comparison !== 0) return rule.order === "asc" ? comparison : -comparison;
|
|
361
|
+
}
|
|
362
|
+
return 0;
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
static {
|
|
366
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
367
|
+
minVersion: "12.0.0",
|
|
368
|
+
version: "22.2.3",
|
|
369
|
+
ngImport: i0,
|
|
370
|
+
type: MockProvider,
|
|
371
|
+
deps: [{ token: "MOCK_PROVIDER_CONFIG" }],
|
|
372
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
static {
|
|
376
|
+
this.ɵprov = i0.ɵɵngDeclareInjectable({
|
|
377
|
+
minVersion: "12.0.0",
|
|
378
|
+
version: "22.2.3",
|
|
379
|
+
ngImport: i0,
|
|
380
|
+
type: MockProvider
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
};
|
|
384
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
385
|
+
minVersion: "12.0.0",
|
|
386
|
+
version: "22.2.3",
|
|
387
|
+
ngImport: i0,
|
|
388
|
+
type: MockProvider,
|
|
389
|
+
decorators: [{ type: Injectable }],
|
|
390
|
+
ctorParameters: () => [{
|
|
391
|
+
type: void 0,
|
|
392
|
+
decorators: [{
|
|
393
|
+
type: Inject,
|
|
394
|
+
args: ["MOCK_PROVIDER_CONFIG"]
|
|
395
|
+
}]
|
|
396
|
+
}]
|
|
397
|
+
});
|
|
398
|
+
var MockProviderFactory = class {
|
|
399
|
+
create(config) {
|
|
400
|
+
const provider = Object.create(MockProvider.prototype);
|
|
401
|
+
Object.defineProperty(provider, "id", {
|
|
402
|
+
value: config.id,
|
|
403
|
+
writable: false,
|
|
404
|
+
enumerable: true,
|
|
405
|
+
configurable: true
|
|
406
|
+
});
|
|
407
|
+
Object.defineProperty(provider, "type", {
|
|
408
|
+
value: "mock",
|
|
409
|
+
writable: false,
|
|
410
|
+
enumerable: true,
|
|
411
|
+
configurable: true
|
|
412
|
+
});
|
|
413
|
+
provider.config = config.mock;
|
|
414
|
+
provider.dataCache = [];
|
|
415
|
+
provider.generateData();
|
|
416
|
+
return provider;
|
|
417
|
+
}
|
|
418
|
+
};
|
|
419
|
+
var ProviderRegistryService = class ProviderRegistryService {
|
|
420
|
+
constructor() {
|
|
421
|
+
this.providers = signal(/* @__PURE__ */ new Map(), ...ngDevMode ? [{ debugName: "providers" }] : /* istanbul ignore next */ []);
|
|
422
|
+
this.factories = /* @__PURE__ */ new Map();
|
|
423
|
+
this.registerFactory("mock", new MockProviderFactory());
|
|
424
|
+
this.registerFactory("api", new ApiProviderFactory());
|
|
425
|
+
}
|
|
426
|
+
registerFactory(type, factory) {
|
|
427
|
+
this.factories.set(type, factory);
|
|
428
|
+
}
|
|
429
|
+
createProvider(config) {
|
|
430
|
+
const factory = this.factories.get(config.type);
|
|
431
|
+
if (!factory) throw new Error(`Unknown provider type: ${config.type}`);
|
|
432
|
+
const provider = factory.create(config);
|
|
433
|
+
this.providers.update((map) => {
|
|
434
|
+
const newMap = new Map(map);
|
|
435
|
+
newMap.set(config.id, provider);
|
|
436
|
+
return newMap;
|
|
437
|
+
});
|
|
438
|
+
return provider;
|
|
439
|
+
}
|
|
440
|
+
getProvider(id) {
|
|
441
|
+
return this.providers().get(id) ?? null;
|
|
442
|
+
}
|
|
443
|
+
destroyProvider(id) {
|
|
444
|
+
const provider = this.providers().get(id);
|
|
445
|
+
if (provider) provider.dispose();
|
|
446
|
+
this.providers.update((map) => {
|
|
447
|
+
const newMap = new Map(map);
|
|
448
|
+
newMap.delete(id);
|
|
449
|
+
return newMap;
|
|
450
|
+
});
|
|
451
|
+
}
|
|
452
|
+
async preloadProviders(configs) {
|
|
453
|
+
await Promise.all(configs.map((config) => {
|
|
454
|
+
const provider = this.createProvider(config);
|
|
455
|
+
return firstValueFrom(provider.healthCheck());
|
|
456
|
+
}));
|
|
457
|
+
}
|
|
458
|
+
static {
|
|
459
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
460
|
+
minVersion: "12.0.0",
|
|
461
|
+
version: "22.2.3",
|
|
462
|
+
ngImport: i0,
|
|
463
|
+
type: ProviderRegistryService,
|
|
464
|
+
deps: [],
|
|
465
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
466
|
+
});
|
|
467
|
+
}
|
|
468
|
+
static {
|
|
469
|
+
this.ɵprov = i0.ɵɵngDeclareInjectable({
|
|
470
|
+
minVersion: "12.0.0",
|
|
471
|
+
version: "22.2.3",
|
|
472
|
+
ngImport: i0,
|
|
473
|
+
type: ProviderRegistryService,
|
|
474
|
+
providedIn: "root"
|
|
475
|
+
});
|
|
476
|
+
}
|
|
477
|
+
};
|
|
478
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
479
|
+
minVersion: "12.0.0",
|
|
480
|
+
version: "22.2.3",
|
|
481
|
+
ngImport: i0,
|
|
482
|
+
type: ProviderRegistryService,
|
|
483
|
+
decorators: [{
|
|
484
|
+
type: Injectable,
|
|
485
|
+
args: [{ providedIn: "root" }]
|
|
486
|
+
}],
|
|
487
|
+
ctorParameters: () => []
|
|
488
|
+
});
|
|
489
|
+
var CacheManagerService = class CacheManagerService {
|
|
490
|
+
constructor() {
|
|
491
|
+
this._store = signal(/* @__PURE__ */ new Map(), ...ngDevMode ? [{ debugName: "_store" }] : /* istanbul ignore next */ []);
|
|
492
|
+
}
|
|
493
|
+
get(key) {
|
|
494
|
+
const entry = this._store().get(key);
|
|
495
|
+
if (!entry) return null;
|
|
496
|
+
if (Date.now() > entry.expiry) {
|
|
497
|
+
this.invalidate(key);
|
|
498
|
+
return null;
|
|
499
|
+
}
|
|
500
|
+
return entry.data;
|
|
501
|
+
}
|
|
502
|
+
set(key, data, strategy) {
|
|
503
|
+
if (!strategy?.enabled) return;
|
|
504
|
+
const ttl = strategy.ttlSeconds ?? 60;
|
|
505
|
+
this._store.update((map) => {
|
|
506
|
+
const newMap = new Map(map);
|
|
507
|
+
newMap.set(key, {
|
|
508
|
+
data,
|
|
509
|
+
createdAt: Date.now(),
|
|
510
|
+
expiry: Date.now() + ttl * 1e3
|
|
511
|
+
});
|
|
512
|
+
return newMap;
|
|
513
|
+
});
|
|
514
|
+
}
|
|
515
|
+
invalidate(key) {
|
|
516
|
+
this._store.update((map) => {
|
|
517
|
+
const newMap = new Map(map);
|
|
518
|
+
newMap.delete(key);
|
|
519
|
+
return newMap;
|
|
520
|
+
});
|
|
521
|
+
}
|
|
522
|
+
clearByComponentId(componentId) {
|
|
523
|
+
const prefix = `component:${componentId}:`;
|
|
524
|
+
this._store.update((map) => {
|
|
525
|
+
const newMap = new Map(map);
|
|
526
|
+
newMap.forEach((_, key) => {
|
|
527
|
+
if (key.startsWith(prefix)) newMap.delete(key);
|
|
528
|
+
});
|
|
529
|
+
return newMap;
|
|
530
|
+
});
|
|
531
|
+
}
|
|
532
|
+
clear() {
|
|
533
|
+
this._store.set(/* @__PURE__ */ new Map());
|
|
534
|
+
}
|
|
535
|
+
static {
|
|
536
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
537
|
+
minVersion: "12.0.0",
|
|
538
|
+
version: "22.2.3",
|
|
539
|
+
ngImport: i0,
|
|
540
|
+
type: CacheManagerService,
|
|
541
|
+
deps: [],
|
|
542
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
543
|
+
});
|
|
544
|
+
}
|
|
545
|
+
static {
|
|
546
|
+
this.ɵprov = i0.ɵɵngDeclareInjectable({
|
|
547
|
+
minVersion: "12.0.0",
|
|
548
|
+
version: "22.2.3",
|
|
549
|
+
ngImport: i0,
|
|
550
|
+
type: CacheManagerService,
|
|
551
|
+
providedIn: "root"
|
|
552
|
+
});
|
|
553
|
+
}
|
|
554
|
+
};
|
|
555
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
556
|
+
minVersion: "12.0.0",
|
|
557
|
+
version: "22.2.3",
|
|
558
|
+
ngImport: i0,
|
|
559
|
+
type: CacheManagerService,
|
|
560
|
+
decorators: [{
|
|
561
|
+
type: Injectable,
|
|
562
|
+
args: [{ providedIn: "root" }]
|
|
563
|
+
}]
|
|
564
|
+
});
|
|
565
|
+
var QueryPipelineService = class QueryPipelineService {
|
|
566
|
+
execute(provider, query) {
|
|
567
|
+
switch (query.type) {
|
|
568
|
+
case "list": return this._executeListQuery(provider, query);
|
|
569
|
+
case "one": return this._executeOneQuery(provider, query);
|
|
570
|
+
case "metric": return this._executeMetricQuery(provider, query);
|
|
571
|
+
case "custom": return this._executeCustomQuery(provider, query);
|
|
572
|
+
default: return of({
|
|
573
|
+
data: [],
|
|
574
|
+
total: 0,
|
|
575
|
+
page: 1,
|
|
576
|
+
pageSize: 0,
|
|
577
|
+
totalPages: 0
|
|
578
|
+
});
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
_executeListQuery(provider, query) {
|
|
582
|
+
return provider.fetchList(query);
|
|
583
|
+
}
|
|
584
|
+
_executeOneQuery(provider, query) {
|
|
585
|
+
const id = query.params?.id;
|
|
586
|
+
if (!id) return of({
|
|
587
|
+
data: [],
|
|
588
|
+
total: 0,
|
|
589
|
+
page: 1,
|
|
590
|
+
pageSize: 0,
|
|
591
|
+
totalPages: 0
|
|
592
|
+
});
|
|
593
|
+
return provider.fetchOne(id).pipe(map((item) => ({
|
|
594
|
+
data: item ? [item] : [],
|
|
595
|
+
total: item ? 1 : 0,
|
|
596
|
+
page: 1,
|
|
597
|
+
pageSize: 1,
|
|
598
|
+
totalPages: 1
|
|
599
|
+
})));
|
|
600
|
+
}
|
|
601
|
+
_executeMetricQuery(provider, query) {
|
|
602
|
+
if (!query.aggregation) return of({
|
|
603
|
+
data: [],
|
|
604
|
+
total: 0,
|
|
605
|
+
page: 1,
|
|
606
|
+
pageSize: 0,
|
|
607
|
+
totalPages: 0
|
|
608
|
+
});
|
|
609
|
+
const listQuery = {
|
|
610
|
+
type: "list",
|
|
611
|
+
filters: query.filters,
|
|
612
|
+
pagination: {
|
|
613
|
+
page: 1,
|
|
614
|
+
size: 1e4
|
|
615
|
+
}
|
|
616
|
+
};
|
|
617
|
+
return provider.fetchList(listQuery).pipe(map((paginatedResult) => {
|
|
618
|
+
const data = paginatedResult.data;
|
|
619
|
+
const values = data.map((r) => r[query.aggregation.field] ?? 0);
|
|
620
|
+
let result = 0;
|
|
621
|
+
switch (query.aggregation?.operation) {
|
|
622
|
+
case "sum":
|
|
623
|
+
result = values.reduce((s, v) => s + v, 0);
|
|
624
|
+
break;
|
|
625
|
+
case "avg":
|
|
626
|
+
result = values.length > 0 ? values.reduce((s, v) => s + v, 0) / values.length : 0;
|
|
627
|
+
break;
|
|
628
|
+
case "min":
|
|
629
|
+
result = values.length > 0 ? Math.min(...values) : 0;
|
|
630
|
+
break;
|
|
631
|
+
case "max":
|
|
632
|
+
result = values.length > 0 ? Math.max(...values) : 0;
|
|
633
|
+
break;
|
|
634
|
+
case "count": result = data.length;
|
|
635
|
+
}
|
|
636
|
+
return {
|
|
637
|
+
data: [{ value: result }],
|
|
638
|
+
total: 1,
|
|
639
|
+
page: 1,
|
|
640
|
+
pageSize: 1,
|
|
641
|
+
totalPages: 1
|
|
642
|
+
};
|
|
643
|
+
}));
|
|
644
|
+
}
|
|
645
|
+
_executeCustomQuery(provider, query) {
|
|
646
|
+
if (query.customQuery) try {
|
|
647
|
+
return provider.fetchList({
|
|
648
|
+
...query,
|
|
649
|
+
type: "list"
|
|
650
|
+
}).pipe(map((result) => {
|
|
651
|
+
try {
|
|
652
|
+
if (query.params && typeof query.params === "object") {
|
|
653
|
+
const filtered = result.data.filter((item) => {
|
|
654
|
+
return Object.entries(query.params).every(([key, value]) => {
|
|
655
|
+
return item[key] === value;
|
|
656
|
+
});
|
|
657
|
+
});
|
|
658
|
+
return {
|
|
659
|
+
...result,
|
|
660
|
+
data: filtered.length > 0 ? filtered : result.data,
|
|
661
|
+
total: filtered.length > 0 ? filtered.length : result.total
|
|
662
|
+
};
|
|
663
|
+
}
|
|
664
|
+
return result;
|
|
665
|
+
} catch (err) {
|
|
666
|
+
console.error("Custom query processing failed:", err);
|
|
667
|
+
return {
|
|
668
|
+
data: [],
|
|
669
|
+
total: 0,
|
|
670
|
+
page: 1,
|
|
671
|
+
pageSize: 0,
|
|
672
|
+
totalPages: 0
|
|
673
|
+
};
|
|
674
|
+
}
|
|
675
|
+
}));
|
|
676
|
+
} catch (err) {
|
|
677
|
+
console.error("Failed to process custom query:", err);
|
|
678
|
+
return of({
|
|
679
|
+
data: [],
|
|
680
|
+
total: 0,
|
|
681
|
+
page: 1,
|
|
682
|
+
pageSize: 0,
|
|
683
|
+
totalPages: 0
|
|
684
|
+
});
|
|
685
|
+
}
|
|
686
|
+
return of({
|
|
687
|
+
data: [],
|
|
688
|
+
total: 0,
|
|
689
|
+
page: 1,
|
|
690
|
+
pageSize: 0,
|
|
691
|
+
totalPages: 0
|
|
692
|
+
});
|
|
693
|
+
}
|
|
694
|
+
static {
|
|
695
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
696
|
+
minVersion: "12.0.0",
|
|
697
|
+
version: "22.2.3",
|
|
698
|
+
ngImport: i0,
|
|
699
|
+
type: QueryPipelineService,
|
|
700
|
+
deps: [],
|
|
701
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
702
|
+
});
|
|
703
|
+
}
|
|
704
|
+
static {
|
|
705
|
+
this.ɵprov = i0.ɵɵngDeclareInjectable({
|
|
706
|
+
minVersion: "12.0.0",
|
|
707
|
+
version: "22.2.3",
|
|
708
|
+
ngImport: i0,
|
|
709
|
+
type: QueryPipelineService,
|
|
710
|
+
providedIn: "root"
|
|
711
|
+
});
|
|
712
|
+
}
|
|
713
|
+
};
|
|
714
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
715
|
+
minVersion: "12.0.0",
|
|
716
|
+
version: "22.2.3",
|
|
717
|
+
ngImport: i0,
|
|
718
|
+
type: QueryPipelineService,
|
|
719
|
+
decorators: [{
|
|
720
|
+
type: Injectable,
|
|
721
|
+
args: [{ providedIn: "root" }]
|
|
722
|
+
}]
|
|
723
|
+
});
|
|
724
|
+
var BindingResolverService = class BindingResolverService {
|
|
725
|
+
constructor() {
|
|
726
|
+
this.bindingCache = /* @__PURE__ */ new Map();
|
|
727
|
+
this.providerRegistry = inject(ProviderRegistryService);
|
|
728
|
+
this.queryPipeline = inject(QueryPipelineService);
|
|
729
|
+
this.cacheManager = inject(CacheManagerService);
|
|
730
|
+
}
|
|
731
|
+
resolveBinding(component, template) {
|
|
732
|
+
if (!component.dataBinding) return of(null);
|
|
733
|
+
const cacheKey = this._generateCacheKey(component, template);
|
|
734
|
+
const cached = this.bindingCache.get(cacheKey);
|
|
735
|
+
if (cached) return cached;
|
|
736
|
+
const result$ = this._executeBinding(component, template).pipe(shareReplay({
|
|
737
|
+
bufferSize: 1,
|
|
738
|
+
refCount: false
|
|
739
|
+
}));
|
|
740
|
+
this.bindingCache.set(cacheKey, result$);
|
|
741
|
+
return result$;
|
|
742
|
+
}
|
|
743
|
+
clearCache(componentId) {
|
|
744
|
+
const keysToDelete = [];
|
|
745
|
+
this.bindingCache.forEach((_, key) => {
|
|
746
|
+
if (key.startsWith(`component:${componentId}:`)) keysToDelete.push(key);
|
|
747
|
+
});
|
|
748
|
+
keysToDelete.forEach((key) => this.bindingCache.delete(key));
|
|
749
|
+
}
|
|
750
|
+
clearDataCache(componentId) {
|
|
751
|
+
this.cacheManager.clearByComponentId(componentId);
|
|
752
|
+
}
|
|
753
|
+
getEnhancedQuery(query, componentParams = [], templateParams = []) {
|
|
754
|
+
return this._enhanceQueryWithParameters(query, componentParams, templateParams);
|
|
755
|
+
}
|
|
756
|
+
getCachedResult(component, template) {
|
|
757
|
+
if (!component.dataBinding) return null;
|
|
758
|
+
const cacheKeyWithTotal = `${this._generateCacheKey(component, template)}:full`;
|
|
759
|
+
return this.cacheManager.get(cacheKeyWithTotal);
|
|
760
|
+
}
|
|
761
|
+
_createFilterCondition(param) {
|
|
762
|
+
let operator = "=";
|
|
763
|
+
let value;
|
|
764
|
+
switch (param.type) {
|
|
765
|
+
case "number":
|
|
766
|
+
value = Number(param.value);
|
|
767
|
+
break;
|
|
768
|
+
case "date":
|
|
769
|
+
value = param.value;
|
|
770
|
+
break;
|
|
771
|
+
case "boolean":
|
|
772
|
+
value = param.value === "true" || param.value === "1";
|
|
773
|
+
break;
|
|
774
|
+
default:
|
|
775
|
+
operator = "like";
|
|
776
|
+
value = String(param.value);
|
|
777
|
+
}
|
|
778
|
+
return {
|
|
779
|
+
field: param.key,
|
|
780
|
+
operator,
|
|
781
|
+
value
|
|
782
|
+
};
|
|
783
|
+
}
|
|
784
|
+
_executeBinding(component, template) {
|
|
785
|
+
const binding = component.dataBinding;
|
|
786
|
+
if (!binding) return of(null);
|
|
787
|
+
const provider = this.providerRegistry.getProvider(binding.providerRef);
|
|
788
|
+
if (!provider) {
|
|
789
|
+
console.error("[BindingResolver] Provider not found:", binding.providerRef);
|
|
790
|
+
return throwError(() => /* @__PURE__ */ new Error(`Provider ${binding.providerRef} not found`));
|
|
791
|
+
}
|
|
792
|
+
const cacheKey = this._generateCacheKey(component, template);
|
|
793
|
+
const cached = this.cacheManager.get(cacheKey);
|
|
794
|
+
if (cached) return of(cached);
|
|
795
|
+
const enhancedQuery = this._enhanceQueryWithParameters(binding.query, component.parameters, template.parameters);
|
|
796
|
+
return this.queryPipeline.execute(provider, enhancedQuery).pipe(tap((result) => {
|
|
797
|
+
const cacheKeyWithTotal = `${cacheKey}:full`;
|
|
798
|
+
this.cacheManager.set(cacheKeyWithTotal, result, binding.cache);
|
|
799
|
+
}), map((result) => {
|
|
800
|
+
return this._applyPipeline(result.data, binding.pipeline);
|
|
801
|
+
}), tap((data) => this.cacheManager.set(cacheKey, data, binding.cache)), timeout(3e4), retry({
|
|
802
|
+
count: 2,
|
|
803
|
+
delay: 1e3
|
|
804
|
+
}), catchError((err) => {
|
|
805
|
+
console.error("[BindingResolver] Query execution failed:", err);
|
|
806
|
+
return of(null);
|
|
807
|
+
}), take(1));
|
|
808
|
+
}
|
|
809
|
+
_enhanceQueryWithParameters(query, componentParams = [], templateParams = []) {
|
|
810
|
+
if (!query) return query;
|
|
811
|
+
const enhancedQuery = JSON.parse(JSON.stringify(query));
|
|
812
|
+
const allParams = /* @__PURE__ */ new Map();
|
|
813
|
+
templateParams.forEach((param) => {
|
|
814
|
+
allParams.set(param.key, param);
|
|
815
|
+
});
|
|
816
|
+
componentParams.forEach((param) => {
|
|
817
|
+
allParams.set(param.key, param);
|
|
818
|
+
});
|
|
819
|
+
if (allParams.size === 0 && (!enhancedQuery.filters || enhancedQuery.filters.length === 0)) return enhancedQuery;
|
|
820
|
+
enhancedQuery.filters ??= [];
|
|
821
|
+
if (enhancedQuery.filters.length === 0) {
|
|
822
|
+
allParams.forEach((param, paramKey) => {
|
|
823
|
+
if (!param.key || param.value === void 0 || param.value === null) return;
|
|
824
|
+
if (param.value === "全部" || param.value === "all" || param.value === "*" || param.value === "") return;
|
|
825
|
+
enhancedQuery.filters?.push(this._createFilterCondition({
|
|
826
|
+
key: paramKey,
|
|
827
|
+
value: this._resolveFilterValue(param),
|
|
828
|
+
type: param.type
|
|
829
|
+
}));
|
|
830
|
+
});
|
|
831
|
+
return enhancedQuery;
|
|
832
|
+
}
|
|
833
|
+
const consumedParamKeys = /* @__PURE__ */ new Set();
|
|
834
|
+
enhancedQuery.filters = enhancedQuery.filters.map((filter) => {
|
|
835
|
+
let updatedFilter = filter;
|
|
836
|
+
allParams.forEach((param, paramKey) => {
|
|
837
|
+
if (updatedFilter === null) return;
|
|
838
|
+
const placeholders = [
|
|
839
|
+
`{{template.parameters.${paramKey}}}`,
|
|
840
|
+
`{{component.parameters.${paramKey}}}`,
|
|
841
|
+
`{{${paramKey}}}`
|
|
842
|
+
];
|
|
843
|
+
for (const placeholder of placeholders) if (typeof updatedFilter.value === "string" && updatedFilter.value.includes(placeholder)) {
|
|
844
|
+
consumedParamKeys.add(paramKey);
|
|
845
|
+
if (param.value === void 0 || param.value === null || param.value === "全部" || param.value === "all" || param.value === "*" || param.value === "") updatedFilter = null;
|
|
846
|
+
else updatedFilter = {
|
|
847
|
+
...updatedFilter,
|
|
848
|
+
value: this._normalizeFilterValue(this._resolveFilterValue(param))
|
|
849
|
+
};
|
|
850
|
+
break;
|
|
851
|
+
}
|
|
852
|
+
});
|
|
853
|
+
if (updatedFilter !== null && typeof updatedFilter.value === "string" && /\{\{[^}]+\}\}/.test(updatedFilter.value)) return null;
|
|
854
|
+
return updatedFilter;
|
|
855
|
+
}).filter((f) => f !== null);
|
|
856
|
+
allParams.forEach((param, paramKey) => {
|
|
857
|
+
if (consumedParamKeys.has(paramKey)) return;
|
|
858
|
+
if (!param.key || param.value === void 0 || param.value === null) return;
|
|
859
|
+
if (param.value === "全部" || param.value === "all" || param.value === "*" || param.value === "") return;
|
|
860
|
+
enhancedQuery.filters?.push(this._createFilterCondition({
|
|
861
|
+
key: paramKey,
|
|
862
|
+
value: this._resolveFilterValue(param),
|
|
863
|
+
type: param.type
|
|
864
|
+
}));
|
|
865
|
+
});
|
|
866
|
+
return enhancedQuery;
|
|
867
|
+
}
|
|
868
|
+
_resolveFilterValue(param) {
|
|
869
|
+
if (param.type === "tree-select") return this._extractTreeSelectIds(param.value);
|
|
870
|
+
return param.value;
|
|
871
|
+
}
|
|
872
|
+
_normalizeFilterValue(value) {
|
|
873
|
+
if (Array.isArray(value)) return value.join(",");
|
|
874
|
+
return value;
|
|
875
|
+
}
|
|
876
|
+
_extractTreeSelectIds(value) {
|
|
877
|
+
if (value === null || value === void 0) return null;
|
|
878
|
+
if (Array.isArray(value)) {
|
|
879
|
+
const ids = value.filter((item) => item?.id !== void 0).map((item) => item.id);
|
|
880
|
+
return ids.length > 0 ? ids : null;
|
|
881
|
+
}
|
|
882
|
+
if (typeof value === "object" && value.id !== void 0) return value.id;
|
|
883
|
+
return value;
|
|
884
|
+
}
|
|
885
|
+
_generateCacheKey(component, template) {
|
|
886
|
+
const binding = component.dataBinding;
|
|
887
|
+
if (!binding) return `component:${component.id}:no-binding`;
|
|
888
|
+
const queryHash = this._hashQueryConfig(binding.query);
|
|
889
|
+
const effectiveParams = this._getEffectiveRelevantParams(binding.query, component.parameters, template.parameters);
|
|
890
|
+
const paramsHash = this._hashParameters(effectiveParams);
|
|
891
|
+
return `component:${component.id}:query:${queryHash}:params:${paramsHash}`;
|
|
892
|
+
}
|
|
893
|
+
_getEffectiveRelevantParams(query, componentParams, templateParams) {
|
|
894
|
+
const merged = /* @__PURE__ */ new Map();
|
|
895
|
+
templateParams?.forEach((p) => merged.set(p.key, p));
|
|
896
|
+
componentParams?.forEach((p) => merged.set(p.key, p));
|
|
897
|
+
const referencedKeys = this._getReferencedTemplateParamKeys(query);
|
|
898
|
+
if (referencedKeys === null) return Array.from(merged.values());
|
|
899
|
+
return Array.from(merged.values()).filter((p) => referencedKeys.has(p.key));
|
|
900
|
+
}
|
|
901
|
+
_getReferencedTemplateParamKeys(query) {
|
|
902
|
+
if (!query?.filters || query.filters.length === 0) return null;
|
|
903
|
+
const referencedKeys = /* @__PURE__ */ new Set();
|
|
904
|
+
const placeholderRegex = /\{\{[^}]*\.?(\w+)\}\}/g;
|
|
905
|
+
let hasAnyPlaceholder = false;
|
|
906
|
+
for (const filter of query.filters) {
|
|
907
|
+
if (typeof filter.value !== "string") continue;
|
|
908
|
+
let match;
|
|
909
|
+
while ((match = placeholderRegex.exec(filter.value)) !== null) {
|
|
910
|
+
hasAnyPlaceholder = true;
|
|
911
|
+
referencedKeys.add(match[1]);
|
|
912
|
+
}
|
|
913
|
+
}
|
|
914
|
+
if (!hasAnyPlaceholder) return null;
|
|
915
|
+
return referencedKeys;
|
|
916
|
+
}
|
|
917
|
+
_hashParameters(parameters) {
|
|
918
|
+
if (!parameters || parameters.length === 0) return "none";
|
|
919
|
+
const str = JSON.stringify([...parameters].sort((a, b) => a.key.localeCompare(b.key)), ["key", "value"]);
|
|
920
|
+
let hash = 0;
|
|
921
|
+
for (let i = 0; i < str.length; i++) {
|
|
922
|
+
const char = str.charCodeAt(i);
|
|
923
|
+
hash = (hash << 5) - hash + char;
|
|
924
|
+
hash = hash & hash;
|
|
925
|
+
}
|
|
926
|
+
return Math.abs(hash).toString(36);
|
|
927
|
+
}
|
|
928
|
+
_hashQueryConfig(query) {
|
|
929
|
+
const str = JSON.stringify(query, Object.keys(query).sort());
|
|
930
|
+
let hash = 0;
|
|
931
|
+
for (let i = 0; i < str.length; i++) {
|
|
932
|
+
const char = str.charCodeAt(i);
|
|
933
|
+
hash = (hash << 5) - hash + char;
|
|
934
|
+
hash = hash & hash;
|
|
935
|
+
}
|
|
936
|
+
return Math.abs(hash).toString(36);
|
|
937
|
+
}
|
|
938
|
+
_applyPipeline(data, pipeline) {
|
|
939
|
+
if (!pipeline) return data;
|
|
940
|
+
let result = data;
|
|
941
|
+
if (pipeline.postProcess && pipeline.postProcess.length > 0) for (const step of pipeline.postProcess) result = this._applyTransformStep(result, step);
|
|
942
|
+
if (pipeline.fieldMapping && pipeline.fieldMapping.length > 0) result = this._applyFieldMapping(result, pipeline.fieldMapping);
|
|
943
|
+
return result;
|
|
944
|
+
}
|
|
945
|
+
_applyTransformStep(data, step) {
|
|
946
|
+
switch (step.type) {
|
|
947
|
+
case "filter": {
|
|
948
|
+
const predicate = step.config.predicate;
|
|
949
|
+
if (typeof predicate === "function") return data.filter(predicate);
|
|
950
|
+
return data;
|
|
951
|
+
}
|
|
952
|
+
case "map": {
|
|
953
|
+
const mapper = step.config.mapper;
|
|
954
|
+
if (typeof mapper === "function") return data.map(mapper);
|
|
955
|
+
return data;
|
|
956
|
+
}
|
|
957
|
+
case "sort": {
|
|
958
|
+
const comparator = step.config.comparator;
|
|
959
|
+
if (typeof comparator === "function") return data.sort(comparator);
|
|
960
|
+
return data;
|
|
961
|
+
}
|
|
962
|
+
case "limit": return data.slice(0, step.config.count ?? data.length);
|
|
963
|
+
default: return data;
|
|
964
|
+
}
|
|
965
|
+
}
|
|
966
|
+
_applyFieldMapping(data, mappings) {
|
|
967
|
+
return data.map((row) => {
|
|
968
|
+
const mapped = {};
|
|
969
|
+
for (const [key, value] of Object.entries(row ?? {})) {
|
|
970
|
+
const mapping = mappings.find((m) => m.from === key);
|
|
971
|
+
mapped[mapping?.to ?? key] = value;
|
|
972
|
+
}
|
|
973
|
+
return mapped;
|
|
974
|
+
});
|
|
975
|
+
}
|
|
976
|
+
static {
|
|
977
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
978
|
+
minVersion: "12.0.0",
|
|
979
|
+
version: "22.2.3",
|
|
980
|
+
ngImport: i0,
|
|
981
|
+
type: BindingResolverService,
|
|
982
|
+
deps: [],
|
|
983
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
984
|
+
});
|
|
985
|
+
}
|
|
986
|
+
static {
|
|
987
|
+
this.ɵprov = i0.ɵɵngDeclareInjectable({
|
|
988
|
+
minVersion: "12.0.0",
|
|
989
|
+
version: "22.2.3",
|
|
990
|
+
ngImport: i0,
|
|
991
|
+
type: BindingResolverService,
|
|
992
|
+
providedIn: "root"
|
|
993
|
+
});
|
|
994
|
+
}
|
|
995
|
+
};
|
|
996
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
997
|
+
minVersion: "12.0.0",
|
|
998
|
+
version: "22.2.3",
|
|
999
|
+
ngImport: i0,
|
|
1000
|
+
type: BindingResolverService,
|
|
1001
|
+
decorators: [{
|
|
1002
|
+
type: Injectable,
|
|
1003
|
+
args: [{ providedIn: "root" }]
|
|
1004
|
+
}]
|
|
1005
|
+
});
|
|
1006
|
+
var ComponentRegistryService = class ComponentRegistryService {
|
|
1007
|
+
constructor() {
|
|
1008
|
+
this._registry = /* @__PURE__ */ new Map();
|
|
1009
|
+
}
|
|
1010
|
+
register(key, component, metadata) {
|
|
1011
|
+
if (this._registry.has(key)) console.warn(`[ComponentRegistry] 组件已存在,将被覆盖: ${key}`);
|
|
1012
|
+
this._registry.set(key, {
|
|
1013
|
+
key,
|
|
1014
|
+
component,
|
|
1015
|
+
metadata: {
|
|
1016
|
+
name: metadata?.name ?? key,
|
|
1017
|
+
description: metadata?.description,
|
|
1018
|
+
category: metadata?.category
|
|
1019
|
+
}
|
|
1020
|
+
});
|
|
1021
|
+
console.log(`[ComponentRegistry] 组件已注册: ${key}`);
|
|
1022
|
+
}
|
|
1023
|
+
registerBatch(entries) {
|
|
1024
|
+
entries.forEach((entry) => {
|
|
1025
|
+
this.register(entry.key, entry.component, entry.metadata);
|
|
1026
|
+
});
|
|
1027
|
+
}
|
|
1028
|
+
getComponent(key) {
|
|
1029
|
+
const entry = this._registry.get(key);
|
|
1030
|
+
if (!entry) {
|
|
1031
|
+
console.warn(`[ComponentRegistry] 未找到组件: ${key}`);
|
|
1032
|
+
console.warn("[ComponentRegistry] 已注册的组件:", Array.from(this._registry.keys()));
|
|
1033
|
+
}
|
|
1034
|
+
return entry?.component;
|
|
1035
|
+
}
|
|
1036
|
+
hasComponent(key) {
|
|
1037
|
+
return this._registry.has(key);
|
|
1038
|
+
}
|
|
1039
|
+
unregister(key) {
|
|
1040
|
+
if (this._registry.delete(key)) console.log(`[ComponentRegistry] 组件已注销: ${key}`);
|
|
1041
|
+
else console.warn(`[ComponentRegistry] 组件不存在,无法注销: ${key}`);
|
|
1042
|
+
}
|
|
1043
|
+
getAllKeys() {
|
|
1044
|
+
return Array.from(this._registry.keys());
|
|
1045
|
+
}
|
|
1046
|
+
getAllEntries() {
|
|
1047
|
+
return Array.from(this._registry.values());
|
|
1048
|
+
}
|
|
1049
|
+
clear() {
|
|
1050
|
+
this._registry.clear();
|
|
1051
|
+
console.log("[ComponentRegistry] 所有组件已注销");
|
|
1052
|
+
}
|
|
1053
|
+
size() {
|
|
1054
|
+
return this._registry.size;
|
|
1055
|
+
}
|
|
1056
|
+
static {
|
|
1057
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
1058
|
+
minVersion: "12.0.0",
|
|
1059
|
+
version: "22.2.3",
|
|
1060
|
+
ngImport: i0,
|
|
1061
|
+
type: ComponentRegistryService,
|
|
1062
|
+
deps: [],
|
|
1063
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
1064
|
+
});
|
|
1065
|
+
}
|
|
1066
|
+
static {
|
|
1067
|
+
this.ɵprov = i0.ɵɵngDeclareInjectable({
|
|
1068
|
+
minVersion: "12.0.0",
|
|
1069
|
+
version: "22.2.3",
|
|
1070
|
+
ngImport: i0,
|
|
1071
|
+
type: ComponentRegistryService,
|
|
1072
|
+
providedIn: "root"
|
|
1073
|
+
});
|
|
1074
|
+
}
|
|
1075
|
+
};
|
|
1076
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
1077
|
+
minVersion: "12.0.0",
|
|
1078
|
+
version: "22.2.3",
|
|
1079
|
+
ngImport: i0,
|
|
1080
|
+
type: ComponentRegistryService,
|
|
1081
|
+
decorators: [{
|
|
1082
|
+
type: Injectable,
|
|
1083
|
+
args: [{ providedIn: "root" }]
|
|
1084
|
+
}]
|
|
1085
|
+
});
|
|
1086
|
+
var DrillDownService = class DrillDownService {
|
|
1087
|
+
constructor() {
|
|
1088
|
+
this._router = inject(Router);
|
|
1089
|
+
this._dialog = inject(MatDialog);
|
|
1090
|
+
this._registry = inject(ComponentRegistryService);
|
|
1091
|
+
}
|
|
1092
|
+
execute(config, context) {
|
|
1093
|
+
if (!config.enabled) {
|
|
1094
|
+
console.warn("[DrillDown] 下钻未启用");
|
|
1095
|
+
return;
|
|
1096
|
+
}
|
|
1097
|
+
const normalizedContext = this._normalizeContext(context);
|
|
1098
|
+
console.log("[DrillDown] 执行下钻:", {
|
|
1099
|
+
config,
|
|
1100
|
+
context: normalizedContext
|
|
1101
|
+
});
|
|
1102
|
+
switch (config.actionType) {
|
|
1103
|
+
case "route":
|
|
1104
|
+
this._handleRoute(config.route, normalizedContext);
|
|
1105
|
+
break;
|
|
1106
|
+
case "dialog":
|
|
1107
|
+
this._handleDialog(config.dialog, normalizedContext);
|
|
1108
|
+
break;
|
|
1109
|
+
case "drawer":
|
|
1110
|
+
this._handleDrawer(config.dialog, normalizedContext);
|
|
1111
|
+
break;
|
|
1112
|
+
default: console.error("[DrillDown] 未知的下钻类型:", config.actionType);
|
|
1113
|
+
}
|
|
1114
|
+
}
|
|
1115
|
+
_normalizeContext(context) {
|
|
1116
|
+
if (context && typeof context === "object" && "componentId" in context) {
|
|
1117
|
+
console.log("[DrillDown] 使用已有的 DrillDownContext:", context);
|
|
1118
|
+
return context;
|
|
1119
|
+
}
|
|
1120
|
+
return {
|
|
1121
|
+
clickedValue: context,
|
|
1122
|
+
rowData: this._extractRowData(context),
|
|
1123
|
+
componentId: "unknown",
|
|
1124
|
+
timestamp: Date.now()
|
|
1125
|
+
};
|
|
1126
|
+
}
|
|
1127
|
+
_extractRowData(context) {
|
|
1128
|
+
if (context && typeof context === "object" && "rowData" in context) return context.rowData;
|
|
1129
|
+
if (Array.isArray(context)) {
|
|
1130
|
+
if (context.length > 0) {
|
|
1131
|
+
const firstElement = context[0];
|
|
1132
|
+
if (firstElement && typeof firstElement === "object" && !Array.isArray(firstElement)) return firstElement;
|
|
1133
|
+
return { value: firstElement };
|
|
1134
|
+
}
|
|
1135
|
+
return;
|
|
1136
|
+
}
|
|
1137
|
+
if (context && typeof context === "object") {
|
|
1138
|
+
const excludedKeys = [
|
|
1139
|
+
"componentId",
|
|
1140
|
+
"templateId",
|
|
1141
|
+
"timestamp",
|
|
1142
|
+
"seriesName",
|
|
1143
|
+
"dimension",
|
|
1144
|
+
"dataIndex"
|
|
1145
|
+
];
|
|
1146
|
+
const filtered = {};
|
|
1147
|
+
for (const [key, value] of Object.entries(context)) if (!excludedKeys.includes(key)) filtered[key] = value;
|
|
1148
|
+
if (Object.keys(filtered).length > 0) return filtered;
|
|
1149
|
+
}
|
|
1150
|
+
}
|
|
1151
|
+
_handleRoute(routeConfig, context) {
|
|
1152
|
+
const queryParams = this._resolveMapping(routeConfig.queryParamsMapping ?? {}, context.rowData ?? {}, context.templateParameters);
|
|
1153
|
+
this._router.navigate([routeConfig.path], { queryParams });
|
|
1154
|
+
}
|
|
1155
|
+
_handleDialog(dialogConfig, context) {
|
|
1156
|
+
const componentClass = this._registry.getComponent(dialogConfig.component);
|
|
1157
|
+
if (!componentClass) {
|
|
1158
|
+
console.error(`[DrillDown] 未找到注册的组件: ${dialogConfig.component}`);
|
|
1159
|
+
return;
|
|
1160
|
+
}
|
|
1161
|
+
const dialogData = this._resolveMapping(dialogConfig.dataMapping ?? {}, context.rowData ?? {}, context.templateParameters);
|
|
1162
|
+
console.log("[DrillDown] 打开 Dialog:", {
|
|
1163
|
+
component: dialogConfig.component,
|
|
1164
|
+
width: dialogConfig.width ?? "80vw",
|
|
1165
|
+
data: dialogData
|
|
1166
|
+
});
|
|
1167
|
+
this._dialog.open(componentClass, {
|
|
1168
|
+
width: dialogConfig.width ?? "80vw",
|
|
1169
|
+
height: dialogConfig.height,
|
|
1170
|
+
data: dialogData
|
|
1171
|
+
}).afterClosed().subscribe((result) => {
|
|
1172
|
+
console.log("[DrillDown] Dialog 关闭:", result);
|
|
1173
|
+
});
|
|
1174
|
+
}
|
|
1175
|
+
_handleDrawer(drawerConfig, context) {
|
|
1176
|
+
if (!this._registry.getComponent(drawerConfig.component)) {
|
|
1177
|
+
console.error(`[DrillDown] 未找到注册的组件: ${drawerConfig.component}`);
|
|
1178
|
+
return;
|
|
1179
|
+
}
|
|
1180
|
+
const drawerData = this._resolveMapping(drawerConfig.dataMapping ?? {}, context.rowData ?? {}, context.templateParameters);
|
|
1181
|
+
console.log("[DrillDown] 打开 Drawer:", {
|
|
1182
|
+
component: drawerConfig.component,
|
|
1183
|
+
width: drawerConfig.width ?? "400px",
|
|
1184
|
+
data: drawerData
|
|
1185
|
+
});
|
|
1186
|
+
console.warn("[DrillDown] Drawer 功能待实现,需要创建自定义 Drawer 容器");
|
|
1187
|
+
}
|
|
1188
|
+
_resolveMapping(mapping, rowData, templateParameters) {
|
|
1189
|
+
const result = {};
|
|
1190
|
+
for (const [target, source] of Object.entries(mapping)) {
|
|
1191
|
+
if (typeof source !== "string") {
|
|
1192
|
+
result[target] = source;
|
|
1193
|
+
continue;
|
|
1194
|
+
}
|
|
1195
|
+
const placeholder = /^\{\{\s*template\.parameters\.([\w.]+)\s*\}\}$/.exec(source);
|
|
1196
|
+
if (placeholder) {
|
|
1197
|
+
result[target] = (templateParameters?.find((p) => p.key === placeholder[1]))?.value;
|
|
1198
|
+
continue;
|
|
1199
|
+
}
|
|
1200
|
+
const fieldValue = this._getNestedValue(rowData, source);
|
|
1201
|
+
result[target] = fieldValue !== void 0 ? fieldValue : source;
|
|
1202
|
+
}
|
|
1203
|
+
for (const key of Object.keys(result)) if (result[key] === void 0 || result[key] === null) delete result[key];
|
|
1204
|
+
return result;
|
|
1205
|
+
}
|
|
1206
|
+
_getNestedValue(obj, path) {
|
|
1207
|
+
if (!obj || !path) return;
|
|
1208
|
+
return path.split(".").reduce((acc, part) => {
|
|
1209
|
+
return acc?.[part];
|
|
1210
|
+
}, obj);
|
|
1211
|
+
}
|
|
1212
|
+
static {
|
|
1213
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
1214
|
+
minVersion: "12.0.0",
|
|
1215
|
+
version: "22.2.3",
|
|
1216
|
+
ngImport: i0,
|
|
1217
|
+
type: DrillDownService,
|
|
1218
|
+
deps: [],
|
|
1219
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
1220
|
+
});
|
|
1221
|
+
}
|
|
1222
|
+
static {
|
|
1223
|
+
this.ɵprov = i0.ɵɵngDeclareInjectable({
|
|
1224
|
+
minVersion: "12.0.0",
|
|
1225
|
+
version: "22.2.3",
|
|
1226
|
+
ngImport: i0,
|
|
1227
|
+
type: DrillDownService,
|
|
1228
|
+
providedIn: "root"
|
|
1229
|
+
});
|
|
1230
|
+
}
|
|
1231
|
+
};
|
|
1232
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
1233
|
+
minVersion: "12.0.0",
|
|
1234
|
+
version: "22.2.3",
|
|
1235
|
+
ngImport: i0,
|
|
1236
|
+
type: DrillDownService,
|
|
1237
|
+
decorators: [{
|
|
1238
|
+
type: Injectable,
|
|
1239
|
+
args: [{ providedIn: "root" }]
|
|
1240
|
+
}]
|
|
1241
|
+
});
|
|
1242
|
+
var BaseRendererComponent = class BaseRendererComponent {
|
|
1243
|
+
constructor() {
|
|
1244
|
+
this.component = input.required(...ngDevMode ? [{ debugName: "component" }] : /* istanbul ignore next */ []);
|
|
1245
|
+
this.template = input.required(...ngDevMode ? [{ debugName: "template" }] : /* istanbul ignore next */ []);
|
|
1246
|
+
this.hasFilterButton = input(false, ...ngDevMode ? [{ debugName: "hasFilterButton" }] : /* istanbul ignore next */ []);
|
|
1247
|
+
this.data = signal(null, ...ngDevMode ? [{ debugName: "data" }] : /* istanbul ignore next */ []);
|
|
1248
|
+
this.loading = signal(false, ...ngDevMode ? [{ debugName: "loading" }] : /* istanbul ignore next */ []);
|
|
1249
|
+
this.error = signal(null, ...ngDevMode ? [{ debugName: "error" }] : /* istanbul ignore next */ []);
|
|
1250
|
+
this.bindingResolver = inject(BindingResolverService);
|
|
1251
|
+
this._componentParamsFingerprint = computed(() => {
|
|
1252
|
+
const comp = this.component();
|
|
1253
|
+
if (!comp?.parameters) return "";
|
|
1254
|
+
return comp.parameters.map((p) => `${p.key}=${JSON.stringify(p.value)}`).sort().join("&");
|
|
1255
|
+
}, ...ngDevMode ? [{ debugName: "_componentParamsFingerprint" }] : /* istanbul ignore next */ []);
|
|
1256
|
+
effect(() => {
|
|
1257
|
+
const comp = this.component();
|
|
1258
|
+
this._componentParamsFingerprint();
|
|
1259
|
+
if (!comp?.dataBinding) return;
|
|
1260
|
+
const tpl = this.template();
|
|
1261
|
+
if (!tpl) return;
|
|
1262
|
+
untracked(() => this.loadData(comp, tpl));
|
|
1263
|
+
});
|
|
1264
|
+
}
|
|
1265
|
+
refresh() {
|
|
1266
|
+
const comp = this.component();
|
|
1267
|
+
if (comp.dataBinding) {
|
|
1268
|
+
this.bindingResolver.clearCache(comp.id);
|
|
1269
|
+
this.loadData(comp, this.template());
|
|
1270
|
+
}
|
|
1271
|
+
}
|
|
1272
|
+
loadData(component, template) {
|
|
1273
|
+
this._dataSubscription?.unsubscribe();
|
|
1274
|
+
this.loading.set(true);
|
|
1275
|
+
this.error.set(null);
|
|
1276
|
+
this._dataSubscription = this.bindingResolver.resolveBinding(component, template).subscribe({
|
|
1277
|
+
next: (value) => {
|
|
1278
|
+
this.data.set(value);
|
|
1279
|
+
this.onDataLoaded(value);
|
|
1280
|
+
this.loading.set(false);
|
|
1281
|
+
},
|
|
1282
|
+
error: (err) => {
|
|
1283
|
+
this.error.set(err instanceof Error ? err : new Error(String(err)));
|
|
1284
|
+
this.loading.set(false);
|
|
1285
|
+
}
|
|
1286
|
+
});
|
|
1287
|
+
}
|
|
1288
|
+
onDataLoaded(data) {}
|
|
1289
|
+
static {
|
|
1290
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
1291
|
+
minVersion: "12.0.0",
|
|
1292
|
+
version: "22.2.3",
|
|
1293
|
+
ngImport: i0,
|
|
1294
|
+
type: BaseRendererComponent,
|
|
1295
|
+
deps: [],
|
|
1296
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
1297
|
+
});
|
|
1298
|
+
}
|
|
1299
|
+
static {
|
|
1300
|
+
this.ɵcmp = i0.ɵɵngDeclareComponent({
|
|
1301
|
+
minVersion: "17.1.0",
|
|
1302
|
+
version: "22.2.3",
|
|
1303
|
+
type: BaseRendererComponent,
|
|
1304
|
+
isStandalone: true,
|
|
1305
|
+
selector: "app-base-renderer",
|
|
1306
|
+
inputs: {
|
|
1307
|
+
component: {
|
|
1308
|
+
classPropertyName: "component",
|
|
1309
|
+
publicName: "component",
|
|
1310
|
+
isSignal: true,
|
|
1311
|
+
isRequired: true,
|
|
1312
|
+
transformFunction: null
|
|
1313
|
+
},
|
|
1314
|
+
template: {
|
|
1315
|
+
classPropertyName: "template",
|
|
1316
|
+
publicName: "template",
|
|
1317
|
+
isSignal: true,
|
|
1318
|
+
isRequired: true,
|
|
1319
|
+
transformFunction: null
|
|
1320
|
+
},
|
|
1321
|
+
hasFilterButton: {
|
|
1322
|
+
classPropertyName: "hasFilterButton",
|
|
1323
|
+
publicName: "hasFilterButton",
|
|
1324
|
+
isSignal: true,
|
|
1325
|
+
isRequired: false,
|
|
1326
|
+
transformFunction: null
|
|
1327
|
+
}
|
|
1328
|
+
},
|
|
1329
|
+
ngImport: i0,
|
|
1330
|
+
template: "",
|
|
1331
|
+
isInline: true,
|
|
1332
|
+
changeDetection: i0.ChangeDetectionStrategy.OnPush
|
|
1333
|
+
});
|
|
1334
|
+
}
|
|
1335
|
+
};
|
|
1336
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
1337
|
+
minVersion: "12.0.0",
|
|
1338
|
+
version: "22.2.3",
|
|
1339
|
+
ngImport: i0,
|
|
1340
|
+
type: BaseRendererComponent,
|
|
1341
|
+
decorators: [{
|
|
1342
|
+
type: Component,
|
|
1343
|
+
args: [{
|
|
1344
|
+
selector: "app-base-renderer",
|
|
1345
|
+
template: "",
|
|
1346
|
+
changeDetection: ChangeDetectionStrategy.OnPush
|
|
1347
|
+
}]
|
|
1348
|
+
}],
|
|
1349
|
+
ctorParameters: () => [],
|
|
1350
|
+
propDecorators: {
|
|
1351
|
+
component: [{
|
|
1352
|
+
type: i0.Input,
|
|
1353
|
+
args: [{
|
|
1354
|
+
isSignal: true,
|
|
1355
|
+
alias: "component",
|
|
1356
|
+
required: true
|
|
1357
|
+
}]
|
|
1358
|
+
}],
|
|
1359
|
+
template: [{
|
|
1360
|
+
type: i0.Input,
|
|
1361
|
+
args: [{
|
|
1362
|
+
isSignal: true,
|
|
1363
|
+
alias: "template",
|
|
1364
|
+
required: true
|
|
1365
|
+
}]
|
|
1366
|
+
}],
|
|
1367
|
+
hasFilterButton: [{
|
|
1368
|
+
type: i0.Input,
|
|
1369
|
+
args: [{
|
|
1370
|
+
isSignal: true,
|
|
1371
|
+
alias: "hasFilterButton",
|
|
1372
|
+
required: false
|
|
1373
|
+
}]
|
|
1374
|
+
}]
|
|
1375
|
+
}
|
|
1376
|
+
});
|
|
1377
|
+
var TextRendererComponent = class TextRendererComponent extends BaseRendererComponent {
|
|
1378
|
+
constructor() {
|
|
1379
|
+
super();
|
|
1380
|
+
this.config = signal(null, ...ngDevMode ? [{ debugName: "config" }] : /* istanbul ignore next */ []);
|
|
1381
|
+
this.twClasses = computed(() => this.config()?.text?.twClasses ?? [], ...ngDevMode ? [{ debugName: "twClasses" }] : /* istanbul ignore next */ []);
|
|
1382
|
+
this.content = computed(() => {
|
|
1383
|
+
const data = this.data();
|
|
1384
|
+
const staticText = this.config()?.text?.staticText;
|
|
1385
|
+
if (staticText?.trim()) return staticText;
|
|
1386
|
+
if (data != null) {
|
|
1387
|
+
if (Array.isArray(data)) {
|
|
1388
|
+
if (data.length > 0) {
|
|
1389
|
+
const firstItem = data[0];
|
|
1390
|
+
if (typeof firstItem === "object" && firstItem !== null) return firstItem.title ?? firstItem.text ?? firstItem.content ?? firstItem.value ?? firstItem.label ?? JSON.stringify(firstItem);
|
|
1391
|
+
return firstItem;
|
|
1392
|
+
}
|
|
1393
|
+
return "";
|
|
1394
|
+
}
|
|
1395
|
+
if (typeof data === "object") {
|
|
1396
|
+
const obj = data;
|
|
1397
|
+
return obj.title ?? obj.text ?? obj.content ?? obj.value ?? obj.label ?? JSON.stringify(data);
|
|
1398
|
+
}
|
|
1399
|
+
return data;
|
|
1400
|
+
}
|
|
1401
|
+
return this.component().label ?? "";
|
|
1402
|
+
}, ...ngDevMode ? [{ debugName: "content" }] : /* istanbul ignore next */ []);
|
|
1403
|
+
this.isDesignerMode = computed(() => {
|
|
1404
|
+
return this.route.snapshot.url.some((segment) => segment.path === "builder");
|
|
1405
|
+
}, ...ngDevMode ? [{ debugName: "isDesignerMode" }] : /* istanbul ignore next */ []);
|
|
1406
|
+
this.route = inject(ActivatedRoute);
|
|
1407
|
+
this._drillDownService = inject(DrillDownService);
|
|
1408
|
+
effect(() => {
|
|
1409
|
+
const comp = this.component();
|
|
1410
|
+
this.config.set(comp.config);
|
|
1411
|
+
});
|
|
1412
|
+
}
|
|
1413
|
+
onTextClick() {
|
|
1414
|
+
if (this.isDesignerMode()) {
|
|
1415
|
+
console.log("[Text] Designer mode - drill down disabled");
|
|
1416
|
+
return;
|
|
1417
|
+
}
|
|
1418
|
+
const config = this.config()?.text;
|
|
1419
|
+
if (!config?.drillDown?.enabled) {
|
|
1420
|
+
console.log("[Text] 下钻未启用");
|
|
1421
|
+
return;
|
|
1422
|
+
}
|
|
1423
|
+
this._drillDownService.execute(config.drillDown, this.data());
|
|
1424
|
+
}
|
|
1425
|
+
static {
|
|
1426
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
1427
|
+
minVersion: "12.0.0",
|
|
1428
|
+
version: "22.2.3",
|
|
1429
|
+
ngImport: i0,
|
|
1430
|
+
type: TextRendererComponent,
|
|
1431
|
+
deps: [],
|
|
1432
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
1433
|
+
});
|
|
1434
|
+
}
|
|
1435
|
+
static {
|
|
1436
|
+
this.ɵcmp = i0.ɵɵngDeclareComponent({
|
|
1437
|
+
minVersion: "14.0.0",
|
|
1438
|
+
version: "22.2.3",
|
|
1439
|
+
type: TextRendererComponent,
|
|
1440
|
+
isStandalone: true,
|
|
1441
|
+
selector: "app-text-renderer",
|
|
1442
|
+
usesInheritance: true,
|
|
1443
|
+
ngImport: i0,
|
|
1444
|
+
template: "<div [class]=\"twClasses().join(' ')\"\n [ngClass]=\"{'cursor-pointer': config()?.text?.drillDown?.enabled && !isDesignerMode()}\"\n [title]=\"config()?.text?.drillDown?.enabled && !isDesignerMode() ? '点击下钻' : ''\" (click)=\"onTextClick()\">\n {{ content() }}\n</div>",
|
|
1445
|
+
styles: ["@charset \"UTF-8\";:host{display:block;height:100%;min-height:0;padding:.5rem;box-sizing:border-box}@media print{:host{padding:.25rem!important;page-break-inside:avoid;break-inside:avoid}}\n"],
|
|
1446
|
+
dependencies: [{
|
|
1447
|
+
kind: "directive",
|
|
1448
|
+
type: NgClass,
|
|
1449
|
+
selector: "[ngClass]",
|
|
1450
|
+
inputs: ["class", "ngClass"]
|
|
1451
|
+
}],
|
|
1452
|
+
changeDetection: i0.ChangeDetectionStrategy.OnPush
|
|
1453
|
+
});
|
|
1454
|
+
}
|
|
1455
|
+
};
|
|
1456
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
1457
|
+
minVersion: "12.0.0",
|
|
1458
|
+
version: "22.2.3",
|
|
1459
|
+
ngImport: i0,
|
|
1460
|
+
type: TextRendererComponent,
|
|
1461
|
+
decorators: [{
|
|
1462
|
+
type: Component,
|
|
1463
|
+
args: [{
|
|
1464
|
+
selector: "app-text-renderer",
|
|
1465
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
1466
|
+
imports: [NgClass],
|
|
1467
|
+
template: "<div [class]=\"twClasses().join(' ')\"\n [ngClass]=\"{'cursor-pointer': config()?.text?.drillDown?.enabled && !isDesignerMode()}\"\n [title]=\"config()?.text?.drillDown?.enabled && !isDesignerMode() ? '点击下钻' : ''\" (click)=\"onTextClick()\">\n {{ content() }}\n</div>",
|
|
1468
|
+
styles: ["@charset \"UTF-8\";:host{display:block;height:100%;min-height:0;padding:.5rem;box-sizing:border-box}@media print{:host{padding:.25rem!important;page-break-inside:avoid;break-inside:avoid}}\n"]
|
|
1469
|
+
}]
|
|
1470
|
+
}],
|
|
1471
|
+
ctorParameters: () => []
|
|
1472
|
+
});
|
|
1473
|
+
var MetricRendererComponent = class MetricRendererComponent extends BaseRendererComponent {
|
|
1474
|
+
constructor() {
|
|
1475
|
+
super();
|
|
1476
|
+
this.config = signal(null, ...ngDevMode ? [{ debugName: "config" }] : /* istanbul ignore next */ []);
|
|
1477
|
+
this.prefix = computed(() => this.config()?.metric?.prefix ?? "", ...ngDevMode ? [{ debugName: "prefix" }] : /* istanbul ignore next */ []);
|
|
1478
|
+
this.suffix = computed(() => this.config()?.metric?.suffix ?? "", ...ngDevMode ? [{ debugName: "suffix" }] : /* istanbul ignore next */ []);
|
|
1479
|
+
this.decimalPlaces = computed(() => this.config()?.metric?.decimalPlaces ?? 0, ...ngDevMode ? [{ debugName: "decimalPlaces" }] : /* istanbul ignore next */ []);
|
|
1480
|
+
this.twClasses = computed(() => this.config()?.twClasses ?? [], ...ngDevMode ? [{ debugName: "twClasses" }] : /* istanbul ignore next */ []);
|
|
1481
|
+
this.formattedValue = computed(() => {
|
|
1482
|
+
const rawData = this.data();
|
|
1483
|
+
let actualValue = rawData;
|
|
1484
|
+
if (Array.isArray(rawData)) {
|
|
1485
|
+
if (rawData.length > 0) actualValue = rawData[0];
|
|
1486
|
+
else return "-";
|
|
1487
|
+
}
|
|
1488
|
+
let numericValue = null;
|
|
1489
|
+
if (typeof actualValue === "number") numericValue = actualValue;
|
|
1490
|
+
else if (typeof actualValue === "object" && actualValue !== null) {
|
|
1491
|
+
const obj = actualValue;
|
|
1492
|
+
for (const key of [
|
|
1493
|
+
"value",
|
|
1494
|
+
"count",
|
|
1495
|
+
"total",
|
|
1496
|
+
"amount",
|
|
1497
|
+
"sum",
|
|
1498
|
+
"num",
|
|
1499
|
+
"number"
|
|
1500
|
+
]) if (obj[key] != null && typeof obj[key] === "number") {
|
|
1501
|
+
numericValue = obj[key];
|
|
1502
|
+
break;
|
|
1503
|
+
}
|
|
1504
|
+
if (numericValue === null && this.config()?.metric?.valueField) {
|
|
1505
|
+
const customKey = this.config().metric.valueField;
|
|
1506
|
+
if (obj[customKey] != null && typeof obj[customKey] === "number") numericValue = obj[customKey];
|
|
1507
|
+
}
|
|
1508
|
+
}
|
|
1509
|
+
if (numericValue === null || numericValue === void 0) return "-";
|
|
1510
|
+
const decimalPlaces = this.config()?.metric?.decimalPlaces ?? 0;
|
|
1511
|
+
const prefix = this.config()?.metric?.prefix ?? "";
|
|
1512
|
+
const suffix = this.config()?.metric?.suffix ?? "";
|
|
1513
|
+
return `${prefix}${numericValue.toLocaleString("zh-CN", {
|
|
1514
|
+
minimumFractionDigits: decimalPlaces,
|
|
1515
|
+
maximumFractionDigits: decimalPlaces
|
|
1516
|
+
})}${suffix}`;
|
|
1517
|
+
}, ...ngDevMode ? [{ debugName: "formattedValue" }] : /* istanbul ignore next */ []);
|
|
1518
|
+
this.label = computed(() => this.component().label, ...ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []);
|
|
1519
|
+
this.route = inject(ActivatedRoute);
|
|
1520
|
+
this._drillDownService = inject(DrillDownService);
|
|
1521
|
+
this.isDesignerMode = computed(() => {
|
|
1522
|
+
return this.route.snapshot.url.some((segment) => segment.path === "builder");
|
|
1523
|
+
}, ...ngDevMode ? [{ debugName: "isDesignerMode" }] : /* istanbul ignore next */ []);
|
|
1524
|
+
effect(() => {
|
|
1525
|
+
const comp = this.component();
|
|
1526
|
+
this.config.set(comp.config);
|
|
1527
|
+
});
|
|
1528
|
+
}
|
|
1529
|
+
onMetricClick() {
|
|
1530
|
+
if (this.isDesignerMode()) {
|
|
1531
|
+
console.log("[Metric] 设计器模式下禁用下钻");
|
|
1532
|
+
return;
|
|
1533
|
+
}
|
|
1534
|
+
const config = this.config();
|
|
1535
|
+
if (!config?.drillDown?.enabled) return;
|
|
1536
|
+
this._drillDownService.execute(config.drillDown, {
|
|
1537
|
+
clickedValue: this.data(),
|
|
1538
|
+
componentId: this.component().id,
|
|
1539
|
+
templateId: this.template().id,
|
|
1540
|
+
timestamp: Date.now()
|
|
1541
|
+
});
|
|
1542
|
+
}
|
|
1543
|
+
static {
|
|
1544
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
1545
|
+
minVersion: "12.0.0",
|
|
1546
|
+
version: "22.2.3",
|
|
1547
|
+
ngImport: i0,
|
|
1548
|
+
type: MetricRendererComponent,
|
|
1549
|
+
deps: [],
|
|
1550
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
1551
|
+
});
|
|
1552
|
+
}
|
|
1553
|
+
static {
|
|
1554
|
+
this.ɵcmp = i0.ɵɵngDeclareComponent({
|
|
1555
|
+
minVersion: "17.0.0",
|
|
1556
|
+
version: "22.2.3",
|
|
1557
|
+
type: MetricRendererComponent,
|
|
1558
|
+
isStandalone: true,
|
|
1559
|
+
selector: "app-metric-renderer",
|
|
1560
|
+
usesInheritance: true,
|
|
1561
|
+
ngImport: i0,
|
|
1562
|
+
template: "<div [class]=\"twClasses().join(' ')\" [ngClass]=\"{'cursor-pointer hover:shadow-md': config()?.drillDown?.enabled && !isDesignerMode(),\n 'metric-card bg-card dark:bg-transparent border':true\n }\" (click)=\"onMetricClick()\">\n @if (prefix()) {\n <span class=\"prefix\">{{ prefix() }}</span>\n }\n <span class=\"value\">\n {{ formattedValue() }}\n </span>\n @if (suffix()) {\n <span class=\"suffix\">{{ suffix() }}</span>\n }\n @if (label()) {\n <div class=\"label\">{{ label() }}</div>\n }\n</div>",
|
|
1563
|
+
styles: ["@charset \"UTF-8\";.metric-card{display:flex;flex-direction:column;align-items:center;justify-content:center;padding:1.5rem;border-radius:.75rem;box-shadow:0 1px 3px #0000001a;transition:all .2s ease}.metric-card:hover{box-shadow:0 4px 6px #0000001a;transform:translateY(-2px)}.metric-card:is(.dark *){-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px)}.prefix{font-size:.875rem;color:#6b7280;margin-right:.25rem}.value{font-weight:700;color:#111827}.value:is(.dark *){color:#f3f4f6}.suffix{font-size:.875rem;color:#6b7280;margin-left:.25rem}.label{margin-top:.5rem;font-size:.875rem;color:#6b7280;text-align:center}@media print{.metric-card{box-shadow:none!important;border:1px solid #e5e7eb!important;background-color:#fff!important;padding:1rem!important;page-break-inside:avoid;break-inside:avoid}.metric-card:hover{transform:none!important}.value{color:#111827!important}.prefix,.suffix,.label{color:#374151!important}}\n"],
|
|
1564
|
+
dependencies: [{
|
|
1565
|
+
kind: "directive",
|
|
1566
|
+
type: NgClass,
|
|
1567
|
+
selector: "[ngClass]",
|
|
1568
|
+
inputs: ["class", "ngClass"]
|
|
1569
|
+
}],
|
|
1570
|
+
changeDetection: i0.ChangeDetectionStrategy.OnPush
|
|
1571
|
+
});
|
|
1572
|
+
}
|
|
1573
|
+
};
|
|
1574
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
1575
|
+
minVersion: "12.0.0",
|
|
1576
|
+
version: "22.2.3",
|
|
1577
|
+
ngImport: i0,
|
|
1578
|
+
type: MetricRendererComponent,
|
|
1579
|
+
decorators: [{
|
|
1580
|
+
type: Component,
|
|
1581
|
+
args: [{
|
|
1582
|
+
selector: "app-metric-renderer",
|
|
1583
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
1584
|
+
imports: [NgClass],
|
|
1585
|
+
template: "<div [class]=\"twClasses().join(' ')\" [ngClass]=\"{'cursor-pointer hover:shadow-md': config()?.drillDown?.enabled && !isDesignerMode(),\n 'metric-card bg-card dark:bg-transparent border':true\n }\" (click)=\"onMetricClick()\">\n @if (prefix()) {\n <span class=\"prefix\">{{ prefix() }}</span>\n }\n <span class=\"value\">\n {{ formattedValue() }}\n </span>\n @if (suffix()) {\n <span class=\"suffix\">{{ suffix() }}</span>\n }\n @if (label()) {\n <div class=\"label\">{{ label() }}</div>\n }\n</div>",
|
|
1586
|
+
styles: ["@charset \"UTF-8\";.metric-card{display:flex;flex-direction:column;align-items:center;justify-content:center;padding:1.5rem;border-radius:.75rem;box-shadow:0 1px 3px #0000001a;transition:all .2s ease}.metric-card:hover{box-shadow:0 4px 6px #0000001a;transform:translateY(-2px)}.metric-card:is(.dark *){-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px)}.prefix{font-size:.875rem;color:#6b7280;margin-right:.25rem}.value{font-weight:700;color:#111827}.value:is(.dark *){color:#f3f4f6}.suffix{font-size:.875rem;color:#6b7280;margin-left:.25rem}.label{margin-top:.5rem;font-size:.875rem;color:#6b7280;text-align:center}@media print{.metric-card{box-shadow:none!important;border:1px solid #e5e7eb!important;background-color:#fff!important;padding:1rem!important;page-break-inside:avoid;break-inside:avoid}.metric-card:hover{transform:none!important}.value{color:#111827!important}.prefix,.suffix,.label{color:#374151!important}}\n"]
|
|
1587
|
+
}]
|
|
1588
|
+
}],
|
|
1589
|
+
ctorParameters: () => []
|
|
1590
|
+
});
|
|
1591
|
+
let NEXT_ID = 0;
|
|
1592
|
+
var TableRendererComponent = class TableRendererComponent extends BaseRendererComponent {
|
|
1593
|
+
constructor() {
|
|
1594
|
+
super();
|
|
1595
|
+
this.id = `table-renderer-${NEXT_ID++}`;
|
|
1596
|
+
this.config = signal(null, ...ngDevMode ? [{ debugName: "config" }] : /* istanbul ignore next */ []);
|
|
1597
|
+
this.allColumns = computed(() => this.config()?.table?.columns ?? [], ...ngDevMode ? [{ debugName: "allColumns" }] : /* istanbul ignore next */ []);
|
|
1598
|
+
this.columnVisibilityMap = signal({}, ...ngDevMode ? [{ debugName: "columnVisibilityMap" }] : /* istanbul ignore next */ []);
|
|
1599
|
+
this.columns = computed(() => {
|
|
1600
|
+
const allCols = this.allColumns();
|
|
1601
|
+
const visibilityMap = this.columnVisibilityMap();
|
|
1602
|
+
return allCols.filter((col) => {
|
|
1603
|
+
if (col.field in visibilityMap) return visibilityMap[col.field];
|
|
1604
|
+
return col.visible !== false;
|
|
1605
|
+
});
|
|
1606
|
+
}, ...ngDevMode ? [{ debugName: "columns" }] : /* istanbul ignore next */ []);
|
|
1607
|
+
this.pagination = computed(() => this.config()?.table?.enablePagination ?? true, ...ngDevMode ? [{ debugName: "pagination" }] : /* istanbul ignore next */ []);
|
|
1608
|
+
this.enableFilter = computed(() => this.config()?.table?.enableFilter ?? false, ...ngDevMode ? [{ debugName: "enableFilter" }] : /* istanbul ignore next */ []);
|
|
1609
|
+
this.enableExport = computed(() => this.config()?.table?.enableExport ?? false, ...ngDevMode ? [{ debugName: "enableExport" }] : /* istanbul ignore next */ []);
|
|
1610
|
+
this.pageSizeOptions = computed(() => this.config()?.table?.pageSizeOptions ?? [
|
|
1611
|
+
10,
|
|
1612
|
+
20,
|
|
1613
|
+
50
|
|
1614
|
+
], ...ngDevMode ? [{ debugName: "pageSizeOptions" }] : /* istanbul ignore next */ []);
|
|
1615
|
+
this.defaultPageSize = computed(() => this.config()?.table?.defaultPageSize ?? 10, ...ngDevMode ? [{ debugName: "defaultPageSize" }] : /* istanbul ignore next */ []);
|
|
1616
|
+
this.twClasses = computed(() => this.config()?.table?.twClasses ?? [], ...ngDevMode ? [{ debugName: "twClasses" }] : /* istanbul ignore next */ []);
|
|
1617
|
+
this.columnKeys = computed(() => {
|
|
1618
|
+
return this.columns().map((c) => c.field);
|
|
1619
|
+
}, ...ngDevMode ? [{ debugName: "columnKeys" }] : /* istanbul ignore next */ []);
|
|
1620
|
+
this.isDesktop = computed(() => this._cmatMediaWatcherService.mediaChange().matchingAliases.includes("lg"), ...ngDevMode ? [{ debugName: "isDesktop" }] : /* istanbul ignore next */ []);
|
|
1621
|
+
this.tableMinWidth = computed(() => {
|
|
1622
|
+
if (!this.isDesktop()) return "100%";
|
|
1623
|
+
const cols = this.columns();
|
|
1624
|
+
if (cols.length === 0) return "100%";
|
|
1625
|
+
let total = 0;
|
|
1626
|
+
for (const col of cols) {
|
|
1627
|
+
const w = col.width;
|
|
1628
|
+
if (w?.endsWith("px")) total += parseInt(w, 10);
|
|
1629
|
+
else if (w?.endsWith("rem")) total += parseFloat(w) * 16;
|
|
1630
|
+
else total += 150;
|
|
1631
|
+
}
|
|
1632
|
+
return total + "px";
|
|
1633
|
+
}, ...ngDevMode ? [{ debugName: "tableMinWidth" }] : /* istanbul ignore next */ []);
|
|
1634
|
+
this.dataSource = computed(() => {
|
|
1635
|
+
return this.data() ?? [];
|
|
1636
|
+
}, ...ngDevMode ? [{ debugName: "dataSource" }] : /* istanbul ignore next */ []);
|
|
1637
|
+
this.currentPage = signal(1, ...ngDevMode ? [{ debugName: "currentPage" }] : /* istanbul ignore next */ []);
|
|
1638
|
+
this.pageSize = signal(10, ...ngDevMode ? [{ debugName: "pageSize" }] : /* istanbul ignore next */ []);
|
|
1639
|
+
this.bindingResolver = inject(BindingResolverService);
|
|
1640
|
+
this._savedPageSize = 0;
|
|
1641
|
+
this._savedCurrentPage = 0;
|
|
1642
|
+
this.providerRegistry = inject(ProviderRegistryService);
|
|
1643
|
+
this.paginationService = inject(CmatPaginationService);
|
|
1644
|
+
this._drillDownService = inject(DrillDownService);
|
|
1645
|
+
this._route = inject(ActivatedRoute);
|
|
1646
|
+
this._cmatMediaWatcherService = inject(CmatMediaWatcherService);
|
|
1647
|
+
this.isDesignerMode = computed(() => {
|
|
1648
|
+
return this._route.snapshot.url.some((segment) => segment.path === "builder");
|
|
1649
|
+
}, ...ngDevMode ? [{ debugName: "isDesignerMode" }] : /* istanbul ignore next */ []);
|
|
1650
|
+
this.paginationService.register({
|
|
1651
|
+
id: this.id,
|
|
1652
|
+
currentPage: this.currentPage(),
|
|
1653
|
+
itemsPerPage: this.pageSize(),
|
|
1654
|
+
totalItems: 0
|
|
1655
|
+
});
|
|
1656
|
+
effect(() => {
|
|
1657
|
+
this.config.set(this.component().config);
|
|
1658
|
+
untracked(() => {
|
|
1659
|
+
const defaultSize = this.config()?.table?.defaultPageSize ?? 10;
|
|
1660
|
+
if (this.pageSize() !== defaultSize && this.currentPage() === 1) {
|
|
1661
|
+
this.pageSize.set(defaultSize);
|
|
1662
|
+
this.paginationService.setItemsPerPage(this.id, defaultSize);
|
|
1663
|
+
}
|
|
1664
|
+
});
|
|
1665
|
+
});
|
|
1666
|
+
}
|
|
1667
|
+
loadData() {
|
|
1668
|
+
const component = this.component();
|
|
1669
|
+
const template = this.template();
|
|
1670
|
+
if (!component.dataBinding) {
|
|
1671
|
+
super.loadData(component, template);
|
|
1672
|
+
return;
|
|
1673
|
+
}
|
|
1674
|
+
const queryWithPagination = {
|
|
1675
|
+
...component.dataBinding.query,
|
|
1676
|
+
pagination: {
|
|
1677
|
+
page: this.currentPage(),
|
|
1678
|
+
size: this.pageSize()
|
|
1679
|
+
}
|
|
1680
|
+
};
|
|
1681
|
+
const tempComponent = {
|
|
1682
|
+
...component,
|
|
1683
|
+
dataBinding: {
|
|
1684
|
+
...component.dataBinding,
|
|
1685
|
+
query: queryWithPagination
|
|
1686
|
+
}
|
|
1687
|
+
};
|
|
1688
|
+
super.loadData(tempComponent, template);
|
|
1689
|
+
}
|
|
1690
|
+
onDataLoaded() {
|
|
1691
|
+
const component = this.component();
|
|
1692
|
+
const template = this.template();
|
|
1693
|
+
if (!component.dataBinding) return;
|
|
1694
|
+
const queryWithPagination = {
|
|
1695
|
+
...component.dataBinding.query,
|
|
1696
|
+
pagination: {
|
|
1697
|
+
page: this.currentPage(),
|
|
1698
|
+
size: this.pageSize()
|
|
1699
|
+
}
|
|
1700
|
+
};
|
|
1701
|
+
const tempComponent = {
|
|
1702
|
+
...component,
|
|
1703
|
+
dataBinding: {
|
|
1704
|
+
...component.dataBinding,
|
|
1705
|
+
query: queryWithPagination
|
|
1706
|
+
}
|
|
1707
|
+
};
|
|
1708
|
+
this.loadTotalCountFromCache(tempComponent, template);
|
|
1709
|
+
}
|
|
1710
|
+
onPageChange(page) {
|
|
1711
|
+
this.currentPage.set(page);
|
|
1712
|
+
this.paginationService.setCurrentPage(this.id, page);
|
|
1713
|
+
const component = this.component();
|
|
1714
|
+
this.bindingResolver.clearCache(component.id);
|
|
1715
|
+
this.bindingResolver.clearDataCache(component.id);
|
|
1716
|
+
this.loadData();
|
|
1717
|
+
}
|
|
1718
|
+
onPageSizeChange(size) {
|
|
1719
|
+
this.pageSize.set(size);
|
|
1720
|
+
this.currentPage.set(1);
|
|
1721
|
+
this.paginationService.setItemsPerPage(this.id, size);
|
|
1722
|
+
this.paginationService.setCurrentPage(this.id, 1);
|
|
1723
|
+
const component = this.component();
|
|
1724
|
+
this.bindingResolver.clearCache(component.id);
|
|
1725
|
+
this.bindingResolver.clearDataCache(component.id);
|
|
1726
|
+
this.loadData();
|
|
1727
|
+
}
|
|
1728
|
+
pauseForPrint() {
|
|
1729
|
+
this._savedPageSize = this.pageSize();
|
|
1730
|
+
this._savedCurrentPage = this.currentPage();
|
|
1731
|
+
this.pageSize.set(99999);
|
|
1732
|
+
this.currentPage.set(1);
|
|
1733
|
+
this.paginationService.setItemsPerPage(this.id, 99999);
|
|
1734
|
+
this.paginationService.setCurrentPage(this.id, 1);
|
|
1735
|
+
const component = this.component();
|
|
1736
|
+
this.bindingResolver.clearCache(component.id);
|
|
1737
|
+
this.bindingResolver.clearDataCache(component.id);
|
|
1738
|
+
this.loadData();
|
|
1739
|
+
return new Promise((resolve) => {
|
|
1740
|
+
const check = () => {
|
|
1741
|
+
if (!this.loading()) resolve();
|
|
1742
|
+
else setTimeout(check, 100);
|
|
1743
|
+
};
|
|
1744
|
+
setTimeout(check, 200);
|
|
1745
|
+
});
|
|
1746
|
+
}
|
|
1747
|
+
resumeFromPrint() {
|
|
1748
|
+
if (!this._savedPageSize) return;
|
|
1749
|
+
this.pageSize.set(this._savedPageSize);
|
|
1750
|
+
this.currentPage.set(this._savedCurrentPage);
|
|
1751
|
+
this.paginationService.setItemsPerPage(this.id, this._savedPageSize);
|
|
1752
|
+
this.paginationService.setCurrentPage(this.id, this._savedCurrentPage);
|
|
1753
|
+
const component = this.component();
|
|
1754
|
+
this.bindingResolver.clearCache(component.id);
|
|
1755
|
+
this.bindingResolver.clearDataCache(component.id);
|
|
1756
|
+
this.loadData();
|
|
1757
|
+
this._savedPageSize = 0;
|
|
1758
|
+
this._savedCurrentPage = 0;
|
|
1759
|
+
}
|
|
1760
|
+
isCellDrillable(row, column) {
|
|
1761
|
+
return !!column.drillDown?.enabled && row[column.field] != null;
|
|
1762
|
+
}
|
|
1763
|
+
onCellClick(row, column) {
|
|
1764
|
+
if (this.isDesignerMode()) {
|
|
1765
|
+
console.log("[TableRenderer] Designer mode - drill down disabled");
|
|
1766
|
+
return;
|
|
1767
|
+
}
|
|
1768
|
+
if (this.isCellDrillable(row, column)) this._drillDownService.execute(column.drillDown, {
|
|
1769
|
+
clickedValue: row[column.field],
|
|
1770
|
+
rowData: row,
|
|
1771
|
+
componentId: this.component().id,
|
|
1772
|
+
templateId: this.template().id,
|
|
1773
|
+
templateParameters: this.template().parameters ?? [],
|
|
1774
|
+
timestamp: Date.now()
|
|
1775
|
+
});
|
|
1776
|
+
}
|
|
1777
|
+
formatValue(value, format) {
|
|
1778
|
+
if (value == null) return "-";
|
|
1779
|
+
switch (format) {
|
|
1780
|
+
case "number": return Number(value).toLocaleString();
|
|
1781
|
+
case "currency": return `¥${Number(value).toFixed(2)}`;
|
|
1782
|
+
case "date": return new Date(value).toLocaleDateString("zh-CN");
|
|
1783
|
+
case "percent": return `${(Number(value) * 100).toFixed(2)}%`;
|
|
1784
|
+
case "boolean": return value ? "是" : "否";
|
|
1785
|
+
default: return value;
|
|
1786
|
+
}
|
|
1787
|
+
}
|
|
1788
|
+
allColumnsVisible() {
|
|
1789
|
+
return this.allColumns().every((col) => this.isColumnVisible(col));
|
|
1790
|
+
}
|
|
1791
|
+
someColumnsVisible() {
|
|
1792
|
+
const visible = this.allColumns().filter((col) => this.isColumnVisible(col));
|
|
1793
|
+
return visible.length > 0 && visible.length < this.allColumns().length;
|
|
1794
|
+
}
|
|
1795
|
+
isColumnVisible(col) {
|
|
1796
|
+
const map = this.columnVisibilityMap();
|
|
1797
|
+
if (col.field in map) return map[col.field];
|
|
1798
|
+
return col.visible !== false;
|
|
1799
|
+
}
|
|
1800
|
+
toggleColumnVisibility(col) {
|
|
1801
|
+
const current = this.isColumnVisible(col);
|
|
1802
|
+
this.columnVisibilityMap.update((map) => ({
|
|
1803
|
+
...map,
|
|
1804
|
+
[col.field]: !current
|
|
1805
|
+
}));
|
|
1806
|
+
}
|
|
1807
|
+
toggleAllColumns() {
|
|
1808
|
+
if (this.allColumnsVisible()) {
|
|
1809
|
+
const newMap = {};
|
|
1810
|
+
this.allColumns().forEach((col) => {
|
|
1811
|
+
newMap[col.field] = false;
|
|
1812
|
+
});
|
|
1813
|
+
this.columnVisibilityMap.set(newMap);
|
|
1814
|
+
} else this.columnVisibilityMap.set({});
|
|
1815
|
+
}
|
|
1816
|
+
resetColumnVisibility() {
|
|
1817
|
+
this.columnVisibilityMap.set({});
|
|
1818
|
+
}
|
|
1819
|
+
exportToCSV() {
|
|
1820
|
+
this._getAllData().subscribe({
|
|
1821
|
+
next: (allData) => {
|
|
1822
|
+
const columns = this.columns();
|
|
1823
|
+
if (!allData || allData.length === 0) {
|
|
1824
|
+
console.warn("[TableRenderer] No data to export");
|
|
1825
|
+
return;
|
|
1826
|
+
}
|
|
1827
|
+
const csvContent = [columns.map((col) => col.header).join(","), ...allData.map((row) => columns.map((col) => {
|
|
1828
|
+
const value = row[col.field];
|
|
1829
|
+
return `"${this.formatValue(value, col.format).replace(/"/g, "\"\"")}"`;
|
|
1830
|
+
}).join(","))].join("\n");
|
|
1831
|
+
this._downloadFile("" + csvContent, `${this.component().label || "table"}.csv`, "text/csv;charset=utf-8;");
|
|
1832
|
+
},
|
|
1833
|
+
error: (err) => {
|
|
1834
|
+
console.error("[TableRenderer] Failed to fetch all data for CSV export:", err);
|
|
1835
|
+
}
|
|
1836
|
+
});
|
|
1837
|
+
}
|
|
1838
|
+
exportToExcel() {
|
|
1839
|
+
this._getAllData().subscribe({
|
|
1840
|
+
next: (allData) => {
|
|
1841
|
+
const columns = this.columns();
|
|
1842
|
+
if (!allData || allData.length === 0) {
|
|
1843
|
+
console.warn("[TableRenderer] No data to export");
|
|
1844
|
+
return;
|
|
1845
|
+
}
|
|
1846
|
+
let html = "<table border=\"1\"><thead><tr>";
|
|
1847
|
+
columns.forEach((col) => {
|
|
1848
|
+
html += `<th>${col.header}</th>`;
|
|
1849
|
+
});
|
|
1850
|
+
html += "</tr></thead><tbody>";
|
|
1851
|
+
allData.forEach((row) => {
|
|
1852
|
+
html += "<tr>";
|
|
1853
|
+
columns.forEach((col) => {
|
|
1854
|
+
const rowData = row;
|
|
1855
|
+
const value = this.formatValue(rowData[col.field], col.format);
|
|
1856
|
+
html += `<td>${value}</td>`;
|
|
1857
|
+
});
|
|
1858
|
+
html += "</tr>";
|
|
1859
|
+
});
|
|
1860
|
+
html += "</tbody></table>";
|
|
1861
|
+
this._downloadFile(html, `${this.component().label || "table"}.xls`, "application/vnd.ms-excel");
|
|
1862
|
+
},
|
|
1863
|
+
error: (err) => {
|
|
1864
|
+
console.error("[TableRenderer] Failed to fetch all data for Excel export:", err);
|
|
1865
|
+
}
|
|
1866
|
+
});
|
|
1867
|
+
}
|
|
1868
|
+
exportToJSON() {
|
|
1869
|
+
this._getAllData().subscribe({
|
|
1870
|
+
next: (allData) => {
|
|
1871
|
+
if (!allData || allData.length === 0) {
|
|
1872
|
+
console.warn("[TableRenderer] No data to export");
|
|
1873
|
+
return;
|
|
1874
|
+
}
|
|
1875
|
+
const jsonContent = JSON.stringify(allData, null, 2);
|
|
1876
|
+
this._downloadFile(jsonContent, `${this.component().label || "table"}.json`, "application/json");
|
|
1877
|
+
},
|
|
1878
|
+
error: (err) => {
|
|
1879
|
+
console.error("[TableRenderer] Failed to fetch all data for JSON export:", err);
|
|
1880
|
+
}
|
|
1881
|
+
});
|
|
1882
|
+
}
|
|
1883
|
+
getIndicatorTarget(row, column) {
|
|
1884
|
+
const indicator = column.indicator;
|
|
1885
|
+
if (!indicator?.enabled) return null;
|
|
1886
|
+
if (indicator.targetField) {
|
|
1887
|
+
const val = row[indicator.targetField];
|
|
1888
|
+
if (val != null && !Number.isNaN(Number(val))) return Number(val);
|
|
1889
|
+
}
|
|
1890
|
+
return indicator.targetValue ?? null;
|
|
1891
|
+
}
|
|
1892
|
+
getHeaderText(column) {
|
|
1893
|
+
const indicator = column.indicator;
|
|
1894
|
+
if (!indicator?.enabled || !indicator.headerTemplate) return column.header;
|
|
1895
|
+
const data = this.dataSource();
|
|
1896
|
+
if (!data?.length) return column.header;
|
|
1897
|
+
const firstRow = data[0];
|
|
1898
|
+
const targetVal = this.getIndicatorTarget(firstRow, column);
|
|
1899
|
+
if (targetVal == null) return column.header;
|
|
1900
|
+
const formattedVal = this.formatValue(targetVal, indicator.headerFormat ?? column.format);
|
|
1901
|
+
return indicator.headerTemplate.replace("{value}", formattedVal);
|
|
1902
|
+
}
|
|
1903
|
+
getMatchedRule(value, row, column) {
|
|
1904
|
+
const rules = column.indicator?.compareRules;
|
|
1905
|
+
if (!rules?.length) return null;
|
|
1906
|
+
const numVal = Number(value);
|
|
1907
|
+
if (Number.isNaN(numVal)) return null;
|
|
1908
|
+
const target = this.getIndicatorTarget(row, column);
|
|
1909
|
+
for (const rule of rules) {
|
|
1910
|
+
const compareVal = rule.compareWith === "target" ? target : rule.compareWith;
|
|
1911
|
+
if (compareVal == null) continue;
|
|
1912
|
+
let match = false;
|
|
1913
|
+
switch (rule.operator) {
|
|
1914
|
+
case "gte":
|
|
1915
|
+
match = numVal >= compareVal;
|
|
1916
|
+
break;
|
|
1917
|
+
case "gt":
|
|
1918
|
+
match = numVal > compareVal;
|
|
1919
|
+
break;
|
|
1920
|
+
case "lte":
|
|
1921
|
+
match = numVal <= compareVal;
|
|
1922
|
+
break;
|
|
1923
|
+
case "lt":
|
|
1924
|
+
match = numVal < compareVal;
|
|
1925
|
+
break;
|
|
1926
|
+
case "eq":
|
|
1927
|
+
match = numVal === compareVal;
|
|
1928
|
+
break;
|
|
1929
|
+
case "neq": match = numVal !== compareVal;
|
|
1930
|
+
}
|
|
1931
|
+
if (match) return rule;
|
|
1932
|
+
}
|
|
1933
|
+
return null;
|
|
1934
|
+
}
|
|
1935
|
+
getCellStyle(value, row, column) {
|
|
1936
|
+
const rule = this.getMatchedRule(value, row, column);
|
|
1937
|
+
if (!rule) return "";
|
|
1938
|
+
return rule.cssClass ?? this._getDefaultStyleClass(rule.style);
|
|
1939
|
+
}
|
|
1940
|
+
getIndicatorIcon(value, row, column) {
|
|
1941
|
+
if (!column.indicator?.showStatusIcon) return "";
|
|
1942
|
+
const rule = this.getMatchedRule(value, row, column);
|
|
1943
|
+
if (!rule) return "";
|
|
1944
|
+
if (rule.icon) return rule.icon;
|
|
1945
|
+
return {
|
|
1946
|
+
success: "heroicons_outline:check-circle",
|
|
1947
|
+
warning: "heroicons_outline:exclamation-triangle",
|
|
1948
|
+
danger: "heroicons_outline:x-circle",
|
|
1949
|
+
info: "heroicons_outline:information-circle"
|
|
1950
|
+
}[rule.style] ?? "";
|
|
1951
|
+
}
|
|
1952
|
+
getIndicatorLabel(value, row, column) {
|
|
1953
|
+
return this.getMatchedRule(value, row, column)?.label ?? "";
|
|
1954
|
+
}
|
|
1955
|
+
getIndicatorProgress(value, row, column) {
|
|
1956
|
+
const numVal = Number(value);
|
|
1957
|
+
if (Number.isNaN(numVal)) return 0;
|
|
1958
|
+
const target = this.getIndicatorTarget(row, column);
|
|
1959
|
+
if (target == null || target === 0) return 0;
|
|
1960
|
+
return Math.min(Math.round(numVal / target * 100), 100);
|
|
1961
|
+
}
|
|
1962
|
+
getIndicatorProgressText(value, row, column) {
|
|
1963
|
+
return `${this.getIndicatorProgress(value, row, column)}%`;
|
|
1964
|
+
}
|
|
1965
|
+
_getDefaultStyleClass(style) {
|
|
1966
|
+
return {
|
|
1967
|
+
success: "text-emerald-600",
|
|
1968
|
+
warning: "text-amber-600",
|
|
1969
|
+
danger: "text-red-600",
|
|
1970
|
+
info: "text-blue-600"
|
|
1971
|
+
}[style] ?? "";
|
|
1972
|
+
}
|
|
1973
|
+
_downloadFile(content, filename, mimeType) {
|
|
1974
|
+
const blob = new Blob([content], { type: mimeType });
|
|
1975
|
+
const url = URL.createObjectURL(blob);
|
|
1976
|
+
const link = document.createElement("a");
|
|
1977
|
+
link.href = url;
|
|
1978
|
+
link.download = filename;
|
|
1979
|
+
document.body.appendChild(link);
|
|
1980
|
+
link.click();
|
|
1981
|
+
document.body.removeChild(link);
|
|
1982
|
+
URL.revokeObjectURL(url);
|
|
1983
|
+
}
|
|
1984
|
+
_getAllData() {
|
|
1985
|
+
const component = this.component();
|
|
1986
|
+
if (!component.dataBinding?.providerRef) return of(this.dataSource());
|
|
1987
|
+
const provider = this.providerRegistry.getProvider(component.dataBinding.providerRef);
|
|
1988
|
+
if (!provider) return of(this.dataSource());
|
|
1989
|
+
const queryWithoutPagination = {
|
|
1990
|
+
...this.bindingResolver.getEnhancedQuery(component.dataBinding.query, component.parameters, this.template().parameters),
|
|
1991
|
+
pagination: {
|
|
1992
|
+
page: 1,
|
|
1993
|
+
size: 1e4
|
|
1994
|
+
}
|
|
1995
|
+
};
|
|
1996
|
+
return provider.fetchList(queryWithoutPagination).pipe(map$1((result) => result.data ?? []));
|
|
1997
|
+
}
|
|
1998
|
+
loadTotalCountFromCache(component, template) {
|
|
1999
|
+
if (!component.dataBinding?.providerRef) return;
|
|
2000
|
+
const cachedResult = this.bindingResolver.getCachedResult(component, template);
|
|
2001
|
+
if (cachedResult?.total !== void 0) {
|
|
2002
|
+
this.paginationService.setTotalItems(this.id, cachedResult.total);
|
|
2003
|
+
return;
|
|
2004
|
+
}
|
|
2005
|
+
this._loadTotalCountOptimized(component, template);
|
|
2006
|
+
}
|
|
2007
|
+
_loadTotalCountOptimized(component, template) {
|
|
2008
|
+
const dataBinding = component.dataBinding;
|
|
2009
|
+
if (!dataBinding?.providerRef) return;
|
|
2010
|
+
const provider = this.providerRegistry.getProvider(dataBinding.providerRef);
|
|
2011
|
+
if (!provider) return;
|
|
2012
|
+
const countQuery = {
|
|
2013
|
+
...this.bindingResolver.getEnhancedQuery(dataBinding.query, component.parameters, template.parameters),
|
|
2014
|
+
pagination: {
|
|
2015
|
+
page: 1,
|
|
2016
|
+
size: 1
|
|
2017
|
+
}
|
|
2018
|
+
};
|
|
2019
|
+
provider.fetchList(countQuery).subscribe({
|
|
2020
|
+
next: (result) => {
|
|
2021
|
+
const total = result.total ?? 0;
|
|
2022
|
+
this.paginationService.setTotalItems(this.id, total);
|
|
2023
|
+
},
|
|
2024
|
+
error: (err) => {
|
|
2025
|
+
console.warn("[TableRenderer] Failed to load total count:", err);
|
|
2026
|
+
const currentDataLength = this.data()?.length ?? 0;
|
|
2027
|
+
this.paginationService.setTotalItems(this.id, currentDataLength);
|
|
2028
|
+
}
|
|
2029
|
+
});
|
|
2030
|
+
}
|
|
2031
|
+
static {
|
|
2032
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
2033
|
+
minVersion: "12.0.0",
|
|
2034
|
+
version: "22.2.3",
|
|
2035
|
+
ngImport: i0,
|
|
2036
|
+
type: TableRendererComponent,
|
|
2037
|
+
deps: [],
|
|
2038
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
2039
|
+
});
|
|
2040
|
+
}
|
|
2041
|
+
static {
|
|
2042
|
+
this.ɵcmp = i0.ɵɵngDeclareComponent({
|
|
2043
|
+
minVersion: "17.0.0",
|
|
2044
|
+
version: "22.2.3",
|
|
2045
|
+
type: TableRendererComponent,
|
|
2046
|
+
isStandalone: true,
|
|
2047
|
+
selector: "app-table-renderer",
|
|
2048
|
+
usesInheritance: true,
|
|
2049
|
+
ngImport: i0,
|
|
2050
|
+
template: "<div class=\"table-container relative group bg-card dark:bg-transparent border\" [ngClass]=\"twClasses().join(' ')\">\n <!-- 显示列按钮(左上角) -->\n @if (allColumns().length > 0 && !loading()) {\n <div class=\"absolute top-2 left-2 z-40 transition-opacity opacity-0 group-hover:opacity-100 print:hidden\">\n <button type=\"button\" matIconButton [matTooltip]=\"'显示列'\" [matMenuTriggerFor]=\"columnsMenu\">\n <mat-icon [svgIcon]=\"'heroicons_outline:adjustments-horizontal'\"></mat-icon>\n </button>\n <mat-menu #columnsMenu=\"matMenu\" [class]=\"'overflow-auto scrollbar-custom'\">\n <button type=\"button\" mat-menu-item (click)=\"toggleAllColumns()\">\n <span class=\"flex items-center\">\n <mat-checkbox class=\"flex items-center pointer-events-none\" disableRipple\n [checked]=\"allColumnsVisible()\" [indeterminate]=\"someColumnsVisible()\"></mat-checkbox>\n <span class=\"ml-1 leading-5 break-keep\">全部</span>\n </span>\n </button>\n @for (col of allColumns(); track col.field) {\n <button type=\"button\" mat-menu-item (click)=\"toggleColumnVisibility(col)\">\n <span class=\"flex items-center\">\n <mat-checkbox class=\"flex items-center pointer-events-none\" disableRipple\n [checked]=\"isColumnVisible(col)\"></mat-checkbox>\n <span class=\"ml-1 leading-5 break-keep\">{{col.header}}</span>\n </span>\n </button>\n }\n </mat-menu>\n </div>\n }\n\n @if (enableExport() && !loading()) {\n <div class=\"absolute bottom-10 lg:bottom-2 right-2 z-40 transition-opacity print:hidden\">\n <button matMiniFab color=\"primary\" class=\"opacity-0 group-hover:opacity-100\"\n [matMenuTriggerFor]=\"exportMenu\" [matTooltip]=\"'导出数据'\">\n <mat-icon [svgIcon]=\"'heroicons_outline:arrow-down-tray'\"></mat-icon>\n </button>\n\n <!-- 导出菜单 -->\n <mat-menu #exportMenu=\"matMenu\" xPosition=\"before\" [class]=\"'overflow-auto scrollbar-custom'\">\n <button mat-menu-item (click)=\"exportToCSV()\">\n <mat-icon [svgIcon]=\"'heroicons_outline:document-text'\"></mat-icon>\n <span>导出为 CSV</span>\n </button>\n <button mat-menu-item (click)=\"exportToExcel()\">\n <mat-icon [svgIcon]=\"'heroicons_outline:table-cells'\"></mat-icon>\n <span>导出为 Excel</span>\n </button>\n <button mat-menu-item (click)=\"exportToJSON()\">\n <mat-icon [svgIcon]=\"'heroicons_outline:document-chart-bar'\"></mat-icon>\n <span>导出为 JSON</span>\n </button>\n </mat-menu>\n </div>\n }\n\n <!-- 加载状态 -->\n @if (loading()) {\n <mat-progress-bar mode=\"indeterminate\"></mat-progress-bar>\n }\n\n <!-- 错误状态 -->\n @if (error()) {\n <div class=\"error-state text-warn\">\n <p>{{ error()?.message }}</p>\n <button mat-button color=\"primary\" (click)=\"refresh()\">重试</button>\n </div>\n }\n\n @if (!loading() && !error() && data() && (data()!.length > 0 || isDesktop())) {\n <!-- 无可见列提示 -->\n @if (columns().length === 0) {\n <div class=\"flex flex-col items-center justify-center py-12 bg-slate-100 dark:bg-transparent\">\n <mat-icon class=\"icon-size-12 text-secondary\" [svgIcon]=\"'heroicons_outline:eye-slash'\"></mat-icon>\n <div class=\"mt-3 text-lg font-bold tracking-tight text-secondary\">未选择显示列</div>\n <button type=\"button\" mat-button color=\"primary\" class=\"mt-2\" (click)=\"resetColumnVisibility()\">\n <mat-icon class=\"icon-size-5 mr-1\" [svgIcon]=\"'heroicons_outline:arrow-path'\"></mat-icon>\n 恢复默认显示\n </button>\n </div>\n } @else {\n <div class=\"table-wrapper flex-auto min-h-0 min-w-0 scrollbar-custom\">\n <table mat-table [ngStyle]=\"{'width': tableMinWidth(), 'table-layout': 'fixed'}\" [dataSource]=\"dataSource()\">\n <!-- 动态列 -->\n @for (column of columns(); track column.field) {\n <ng-container [matColumnDef]=\"column.field\">\n <!-- 表头:支持指标模板展示 -->\n <th *matHeaderCellDef mat-header-cell\n [ngStyle]=\"{'width':column.width,'text-align':column.align || 'left','padding-left':$first && allColumns().length > 0 ? '3.5rem' : undefined,'padding-right':$last && hasFilterButton() && component().parameters?.length ? '3.5rem' : undefined}\">\n <span>{{ getHeaderText(column) }}</span>\n </th>\n\n <!-- 单元格:支持对比样式、图标、进度 -->\n <td *matCellDef=\"let row\" mat-cell [ngStyle]=\"{'width':column.width,'text-align':column.align || 'left','padding-left':$first && allColumns().length > 0 ? '3.5rem' : undefined,'padding-right':$last && hasFilterButton() && component().parameters?.length ? '3.5rem' : undefined}\">\n\n <div class=\"has-label-on-mobile flex items-center gap-1\" [attr.data-label]=\"column.header+':'\"\n [ngStyle]=\"{'justify-content': (column.align || 'left') === 'right' ? 'flex-end' : (column.align || 'left') === 'center' ? 'center' : 'flex-start'}\">\n <!-- 设计器模式显示锁图标 -->\n @if (isDesignerMode() && column.drillDown?.enabled) {\n <mat-icon class=\"icon-size-3 text-warn-400\" matTooltip=\"设计模式下禁用下钻\"\n [svgIcon]=\"'heroicons_outline:lock-closed'\">\n </mat-icon>\n }\n\n <!-- 进度条模式 -->\n @if (column.indicator?.enabled && column.indicator.progressMode === 'bar') {\n <div class=\"flex items-center gap-1.5 w-full\"\n [ngStyle]=\"{'justify-content': (column.align || 'left') === 'right' ? 'flex-end' : (column.align || 'left') === 'center' ? 'center' : 'flex-start'}\">\n <span class=\"shrink-0 font-medium\"\n [ngClass]=\"getCellStyle(row[column.field], row, column)\"\n [ngStyle]=\"{'cursor': !isDesignerMode() && isCellDrillable(row, column) ? 'pointer' : 'default'}\"\n (click)=\"onCellClick(row, column)\">\n {{ formatValue(row[column.field], column.format) }}\n </span>\n <div class=\"flex-1 min-w-[40px] h-1.5 bg-gray-200 dark:bg-gray-700 rounded-full overflow-hidden\">\n <div class=\"h-full rounded-full transition-all duration-300\"\n [ngClass]=\"{\n 'bg-emerald-500': getIndicatorProgress(row[column.field], row, column) >= 100,\n 'bg-amber-500': getIndicatorProgress(row[column.field], row, column) >= 60 && getIndicatorProgress(row[column.field], row, column) < 100,\n 'bg-red-500': getIndicatorProgress(row[column.field], row, column) < 60\n }\"\n [ngStyle]=\"{'width': getIndicatorProgress(row[column.field], row, column) + '%'}\">\n </div>\n </div>\n <span class=\"shrink-0 text-[10px] text-secondary\">\n {{ getIndicatorProgressText(row[column.field], row, column) }}\n </span>\n </div>\n }\n\n <!-- 普通模式(无进度条) -->\n @if (!(column.indicator?.enabled && column.indicator.progressMode === 'bar')) {\n <span\n [ngClass]=\"getCellStyle(row[column.field], row, column)\"\n [ngStyle]=\"{'cursor': !isDesignerMode() && isCellDrillable(row, column) ? 'pointer' : 'default'}\"\n [class.cursor-pointer]=\"!isDesignerMode() && isCellDrillable(row, column)\"\n [class.text-primary-600]=\"!isDesignerMode() && isCellDrillable(row, column)\"\n [class.underline]=\"!isDesignerMode() && isCellDrillable(row, column)\"\n [class.lg:no-underline]=\"!isDesignerMode() && isCellDrillable(row, column)\"\n [class.lg:hover:underline]=\"!isDesignerMode() && isCellDrillable(row, column)\"\n (click)=\"onCellClick(row, column)\">\n {{ formatValue(row[column.field], column.format) }}\n @if (column.indicator?.enabled && column.indicator.progressMode === 'text') {\n <span class=\"text-xs opacity-70 ml-0.5\">({{ getIndicatorProgressText(row[column.field], row, column) }})</span>\n }\n </span>\n }\n\n <!-- 指标状态图标 -->\n @if (column.indicator?.showStatusIcon) {\n @if (getIndicatorIcon(row[column.field], row, column)) {\n <mat-icon class=\"icon-size-4\"\n [ngClass]=\"getCellStyle(row[column.field], row, column)\"\n [svgIcon]=\"getIndicatorIcon(row[column.field], row, column)\"\n [matTooltip]=\"getIndicatorLabel(row[column.field], row, column)\">\n </mat-icon>\n }\n }\n\n <!-- 指标文本标签 -->\n @if (column.indicator?.enabled && !column.indicator.showStatusIcon) {\n @if (getIndicatorLabel(row[column.field], row, column)) {\n <span class=\"text-[10px] px-1 rounded\"\n [ngClass]=\"getCellStyle(row[column.field], row, column)\">\n {{ getIndicatorLabel(row[column.field], row, column) }}\n </span>\n }\n }\n </div>\n </td>\n </ng-container>\n }\n\n <tr *matHeaderRowDef=\"columnKeys(); sticky: true\" mat-header-row></tr>\n <tr *matRowDef=\"let row; columns: columnKeys();\" mat-row></tr>\n </table>\n </div>\n\n @if (pagination()&&data() && data()!.length !== 0) {\n <div class=\"pagination-wrapper\">\n <cmat-pagination [id]=\"id\" [itemsPerPages]=\"pageSizeOptions()\" [initPerPage]=\"defaultPageSize()\"\n (pageChange)=\"onPageChange($event)\" (perPageCountChange)=\"onPageSizeChange($event)\">\n </cmat-pagination>\n </div>\n }\n }\n }\n\n <!-- 空状态 -->\n @if (!loading() && !error() && data() && data()!.length === 0) {\n <div class=\"flex h-full flex-col items-center justify-center py-4 bg-slate-100 dark:bg-transparent print:border\">\n <mat-icon class=\"icon-size-12\" [svgIcon]=\"'heroicons_outline:document-magnifying-glass'\"></mat-icon>\n <div class=\"mt-4 text-lg font-bold tracking-tight text-secondary\">暂无数据</div>\n </div>\n }\n</div>",
|
|
2051
|
+
styles: ["@charset \"UTF-8\";:host{display:flex;flex-direction:column;width:100%;height:100%;min-height:0;box-sizing:border-box}.table-container{display:flex;flex-direction:column;flex:1 1 auto;width:100%;min-height:0;min-width:0;overflow:hidden;border-radius:.75rem}.table-wrapper{flex:1 1 auto;min-height:0;min-width:0;overflow-x:auto;overflow-y:auto}@media(min-width:1024px){.table-wrapper{max-height:calc(100vh - 14rem)}}@media(max-width:1023px){.table-wrapper{max-height:calc(100vh - 12rem)}}table{min-width:100%;display:table!important}@media(min-width:1024px){table{table-layout:fixed}}.pagination-wrapper{flex:none;border-top:1px solid #e5e7eb;background:#f9fafb}:host ::ng-deep .dark .pagination-wrapper{background:transparent;border-top-color:#334155}.error-state{padding:1rem;text-align:center}@media print{.table-container{overflow:visible!important;border-radius:.75rem;page-break-inside:avoid;break-inside:avoid}table{page-break-inside:auto}tr{page-break-inside:avoid;break-inside:avoid}th{background-color:#f9fafb!important;-webkit-print-color-adjust:exact;print-color-adjust:exact}td,th{border:1px solid #e5e7eb!important;padding:.25rem .5rem!important}}\n"],
|
|
2052
|
+
dependencies: [
|
|
2053
|
+
{
|
|
2054
|
+
kind: "ngmodule",
|
|
2055
|
+
type: CommonModule
|
|
2056
|
+
},
|
|
2057
|
+
{
|
|
2058
|
+
kind: "directive",
|
|
2059
|
+
type: i1.NgClass,
|
|
2060
|
+
selector: "[ngClass]",
|
|
2061
|
+
inputs: ["class", "ngClass"]
|
|
2062
|
+
},
|
|
2063
|
+
{
|
|
2064
|
+
kind: "directive",
|
|
2065
|
+
type: i1.NgStyle,
|
|
2066
|
+
selector: "[ngStyle]",
|
|
2067
|
+
inputs: ["ngStyle"]
|
|
2068
|
+
},
|
|
2069
|
+
{
|
|
2070
|
+
kind: "ngmodule",
|
|
2071
|
+
type: MatTableModule
|
|
2072
|
+
},
|
|
2073
|
+
{
|
|
2074
|
+
kind: "component",
|
|
2075
|
+
type: i2.MatTable,
|
|
2076
|
+
selector: "mat-table, table[mat-table]",
|
|
2077
|
+
exportAs: ["matTable"]
|
|
2078
|
+
},
|
|
2079
|
+
{
|
|
2080
|
+
kind: "directive",
|
|
2081
|
+
type: i2.MatHeaderCellDef,
|
|
2082
|
+
selector: "[matHeaderCellDef]"
|
|
2083
|
+
},
|
|
2084
|
+
{
|
|
2085
|
+
kind: "directive",
|
|
2086
|
+
type: i2.MatHeaderRowDef,
|
|
2087
|
+
selector: "[matHeaderRowDef]",
|
|
2088
|
+
inputs: ["matHeaderRowDef", "matHeaderRowDefSticky"]
|
|
2089
|
+
},
|
|
2090
|
+
{
|
|
2091
|
+
kind: "directive",
|
|
2092
|
+
type: i2.MatColumnDef,
|
|
2093
|
+
selector: "[matColumnDef]",
|
|
2094
|
+
inputs: ["matColumnDef"]
|
|
2095
|
+
},
|
|
2096
|
+
{
|
|
2097
|
+
kind: "directive",
|
|
2098
|
+
type: i2.MatCellDef,
|
|
2099
|
+
selector: "[matCellDef]"
|
|
2100
|
+
},
|
|
2101
|
+
{
|
|
2102
|
+
kind: "directive",
|
|
2103
|
+
type: i2.MatRowDef,
|
|
2104
|
+
selector: "[matRowDef]",
|
|
2105
|
+
inputs: ["matRowDefColumns", "matRowDefWhen"]
|
|
2106
|
+
},
|
|
2107
|
+
{
|
|
2108
|
+
kind: "directive",
|
|
2109
|
+
type: i2.MatHeaderCell,
|
|
2110
|
+
selector: "mat-header-cell, th[mat-header-cell]"
|
|
2111
|
+
},
|
|
2112
|
+
{
|
|
2113
|
+
kind: "directive",
|
|
2114
|
+
type: i2.MatCell,
|
|
2115
|
+
selector: "mat-cell, td[mat-cell]"
|
|
2116
|
+
},
|
|
2117
|
+
{
|
|
2118
|
+
kind: "component",
|
|
2119
|
+
type: i2.MatHeaderRow,
|
|
2120
|
+
selector: "mat-header-row, tr[mat-header-row]",
|
|
2121
|
+
exportAs: ["matHeaderRow"]
|
|
2122
|
+
},
|
|
2123
|
+
{
|
|
2124
|
+
kind: "component",
|
|
2125
|
+
type: i2.MatRow,
|
|
2126
|
+
selector: "mat-row, tr[mat-row]",
|
|
2127
|
+
exportAs: ["matRow"]
|
|
2128
|
+
},
|
|
2129
|
+
{
|
|
2130
|
+
kind: "ngmodule",
|
|
2131
|
+
type: MatProgressBarModule
|
|
2132
|
+
},
|
|
2133
|
+
{
|
|
2134
|
+
kind: "component",
|
|
2135
|
+
type: i3.MatProgressBar,
|
|
2136
|
+
selector: "mat-progress-bar",
|
|
2137
|
+
inputs: [
|
|
2138
|
+
"color",
|
|
2139
|
+
"value",
|
|
2140
|
+
"bufferValue",
|
|
2141
|
+
"mode"
|
|
2142
|
+
],
|
|
2143
|
+
outputs: ["animationEnd"],
|
|
2144
|
+
exportAs: ["matProgressBar"]
|
|
2145
|
+
},
|
|
2146
|
+
{
|
|
2147
|
+
kind: "ngmodule",
|
|
2148
|
+
type: MatButtonModule
|
|
2149
|
+
},
|
|
2150
|
+
{
|
|
2151
|
+
kind: "component",
|
|
2152
|
+
type: i4.MatButton,
|
|
2153
|
+
selector: " button[matButton], a[matButton], button[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button], a[mat-button], a[mat-raised-button], a[mat-flat-button], a[mat-stroked-button] ",
|
|
2154
|
+
inputs: ["matButton"],
|
|
2155
|
+
exportAs: ["matButton", "matAnchor"]
|
|
2156
|
+
},
|
|
2157
|
+
{
|
|
2158
|
+
kind: "component",
|
|
2159
|
+
type: i4.MatMiniFabButton,
|
|
2160
|
+
selector: "button[mat-mini-fab], a[mat-mini-fab], button[matMiniFab], a[matMiniFab]",
|
|
2161
|
+
exportAs: ["matButton", "matAnchor"]
|
|
2162
|
+
},
|
|
2163
|
+
{
|
|
2164
|
+
kind: "component",
|
|
2165
|
+
type: i4.MatIconButton,
|
|
2166
|
+
selector: "button[mat-icon-button], a[mat-icon-button], button[matIconButton], a[matIconButton]",
|
|
2167
|
+
exportAs: ["matButton", "matAnchor"]
|
|
2168
|
+
},
|
|
2169
|
+
{
|
|
2170
|
+
kind: "ngmodule",
|
|
2171
|
+
type: MatMenuModule
|
|
2172
|
+
},
|
|
2173
|
+
{
|
|
2174
|
+
kind: "component",
|
|
2175
|
+
type: i5.MatMenu,
|
|
2176
|
+
selector: "mat-menu",
|
|
2177
|
+
inputs: [
|
|
2178
|
+
"backdropClass",
|
|
2179
|
+
"aria-label",
|
|
2180
|
+
"aria-labelledby",
|
|
2181
|
+
"aria-describedby",
|
|
2182
|
+
"xPosition",
|
|
2183
|
+
"yPosition",
|
|
2184
|
+
"overlapTrigger",
|
|
2185
|
+
"hasBackdrop",
|
|
2186
|
+
"class",
|
|
2187
|
+
"classList"
|
|
2188
|
+
],
|
|
2189
|
+
outputs: ["closed", "close"],
|
|
2190
|
+
exportAs: ["matMenu"]
|
|
2191
|
+
},
|
|
2192
|
+
{
|
|
2193
|
+
kind: "component",
|
|
2194
|
+
type: i5.MatMenuItem,
|
|
2195
|
+
selector: "[mat-menu-item]",
|
|
2196
|
+
inputs: [
|
|
2197
|
+
"role",
|
|
2198
|
+
"disabled",
|
|
2199
|
+
"disabledInteractive",
|
|
2200
|
+
"disableRipple"
|
|
2201
|
+
],
|
|
2202
|
+
exportAs: ["matMenuItem"]
|
|
2203
|
+
},
|
|
2204
|
+
{
|
|
2205
|
+
kind: "directive",
|
|
2206
|
+
type: i5.MatMenuTrigger,
|
|
2207
|
+
selector: "[mat-menu-trigger-for], [matMenuTriggerFor]",
|
|
2208
|
+
inputs: [
|
|
2209
|
+
"mat-menu-trigger-for",
|
|
2210
|
+
"matMenuTriggerFor",
|
|
2211
|
+
"matMenuTriggerData",
|
|
2212
|
+
"matMenuTriggerRestoreFocus"
|
|
2213
|
+
],
|
|
2214
|
+
outputs: [
|
|
2215
|
+
"menuOpened",
|
|
2216
|
+
"onMenuOpen",
|
|
2217
|
+
"menuClosed",
|
|
2218
|
+
"onMenuClose"
|
|
2219
|
+
],
|
|
2220
|
+
exportAs: ["matMenuTrigger"]
|
|
2221
|
+
},
|
|
2222
|
+
{
|
|
2223
|
+
kind: "component",
|
|
2224
|
+
type: CmatPaginationComponent,
|
|
2225
|
+
selector: "cmat-pagination",
|
|
2226
|
+
inputs: [
|
|
2227
|
+
"id",
|
|
2228
|
+
"maxSize",
|
|
2229
|
+
"itemsPerPages",
|
|
2230
|
+
"initPerPage",
|
|
2231
|
+
"autoHide"
|
|
2232
|
+
],
|
|
2233
|
+
outputs: [
|
|
2234
|
+
"pageChange",
|
|
2235
|
+
"pageBoundsCorrection",
|
|
2236
|
+
"perPageCountChange"
|
|
2237
|
+
],
|
|
2238
|
+
exportAs: ["cmatPagination"]
|
|
2239
|
+
},
|
|
2240
|
+
{
|
|
2241
|
+
kind: "ngmodule",
|
|
2242
|
+
type: MatIconModule
|
|
2243
|
+
},
|
|
2244
|
+
{
|
|
2245
|
+
kind: "component",
|
|
2246
|
+
type: i6.MatIcon,
|
|
2247
|
+
selector: "mat-icon",
|
|
2248
|
+
inputs: [
|
|
2249
|
+
"color",
|
|
2250
|
+
"inline",
|
|
2251
|
+
"svgIcon",
|
|
2252
|
+
"fontSet",
|
|
2253
|
+
"fontIcon"
|
|
2254
|
+
],
|
|
2255
|
+
exportAs: ["matIcon"]
|
|
2256
|
+
},
|
|
2257
|
+
{
|
|
2258
|
+
kind: "ngmodule",
|
|
2259
|
+
type: MatTooltipModule
|
|
2260
|
+
},
|
|
2261
|
+
{
|
|
2262
|
+
kind: "directive",
|
|
2263
|
+
type: i7.MatTooltip,
|
|
2264
|
+
selector: "[matTooltip]",
|
|
2265
|
+
inputs: [
|
|
2266
|
+
"matTooltipPosition",
|
|
2267
|
+
"matTooltipPositionAtOrigin",
|
|
2268
|
+
"matTooltipDisabled",
|
|
2269
|
+
"matTooltipShowDelay",
|
|
2270
|
+
"matTooltipHideDelay",
|
|
2271
|
+
"matTooltipTouchGestures",
|
|
2272
|
+
"matTooltip",
|
|
2273
|
+
"matTooltipClass"
|
|
2274
|
+
],
|
|
2275
|
+
exportAs: ["matTooltip"]
|
|
2276
|
+
},
|
|
2277
|
+
{
|
|
2278
|
+
kind: "ngmodule",
|
|
2279
|
+
type: MatCheckboxModule
|
|
2280
|
+
},
|
|
2281
|
+
{
|
|
2282
|
+
kind: "component",
|
|
2283
|
+
type: i8.MatCheckbox,
|
|
2284
|
+
selector: "mat-checkbox",
|
|
2285
|
+
inputs: [
|
|
2286
|
+
"aria-label",
|
|
2287
|
+
"aria-labelledby",
|
|
2288
|
+
"aria-describedby",
|
|
2289
|
+
"aria-expanded",
|
|
2290
|
+
"aria-controls",
|
|
2291
|
+
"aria-owns",
|
|
2292
|
+
"id",
|
|
2293
|
+
"required",
|
|
2294
|
+
"labelPosition",
|
|
2295
|
+
"name",
|
|
2296
|
+
"value",
|
|
2297
|
+
"disableRipple",
|
|
2298
|
+
"tabIndex",
|
|
2299
|
+
"color",
|
|
2300
|
+
"disabledInteractive",
|
|
2301
|
+
"checked",
|
|
2302
|
+
"disabled",
|
|
2303
|
+
"indeterminate"
|
|
2304
|
+
],
|
|
2305
|
+
outputs: ["change", "indeterminateChange"],
|
|
2306
|
+
exportAs: ["matCheckbox"]
|
|
2307
|
+
}
|
|
2308
|
+
],
|
|
2309
|
+
changeDetection: i0.ChangeDetectionStrategy.OnPush
|
|
2310
|
+
});
|
|
2311
|
+
}
|
|
2312
|
+
};
|
|
2313
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
2314
|
+
minVersion: "12.0.0",
|
|
2315
|
+
version: "22.2.3",
|
|
2316
|
+
ngImport: i0,
|
|
2317
|
+
type: TableRendererComponent,
|
|
2318
|
+
decorators: [{
|
|
2319
|
+
type: Component,
|
|
2320
|
+
args: [{
|
|
2321
|
+
selector: "app-table-renderer",
|
|
2322
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
2323
|
+
imports: [
|
|
2324
|
+
CommonModule,
|
|
2325
|
+
MatTableModule,
|
|
2326
|
+
MatProgressBarModule,
|
|
2327
|
+
MatButtonModule,
|
|
2328
|
+
MatMenuModule,
|
|
2329
|
+
CmatPaginationComponent,
|
|
2330
|
+
MatIconModule,
|
|
2331
|
+
MatTooltipModule,
|
|
2332
|
+
MatCheckboxModule
|
|
2333
|
+
],
|
|
2334
|
+
template: "<div class=\"table-container relative group bg-card dark:bg-transparent border\" [ngClass]=\"twClasses().join(' ')\">\n <!-- 显示列按钮(左上角) -->\n @if (allColumns().length > 0 && !loading()) {\n <div class=\"absolute top-2 left-2 z-40 transition-opacity opacity-0 group-hover:opacity-100 print:hidden\">\n <button type=\"button\" matIconButton [matTooltip]=\"'显示列'\" [matMenuTriggerFor]=\"columnsMenu\">\n <mat-icon [svgIcon]=\"'heroicons_outline:adjustments-horizontal'\"></mat-icon>\n </button>\n <mat-menu #columnsMenu=\"matMenu\" [class]=\"'overflow-auto scrollbar-custom'\">\n <button type=\"button\" mat-menu-item (click)=\"toggleAllColumns()\">\n <span class=\"flex items-center\">\n <mat-checkbox class=\"flex items-center pointer-events-none\" disableRipple\n [checked]=\"allColumnsVisible()\" [indeterminate]=\"someColumnsVisible()\"></mat-checkbox>\n <span class=\"ml-1 leading-5 break-keep\">全部</span>\n </span>\n </button>\n @for (col of allColumns(); track col.field) {\n <button type=\"button\" mat-menu-item (click)=\"toggleColumnVisibility(col)\">\n <span class=\"flex items-center\">\n <mat-checkbox class=\"flex items-center pointer-events-none\" disableRipple\n [checked]=\"isColumnVisible(col)\"></mat-checkbox>\n <span class=\"ml-1 leading-5 break-keep\">{{col.header}}</span>\n </span>\n </button>\n }\n </mat-menu>\n </div>\n }\n\n @if (enableExport() && !loading()) {\n <div class=\"absolute bottom-10 lg:bottom-2 right-2 z-40 transition-opacity print:hidden\">\n <button matMiniFab color=\"primary\" class=\"opacity-0 group-hover:opacity-100\"\n [matMenuTriggerFor]=\"exportMenu\" [matTooltip]=\"'导出数据'\">\n <mat-icon [svgIcon]=\"'heroicons_outline:arrow-down-tray'\"></mat-icon>\n </button>\n\n <!-- 导出菜单 -->\n <mat-menu #exportMenu=\"matMenu\" xPosition=\"before\" [class]=\"'overflow-auto scrollbar-custom'\">\n <button mat-menu-item (click)=\"exportToCSV()\">\n <mat-icon [svgIcon]=\"'heroicons_outline:document-text'\"></mat-icon>\n <span>导出为 CSV</span>\n </button>\n <button mat-menu-item (click)=\"exportToExcel()\">\n <mat-icon [svgIcon]=\"'heroicons_outline:table-cells'\"></mat-icon>\n <span>导出为 Excel</span>\n </button>\n <button mat-menu-item (click)=\"exportToJSON()\">\n <mat-icon [svgIcon]=\"'heroicons_outline:document-chart-bar'\"></mat-icon>\n <span>导出为 JSON</span>\n </button>\n </mat-menu>\n </div>\n }\n\n <!-- 加载状态 -->\n @if (loading()) {\n <mat-progress-bar mode=\"indeterminate\"></mat-progress-bar>\n }\n\n <!-- 错误状态 -->\n @if (error()) {\n <div class=\"error-state text-warn\">\n <p>{{ error()?.message }}</p>\n <button mat-button color=\"primary\" (click)=\"refresh()\">重试</button>\n </div>\n }\n\n @if (!loading() && !error() && data() && (data()!.length > 0 || isDesktop())) {\n <!-- 无可见列提示 -->\n @if (columns().length === 0) {\n <div class=\"flex flex-col items-center justify-center py-12 bg-slate-100 dark:bg-transparent\">\n <mat-icon class=\"icon-size-12 text-secondary\" [svgIcon]=\"'heroicons_outline:eye-slash'\"></mat-icon>\n <div class=\"mt-3 text-lg font-bold tracking-tight text-secondary\">未选择显示列</div>\n <button type=\"button\" mat-button color=\"primary\" class=\"mt-2\" (click)=\"resetColumnVisibility()\">\n <mat-icon class=\"icon-size-5 mr-1\" [svgIcon]=\"'heroicons_outline:arrow-path'\"></mat-icon>\n 恢复默认显示\n </button>\n </div>\n } @else {\n <div class=\"table-wrapper flex-auto min-h-0 min-w-0 scrollbar-custom\">\n <table mat-table [ngStyle]=\"{'width': tableMinWidth(), 'table-layout': 'fixed'}\" [dataSource]=\"dataSource()\">\n <!-- 动态列 -->\n @for (column of columns(); track column.field) {\n <ng-container [matColumnDef]=\"column.field\">\n <!-- 表头:支持指标模板展示 -->\n <th *matHeaderCellDef mat-header-cell\n [ngStyle]=\"{'width':column.width,'text-align':column.align || 'left','padding-left':$first && allColumns().length > 0 ? '3.5rem' : undefined,'padding-right':$last && hasFilterButton() && component().parameters?.length ? '3.5rem' : undefined}\">\n <span>{{ getHeaderText(column) }}</span>\n </th>\n\n <!-- 单元格:支持对比样式、图标、进度 -->\n <td *matCellDef=\"let row\" mat-cell [ngStyle]=\"{'width':column.width,'text-align':column.align || 'left','padding-left':$first && allColumns().length > 0 ? '3.5rem' : undefined,'padding-right':$last && hasFilterButton() && component().parameters?.length ? '3.5rem' : undefined}\">\n\n <div class=\"has-label-on-mobile flex items-center gap-1\" [attr.data-label]=\"column.header+':'\"\n [ngStyle]=\"{'justify-content': (column.align || 'left') === 'right' ? 'flex-end' : (column.align || 'left') === 'center' ? 'center' : 'flex-start'}\">\n <!-- 设计器模式显示锁图标 -->\n @if (isDesignerMode() && column.drillDown?.enabled) {\n <mat-icon class=\"icon-size-3 text-warn-400\" matTooltip=\"设计模式下禁用下钻\"\n [svgIcon]=\"'heroicons_outline:lock-closed'\">\n </mat-icon>\n }\n\n <!-- 进度条模式 -->\n @if (column.indicator?.enabled && column.indicator.progressMode === 'bar') {\n <div class=\"flex items-center gap-1.5 w-full\"\n [ngStyle]=\"{'justify-content': (column.align || 'left') === 'right' ? 'flex-end' : (column.align || 'left') === 'center' ? 'center' : 'flex-start'}\">\n <span class=\"shrink-0 font-medium\"\n [ngClass]=\"getCellStyle(row[column.field], row, column)\"\n [ngStyle]=\"{'cursor': !isDesignerMode() && isCellDrillable(row, column) ? 'pointer' : 'default'}\"\n (click)=\"onCellClick(row, column)\">\n {{ formatValue(row[column.field], column.format) }}\n </span>\n <div class=\"flex-1 min-w-[40px] h-1.5 bg-gray-200 dark:bg-gray-700 rounded-full overflow-hidden\">\n <div class=\"h-full rounded-full transition-all duration-300\"\n [ngClass]=\"{\n 'bg-emerald-500': getIndicatorProgress(row[column.field], row, column) >= 100,\n 'bg-amber-500': getIndicatorProgress(row[column.field], row, column) >= 60 && getIndicatorProgress(row[column.field], row, column) < 100,\n 'bg-red-500': getIndicatorProgress(row[column.field], row, column) < 60\n }\"\n [ngStyle]=\"{'width': getIndicatorProgress(row[column.field], row, column) + '%'}\">\n </div>\n </div>\n <span class=\"shrink-0 text-[10px] text-secondary\">\n {{ getIndicatorProgressText(row[column.field], row, column) }}\n </span>\n </div>\n }\n\n <!-- 普通模式(无进度条) -->\n @if (!(column.indicator?.enabled && column.indicator.progressMode === 'bar')) {\n <span\n [ngClass]=\"getCellStyle(row[column.field], row, column)\"\n [ngStyle]=\"{'cursor': !isDesignerMode() && isCellDrillable(row, column) ? 'pointer' : 'default'}\"\n [class.cursor-pointer]=\"!isDesignerMode() && isCellDrillable(row, column)\"\n [class.text-primary-600]=\"!isDesignerMode() && isCellDrillable(row, column)\"\n [class.underline]=\"!isDesignerMode() && isCellDrillable(row, column)\"\n [class.lg:no-underline]=\"!isDesignerMode() && isCellDrillable(row, column)\"\n [class.lg:hover:underline]=\"!isDesignerMode() && isCellDrillable(row, column)\"\n (click)=\"onCellClick(row, column)\">\n {{ formatValue(row[column.field], column.format) }}\n @if (column.indicator?.enabled && column.indicator.progressMode === 'text') {\n <span class=\"text-xs opacity-70 ml-0.5\">({{ getIndicatorProgressText(row[column.field], row, column) }})</span>\n }\n </span>\n }\n\n <!-- 指标状态图标 -->\n @if (column.indicator?.showStatusIcon) {\n @if (getIndicatorIcon(row[column.field], row, column)) {\n <mat-icon class=\"icon-size-4\"\n [ngClass]=\"getCellStyle(row[column.field], row, column)\"\n [svgIcon]=\"getIndicatorIcon(row[column.field], row, column)\"\n [matTooltip]=\"getIndicatorLabel(row[column.field], row, column)\">\n </mat-icon>\n }\n }\n\n <!-- 指标文本标签 -->\n @if (column.indicator?.enabled && !column.indicator.showStatusIcon) {\n @if (getIndicatorLabel(row[column.field], row, column)) {\n <span class=\"text-[10px] px-1 rounded\"\n [ngClass]=\"getCellStyle(row[column.field], row, column)\">\n {{ getIndicatorLabel(row[column.field], row, column) }}\n </span>\n }\n }\n </div>\n </td>\n </ng-container>\n }\n\n <tr *matHeaderRowDef=\"columnKeys(); sticky: true\" mat-header-row></tr>\n <tr *matRowDef=\"let row; columns: columnKeys();\" mat-row></tr>\n </table>\n </div>\n\n @if (pagination()&&data() && data()!.length !== 0) {\n <div class=\"pagination-wrapper\">\n <cmat-pagination [id]=\"id\" [itemsPerPages]=\"pageSizeOptions()\" [initPerPage]=\"defaultPageSize()\"\n (pageChange)=\"onPageChange($event)\" (perPageCountChange)=\"onPageSizeChange($event)\">\n </cmat-pagination>\n </div>\n }\n }\n }\n\n <!-- 空状态 -->\n @if (!loading() && !error() && data() && data()!.length === 0) {\n <div class=\"flex h-full flex-col items-center justify-center py-4 bg-slate-100 dark:bg-transparent print:border\">\n <mat-icon class=\"icon-size-12\" [svgIcon]=\"'heroicons_outline:document-magnifying-glass'\"></mat-icon>\n <div class=\"mt-4 text-lg font-bold tracking-tight text-secondary\">暂无数据</div>\n </div>\n }\n</div>",
|
|
2335
|
+
styles: ["@charset \"UTF-8\";:host{display:flex;flex-direction:column;width:100%;height:100%;min-height:0;box-sizing:border-box}.table-container{display:flex;flex-direction:column;flex:1 1 auto;width:100%;min-height:0;min-width:0;overflow:hidden;border-radius:.75rem}.table-wrapper{flex:1 1 auto;min-height:0;min-width:0;overflow-x:auto;overflow-y:auto}@media(min-width:1024px){.table-wrapper{max-height:calc(100vh - 14rem)}}@media(max-width:1023px){.table-wrapper{max-height:calc(100vh - 12rem)}}table{min-width:100%;display:table!important}@media(min-width:1024px){table{table-layout:fixed}}.pagination-wrapper{flex:none;border-top:1px solid #e5e7eb;background:#f9fafb}:host ::ng-deep .dark .pagination-wrapper{background:transparent;border-top-color:#334155}.error-state{padding:1rem;text-align:center}@media print{.table-container{overflow:visible!important;border-radius:.75rem;page-break-inside:avoid;break-inside:avoid}table{page-break-inside:auto}tr{page-break-inside:avoid;break-inside:avoid}th{background-color:#f9fafb!important;-webkit-print-color-adjust:exact;print-color-adjust:exact}td,th{border:1px solid #e5e7eb!important;padding:.25rem .5rem!important}}\n"]
|
|
2336
|
+
}]
|
|
2337
|
+
}],
|
|
2338
|
+
ctorParameters: () => []
|
|
2339
|
+
});
|
|
2340
|
+
var ChartRendererComponent = class ChartRendererComponent extends BaseRendererComponent {
|
|
2341
|
+
constructor() {
|
|
2342
|
+
super();
|
|
2343
|
+
this.chartContainer = viewChild("chartContainer", ...ngDevMode ? [{ debugName: "chartContainer" }] : /* istanbul ignore next */ []);
|
|
2344
|
+
this.config = signal(null, ...ngDevMode ? [{ debugName: "config" }] : /* istanbul ignore next */ []);
|
|
2345
|
+
this.chartType = computed(() => this.config()?.chart?.chartType ?? "bar", ...ngDevMode ? [{ debugName: "chartType" }] : /* istanbul ignore next */ []);
|
|
2346
|
+
this.xAxisField = computed(() => this.config()?.chart?.xAxisField ?? "", ...ngDevMode ? [{ debugName: "xAxisField" }] : /* istanbul ignore next */ []);
|
|
2347
|
+
this.yAxisField = computed(() => {
|
|
2348
|
+
const field = this.config()?.chart?.yAxisField;
|
|
2349
|
+
return Array.isArray(field) ? field : field ? [field] : [];
|
|
2350
|
+
}, ...ngDevMode ? [{ debugName: "yAxisField" }] : /* istanbul ignore next */ []);
|
|
2351
|
+
this.title = computed(() => this.config()?.chart?.title ?? "", ...ngDevMode ? [{ debugName: "title" }] : /* istanbul ignore next */ []);
|
|
2352
|
+
this.showLegend = computed(() => this.config()?.chart?.showLegend ?? true, ...ngDevMode ? [{ debugName: "showLegend" }] : /* istanbul ignore next */ []);
|
|
2353
|
+
this.legendPosition = computed(() => this.config()?.chart?.legendPosition ?? "top", ...ngDevMode ? [{ debugName: "legendPosition" }] : /* istanbul ignore next */ []);
|
|
2354
|
+
this.showGrid = computed(() => this.config()?.chart?.showGrid ?? true, ...ngDevMode ? [{ debugName: "showGrid" }] : /* istanbul ignore next */ []);
|
|
2355
|
+
this.colors = computed(() => this.config()?.chart?.colors ?? [
|
|
2356
|
+
"#5470c6",
|
|
2357
|
+
"#91cc75",
|
|
2358
|
+
"#fac858",
|
|
2359
|
+
"#ee6666",
|
|
2360
|
+
"#73c0de"
|
|
2361
|
+
], ...ngDevMode ? [{ debugName: "colors" }] : /* istanbul ignore next */ []);
|
|
2362
|
+
this.smooth = computed(() => this.config()?.chart?.smooth ?? false, ...ngDevMode ? [{ debugName: "smooth" }] : /* istanbul ignore next */ []);
|
|
2363
|
+
this.stack = computed(() => this.config()?.chart?.stack ?? false, ...ngDevMode ? [{ debugName: "stack" }] : /* istanbul ignore next */ []);
|
|
2364
|
+
this.xAxisName = computed(() => this.config()?.chart?.xAxisName ?? "", ...ngDevMode ? [{ debugName: "xAxisName" }] : /* istanbul ignore next */ []);
|
|
2365
|
+
this.yAxisName = computed(() => this.config()?.chart?.yAxisName ?? "", ...ngDevMode ? [{ debugName: "yAxisName" }] : /* istanbul ignore next */ []);
|
|
2366
|
+
this.xAxisRotate = computed(() => this.config()?.chart?.xAxisRotate ?? 0, ...ngDevMode ? [{ debugName: "xAxisRotate" }] : /* istanbul ignore next */ []);
|
|
2367
|
+
this.showXAxisLabel = computed(() => this.config()?.chart?.showXAxisLabel ?? true, ...ngDevMode ? [{ debugName: "showXAxisLabel" }] : /* istanbul ignore next */ []);
|
|
2368
|
+
this.showYAxisLabel = computed(() => this.config()?.chart?.showYAxisLabel ?? true, ...ngDevMode ? [{ debugName: "showYAxisLabel" }] : /* istanbul ignore next */ []);
|
|
2369
|
+
this.tooltipTrigger = computed(() => this.config()?.chart?.tooltipTrigger ?? "axis", ...ngDevMode ? [{ debugName: "tooltipTrigger" }] : /* istanbul ignore next */ []);
|
|
2370
|
+
this.tooltipFormatter = computed(() => this.config()?.chart?.tooltipFormatter ?? "", ...ngDevMode ? [{ debugName: "tooltipFormatter" }] : /* istanbul ignore next */ []);
|
|
2371
|
+
this.showMarkLine = computed(() => this.config()?.chart?.showMarkLine ?? false, ...ngDevMode ? [{ debugName: "showMarkLine" }] : /* istanbul ignore next */ []);
|
|
2372
|
+
this.markLineType = computed(() => this.config()?.chart?.markLineType ?? "average", ...ngDevMode ? [{ debugName: "markLineType" }] : /* istanbul ignore next */ []);
|
|
2373
|
+
this.showMarkPoint = computed(() => this.config()?.chart?.showMarkPoint ?? false, ...ngDevMode ? [{ debugName: "showMarkPoint" }] : /* istanbul ignore next */ []);
|
|
2374
|
+
this.animationEnabled = computed(() => this.config()?.chart?.animationEnabled ?? true, ...ngDevMode ? [{ debugName: "animationEnabled" }] : /* istanbul ignore next */ []);
|
|
2375
|
+
this.animationDuration = computed(() => this.config()?.chart?.animationDuration ?? 1e3, ...ngDevMode ? [{ debugName: "animationDuration" }] : /* istanbul ignore next */ []);
|
|
2376
|
+
this.pieRadius = computed(() => this.config()?.chart?.pieRadius ?? "60%", ...ngDevMode ? [{ debugName: "pieRadius" }] : /* istanbul ignore next */ []);
|
|
2377
|
+
this.pieRoseType = computed(() => this.config()?.chart?.pieRoseType ?? false, ...ngDevMode ? [{ debugName: "pieRoseType" }] : /* istanbul ignore next */ []);
|
|
2378
|
+
this.barWidth = computed(() => this.config()?.chart?.barWidth, ...ngDevMode ? [{ debugName: "barWidth" }] : /* istanbul ignore next */ []);
|
|
2379
|
+
this.barGap = computed(() => this.config()?.chart?.barGap, ...ngDevMode ? [{ debugName: "barGap" }] : /* istanbul ignore next */ []);
|
|
2380
|
+
this.lineSymbol = computed(() => this.config()?.chart?.lineSymbol ?? "circle", ...ngDevMode ? [{ debugName: "lineSymbol" }] : /* istanbul ignore next */ []);
|
|
2381
|
+
this.lineSymbolSize = computed(() => this.config()?.chart?.lineSymbolSize ?? 4, ...ngDevMode ? [{ debugName: "lineSymbolSize" }] : /* istanbul ignore next */ []);
|
|
2382
|
+
this.gridLeft = computed(() => this.config()?.chart?.gridLeft ?? "4%", ...ngDevMode ? [{ debugName: "gridLeft" }] : /* istanbul ignore next */ []);
|
|
2383
|
+
this.gridRight = computed(() => this.config()?.chart?.gridRight ?? "4%", ...ngDevMode ? [{ debugName: "gridRight" }] : /* istanbul ignore next */ []);
|
|
2384
|
+
this.gridTop = computed(() => this.config()?.chart?.gridTop ?? "12%", ...ngDevMode ? [{ debugName: "gridTop" }] : /* istanbul ignore next */ []);
|
|
2385
|
+
this.gridBottom = computed(() => this.config()?.chart?.gridBottom ?? "8%", ...ngDevMode ? [{ debugName: "gridBottom" }] : /* istanbul ignore next */ []);
|
|
2386
|
+
this.twClasses = computed(() => this.config()?.chart?.twClasses ?? [], ...ngDevMode ? [{ debugName: "twClasses" }] : /* istanbul ignore next */ []);
|
|
2387
|
+
this.route = inject(ActivatedRoute);
|
|
2388
|
+
this._drillDownService = inject(DrillDownService);
|
|
2389
|
+
this._cmatConfigService = inject(CmatConfigService);
|
|
2390
|
+
this._scheme = computed(() => this._cmatConfigService.config().scheme, ...ngDevMode ? [{ debugName: "_scheme" }] : /* istanbul ignore next */ []);
|
|
2391
|
+
this.isDesignerMode = computed(() => {
|
|
2392
|
+
return this.route.snapshot.url.some((segment) => segment.path === "builder");
|
|
2393
|
+
}, ...ngDevMode ? [{ debugName: "isDesignerMode" }] : /* istanbul ignore next */ []);
|
|
2394
|
+
this._chartInstance = null;
|
|
2395
|
+
this._resizeHandler = this._handleResize.bind(this);
|
|
2396
|
+
this._beforePrintHandler = this._handleBeforePrint.bind(this);
|
|
2397
|
+
this._afterPrintHandler = this._handleAfterPrint.bind(this);
|
|
2398
|
+
effect(() => {
|
|
2399
|
+
const component = this.component();
|
|
2400
|
+
if (component?.config) this.config.set(component.config);
|
|
2401
|
+
});
|
|
2402
|
+
effect(() => {
|
|
2403
|
+
const data = this.data();
|
|
2404
|
+
this._scheme();
|
|
2405
|
+
untracked(() => {
|
|
2406
|
+
if (data && data.length > 0) requestAnimationFrame(() => {
|
|
2407
|
+
const container = this.chartContainer()?.nativeElement;
|
|
2408
|
+
if (!container || container.clientWidth === 0) return;
|
|
2409
|
+
if (!this._chartInstance || this._chartInstance.isDisposed()) this._initChart(container);
|
|
2410
|
+
if (this._chartInstance && !this._chartInstance.isDisposed()) {
|
|
2411
|
+
this._chartInstance.resize();
|
|
2412
|
+
this._updateChart(data);
|
|
2413
|
+
}
|
|
2414
|
+
});
|
|
2415
|
+
});
|
|
2416
|
+
});
|
|
2417
|
+
}
|
|
2418
|
+
ngAfterViewInit() {
|
|
2419
|
+
window.addEventListener("resize", this._resizeHandler);
|
|
2420
|
+
window.addEventListener("beforeprint", this._beforePrintHandler);
|
|
2421
|
+
window.addEventListener("afterprint", this._afterPrintHandler);
|
|
2422
|
+
}
|
|
2423
|
+
ngOnDestroy() {
|
|
2424
|
+
if (this._chartInstance) {
|
|
2425
|
+
this._chartInstance.dispose();
|
|
2426
|
+
this._chartInstance = null;
|
|
2427
|
+
}
|
|
2428
|
+
window.removeEventListener("resize", this._resizeHandler);
|
|
2429
|
+
window.removeEventListener("beforeprint", this._beforePrintHandler);
|
|
2430
|
+
window.removeEventListener("afterprint", this._afterPrintHandler);
|
|
2431
|
+
}
|
|
2432
|
+
refresh() {
|
|
2433
|
+
super.refresh();
|
|
2434
|
+
}
|
|
2435
|
+
_initChart(container) {
|
|
2436
|
+
this._chartInstance = echarts.init(container);
|
|
2437
|
+
this._chartInstance.on("click", (params) => {
|
|
2438
|
+
this._onChartClick(params);
|
|
2439
|
+
});
|
|
2440
|
+
}
|
|
2441
|
+
_handleResize() {
|
|
2442
|
+
if (this._chartInstance) this._chartInstance.resize();
|
|
2443
|
+
}
|
|
2444
|
+
_handleBeforePrint() {
|
|
2445
|
+
if (this._chartInstance && this.chartContainer()) setTimeout(() => {
|
|
2446
|
+
const container = this.chartContainer().nativeElement;
|
|
2447
|
+
const width = container.clientWidth;
|
|
2448
|
+
const height = container.clientHeight;
|
|
2449
|
+
this._chartInstance.resize({
|
|
2450
|
+
width,
|
|
2451
|
+
height,
|
|
2452
|
+
animation: { duration: 0 }
|
|
2453
|
+
});
|
|
2454
|
+
}, 150);
|
|
2455
|
+
}
|
|
2456
|
+
_handleAfterPrint() {
|
|
2457
|
+
if (this._chartInstance && this.chartContainer()) setTimeout(() => {
|
|
2458
|
+
this._chartInstance.resize({ animation: { duration: 300 } });
|
|
2459
|
+
}, 150);
|
|
2460
|
+
}
|
|
2461
|
+
_updateChart(data) {
|
|
2462
|
+
if (!this._chartInstance || !data || data.length === 0) return;
|
|
2463
|
+
const option = this._generateOption(data);
|
|
2464
|
+
this._chartInstance.setOption(option, true);
|
|
2465
|
+
}
|
|
2466
|
+
_generateOption(data) {
|
|
2467
|
+
const type = this.chartType();
|
|
2468
|
+
const xField = this.xAxisField();
|
|
2469
|
+
const yFields = this.yAxisField();
|
|
2470
|
+
const schema = this._getSchema();
|
|
2471
|
+
const xAxisData = data.map((item) => item[xField]);
|
|
2472
|
+
const series = yFields.map((field, index) => {
|
|
2473
|
+
const fieldLabel = this._getFieldLabel(field, schema);
|
|
2474
|
+
const seriesData = data.map((item) => Number(item[field]) || 0);
|
|
2475
|
+
const baseSeries = {
|
|
2476
|
+
name: fieldLabel,
|
|
2477
|
+
type: type === "area" ? "line" : type,
|
|
2478
|
+
data: seriesData,
|
|
2479
|
+
itemStyle: { color: this.colors()[index % this.colors().length] },
|
|
2480
|
+
label: { color: this._scheme() == "dark" ? "#fff" : "#212121" }
|
|
2481
|
+
};
|
|
2482
|
+
if (type === "line" || type === "area") {
|
|
2483
|
+
baseSeries.smooth = this.smooth();
|
|
2484
|
+
if (type === "area") baseSeries.areaStyle = { opacity: .3 };
|
|
2485
|
+
if (this.lineSymbol() !== "none") {
|
|
2486
|
+
baseSeries.symbol = this.lineSymbol();
|
|
2487
|
+
baseSeries.symbolSize = this.lineSymbolSize();
|
|
2488
|
+
}
|
|
2489
|
+
}
|
|
2490
|
+
if (this.stack()) baseSeries.stack = "total";
|
|
2491
|
+
if (type === "bar") {
|
|
2492
|
+
if (this.barWidth()) baseSeries.barWidth = this.barWidth();
|
|
2493
|
+
if (this.barGap()) baseSeries.barGap = this.barGap();
|
|
2494
|
+
}
|
|
2495
|
+
if (this.showMarkPoint()) baseSeries.markPoint = { data: [{
|
|
2496
|
+
type: "max",
|
|
2497
|
+
name: "最大值"
|
|
2498
|
+
}, {
|
|
2499
|
+
type: "min",
|
|
2500
|
+
name: "最小值"
|
|
2501
|
+
}] };
|
|
2502
|
+
if (this.showMarkLine()) baseSeries.markLine = { data: [{
|
|
2503
|
+
type: this.markLineType(),
|
|
2504
|
+
name: this.markLineType()
|
|
2505
|
+
}] };
|
|
2506
|
+
return baseSeries;
|
|
2507
|
+
});
|
|
2508
|
+
if (type === "pie") {
|
|
2509
|
+
const pieData = data.map((item, index) => ({
|
|
2510
|
+
name: item[xField],
|
|
2511
|
+
value: Number(item[yFields[0]]) || 0,
|
|
2512
|
+
itemStyle: { color: this.colors()[index % this.colors().length] }
|
|
2513
|
+
}));
|
|
2514
|
+
return {
|
|
2515
|
+
title: {
|
|
2516
|
+
text: this.title(),
|
|
2517
|
+
left: "center",
|
|
2518
|
+
top: 10,
|
|
2519
|
+
textStyle: {
|
|
2520
|
+
fontSize: 14,
|
|
2521
|
+
fontWeight: "bold",
|
|
2522
|
+
color: this._scheme() == "dark" ? "#fff" : "#212121"
|
|
2523
|
+
}
|
|
2524
|
+
},
|
|
2525
|
+
tooltip: {
|
|
2526
|
+
trigger: "item",
|
|
2527
|
+
formatter: this.tooltipFormatter() || "{b}: {c} ({d}%)"
|
|
2528
|
+
},
|
|
2529
|
+
legend: this.showLegend() ? {
|
|
2530
|
+
orient: this.legendPosition() === "left" || this.legendPosition() === "right" ? "vertical" : "horizontal",
|
|
2531
|
+
left: this.legendPosition() === "left" ? "left" : this.legendPosition() === "right" ? "right" : "right",
|
|
2532
|
+
top: this.legendPosition() === "top" ? 10 : this.legendPosition() === "bottom" ? "bottom" : 10,
|
|
2533
|
+
right: this.legendPosition() === "right" ? 10 : void 0,
|
|
2534
|
+
bottom: this.legendPosition() === "bottom" ? 10 : void 0,
|
|
2535
|
+
type: "scroll",
|
|
2536
|
+
textStyle: { color: this._scheme() == "dark" ? "#fff" : "#212121" }
|
|
2537
|
+
} : void 0,
|
|
2538
|
+
series: [{
|
|
2539
|
+
type: "pie",
|
|
2540
|
+
radius: this.pieRadius(),
|
|
2541
|
+
roseType: this.pieRoseType() ? "area" : void 0,
|
|
2542
|
+
data: pieData,
|
|
2543
|
+
emphasis: { itemStyle: {
|
|
2544
|
+
shadowBlur: 10,
|
|
2545
|
+
shadowOffsetX: 0,
|
|
2546
|
+
shadowColor: "rgba(0, 0, 0, 0.5)"
|
|
2547
|
+
} },
|
|
2548
|
+
label: { color: this._scheme() == "dark" ? "#fff" : "#212121" }
|
|
2549
|
+
}]
|
|
2550
|
+
};
|
|
2551
|
+
}
|
|
2552
|
+
return {
|
|
2553
|
+
title: {
|
|
2554
|
+
text: this.title(),
|
|
2555
|
+
left: "center",
|
|
2556
|
+
top: 10,
|
|
2557
|
+
textStyle: {
|
|
2558
|
+
fontSize: 14,
|
|
2559
|
+
fontWeight: "bold",
|
|
2560
|
+
color: this._scheme() == "dark" ? "#fff" : "#212121"
|
|
2561
|
+
}
|
|
2562
|
+
},
|
|
2563
|
+
tooltip: {
|
|
2564
|
+
trigger: this.tooltipTrigger(),
|
|
2565
|
+
formatter: this.tooltipFormatter() || void 0
|
|
2566
|
+
},
|
|
2567
|
+
legend: this.showLegend() ? {
|
|
2568
|
+
data: yFields.map((field) => this._getFieldLabel(field, schema)),
|
|
2569
|
+
orient: this.legendPosition() === "left" || this.legendPosition() === "right" ? "vertical" : "horizontal",
|
|
2570
|
+
left: this.legendPosition() === "left" ? "left" : this.legendPosition() === "right" ? "right" : "right",
|
|
2571
|
+
top: this.legendPosition() === "top" ? 10 : this.legendPosition() === "bottom" ? "bottom" : 10,
|
|
2572
|
+
right: this.legendPosition() === "right" ? 10 : void 0,
|
|
2573
|
+
bottom: this.legendPosition() === "bottom" ? 10 : void 0,
|
|
2574
|
+
type: "scroll",
|
|
2575
|
+
textStyle: { color: this._scheme() == "dark" ? "#fff" : "#212121" }
|
|
2576
|
+
} : void 0,
|
|
2577
|
+
grid: this.showGrid() ? {
|
|
2578
|
+
left: this.gridLeft(),
|
|
2579
|
+
right: this.gridRight(),
|
|
2580
|
+
top: this.gridTop(),
|
|
2581
|
+
bottom: this.gridBottom(),
|
|
2582
|
+
containLabel: true
|
|
2583
|
+
} : void 0,
|
|
2584
|
+
xAxis: {
|
|
2585
|
+
type: "category",
|
|
2586
|
+
data: xAxisData,
|
|
2587
|
+
name: this.xAxisName() || void 0,
|
|
2588
|
+
axisLabel: {
|
|
2589
|
+
show: this.showXAxisLabel(),
|
|
2590
|
+
rotate: this.xAxisRotate()
|
|
2591
|
+
}
|
|
2592
|
+
},
|
|
2593
|
+
yAxis: {
|
|
2594
|
+
type: "value",
|
|
2595
|
+
name: this.yAxisName() || void 0,
|
|
2596
|
+
axisLabel: { show: this.showYAxisLabel() }
|
|
2597
|
+
},
|
|
2598
|
+
series,
|
|
2599
|
+
animation: this.animationEnabled() ?? false,
|
|
2600
|
+
animationDuration: this.animationEnabled() ? this.animationDuration() ?? 0 : 0
|
|
2601
|
+
};
|
|
2602
|
+
}
|
|
2603
|
+
_getSchema() {
|
|
2604
|
+
const template = this.template();
|
|
2605
|
+
const component = this.component();
|
|
2606
|
+
if (!template?.providers || !component?.dataBinding?.providerRef) return [];
|
|
2607
|
+
const provider = template.providers.find((p) => p.id === component.dataBinding?.providerRef);
|
|
2608
|
+
if (provider?.type !== "mock" || !provider.mock?.schema) return [];
|
|
2609
|
+
return provider.mock.schema;
|
|
2610
|
+
}
|
|
2611
|
+
_getFieldLabel(fieldName, schema) {
|
|
2612
|
+
if (!schema || schema.length === 0) return fieldName;
|
|
2613
|
+
return schema.find((s) => s.name === fieldName)?.label ?? fieldName;
|
|
2614
|
+
}
|
|
2615
|
+
_onChartClick(params) {
|
|
2616
|
+
if (this.isDesignerMode()) {
|
|
2617
|
+
console.log("[Chart] Designer mode - drill down disabled");
|
|
2618
|
+
return;
|
|
2619
|
+
}
|
|
2620
|
+
const config = this.config()?.chart;
|
|
2621
|
+
if (!config?.drillDown?.enabled) return;
|
|
2622
|
+
const dataPoint = {
|
|
2623
|
+
name: params.name,
|
|
2624
|
+
value: params.value,
|
|
2625
|
+
seriesName: params.seriesName,
|
|
2626
|
+
dataIndex: params.dataIndex,
|
|
2627
|
+
rawData: this.data()?.[params.dataIndex]
|
|
2628
|
+
};
|
|
2629
|
+
this._drillDownService.execute(config.drillDown, dataPoint.rawData ?? dataPoint);
|
|
2630
|
+
}
|
|
2631
|
+
static {
|
|
2632
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
2633
|
+
minVersion: "12.0.0",
|
|
2634
|
+
version: "22.2.3",
|
|
2635
|
+
ngImport: i0,
|
|
2636
|
+
type: ChartRendererComponent,
|
|
2637
|
+
deps: [],
|
|
2638
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
2639
|
+
});
|
|
2640
|
+
}
|
|
2641
|
+
static {
|
|
2642
|
+
this.ɵcmp = i0.ɵɵngDeclareComponent({
|
|
2643
|
+
minVersion: "17.0.0",
|
|
2644
|
+
version: "22.2.3",
|
|
2645
|
+
type: ChartRendererComponent,
|
|
2646
|
+
isStandalone: true,
|
|
2647
|
+
selector: "app-chart-renderer",
|
|
2648
|
+
viewQueries: [{
|
|
2649
|
+
propertyName: "chartContainer",
|
|
2650
|
+
first: true,
|
|
2651
|
+
predicate: ["chartContainer"],
|
|
2652
|
+
descendants: true,
|
|
2653
|
+
isSignal: true
|
|
2654
|
+
}],
|
|
2655
|
+
usesInheritance: true,
|
|
2656
|
+
ngImport: i0,
|
|
2657
|
+
template: "<div [class]=\"twClasses().join(' ')\" [ngClass]=\"{'cursor-pointer': config()?.chart?.drillDown?.enabled && !isDesignerMode(),\n 'chart-container bg-card dark:bg-transparent border':true\n }\" [title]=\"config()?.chart?.drillDown?.enabled && !isDesignerMode() ? '点击图表元素下钻' : ''\">\n <!-- 加载状态 -->\n @if (loading()) {\n <div class=\"loading-state\">\n <mat-progress-bar mode=\"indeterminate\"></mat-progress-bar>\n <p class=\"mt-2 text-sm text-secondary\">加载中...</p>\n </div>\n }\n\n <!-- 错误状态 -->\n @if (error()) {\n <div class=\"error-state\">\n <mat-icon class=\"icon-size-8 text-warn\" [svgIcon]=\"'heroicons_outline:exclamation-circle'\"></mat-icon>\n <p class=\"mt-2\">{{ error()?.message }}</p>\n <button mat-button color=\"primary\" (click)=\"refresh()\">重试</button>\n </div>\n }\n\n <!-- 空状态 -->\n @if (!loading() && !error() && (!data() || data()!.length === 0)) {\n <div class=\"empty-state\">\n <mat-icon class=\"icon-size-12 opacity-50\" [svgIcon]=\"'heroicons_outline:chart-bar'\"></mat-icon>\n <p class=\"mt-2 text-sm text-secondary\">暂无数据</p>\n </div>\n }\n\n <!-- 图表容器(始终存在于 DOM,确保 viewChild 和 ngAfterViewInit 可用) -->\n <div #chartContainer class=\"chart-canvas\"\n [ngStyle]=\"{'display': ((!loading() && !error() && data() && data()!.length > 0) ? 'block' : 'none')}\"></div>\n</div>",
|
|
2658
|
+
styles: ["@charset \"UTF-8\";.chart-container{position:relative;width:100%;height:100%;min-height:280px;padding:.5rem;border-radius:.75rem;box-shadow:0 1px 3px #0000001a;transition:all .2s ease;overflow:hidden}.chart-container:hover{box-shadow:0 4px 6px #0000001a}.chart-container:is(.dark *){-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px)}.chart-canvas{width:100%;height:100%;min-height:240px;overflow:hidden}.loading-state,.error-state,.empty-state{display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;min-height:240px;text-align:center;color:#6b7280}@media print{.chart-container{box-shadow:none!important;border:1px solid #e5e7eb!important;background-color:#fff!important;padding:1rem!important;page-break-inside:avoid;break-inside:avoid;width:100%!important;max-width:100%!important;box-sizing:border-box!important;overflow:hidden!important}.chart-canvas{min-height:200px!important;page-break-inside:avoid;break-inside:avoid;width:100%!important;max-width:100%!important;overflow:hidden!important}.chart-canvas>div{width:100%!important;max-width:100%!important;overflow:hidden!important}}\n"],
|
|
2659
|
+
dependencies: [
|
|
2660
|
+
{
|
|
2661
|
+
kind: "ngmodule",
|
|
2662
|
+
type: MatButtonModule
|
|
2663
|
+
},
|
|
2664
|
+
{
|
|
2665
|
+
kind: "component",
|
|
2666
|
+
type: i4.MatButton,
|
|
2667
|
+
selector: " button[matButton], a[matButton], button[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button], a[mat-button], a[mat-raised-button], a[mat-flat-button], a[mat-stroked-button] ",
|
|
2668
|
+
inputs: ["matButton"],
|
|
2669
|
+
exportAs: ["matButton", "matAnchor"]
|
|
2670
|
+
},
|
|
2671
|
+
{
|
|
2672
|
+
kind: "ngmodule",
|
|
2673
|
+
type: MatIconModule
|
|
2674
|
+
},
|
|
2675
|
+
{
|
|
2676
|
+
kind: "component",
|
|
2677
|
+
type: i6.MatIcon,
|
|
2678
|
+
selector: "mat-icon",
|
|
2679
|
+
inputs: [
|
|
2680
|
+
"color",
|
|
2681
|
+
"inline",
|
|
2682
|
+
"svgIcon",
|
|
2683
|
+
"fontSet",
|
|
2684
|
+
"fontIcon"
|
|
2685
|
+
],
|
|
2686
|
+
exportAs: ["matIcon"]
|
|
2687
|
+
},
|
|
2688
|
+
{
|
|
2689
|
+
kind: "ngmodule",
|
|
2690
|
+
type: MatProgressBarModule
|
|
2691
|
+
},
|
|
2692
|
+
{
|
|
2693
|
+
kind: "component",
|
|
2694
|
+
type: i3.MatProgressBar,
|
|
2695
|
+
selector: "mat-progress-bar",
|
|
2696
|
+
inputs: [
|
|
2697
|
+
"color",
|
|
2698
|
+
"value",
|
|
2699
|
+
"bufferValue",
|
|
2700
|
+
"mode"
|
|
2701
|
+
],
|
|
2702
|
+
outputs: ["animationEnd"],
|
|
2703
|
+
exportAs: ["matProgressBar"]
|
|
2704
|
+
},
|
|
2705
|
+
{
|
|
2706
|
+
kind: "directive",
|
|
2707
|
+
type: NgClass,
|
|
2708
|
+
selector: "[ngClass]",
|
|
2709
|
+
inputs: ["class", "ngClass"]
|
|
2710
|
+
},
|
|
2711
|
+
{
|
|
2712
|
+
kind: "directive",
|
|
2713
|
+
type: NgStyle,
|
|
2714
|
+
selector: "[ngStyle]",
|
|
2715
|
+
inputs: ["ngStyle"]
|
|
2716
|
+
}
|
|
2717
|
+
],
|
|
2718
|
+
changeDetection: i0.ChangeDetectionStrategy.OnPush
|
|
2719
|
+
});
|
|
2720
|
+
}
|
|
2721
|
+
};
|
|
2722
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
2723
|
+
minVersion: "12.0.0",
|
|
2724
|
+
version: "22.2.3",
|
|
2725
|
+
ngImport: i0,
|
|
2726
|
+
type: ChartRendererComponent,
|
|
2727
|
+
decorators: [{
|
|
2728
|
+
type: Component,
|
|
2729
|
+
args: [{
|
|
2730
|
+
selector: "app-chart-renderer",
|
|
2731
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
2732
|
+
imports: [
|
|
2733
|
+
MatButtonModule,
|
|
2734
|
+
MatIconModule,
|
|
2735
|
+
MatProgressBarModule,
|
|
2736
|
+
NgClass,
|
|
2737
|
+
NgStyle
|
|
2738
|
+
],
|
|
2739
|
+
template: "<div [class]=\"twClasses().join(' ')\" [ngClass]=\"{'cursor-pointer': config()?.chart?.drillDown?.enabled && !isDesignerMode(),\n 'chart-container bg-card dark:bg-transparent border':true\n }\" [title]=\"config()?.chart?.drillDown?.enabled && !isDesignerMode() ? '点击图表元素下钻' : ''\">\n <!-- 加载状态 -->\n @if (loading()) {\n <div class=\"loading-state\">\n <mat-progress-bar mode=\"indeterminate\"></mat-progress-bar>\n <p class=\"mt-2 text-sm text-secondary\">加载中...</p>\n </div>\n }\n\n <!-- 错误状态 -->\n @if (error()) {\n <div class=\"error-state\">\n <mat-icon class=\"icon-size-8 text-warn\" [svgIcon]=\"'heroicons_outline:exclamation-circle'\"></mat-icon>\n <p class=\"mt-2\">{{ error()?.message }}</p>\n <button mat-button color=\"primary\" (click)=\"refresh()\">重试</button>\n </div>\n }\n\n <!-- 空状态 -->\n @if (!loading() && !error() && (!data() || data()!.length === 0)) {\n <div class=\"empty-state\">\n <mat-icon class=\"icon-size-12 opacity-50\" [svgIcon]=\"'heroicons_outline:chart-bar'\"></mat-icon>\n <p class=\"mt-2 text-sm text-secondary\">暂无数据</p>\n </div>\n }\n\n <!-- 图表容器(始终存在于 DOM,确保 viewChild 和 ngAfterViewInit 可用) -->\n <div #chartContainer class=\"chart-canvas\"\n [ngStyle]=\"{'display': ((!loading() && !error() && data() && data()!.length > 0) ? 'block' : 'none')}\"></div>\n</div>",
|
|
2740
|
+
styles: ["@charset \"UTF-8\";.chart-container{position:relative;width:100%;height:100%;min-height:280px;padding:.5rem;border-radius:.75rem;box-shadow:0 1px 3px #0000001a;transition:all .2s ease;overflow:hidden}.chart-container:hover{box-shadow:0 4px 6px #0000001a}.chart-container:is(.dark *){-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px)}.chart-canvas{width:100%;height:100%;min-height:240px;overflow:hidden}.loading-state,.error-state,.empty-state{display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;min-height:240px;text-align:center;color:#6b7280}@media print{.chart-container{box-shadow:none!important;border:1px solid #e5e7eb!important;background-color:#fff!important;padding:1rem!important;page-break-inside:avoid;break-inside:avoid;width:100%!important;max-width:100%!important;box-sizing:border-box!important;overflow:hidden!important}.chart-canvas{min-height:200px!important;page-break-inside:avoid;break-inside:avoid;width:100%!important;max-width:100%!important;overflow:hidden!important}.chart-canvas>div{width:100%!important;max-width:100%!important;overflow:hidden!important}}\n"]
|
|
2741
|
+
}]
|
|
2742
|
+
}],
|
|
2743
|
+
ctorParameters: () => [],
|
|
2744
|
+
propDecorators: { chartContainer: [{
|
|
2745
|
+
type: i0.ViewChild,
|
|
2746
|
+
args: ["chartContainer", { isSignal: true }]
|
|
2747
|
+
}] }
|
|
2748
|
+
});
|
|
2749
|
+
export { ApiProvider, ApiProviderFactory, BaseRendererComponent, BindingResolverService, CacheManagerService, ChartRendererComponent, ComponentRegistryService, DrillDownService, MetricRendererComponent, MockProvider, MockProviderFactory, ProviderRegistryService, QueryPipelineService, REPORT_BFF_CONFIG, TableRendererComponent, TextRendererComponent };
|
|
2750
|
+
|
|
2751
|
+
//# sourceMappingURL=cmat-reports.mjs.map
|