ngx-axis-appforge 0.0.83 → 0.0.85
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/axis-components/table/index.d.ts +1 -0
- package/axis-components/table-helper/index.d.ts +26 -2
- package/axis-components/tree-selector/index.d.ts +1 -0
- package/fesm2022/ngx-axis-appforge-axis-components-table-design.mjs +16 -3
- package/fesm2022/ngx-axis-appforge-axis-components-table-design.mjs.map +1 -1
- package/fesm2022/ngx-axis-appforge-axis-components-table-helper.mjs +150 -30
- package/fesm2022/ngx-axis-appforge-axis-components-table-helper.mjs.map +1 -1
- package/fesm2022/ngx-axis-appforge-axis-components-table.mjs +18 -11
- package/fesm2022/ngx-axis-appforge-axis-components-table.mjs.map +1 -1
- package/fesm2022/ngx-axis-appforge-axis-components-tree-selector-design.mjs +3 -2
- package/fesm2022/ngx-axis-appforge-axis-components-tree-selector-design.mjs.map +1 -1
- package/fesm2022/ngx-axis-appforge-axis-components-tree-selector.mjs +20 -2
- package/fesm2022/ngx-axis-appforge-axis-components-tree-selector.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -29,7 +29,7 @@ class TableFieldDisplayService {
|
|
|
29
29
|
if (!this.fieldDisplayCache.has(field.field())) {
|
|
30
30
|
this.fieldDisplayCache.set(field.field(), new Map());
|
|
31
31
|
}
|
|
32
|
-
if (!this.fieldDisplayCache.get(field.field()).has(row[field.field()])) {
|
|
32
|
+
if (row[field.field()] === undefined || !this.fieldDisplayCache.get(field.field()).has(row[field.field()])) {
|
|
33
33
|
const child = this.scope?.snapshotOptions(field.child(), { row, loopRow });
|
|
34
34
|
let text;
|
|
35
35
|
switch (child.component) {
|
|
@@ -61,6 +61,9 @@ class TableFieldDisplayService {
|
|
|
61
61
|
text = child.text;
|
|
62
62
|
break;
|
|
63
63
|
}
|
|
64
|
+
if (row[field.field()] === undefined) {
|
|
65
|
+
return text;
|
|
66
|
+
}
|
|
64
67
|
this.fieldDisplayCache.get(field.field()).set(row[field.field()], text);
|
|
65
68
|
}
|
|
66
69
|
return this.fieldDisplayCache.get(field.field()).get(row[field.field()]);
|
|
@@ -117,6 +120,7 @@ class TableService {
|
|
|
117
120
|
}
|
|
118
121
|
ready = signal(false, ...(ngDevMode ? [{ debugName: "ready" }] : []));
|
|
119
122
|
data;
|
|
123
|
+
customExportData;
|
|
120
124
|
options;
|
|
121
125
|
fields;
|
|
122
126
|
getRow;
|
|
@@ -126,7 +130,13 @@ class TableService {
|
|
|
126
130
|
fields.sort((a, b) => (a.groupLevel() ?? 0) - (b.groupLevel() ?? 0));
|
|
127
131
|
return fields;
|
|
128
132
|
}, ...(ngDevMode ? [{ debugName: "groupAbleFields" }] : []));
|
|
133
|
+
groupAbleFieldsForExport = computed(() => {
|
|
134
|
+
const fields = this.fields().filter(f => f.groupAble() && f.export?.());
|
|
135
|
+
fields.sort((a, b) => (a.groupLevel() ?? 0) - (b.groupLevel() ?? 0));
|
|
136
|
+
return fields;
|
|
137
|
+
}, ...(ngDevMode ? [{ debugName: "groupAbleFieldsForExport" }] : []));
|
|
129
138
|
rowsGroupMap = computed(() => this.buildRowsGroupMap(), ...(ngDevMode ? [{ debugName: "rowsGroupMap" }] : []));
|
|
139
|
+
rowsGroupMapForExport = computed(() => this.buildRowsGroupMapForExport(), ...(ngDevMode ? [{ debugName: "rowsGroupMapForExport" }] : []));
|
|
130
140
|
useBackEndPaging = computed(() => this.options.showPagination() && this.options.useBackEndPaging(), ...(ngDevMode ? [{ debugName: "useBackEndPaging" }] : []));
|
|
131
141
|
rows = computed(() => this.useBackEndPaging() ? this.data()?.rows : this.data(), ...(ngDevMode ? [{ debugName: "rows" }] : []));
|
|
132
142
|
pageIndex = signal(1, ...(ngDevMode ? [{ debugName: "pageIndex" }] : []));
|
|
@@ -139,6 +149,7 @@ class TableService {
|
|
|
139
149
|
return this.fields().filter(f => f.inuse());
|
|
140
150
|
}, ...(ngDevMode ? [{ debugName: "displayFields" }] : []));
|
|
141
151
|
fieldsControlsMap = signal({}, ...(ngDevMode ? [{ debugName: "fieldsControlsMap" }] : []));
|
|
152
|
+
tableDataForExport = computed(() => this.buildTableDataForExport(), ...(ngDevMode ? [{ debugName: "tableDataForExport" }] : []));
|
|
142
153
|
tableData = signal([], ...(ngDevMode ? [{ debugName: "tableData" }] : []));
|
|
143
154
|
fieldsFilterValueMap = new Map();
|
|
144
155
|
filedsFilterItemsCache = new Map();
|
|
@@ -148,6 +159,7 @@ class TableService {
|
|
|
148
159
|
pageCursorMarkIndexs = [];
|
|
149
160
|
init(opts) {
|
|
150
161
|
this.data = opts.data;
|
|
162
|
+
this.customExportData = opts.customExportData;
|
|
151
163
|
this.options = opts.options;
|
|
152
164
|
this.fields = opts.fields;
|
|
153
165
|
this.getRow = opts.getRow;
|
|
@@ -155,6 +167,58 @@ class TableService {
|
|
|
155
167
|
this.ready.set(true);
|
|
156
168
|
this.refreshTableData();
|
|
157
169
|
}
|
|
170
|
+
buildTableDataForExport() {
|
|
171
|
+
const data = [...(this.customExportData?.() ?? this.tableData())];
|
|
172
|
+
const sortFields = this.fields().filter(f => f.export?.() && this.fieldSortAble(f) && f.sortOrder() != null);
|
|
173
|
+
if (sortFields.length) {
|
|
174
|
+
sortFields.sort((a, b) => {
|
|
175
|
+
let ap = this.fieldSortPriority(a, this.groupAbleFieldsForExport());
|
|
176
|
+
let bp = this.fieldSortPriority(b, this.groupAbleFieldsForExport());
|
|
177
|
+
if (ap === bp) {
|
|
178
|
+
return 0;
|
|
179
|
+
}
|
|
180
|
+
if (ap === false) {
|
|
181
|
+
return 1;
|
|
182
|
+
}
|
|
183
|
+
else if (bp === false) {
|
|
184
|
+
return -1;
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
return bp - ap;
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
data.sort((a, b) => {
|
|
191
|
+
for (const f of sortFields) {
|
|
192
|
+
let sortFn = this.fieldsControlsMap()[f.field()]?.sortFn;
|
|
193
|
+
if (typeof sortFn != "function") {
|
|
194
|
+
sortFn = (a, b) => {
|
|
195
|
+
const va = a[f.field()];
|
|
196
|
+
const vb = b[f.field()];
|
|
197
|
+
const ta = typeof va;
|
|
198
|
+
const tb = typeof vb;
|
|
199
|
+
if (ta == tb) {
|
|
200
|
+
if (ta == "number") {
|
|
201
|
+
return va - vb;
|
|
202
|
+
}
|
|
203
|
+
else {
|
|
204
|
+
return va.localeCompare(vb);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
else if (ta == "number") {
|
|
208
|
+
return -1;
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
const res = sortFn(a, b);
|
|
213
|
+
if (res != 0) {
|
|
214
|
+
return res * (f.sortOrder() == "descend" ? -1 : 1);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
return 0;
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
return data;
|
|
221
|
+
}
|
|
158
222
|
refreshTableData() {
|
|
159
223
|
let data = [...(this.rows() ?? [])];
|
|
160
224
|
if (!this.useBackEndPaging()) {
|
|
@@ -210,13 +274,20 @@ class TableService {
|
|
|
210
274
|
this.tableData.set(data);
|
|
211
275
|
}
|
|
212
276
|
buildRowsGroupMap() {
|
|
277
|
+
return this._buildRowsGroupMap(this.tableData(), this.useBackEndPaging());
|
|
278
|
+
}
|
|
279
|
+
buildRowsGroupMapForExport() {
|
|
280
|
+
return this._buildRowsGroupMap(this.tableDataForExport(), false, this.groupAbleFieldsForExport());
|
|
281
|
+
}
|
|
282
|
+
_buildRowsGroupMap(data, useBackEndPaging = false, groupAbleFields) {
|
|
213
283
|
const rowsGroupMap = new Map();
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
284
|
+
groupAbleFields ??= this.groupAbleFields();
|
|
285
|
+
if (!useBackEndPaging) {
|
|
286
|
+
if (groupAbleFields.length > 0) {
|
|
287
|
+
for (let i = 0; i < data.length; i++) {
|
|
217
288
|
let valuePerfix = "";
|
|
218
|
-
const row =
|
|
219
|
-
for (const field of
|
|
289
|
+
const row = data[i];
|
|
290
|
+
for (const field of groupAbleFields) {
|
|
220
291
|
if (!rowsGroupMap.has(field.field())) {
|
|
221
292
|
rowsGroupMap.set(field.field(), new Map());
|
|
222
293
|
}
|
|
@@ -234,11 +305,13 @@ class TableService {
|
|
|
234
305
|
}
|
|
235
306
|
}
|
|
236
307
|
}
|
|
237
|
-
|
|
238
|
-
for (
|
|
239
|
-
|
|
240
|
-
|
|
308
|
+
else {
|
|
309
|
+
for (const field in data.group_result ?? {}) {
|
|
310
|
+
const groups = new Map();
|
|
311
|
+
for (const value in data.group_result[field]) {
|
|
312
|
+
groups.set(value, data.group_result[field][value]);
|
|
241
313
|
}
|
|
314
|
+
rowsGroupMap.set(field, groups);
|
|
242
315
|
}
|
|
243
316
|
}
|
|
244
317
|
return rowsGroupMap;
|
|
@@ -249,14 +322,15 @@ class TableService {
|
|
|
249
322
|
fieldSortDirections(f) {
|
|
250
323
|
return f.groupAble() ? ['ascend', 'descend'] : ['ascend', 'descend', null];
|
|
251
324
|
}
|
|
252
|
-
fieldSortPriority(f) {
|
|
325
|
+
fieldSortPriority(f, groupAbleFields) {
|
|
253
326
|
if (f.groupAble()) {
|
|
254
|
-
return (f.groupLevel() ?? 0);
|
|
327
|
+
return (f.groupLevel() ?? 0) * -1;
|
|
255
328
|
}
|
|
329
|
+
groupAbleFields ??= this.groupAbleFields();
|
|
256
330
|
if (f.sortAble()) {
|
|
257
331
|
let p = 0;
|
|
258
|
-
if (
|
|
259
|
-
p =
|
|
332
|
+
if (groupAbleFields.length) {
|
|
333
|
+
p = groupAbleFields[groupAbleFields.length - 1].groupLevel() ?? 0;
|
|
260
334
|
p *= -1;
|
|
261
335
|
}
|
|
262
336
|
return (p - 1 + (f.sortPriority() ?? 0));
|
|
@@ -266,6 +340,9 @@ class TableService {
|
|
|
266
340
|
getGroupValue(row) {
|
|
267
341
|
return row[this.groupAbleFields()[0].field()];
|
|
268
342
|
}
|
|
343
|
+
getGroupValueForExport(row) {
|
|
344
|
+
return row[this.groupAbleFieldsForExport()[0].field()];
|
|
345
|
+
}
|
|
269
346
|
isGroupEnd(index, row) {
|
|
270
347
|
const topGroupField = this.groupAbleFields()[0];
|
|
271
348
|
if (!topGroupField) {
|
|
@@ -277,6 +354,17 @@ class TableService {
|
|
|
277
354
|
}
|
|
278
355
|
return false;
|
|
279
356
|
}
|
|
357
|
+
isGroupEndForExport(index, row) {
|
|
358
|
+
const topGroupField = this.groupAbleFieldsForExport()[0];
|
|
359
|
+
if (!topGroupField) {
|
|
360
|
+
return false;
|
|
361
|
+
}
|
|
362
|
+
const indexs = this.rowsGroupMapForExport().get(topGroupField.field())?.get(row[topGroupField.field()]?.toString());
|
|
363
|
+
if (indexs) {
|
|
364
|
+
return indexs[indexs.length - 1] == index;
|
|
365
|
+
}
|
|
366
|
+
return false;
|
|
367
|
+
}
|
|
280
368
|
rowspan(f, index, pageIndex, pageSize, row) {
|
|
281
369
|
if (f.groupAble()) {
|
|
282
370
|
const value = this.groupAbleFields().slice(0, this.groupAbleFields().findIndex(_f => _f.field() == f.field()) + 1).map(_f => row[_f.field()]).join("@");
|
|
@@ -462,13 +550,16 @@ class TableService {
|
|
|
462
550
|
this.pageCursorMarks.clear();
|
|
463
551
|
}
|
|
464
552
|
get backEndPageParams() {
|
|
553
|
+
const sortFields = this.displayFields().filter(f => this.fieldSortAble(f) && f.sortOrder() != null);
|
|
554
|
+
sortFields.sort((a, b) => this.fieldSortPriority(b) - this.fieldSortPriority(a));
|
|
465
555
|
return {
|
|
466
556
|
use_page: true,
|
|
467
557
|
page_index: this.pageIndex() - 1,
|
|
468
558
|
page_size: this.options.pageSize(),
|
|
469
559
|
query_total: !this.hasTotal,
|
|
470
560
|
cursor_mark: this.getNearestCursorMark(),
|
|
471
|
-
|
|
561
|
+
group_fields: this.groupAbleFields().map(f => f.field()),
|
|
562
|
+
order_by: sortFields.map(f => ({
|
|
472
563
|
column: f.field(),
|
|
473
564
|
desc_order: f.sortOrder() == "descend"
|
|
474
565
|
}))
|
|
@@ -759,9 +850,12 @@ class StatisticService {
|
|
|
759
850
|
fields;
|
|
760
851
|
getRow;
|
|
761
852
|
tableSvc;
|
|
853
|
+
useBackEndPaging = computed(() => this.options.showPagination() && this.options.useBackEndPaging(), ...(ngDevMode ? [{ debugName: "useBackEndPaging" }] : []));
|
|
762
854
|
hasStatistic = false;
|
|
763
855
|
statisticMap = computed(() => this.buildStatisticMap(), ...(ngDevMode ? [{ debugName: "statisticMap" }] : []));
|
|
856
|
+
statisticMapForExport = computed(() => this.buildStatisticMapForExport(), ...(ngDevMode ? [{ debugName: "statisticMapForExport" }] : []));
|
|
764
857
|
statisticGroupMap = computed(() => this.buildStatisticGroupMap(), ...(ngDevMode ? [{ debugName: "statisticGroupMap" }] : []));
|
|
858
|
+
statisticGroupMapForExport = computed(() => this.buildStatisticGroupMapForExport(), ...(ngDevMode ? [{ debugName: "statisticGroupMapForExport" }] : []));
|
|
765
859
|
init(opts) {
|
|
766
860
|
this.options = opts.options;
|
|
767
861
|
this.data = opts.data;
|
|
@@ -771,36 +865,62 @@ class StatisticService {
|
|
|
771
865
|
this.ready.set(true);
|
|
772
866
|
}
|
|
773
867
|
buildStatisticMap() {
|
|
868
|
+
return this._buildStatisticMap(this.data());
|
|
869
|
+
}
|
|
870
|
+
buildStatisticMapForExport() {
|
|
871
|
+
return this._buildStatisticMap(this.tableSvc?.customExportData?.() ?? this.data());
|
|
872
|
+
}
|
|
873
|
+
_buildStatisticMap(data) {
|
|
774
874
|
if (!this.ready()) {
|
|
775
875
|
return {};
|
|
776
876
|
}
|
|
777
877
|
let res = {};
|
|
778
|
-
if (this.options.showStatistic() &&
|
|
779
|
-
if (this.
|
|
780
|
-
res =
|
|
878
|
+
if (this.options.showStatistic() && data) {
|
|
879
|
+
if (this.useBackEndPaging()) {
|
|
880
|
+
res = data.statistic_result;
|
|
781
881
|
}
|
|
782
882
|
else {
|
|
783
|
-
res = this.statisticCompute(
|
|
883
|
+
res = this.statisticCompute(data);
|
|
784
884
|
}
|
|
785
885
|
}
|
|
786
|
-
return res;
|
|
886
|
+
return res ?? {};
|
|
787
887
|
}
|
|
788
888
|
buildStatisticGroupMap() {
|
|
889
|
+
if (!this.ready() || !this.tableSvc) {
|
|
890
|
+
return {};
|
|
891
|
+
}
|
|
892
|
+
return this._buildStatisticGroupMap(this.tableSvc.tableData(), this.useBackEndPaging());
|
|
893
|
+
}
|
|
894
|
+
buildStatisticGroupMapForExport() {
|
|
895
|
+
if (!this.ready() || !this.tableSvc) {
|
|
896
|
+
return {};
|
|
897
|
+
}
|
|
898
|
+
return this._buildStatisticGroupMap(this.tableSvc.tableDataForExport(), false, this.tableSvc.groupAbleFieldsForExport(), this.tableSvc.rowsGroupMapForExport());
|
|
899
|
+
}
|
|
900
|
+
_buildStatisticGroupMap(data, useBackEndPaging = false, groupAbleFields, rowsGroupMap) {
|
|
789
901
|
if (!this.ready() || !this.tableSvc) {
|
|
790
902
|
return {};
|
|
791
903
|
}
|
|
792
904
|
let res = {};
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
res = this.data().statistic_result;
|
|
905
|
+
if (useBackEndPaging) {
|
|
906
|
+
if (data?.query_statistic_group) {
|
|
907
|
+
res = data.statistic_group_result ?? {};
|
|
797
908
|
}
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
909
|
+
}
|
|
910
|
+
else {
|
|
911
|
+
groupAbleFields ??= this.tableSvc.groupAbleFields();
|
|
912
|
+
const groupField = groupAbleFields[0];
|
|
913
|
+
if (this.options.showStatistic() && groupField) {
|
|
914
|
+
if (useBackEndPaging) {
|
|
915
|
+
res = data.statistic_result;
|
|
916
|
+
}
|
|
917
|
+
else {
|
|
918
|
+
rowsGroupMap ??= this.tableSvc.rowsGroupMap();
|
|
919
|
+
const group = rowsGroupMap.get(groupField.field());
|
|
920
|
+
if (group) {
|
|
921
|
+
for (const [value, indexs] of group) {
|
|
922
|
+
res[value] = this.statisticCompute(indexs.map(index => data[index]));
|
|
923
|
+
}
|
|
804
924
|
}
|
|
805
925
|
}
|
|
806
926
|
}
|