aldehyde 0.2.122 → 0.2.124
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/lib/form/criteria-form.js +1 -1
- package/lib/form/criteria-form.js.map +1 -1
- package/lib/locale/LocaleProvider.d.ts.map +1 -1
- package/lib/locale/LocaleProvider.js +1 -1
- package/lib/locale/LocaleProvider.js.map +1 -1
- package/lib/table/act-table.d.ts.map +1 -1
- package/lib/table/act-table.js +11 -1
- package/lib/table/act-table.js.map +1 -1
- package/lib/table/index.css +39 -23
- package/lib/table/query-table.d.ts +24 -0
- package/lib/table/query-table.d.ts.map +1 -1
- package/lib/table/query-table.js +371 -10
- package/lib/table/query-table.js.map +1 -1
- package/lib/tmpl/hcservice-v3.d.ts.map +1 -1
- package/lib/tmpl/hcservice-v3.js +4 -0
- package/lib/tmpl/hcservice-v3.js.map +1 -1
- package/lib/tmpl/interface.d.ts +7 -0
- package/lib/tmpl/interface.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/aldehyde/form/criteria-form.tsx +1 -1
- package/src/aldehyde/locale/LocaleProvider.tsx +3 -1
- package/src/aldehyde/table/act-table.tsx +14 -0
- package/src/aldehyde/table/index.css +39 -23
- package/src/aldehyde/table/query-table.tsx +492 -8
- package/src/aldehyde/tmpl/hcservice-v3.tsx +6 -0
- package/src/aldehyde/tmpl/interface.tsx +3 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from "react";
|
|
1
|
+
import React, { Children } from "react";
|
|
2
2
|
import { Card, Collapse, Descriptions, List } from "antd";
|
|
3
3
|
import Table from "./control-table-x-axis-wrapper";
|
|
4
4
|
import "./index.css";
|
|
@@ -53,6 +53,8 @@ interface QueryTableProps {
|
|
|
53
53
|
viewModel?: string;
|
|
54
54
|
columnConfigs?: FieldConfig[];
|
|
55
55
|
summaryConfigs?: { id: string; aggFunc: "sum" | "avg" }[];
|
|
56
|
+
subtotalXColumn?: { id: string }[];
|
|
57
|
+
subtotalYColumn?: { id: string }[];
|
|
56
58
|
}
|
|
57
59
|
|
|
58
60
|
interface QueryTableStat {
|
|
@@ -74,6 +76,7 @@ class QueryTable extends React.PureComponent<QueryTableProps, QueryTableStat> {
|
|
|
74
76
|
hiddenRowCodes: [],
|
|
75
77
|
selectedRows: [],
|
|
76
78
|
viewModels: ["table"],
|
|
79
|
+
summaryConfigs: [],
|
|
77
80
|
};
|
|
78
81
|
|
|
79
82
|
state = {
|
|
@@ -350,24 +353,505 @@ class QueryTable extends React.PureComponent<QueryTableProps, QueryTableStat> {
|
|
|
350
353
|
return Number(value[0].split("@R@")[1]);
|
|
351
354
|
}
|
|
352
355
|
|
|
356
|
+
deepClone(source, hash = new WeakMap()) {
|
|
357
|
+
if (typeof source !== "object" || source === null) {
|
|
358
|
+
return source;
|
|
359
|
+
}
|
|
360
|
+
if (hash.has(source)) {
|
|
361
|
+
return hash.get(source);
|
|
362
|
+
}
|
|
363
|
+
const target = Array.isArray(source) ? [] : {};
|
|
364
|
+
Reflect.ownKeys(source).forEach((key) => {
|
|
365
|
+
const val = source[key];
|
|
366
|
+
if (typeof val === "object" && val != null) {
|
|
367
|
+
target[key] = this.deepClone(val, hash);
|
|
368
|
+
} else {
|
|
369
|
+
target[key] = val;
|
|
370
|
+
}
|
|
371
|
+
});
|
|
372
|
+
return target;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
buildKeys(keys: { title: string; dataKey: string }[]) {
|
|
376
|
+
return keys.map((i) => i.title).join("-");
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
buildColTag(cols, keys = []) {
|
|
380
|
+
for (const col of cols) {
|
|
381
|
+
if (!col.children) {
|
|
382
|
+
// if (col.dataIndex === undefined)
|
|
383
|
+
col.dataIndex = this.buildKeys([
|
|
384
|
+
...keys,
|
|
385
|
+
{ dataKey: col._type ? col._type : col.title, title: col.title },
|
|
386
|
+
]);
|
|
387
|
+
if (col.keys === undefined)
|
|
388
|
+
col.keys = [
|
|
389
|
+
...keys,
|
|
390
|
+
{ dataKey: col._type ? col._type : col.title, title: col.title },
|
|
391
|
+
];
|
|
392
|
+
} else {
|
|
393
|
+
this.buildColTag(col.children, [
|
|
394
|
+
...keys,
|
|
395
|
+
{ dataKey: col._type ? col._type : col.title, title: col.title },
|
|
396
|
+
]);
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
getCurCalKeys(cols, keys = []) {
|
|
402
|
+
for (const col of cols) {
|
|
403
|
+
if (Array.isArray(col.children)) {
|
|
404
|
+
this.getCurCalKeys(col.children, keys);
|
|
405
|
+
} else {
|
|
406
|
+
keys.push({
|
|
407
|
+
factIndex: col.keys[col.keys.length - 1],
|
|
408
|
+
dataIndex: col.dataIndex,
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
return keys;
|
|
414
|
+
}
|
|
415
|
+
setSumColKeys(sumCol, sumKeys) {
|
|
416
|
+
if (sumKeys.length === 0) return;
|
|
417
|
+
if (Array.isArray(sumCol.children)) {
|
|
418
|
+
this.setSumColKeys(sumCol.children, sumKeys);
|
|
419
|
+
} else {
|
|
420
|
+
for (const col of sumCol) {
|
|
421
|
+
const factKey = col.keys[col.keys.length - 1].dataKey;
|
|
422
|
+
col.sumDataIndex = sumKeys.filter(
|
|
423
|
+
({ factIndex: { dataKey } }) => dataKey === factKey
|
|
424
|
+
);
|
|
425
|
+
col.keys[col.keys.length - 1].sumDataIndex = col.sumDataIndex.map(
|
|
426
|
+
({ dataIndex }) => dataIndex
|
|
427
|
+
);
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
handleProSummaryTable(data: any[]) {
|
|
433
|
+
const isProSumarryTable = Boolean(
|
|
434
|
+
this.props.subtotalXColumn || this.props.subtotalYColumn
|
|
435
|
+
);
|
|
436
|
+
if (!isProSumarryTable)
|
|
437
|
+
return { proSummaryTableColumns: [], proSummaryTableData: [] };
|
|
438
|
+
|
|
439
|
+
const { translate } = this.context;
|
|
440
|
+
|
|
441
|
+
const { subtotalXColumn, subtotalYColumn, columns: _columns } = this.props;
|
|
442
|
+
const columns = _columns;
|
|
443
|
+
for (const d of data) {
|
|
444
|
+
for (const [k, v] of Object.entries(d)) {
|
|
445
|
+
if (typeof v === "string" && (v as string)?.includes("@R@"))
|
|
446
|
+
d[k] = (v as string).split("@R@")[1];
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
console.log("data", data);
|
|
451
|
+
console.log("columns", columns);
|
|
452
|
+
|
|
453
|
+
const colMp = { dimension: [], fact: [] };
|
|
454
|
+
const colIdToNameMp = {};
|
|
455
|
+
const colNameToIdMp = {};
|
|
456
|
+
for (const col of columns) {
|
|
457
|
+
colIdToNameMp[col["dataIndex"]] = col["title"];
|
|
458
|
+
colNameToIdMp[col["title"]] = col["dataIndex"];
|
|
459
|
+
if (col.statColType !== undefined)
|
|
460
|
+
colMp[col.statColType].push(JSON.parse(JSON.stringify(col)));
|
|
461
|
+
}
|
|
462
|
+
console.log("colIdToNameMp", colIdToNameMp);
|
|
463
|
+
console.log("colNameToIdMp", colNameToIdMp);
|
|
464
|
+
console.log("colMp", colMp);
|
|
465
|
+
|
|
466
|
+
// canReadData
|
|
467
|
+
const canReadData = [];
|
|
468
|
+
for (const d of data) {
|
|
469
|
+
const item = {};
|
|
470
|
+
for (const [k, v] of Object.entries(d)) {
|
|
471
|
+
item[colIdToNameMp[k]] = v;
|
|
472
|
+
}
|
|
473
|
+
canReadData.push(item);
|
|
474
|
+
}
|
|
475
|
+
console.log("canReadData", canReadData);
|
|
476
|
+
|
|
477
|
+
let proSummaryTableColumns = [
|
|
478
|
+
...JSON.parse(JSON.stringify(colMp.dimension)),
|
|
479
|
+
],
|
|
480
|
+
proSummaryTableData = [];
|
|
481
|
+
|
|
482
|
+
const cal = colMp.fact[0]?.cal;
|
|
483
|
+
const calTxt = cal === "sum" ? translate("合计") : translate("均值");
|
|
484
|
+
|
|
485
|
+
// 计算列
|
|
486
|
+
if (
|
|
487
|
+
subtotalYColumn &&
|
|
488
|
+
Array.isArray(subtotalYColumn) &&
|
|
489
|
+
subtotalYColumn.length
|
|
490
|
+
) {
|
|
491
|
+
// col
|
|
492
|
+
let tnodes = [];
|
|
493
|
+
|
|
494
|
+
for (let i = 0; i < subtotalYColumn.length; i++) {
|
|
495
|
+
const y = subtotalYColumn[i];
|
|
496
|
+
const id = y.id;
|
|
497
|
+
const mp = {};
|
|
498
|
+
let _tnodes = [];
|
|
499
|
+
for (const d of data) mp[d[id]] = colIdToNameMp[id];
|
|
500
|
+
for (const [k, v] of Object.entries(mp)) {
|
|
501
|
+
const tnode = {
|
|
502
|
+
title: k,
|
|
503
|
+
_type: v,
|
|
504
|
+
children: [
|
|
505
|
+
...JSON.parse(JSON.stringify(i === 0 ? colMp.fact : tnodes)),
|
|
506
|
+
],
|
|
507
|
+
};
|
|
508
|
+
_tnodes.push(tnode);
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
this.buildColTag(_tnodes);
|
|
512
|
+
console.log("_tnodes", JSON.parse(JSON.stringify(_tnodes)));
|
|
513
|
+
|
|
514
|
+
const sumCol = {
|
|
515
|
+
title: calTxt,
|
|
516
|
+
children: [...JSON.parse(JSON.stringify(colMp.fact))],
|
|
517
|
+
TYPE: cal,
|
|
518
|
+
};
|
|
519
|
+
this.buildColTag([sumCol]);
|
|
520
|
+
this.setSumColKeys(sumCol, this.getCurCalKeys(_tnodes));
|
|
521
|
+
_tnodes.unshift(sumCol);
|
|
522
|
+
|
|
523
|
+
tnodes = _tnodes;
|
|
524
|
+
proSummaryTableColumns.splice(
|
|
525
|
+
proSummaryTableColumns.findIndex((item) => item.dataIndex === id),
|
|
526
|
+
1
|
|
527
|
+
);
|
|
528
|
+
}
|
|
529
|
+
proSummaryTableColumns.push(...tnodes);
|
|
530
|
+
} else {
|
|
531
|
+
proSummaryTableColumns.push(...colMp.fact);
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
// buildData
|
|
535
|
+
this.buildColTag(proSummaryTableColumns);
|
|
536
|
+
|
|
537
|
+
// 处理行
|
|
538
|
+
const rowMp = {};
|
|
539
|
+
const rowKey = [];
|
|
540
|
+
for (const col of proSummaryTableColumns) {
|
|
541
|
+
if (Array.isArray(col.keys) && col.keys.length === 1) rowKey.push(col);
|
|
542
|
+
}
|
|
543
|
+
console.log("rowKey", rowKey);
|
|
544
|
+
|
|
545
|
+
for (const d of canReadData) {
|
|
546
|
+
let t: any = rowMp;
|
|
547
|
+
for (let i = 0; i < rowKey.length; i++) {
|
|
548
|
+
const key = rowKey[i].title;
|
|
549
|
+
if (t[d[key]] === undefined) {
|
|
550
|
+
if (i !== rowKey.length - 1) t[d[key]] = {};
|
|
551
|
+
else t[d[key]] = [];
|
|
552
|
+
}
|
|
553
|
+
t = t[d[key]];
|
|
554
|
+
}
|
|
555
|
+
if (Array.isArray(t)) t.push(d);
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
// 行数据处理完毕
|
|
559
|
+
console.log("rowMp", rowMp);
|
|
560
|
+
|
|
561
|
+
// 处理列
|
|
562
|
+
const colKey = [];
|
|
563
|
+
const colKeyTitle = this.flatSummaryCol(proSummaryTableColumns);
|
|
564
|
+
for (const col of proSummaryTableColumns) {
|
|
565
|
+
if (Array.isArray(col.children) && col.TYPE === undefined) {
|
|
566
|
+
colKey.push(col);
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
const flatSummaryColTitle = this.flatSummaryCol(colKey);
|
|
570
|
+
const flatSummaryRowTitle = this.flatSummaryCol(rowKey);
|
|
571
|
+
const flatSummaryCalTitle = this.flatSummaryCol(
|
|
572
|
+
proSummaryTableColumns.filter(({ TYPE }) => TYPE !== undefined)
|
|
573
|
+
);
|
|
574
|
+
console.log("colKey", colKey);
|
|
575
|
+
console.log("colKeyTitle", colKeyTitle);
|
|
576
|
+
console.log("flatSummaryColTitle", flatSummaryColTitle);
|
|
577
|
+
console.log("flatSummaryRowTitle", flatSummaryRowTitle);
|
|
578
|
+
console.log("flatSummaryCalTitle", flatSummaryCalTitle);
|
|
579
|
+
|
|
580
|
+
proSummaryTableData = this.handleColData(
|
|
581
|
+
rowMp,
|
|
582
|
+
flatSummaryRowTitle,
|
|
583
|
+
flatSummaryColTitle,
|
|
584
|
+
flatSummaryCalTitle,
|
|
585
|
+
cal
|
|
586
|
+
);
|
|
587
|
+
|
|
588
|
+
if (
|
|
589
|
+
subtotalXColumn &&
|
|
590
|
+
Array.isArray(subtotalXColumn) &&
|
|
591
|
+
subtotalXColumn.length
|
|
592
|
+
) {
|
|
593
|
+
const sortKeys = subtotalXColumn.map(({ id }) => colIdToNameMp[id]);
|
|
594
|
+
|
|
595
|
+
const rowSumMp = this.buildRowMp(proSummaryTableData, sortKeys);
|
|
596
|
+
console.log("rowSumMp", rowSumMp);
|
|
597
|
+
|
|
598
|
+
const calRowKeys = [
|
|
599
|
+
...flatSummaryCalTitle,
|
|
600
|
+
...flatSummaryColTitle,
|
|
601
|
+
].map((i) => this.buildKeys(i));
|
|
602
|
+
console.log("calRowKeys", calRowKeys);
|
|
603
|
+
|
|
604
|
+
proSummaryTableData = this.handleRowData(
|
|
605
|
+
rowSumMp,
|
|
606
|
+
calRowKeys,
|
|
607
|
+
cal,
|
|
608
|
+
calTxt,
|
|
609
|
+
sortKeys[0]
|
|
610
|
+
);
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
// 做总计
|
|
614
|
+
if (
|
|
615
|
+
this.props.summaryConfigs &&
|
|
616
|
+
this.props.summaryConfigs?.length !== 0 &&
|
|
617
|
+
flatSummaryRowTitle.length
|
|
618
|
+
) {
|
|
619
|
+
const calkeys = [
|
|
620
|
+
...flatSummaryCalTitle,
|
|
621
|
+
...flatSummaryColTitle,
|
|
622
|
+
].map((i) => this.buildKeys(i));
|
|
623
|
+
|
|
624
|
+
const sumData = {
|
|
625
|
+
[flatSummaryRowTitle[0][0]?.dataKey]: calTxt,
|
|
626
|
+
_type: cal,
|
|
627
|
+
_calRange: "all",
|
|
628
|
+
};
|
|
629
|
+
|
|
630
|
+
for (const key of calkeys) {
|
|
631
|
+
if (cal === "sum")
|
|
632
|
+
sumData[key] = proSummaryTableData.reduce(
|
|
633
|
+
(last, d) => last.plus(BigNumber(d[key])),
|
|
634
|
+
BigNumber(0)
|
|
635
|
+
);
|
|
636
|
+
if (cal === "avg")
|
|
637
|
+
sumData[key] = proSummaryTableData.reduce(
|
|
638
|
+
(last, d) =>
|
|
639
|
+
last.plus(BigNumber(d[key]).div(proSummaryTableData.length)),
|
|
640
|
+
BigNumber(0)
|
|
641
|
+
);
|
|
642
|
+
sumData[key] = sumData[key]?.toString();
|
|
643
|
+
}
|
|
644
|
+
proSummaryTableData.push(sumData);
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
// 给小计和总计染色
|
|
648
|
+
this.stain(proSummaryTableColumns);
|
|
649
|
+
|
|
650
|
+
console.log("proSummaryTableColumns", proSummaryTableColumns);
|
|
651
|
+
console.log("proSummaryTableData", proSummaryTableData);
|
|
652
|
+
|
|
653
|
+
return { proSummaryTableColumns, proSummaryTableData };
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
flatSummaryCol(arr, res = []) {
|
|
657
|
+
for (const i of arr) {
|
|
658
|
+
if (!i.children) res.push(i.keys);
|
|
659
|
+
else this.flatSummaryCol(i.children, res);
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
return res;
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
handleColData(
|
|
666
|
+
rowMp,
|
|
667
|
+
flatSummaryRowTitle,
|
|
668
|
+
flatSummaryColTitle,
|
|
669
|
+
flatSummaryCalTitle,
|
|
670
|
+
cal,
|
|
671
|
+
idx = 0,
|
|
672
|
+
data = {},
|
|
673
|
+
list = []
|
|
674
|
+
) {
|
|
675
|
+
if (Array.isArray(rowMp)) {
|
|
676
|
+
for (const col of flatSummaryColTitle) {
|
|
677
|
+
const key = this.buildKeys(col);
|
|
678
|
+
const colTarget = [];
|
|
679
|
+
const preConditions = col.slice(0, col.length - 1);
|
|
680
|
+
const targetKey = col.slice(col.length - 1)[0].title;
|
|
681
|
+
for (const d of rowMp) {
|
|
682
|
+
if (
|
|
683
|
+
preConditions.every(({ dataKey, title }) => d[dataKey] === title)
|
|
684
|
+
) {
|
|
685
|
+
colTarget.push(d);
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
if (data[key] === undefined) data[key] = BigNumber(0);
|
|
690
|
+
if (cal === "sum")
|
|
691
|
+
data[key] = colTarget.reduce(
|
|
692
|
+
(last, d) => last.plus(BigNumber(d[targetKey])),
|
|
693
|
+
BigNumber(0)
|
|
694
|
+
);
|
|
695
|
+
if (cal === "avg")
|
|
696
|
+
data[key] = colTarget.reduce(
|
|
697
|
+
(last, d) =>
|
|
698
|
+
last.plus(BigNumber(d[targetKey]).div(colTarget.length)),
|
|
699
|
+
BigNumber(0)
|
|
700
|
+
);
|
|
701
|
+
data[key] = data[key]?.toString();
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
for (const calCol of flatSummaryCalTitle) {
|
|
705
|
+
const key = this.buildKeys(calCol);
|
|
706
|
+
const sumDataIndex = calCol[calCol.length - 1].sumDataIndex;
|
|
707
|
+
|
|
708
|
+
if (data[key] === undefined) data[key] = BigNumber(0);
|
|
709
|
+
if (cal === "sum")
|
|
710
|
+
data[key] = sumDataIndex.reduce(
|
|
711
|
+
(last, dataKey) => last.plus(BigNumber(data[dataKey])),
|
|
712
|
+
BigNumber(0)
|
|
713
|
+
);
|
|
714
|
+
if (cal === "avg")
|
|
715
|
+
data[key] = sumDataIndex.reduce(
|
|
716
|
+
(last, dataKey) =>
|
|
717
|
+
last.plus(BigNumber(data[dataKey]).div(sumDataIndex.length)),
|
|
718
|
+
BigNumber(0)
|
|
719
|
+
);
|
|
720
|
+
data[key] = data[key]?.toString();
|
|
721
|
+
}
|
|
722
|
+
list.push(data);
|
|
723
|
+
} else {
|
|
724
|
+
for (const [k, v] of Object.entries(rowMp)) {
|
|
725
|
+
const dataKey = flatSummaryRowTitle[idx][0].dataKey;
|
|
726
|
+
data[dataKey] = k;
|
|
727
|
+
this.handleColData(
|
|
728
|
+
v,
|
|
729
|
+
flatSummaryRowTitle,
|
|
730
|
+
flatSummaryColTitle,
|
|
731
|
+
flatSummaryCalTitle,
|
|
732
|
+
cal,
|
|
733
|
+
idx + 1,
|
|
734
|
+
JSON.parse(JSON.stringify(data)),
|
|
735
|
+
list
|
|
736
|
+
);
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
return list;
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
buildRowMp(data, sortKeys, idx = 0, mp = {}) {
|
|
744
|
+
if (idx >= sortKeys.length) return data;
|
|
745
|
+
|
|
746
|
+
const dataKey = sortKeys[idx];
|
|
747
|
+
|
|
748
|
+
for (const d of data) {
|
|
749
|
+
if (mp[d[dataKey]] === undefined) mp[d[dataKey]] = [];
|
|
750
|
+
mp[d[dataKey]].push(d);
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
for (const [k, v] of Object.entries(mp)) {
|
|
754
|
+
mp[k] = this.buildRowMp(v, sortKeys, idx + 1);
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
return mp;
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
handleRowData(data, calKeys, cal, calTxt, calTxtKey, res = []) {
|
|
761
|
+
for (const [k, v] of Object.entries(data)) {
|
|
762
|
+
if (Array.isArray(v)) {
|
|
763
|
+
const sumData = {
|
|
764
|
+
[calTxtKey]: calTxt,
|
|
765
|
+
_type: cal,
|
|
766
|
+
_calRange: "small",
|
|
767
|
+
};
|
|
768
|
+
for (const calKey of calKeys) {
|
|
769
|
+
if (cal === "sum")
|
|
770
|
+
sumData[calKey] = v.reduce(
|
|
771
|
+
(last, d) => last.plus(BigNumber(d[calKey])),
|
|
772
|
+
BigNumber(0)
|
|
773
|
+
);
|
|
774
|
+
if (cal === "avg")
|
|
775
|
+
sumData[calKey] = v.reduce(
|
|
776
|
+
(last, d) => last.plus(BigNumber(d[calKey]).div(v.length)),
|
|
777
|
+
BigNumber(0)
|
|
778
|
+
);
|
|
779
|
+
sumData[calKey] = sumData[calKey]?.toString();
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
res.push(...v, sumData);
|
|
783
|
+
} else {
|
|
784
|
+
this.handleRowData(v, calKeys, cal, calTxt, calTxtKey, res);
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
return res;
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
stain(cols) {
|
|
792
|
+
for (const col of cols) {
|
|
793
|
+
if (Array.isArray(col.children)) {
|
|
794
|
+
this.stain(col.children);
|
|
795
|
+
} else {
|
|
796
|
+
col.render = function(text, record, index) {
|
|
797
|
+
let className = "";
|
|
798
|
+
if (record._type !== undefined) {
|
|
799
|
+
if (record._calRange === "small") className = "xiaoji";
|
|
800
|
+
else className = "zongji";
|
|
801
|
+
}
|
|
802
|
+
return <div className={className}>{text}</div>;
|
|
803
|
+
};
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
|
|
353
808
|
render() {
|
|
354
|
-
const {
|
|
809
|
+
const {
|
|
810
|
+
pageInfo,
|
|
811
|
+
columns,
|
|
812
|
+
viewModels,
|
|
813
|
+
summaryConfigs,
|
|
814
|
+
subtotalXColumn,
|
|
815
|
+
subtotalYColumn,
|
|
816
|
+
} = this.props;
|
|
355
817
|
const { touchEnd, total, loading, virtualEndPageNo } = this.state;
|
|
356
818
|
const { translate } = this.context;
|
|
357
819
|
|
|
820
|
+
const isProSumarryTable = Boolean(subtotalXColumn || subtotalYColumn);
|
|
821
|
+
|
|
822
|
+
const {
|
|
823
|
+
proSummaryTableColumns,
|
|
824
|
+
proSummaryTableData,
|
|
825
|
+
} = this.handleProSummaryTable(this.getUnHidenDataSource());
|
|
826
|
+
|
|
358
827
|
return (
|
|
359
828
|
<>
|
|
360
829
|
{viewModels.includes("table") ? (
|
|
361
830
|
<Table
|
|
362
831
|
size={"middle"}
|
|
363
832
|
rowSelection={this.getRowSelection()}
|
|
364
|
-
columns={
|
|
365
|
-
|
|
833
|
+
columns={
|
|
834
|
+
isProSumarryTable
|
|
835
|
+
? proSummaryTableColumns
|
|
836
|
+
: columns
|
|
837
|
+
? columns
|
|
838
|
+
: []
|
|
839
|
+
}
|
|
840
|
+
dataSource={
|
|
841
|
+
isProSumarryTable
|
|
842
|
+
? proSummaryTableData
|
|
843
|
+
: this.getUnHidenDataSource()
|
|
844
|
+
}
|
|
366
845
|
bordered
|
|
367
846
|
pagination={false}
|
|
368
847
|
style={{ display: columns ? "block" : "none" }}
|
|
369
848
|
summary={(pageData) => {
|
|
370
849
|
if (!summaryConfigs || summaryConfigs?.length === 0) return <></>;
|
|
850
|
+
|
|
851
|
+
const columns = isProSumarryTable
|
|
852
|
+
? proSummaryTableColumns
|
|
853
|
+
: this.props.columns;
|
|
854
|
+
|
|
371
855
|
const sumConfigs: {
|
|
372
856
|
sum: { value: string; id: string }[];
|
|
373
857
|
avg: { value: string; id: string }[];
|
|
@@ -422,7 +906,7 @@ class QueryTable extends React.PureComponent<QueryTableProps, QueryTableStat> {
|
|
|
422
906
|
),
|
|
423
907
|
new BigNumber(0)
|
|
424
908
|
)
|
|
425
|
-
|
|
909
|
+
?.toString();
|
|
426
910
|
if (argFun === "avg")
|
|
427
911
|
sum.value = pageData
|
|
428
912
|
.reduce(
|
|
@@ -434,7 +918,7 @@ class QueryTable extends React.PureComponent<QueryTableProps, QueryTableStat> {
|
|
|
434
918
|
),
|
|
435
919
|
new BigNumber(0)
|
|
436
920
|
)
|
|
437
|
-
|
|
921
|
+
?.toString();
|
|
438
922
|
|
|
439
923
|
sum.id = dataIndex;
|
|
440
924
|
if (argFun === "avg") {
|
|
@@ -457,7 +941,7 @@ class QueryTable extends React.PureComponent<QueryTableProps, QueryTableStat> {
|
|
|
457
941
|
) : (
|
|
458
942
|
<Table.Summary.Row>
|
|
459
943
|
{sumConfigs["sum"].map(({ id, value }, idx) => (
|
|
460
|
-
<Table.Summary.Cell index={idx}>
|
|
944
|
+
<Table.Summary.Cell index={idx} className="zongji">
|
|
461
945
|
{value}
|
|
462
946
|
</Table.Summary.Cell>
|
|
463
947
|
))}
|
|
@@ -468,7 +952,7 @@ class QueryTable extends React.PureComponent<QueryTableProps, QueryTableStat> {
|
|
|
468
952
|
) : (
|
|
469
953
|
<Table.Summary.Row>
|
|
470
954
|
{sumConfigs["avg"].map(({ id, value }, idx) => (
|
|
471
|
-
<Table.Summary.Cell index={idx}>
|
|
955
|
+
<Table.Summary.Cell index={idx} className="zongji">
|
|
472
956
|
{value}
|
|
473
957
|
</Table.Summary.Cell>
|
|
474
958
|
))}
|
|
@@ -5,11 +5,17 @@ import { message } from "antd";
|
|
|
5
5
|
import EncryptUtils from "../units/EncryptUtils";
|
|
6
6
|
import "dayjs/locale/en";
|
|
7
7
|
import dayjs from "dayjs";
|
|
8
|
+
import utc from "dayjs/plugin/utc";
|
|
9
|
+
import timezone from "dayjs/plugin/timezone";
|
|
10
|
+
|
|
8
11
|
import { CodeSource, DtmplConfig, PageInfo, SelectedRow } from "./interface";
|
|
9
12
|
|
|
10
13
|
import { ProgramConfig } from "../index";
|
|
11
14
|
import translate from "../locale/translate";
|
|
12
15
|
|
|
16
|
+
dayjs.extend(utc);
|
|
17
|
+
dayjs.extend(timezone);
|
|
18
|
+
|
|
13
19
|
export default class HcserviceV3 {
|
|
14
20
|
static async requestEnum(serverKey: string, mstrucIds, path: string) {
|
|
15
21
|
if (!path) {
|
|
@@ -108,6 +108,7 @@ export interface CriteriaConfig extends FieldConfig {}
|
|
|
108
108
|
export interface ColumnConfig extends FieldConfig {
|
|
109
109
|
statColType?: StatColType;
|
|
110
110
|
colWidth?: number;
|
|
111
|
+
id: string;
|
|
111
112
|
}
|
|
112
113
|
|
|
113
114
|
export type CodeSource = "new" | "listop" | "listop-new" | undefined;
|
|
@@ -310,6 +311,8 @@ export interface LtmplConfig extends SelectConfig {
|
|
|
310
311
|
footer?: string;
|
|
311
312
|
header?: string;
|
|
312
313
|
totalColumnConfigs?: { id: string; aggFunc: "sum" | "avg"; title: string }[];
|
|
314
|
+
subtotalXColumn?: { id: string }[];
|
|
315
|
+
subtotalYColumn?: { id: string }[];
|
|
313
316
|
}
|
|
314
317
|
|
|
315
318
|
export interface EnumItem {
|