aldehyde 0.2.119 → 0.2.121
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/table/act-table.d.ts.map +1 -1
- package/lib/table/act-table.js +5 -2
- package/lib/table/act-table.js.map +1 -1
- package/lib/table/control-table-x-axis-wrapper.d.ts +12 -4
- package/lib/table/control-table-x-axis-wrapper.d.ts.map +1 -1
- package/lib/table/control-table-x-axis-wrapper.js +58 -52
- package/lib/table/control-table-x-axis-wrapper.js.map +1 -1
- package/lib/table/query-table.d.ts +5 -0
- package/lib/table/query-table.d.ts.map +1 -1
- package/lib/table/query-table.js +70 -3
- package/lib/table/query-table.js.map +1 -1
- package/lib/table/relation-table.js +1 -1
- package/lib/table/relation-table.js.map +1 -1
- package/lib/tmpl/hcservice-v3.d.ts.map +1 -1
- package/lib/tmpl/hcservice-v3.js.map +1 -1
- package/lib/tmpl/interface.d.ts +33 -24
- package/lib/tmpl/interface.d.ts.map +1 -1
- package/lib/tmpl/interface.js +0 -3
- package/lib/tmpl/interface.js.map +1 -1
- package/package.json +2 -1
- package/src/aldehyde/form/criteria-form.tsx +1 -1
- package/src/aldehyde/table/act-table.tsx +5 -1
- package/src/aldehyde/table/control-table-x-axis-wrapper.tsx +71 -43
- package/src/aldehyde/table/query-table.tsx +121 -3
- package/src/aldehyde/table/relation-table.tsx +2 -2
- package/src/aldehyde/tmpl/hcservice-v3.tsx +7 -3
- package/src/aldehyde/tmpl/interface.tsx +341 -295
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { Card, Collapse, Descriptions, List } from "antd";
|
|
3
|
-
import
|
|
3
|
+
import Table from "./control-table-x-axis-wrapper";
|
|
4
4
|
import "./index.css";
|
|
5
5
|
import {
|
|
6
6
|
ActTableViewModel,
|
|
@@ -20,6 +20,7 @@ import { arrayMoveImmutable } from "array-move";
|
|
|
20
20
|
import ViewControl from "../controls/view-control";
|
|
21
21
|
import Scrollbars from "react-custom-scrollbars";
|
|
22
22
|
import { LocaleContext } from "../locale/LocaleProvider";
|
|
23
|
+
import { BigNumber } from "bignumber.js";
|
|
23
24
|
const { Panel } = Collapse;
|
|
24
25
|
const SortableItem = SortableElement((props) => <tr {...props} />);
|
|
25
26
|
const SortableBody = SortableContainer((props) => <tbody {...props} />);
|
|
@@ -51,6 +52,7 @@ interface QueryTableProps {
|
|
|
51
52
|
hiddenRowCodes?: string[];
|
|
52
53
|
viewModel?: string;
|
|
53
54
|
columnConfigs?: FieldConfig[];
|
|
55
|
+
summaryConfigs?: { id: string; aggFunc: "sum" | "avg" }[];
|
|
54
56
|
}
|
|
55
57
|
|
|
56
58
|
interface QueryTableStat {
|
|
@@ -306,7 +308,7 @@ class QueryTable extends React.PureComponent<QueryTableProps, QueryTableStat> {
|
|
|
306
308
|
const formItemList = [];
|
|
307
309
|
if (columnConfigs.length > 0) {
|
|
308
310
|
columnConfigs.forEach((item, index) => {
|
|
309
|
-
if (item.id != "10000"
|
|
311
|
+
if (item.id != "10000" && item.id != "20000" && item.title != "操作") {
|
|
310
312
|
const title = item.title;
|
|
311
313
|
let fieldValue = data ? data[item.id] : undefined;
|
|
312
314
|
if (title == "序号") {
|
|
@@ -341,9 +343,16 @@ class QueryTable extends React.PureComponent<QueryTableProps, QueryTableStat> {
|
|
|
341
343
|
return formItemList;
|
|
342
344
|
};
|
|
343
345
|
|
|
346
|
+
getTableSummaryNumberValue(value: "" | string[]) {
|
|
347
|
+
if (typeof value === "string") return Number(value);
|
|
348
|
+
|
|
349
|
+
return Number(value[0].split("@R@")[1]);
|
|
350
|
+
}
|
|
351
|
+
|
|
344
352
|
render() {
|
|
345
|
-
const { pageInfo, columns, viewModels } = this.props;
|
|
353
|
+
const { pageInfo, columns, viewModels, summaryConfigs } = this.props;
|
|
346
354
|
const { touchEnd, total, loading, virtualEndPageNo } = this.state;
|
|
355
|
+
const { translate } = this.context;
|
|
347
356
|
|
|
348
357
|
return (
|
|
349
358
|
<>
|
|
@@ -356,6 +365,115 @@ class QueryTable extends React.PureComponent<QueryTableProps, QueryTableStat> {
|
|
|
356
365
|
bordered
|
|
357
366
|
pagination={false}
|
|
358
367
|
style={{ display: columns ? "block" : "none" }}
|
|
368
|
+
summary={(pageData) => {
|
|
369
|
+
if (!summaryConfigs || summaryConfigs?.length === 0) return <></>;
|
|
370
|
+
const sumConfigs: {
|
|
371
|
+
sum: { value: string; id: string }[];
|
|
372
|
+
avg: { value: string; id: string }[];
|
|
373
|
+
} = { sum: [], avg: [] };
|
|
374
|
+
|
|
375
|
+
if (this.getRowSelection()) {
|
|
376
|
+
sumConfigs["avg"].push({
|
|
377
|
+
value: "",
|
|
378
|
+
id: "",
|
|
379
|
+
});
|
|
380
|
+
sumConfigs["sum"].push({
|
|
381
|
+
value: "",
|
|
382
|
+
id: "",
|
|
383
|
+
});
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
sumConfigs["sum"].push({
|
|
387
|
+
value: translate("合计"),
|
|
388
|
+
id: "title",
|
|
389
|
+
});
|
|
390
|
+
sumConfigs["avg"].push({
|
|
391
|
+
value: translate("均值"),
|
|
392
|
+
id: "title",
|
|
393
|
+
});
|
|
394
|
+
|
|
395
|
+
let sumLen = 0,
|
|
396
|
+
avgLen = 0;
|
|
397
|
+
|
|
398
|
+
for (let i = 0; i < columns.length; i++) {
|
|
399
|
+
const idx = i,
|
|
400
|
+
dataIndex = columns[i].dataIndex;
|
|
401
|
+
if (idx === 0) continue;
|
|
402
|
+
const sum = { value: "", id: "" };
|
|
403
|
+
const sumConfigIdx = summaryConfigs.findIndex(
|
|
404
|
+
({ id }) => id === dataIndex
|
|
405
|
+
);
|
|
406
|
+
if (sumConfigIdx === -1) {
|
|
407
|
+
sumConfigs["sum"].push(sum);
|
|
408
|
+
sumConfigs["avg"].push(sum);
|
|
409
|
+
continue;
|
|
410
|
+
}
|
|
411
|
+
const argFun = summaryConfigs[sumConfigIdx].aggFunc;
|
|
412
|
+
|
|
413
|
+
if (argFun === "sum")
|
|
414
|
+
sum.value = pageData
|
|
415
|
+
.reduce(
|
|
416
|
+
(lastNum, item) =>
|
|
417
|
+
lastNum.plus(
|
|
418
|
+
new BigNumber(
|
|
419
|
+
this.getTableSummaryNumberValue(item[dataIndex])
|
|
420
|
+
)
|
|
421
|
+
),
|
|
422
|
+
new BigNumber(0)
|
|
423
|
+
)
|
|
424
|
+
.toString();
|
|
425
|
+
if (argFun === "avg")
|
|
426
|
+
sum.value = pageData
|
|
427
|
+
.reduce(
|
|
428
|
+
(lastNum, item) =>
|
|
429
|
+
lastNum.plus(
|
|
430
|
+
new BigNumber(
|
|
431
|
+
this.getTableSummaryNumberValue(item[dataIndex])
|
|
432
|
+
).div(pageData.length)
|
|
433
|
+
),
|
|
434
|
+
new BigNumber(0)
|
|
435
|
+
)
|
|
436
|
+
.toString();
|
|
437
|
+
|
|
438
|
+
sum.id = dataIndex;
|
|
439
|
+
if (argFun === "avg") {
|
|
440
|
+
sumConfigs["avg"].push(sum);
|
|
441
|
+
avgLen++;
|
|
442
|
+
} else sumConfigs["avg"].push({ value: "", id: "" });
|
|
443
|
+
|
|
444
|
+
if (argFun === "sum") {
|
|
445
|
+
sumConfigs["sum"].push(sum);
|
|
446
|
+
sumLen++;
|
|
447
|
+
} else sumConfigs["sum"].push({ value: "", id: "" });
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
return (
|
|
451
|
+
<>
|
|
452
|
+
{sumLen === 0 ? (
|
|
453
|
+
<></>
|
|
454
|
+
) : (
|
|
455
|
+
<Table.Summary.Row>
|
|
456
|
+
{sumConfigs["sum"].map(({ id, value }, idx) => (
|
|
457
|
+
<Table.Summary.Cell index={idx}>
|
|
458
|
+
{value}
|
|
459
|
+
</Table.Summary.Cell>
|
|
460
|
+
))}
|
|
461
|
+
</Table.Summary.Row>
|
|
462
|
+
)}
|
|
463
|
+
{avgLen === 0 ? (
|
|
464
|
+
<></>
|
|
465
|
+
) : (
|
|
466
|
+
<Table.Summary.Row>
|
|
467
|
+
{sumConfigs["avg"].map(({ id, value }, idx) => (
|
|
468
|
+
<Table.Summary.Cell index={idx}>
|
|
469
|
+
{value}
|
|
470
|
+
</Table.Summary.Cell>
|
|
471
|
+
))}
|
|
472
|
+
</Table.Summary.Row>
|
|
473
|
+
)}
|
|
474
|
+
</>
|
|
475
|
+
);
|
|
476
|
+
}}
|
|
359
477
|
loading={loading}
|
|
360
478
|
components={{
|
|
361
479
|
body: {
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
Tooltip,
|
|
11
11
|
Typography,
|
|
12
12
|
} from "antd";
|
|
13
|
-
import
|
|
13
|
+
import Table from "./control-table-x-axis-wrapper";
|
|
14
14
|
import {
|
|
15
15
|
AlignLeftOutlined,
|
|
16
16
|
DeleteOutlined,
|
|
@@ -650,7 +650,7 @@ class RelationTable extends React.PureComponent<
|
|
|
650
650
|
{fieldGroupConfig.min && (!value || value.length <= 0) ? (
|
|
651
651
|
<Text style={{ color: "red" }}>
|
|
652
652
|
{translate("${请选择或添加}")}
|
|
653
|
-
{translate("${"+fieldGroupConfig.title +"}")}
|
|
653
|
+
{translate("${" + fieldGroupConfig.title + "}")}
|
|
654
654
|
</Text>
|
|
655
655
|
) : null}
|
|
656
656
|
<FormItem
|
|
@@ -719,7 +719,9 @@ export default class HcserviceV3 {
|
|
|
719
719
|
}
|
|
720
720
|
|
|
721
721
|
static getFileUrl(serverKey: string, path) {
|
|
722
|
-
const hydrocarbonToken = Units.hydrocarbonToken(
|
|
722
|
+
const hydrocarbonToken = Units.hydrocarbonToken(
|
|
723
|
+
Units.programCode(serverKey)
|
|
724
|
+
);
|
|
723
725
|
let url =
|
|
724
726
|
Units.joinPath(Units.api(serverKey), Units.joinPath("/v3/files", path)) +
|
|
725
727
|
`?@token=${hydrocarbonToken}&@programToken=${Units.programCode()}`;
|
|
@@ -727,7 +729,9 @@ export default class HcserviceV3 {
|
|
|
727
729
|
}
|
|
728
730
|
|
|
729
731
|
static getFileTxtUrl(serverKey: string, path) {
|
|
730
|
-
const hydrocarbonToken = Units.hydrocarbonToken(
|
|
732
|
+
const hydrocarbonToken = Units.hydrocarbonToken(
|
|
733
|
+
Units.programCode(serverKey)
|
|
734
|
+
);
|
|
731
735
|
let url =
|
|
732
736
|
Units.joinPath(
|
|
733
737
|
Units.api(serverKey),
|
|
@@ -832,7 +836,7 @@ export default class HcserviceV3 {
|
|
|
832
836
|
kaptchaText,
|
|
833
837
|
pubkey,
|
|
834
838
|
programCode?: string,
|
|
835
|
-
serverKey?:string
|
|
839
|
+
serverKey?: string
|
|
836
840
|
) {
|
|
837
841
|
let datetime = dayjs(new Date())
|
|
838
842
|
.tz("Europe/London")
|