aldehyde 0.2.213 → 0.2.215
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/controls/action/index.d.ts.map +1 -1
- package/lib/controls/chemstruc/graph.d.ts.map +1 -1
- package/lib/controls/collapse-card/index.d.ts.map +1 -1
- package/lib/controls/color-picker/index.d.ts.map +1 -1
- package/lib/controls/cquery/cquick-button.d.ts.map +1 -1
- package/lib/controls/entity-select/entity-select.d.ts.map +1 -1
- package/lib/controls/entity-select/lab-tree-select.d.ts.map +1 -1
- package/lib/controls/entity-select/popover-entity-select.d.ts.map +1 -1
- package/lib/controls/file-view/index.js +2 -2
- package/lib/controls/file-view/index.js.map +1 -1
- package/lib/controls/password-setter/index.d.ts.map +1 -1
- package/lib/controls/relation-existion/index.d.ts.map +1 -1
- package/lib/controls/rfield/index.d.ts.map +1 -1
- package/lib/controls/select/index.d.ts.map +1 -1
- package/lib/controls/signature/index.d.ts.map +1 -1
- package/lib/controls/text/ellipsis-text.d.ts.map +1 -1
- package/lib/controls/text/ellipsis-text.js +4 -4
- package/lib/controls/text/ellipsis-text.js.map +1 -1
- package/lib/controls/upload/index.d.ts.map +1 -1
- package/lib/controls/view-control.d.ts.map +1 -1
- package/lib/controls/view-control.js +5 -5
- package/lib/controls/view-control.js.map +1 -1
- package/lib/custom-page/dtmpl-custom-edit-modal-page.d.ts.map +1 -1
- package/lib/detail/button/bottom-submit-button-bar.d.ts.map +1 -1
- package/lib/detail/button/cquery-button-bar.d.ts.map +1 -1
- package/lib/detail/button/fix-right-submit-button-bar.d.ts.map +1 -1
- package/lib/detail/edit/dtmpl-edit.d.ts.map +1 -1
- package/lib/detail/edit/dtmpl-edit.js +0 -2
- package/lib/detail/edit/dtmpl-edit.js.map +1 -1
- package/lib/detail/edit/fields-edit-card.d.ts.map +1 -1
- package/lib/detail/edit/modal-row-edit.d.ts.map +1 -1
- package/lib/detail/edit/row-edit-card.d.ts.map +1 -1
- package/lib/detail/rightbar/index.d.ts.map +1 -1
- package/lib/detail/view/act-dtmpl-view.d.ts.map +1 -1
- package/lib/detail/view/field-view-group.d.ts.map +1 -1
- package/lib/detail/view/field-view-group.js +1 -1
- package/lib/detail/view/field-view-group.js.map +1 -1
- package/lib/detail/view/modal-dtmpl-view.d.ts.map +1 -1
- package/lib/detail/view/snapshot-timeline.d.ts.map +1 -1
- package/lib/export/export-frame.d.ts.map +1 -1
- package/lib/export/select-code-export-frame.d.ts.map +1 -1
- package/lib/form/dtmpl-form.d.ts.map +1 -1
- package/lib/form/dtmpl-form.js +1 -1
- package/lib/form/dtmpl-form.js.map +1 -1
- package/lib/form/field-group-form.d.ts.map +1 -1
- package/lib/form/form-Item-group.d.ts.map +1 -1
- package/lib/form/form-Item-group.js +6 -6
- package/lib/form/form-Item-group.js.map +1 -1
- package/lib/import/excel-import.d.ts.map +1 -1
- package/lib/index.d.ts +3 -3
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +4 -3
- package/lib/index.js.map +1 -1
- package/lib/layout/header/index.d.ts.map +1 -1
- package/lib/layout/header/index.js.map +1 -1
- package/lib/layout/menu/block.d.ts.map +1 -1
- package/lib/layout/menu/l2menu-quick-bar.d.ts.map +1 -1
- package/lib/layout/menu/menu-2layers.d.ts.map +1 -1
- package/lib/layout/menu/menu-render.d.ts.map +1 -1
- package/lib/layout/menu/menu-render.js +4 -1
- package/lib/layout/menu/menu-render.js.map +1 -1
- package/lib/layout/menu/reset-password.d.ts.map +1 -1
- package/lib/layout/menu/user-bar.d.ts.map +1 -1
- package/lib/layout/menu/userinfo-bar.d.ts.map +1 -1
- package/lib/layout2/css/header.css +1 -1
- package/lib/layout2/header.d.ts.map +1 -1
- package/lib/layout2/header.js +2 -1
- package/lib/layout2/header.js.map +1 -1
- package/lib/layout2/page.d.ts.map +1 -1
- package/lib/layout2/page.js +3 -0
- package/lib/layout2/page.js.map +1 -1
- package/lib/locale/useLocale.d.ts +1 -0
- package/lib/locale/useLocale.d.ts.map +1 -1
- package/lib/locale/useLocale.js +2 -2
- package/lib/locale/useLocale.js.map +1 -1
- package/lib/login/context-setter.d.ts.map +1 -1
- package/lib/login/context-setter.js.map +1 -1
- package/lib/login/login.d.ts.map +1 -1
- package/lib/login2/login-page.d.ts +8 -0
- package/lib/login2/login-page.d.ts.map +1 -0
- package/lib/login2/{LoginPage.js → login-page.js} +26 -8
- package/lib/login2/login-page.js.map +1 -0
- package/lib/login2/{Login.d.ts → login.d.ts} +1 -1
- package/lib/login2/{Login.d.ts.map → login.d.ts.map} +1 -1
- package/lib/login2/{Login.js → login.js} +1 -1
- package/lib/login2/{Login.js.map → login.js.map} +1 -1
- package/lib/module/dtmpl-edit-card.d.ts.map +1 -1
- package/lib/module/dtmpl-edit-card.js +0 -1
- package/lib/module/dtmpl-edit-card.js.map +1 -1
- package/lib/module/dtmpl-edit-page.d.ts.map +1 -1
- package/lib/module/ltmpl-modal.d.ts.map +1 -1
- package/lib/module/ltmpl-table.d.ts.map +1 -1
- package/lib/routable/ltmpl-route.d.ts +1 -0
- package/lib/routable/ltmpl-route.d.ts.map +1 -1
- package/lib/routable/ltmpl-route.js +10 -5
- package/lib/routable/ltmpl-route.js.map +1 -1
- package/lib/table/act-table.d.ts +2 -2
- package/lib/table/act-table.d.ts.map +1 -1
- package/lib/table/act-table.js +45 -263
- package/lib/table/act-table.js.map +1 -1
- package/lib/table/column/column-builder.d.ts +35 -0
- package/lib/table/column/column-builder.d.ts.map +1 -0
- package/lib/table/column/column-builder.js +307 -0
- package/lib/table/column/column-builder.js.map +1 -0
- package/lib/table/column/theme-color-getter.d.ts +6 -0
- package/lib/table/column/theme-color-getter.d.ts.map +1 -0
- package/lib/table/column/theme-color-getter.js +19 -0
- package/lib/table/column/theme-color-getter.js.map +1 -0
- package/lib/table/modal-select-table.d.ts.map +1 -1
- package/lib/table/pagination.d.ts.map +1 -1
- package/lib/table/query-table.d.ts +1 -41
- package/lib/table/query-table.d.ts.map +1 -1
- package/lib/table/query-table.js +104 -117
- package/lib/table/query-table.js.map +1 -1
- package/lib/table/relation-table.d.ts.map +1 -1
- package/lib/table/report-table.d.ts +6 -0
- package/lib/table/report-table.d.ts.map +1 -0
- package/lib/table/report-table.js +86 -0
- package/lib/table/report-table.js.map +1 -0
- package/lib/table/select-table.d.ts.map +1 -1
- package/lib/table/selected-rows-card.d.ts.map +1 -1
- package/lib/table/stat/restat.d.ts.map +1 -1
- package/lib/tmpl/hc-data-source.d.ts.map +1 -1
- package/lib/tmpl/hc-data-source.js +15 -0
- package/lib/tmpl/hc-data-source.js.map +1 -1
- package/lib/tmpl/hcservice-v3.d.ts +1 -0
- package/lib/tmpl/hcservice-v3.d.ts.map +1 -1
- package/lib/tmpl/hcservice-v3.js +12 -0
- package/lib/tmpl/hcservice-v3.js.map +1 -1
- package/lib/tmpl/interface.d.ts +61 -9
- package/lib/tmpl/interface.d.ts.map +1 -1
- package/lib/tmpl/interface.js.map +1 -1
- package/lib/tree/act-tree.d.ts.map +1 -1
- package/lib/tree/tmpl-tree.d.ts.map +1 -1
- package/lib/welcome/quick-entrance.d.ts.map +1 -1
- package/lib/welcome/workbench.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/aldehyde/controls/file-view/index.tsx +2 -2
- package/src/aldehyde/controls/text/ellipsis-text.tsx +5 -5
- package/src/aldehyde/controls/view-control.tsx +7 -5
- package/src/aldehyde/detail/edit/dtmpl-edit.tsx +1 -2
- package/src/aldehyde/detail/view/field-view-group.tsx +1 -1
- package/src/aldehyde/form/dtmpl-form.tsx +1 -1
- package/src/aldehyde/form/form-Item-group.tsx +6 -6
- package/src/aldehyde/index.tsx +7 -4
- package/src/aldehyde/layout/header/index.tsx +7 -0
- package/src/aldehyde/layout/menu/menu-render.tsx +4 -1
- package/src/aldehyde/layout2/css/header.css +1 -1
- package/src/aldehyde/layout2/header.tsx +3 -3
- package/src/aldehyde/layout2/page.tsx +3 -0
- package/src/aldehyde/locale/LocaleProvider.tsx +1 -1
- package/src/aldehyde/locale/useLocale.ts +2 -1
- package/src/aldehyde/login/context-setter.tsx +0 -1
- package/src/aldehyde/login2/login-page.tsx +94 -0
- package/src/aldehyde/module/dtmpl-edit-card.tsx +0 -1
- package/src/aldehyde/routable/ltmpl-route.tsx +12 -5
- package/src/aldehyde/table/act-table.tsx +50 -485
- package/src/aldehyde/table/column/column-builder.tsx +566 -0
- package/src/aldehyde/table/column/theme-color-getter.tsx +25 -0
- package/src/aldehyde/table/query-table.tsx +187 -239
- package/src/aldehyde/table/report-table.tsx +116 -0
- package/src/aldehyde/tmpl/hc-data-source.tsx +16 -0
- package/src/aldehyde/tmpl/hcservice-v3.tsx +14 -0
- package/src/aldehyde/tmpl/interface.tsx +69 -9
- package/lib/login2/LoginPage.d.ts +0 -4
- package/lib/login2/LoginPage.d.ts.map +0 -1
- package/lib/login2/LoginPage.js.map +0 -1
- package/lib/login2/index.d.ts +0 -4
- package/lib/login2/index.d.ts.map +0 -1
- package/lib/login2/index.js +0 -4
- package/lib/login2/index.js.map +0 -1
- package/src/aldehyde/login2/LoginPage.tsx +0 -64
- package/src/aldehyde/login2/index.tsx +0 -4
- /package/src/aldehyde/login2/{Login.tsx → login.tsx} +0 -0
|
@@ -3,14 +3,10 @@ import { Card, Collapse, Descriptions, List } from "antd";
|
|
|
3
3
|
import Table from "./control-table-x-axis-wrapper";
|
|
4
4
|
import "./index.css";
|
|
5
5
|
import {
|
|
6
|
-
ActTableViewModel,
|
|
7
|
-
ColumnConfig,
|
|
8
6
|
DtmplData,
|
|
9
|
-
FieldConfig,
|
|
10
7
|
PageInfo,
|
|
11
8
|
QueryData,
|
|
12
|
-
|
|
13
|
-
SelectedRow,
|
|
9
|
+
SelectedRow,QueryTableProps
|
|
14
10
|
} from "../tmpl/interface";
|
|
15
11
|
import HcserviceV3 from "../tmpl/hcservice-v3";
|
|
16
12
|
import Pagination from "./pagination";
|
|
@@ -33,43 +29,6 @@ interface CacheData {
|
|
|
33
29
|
pageInfo: PageInfo;
|
|
34
30
|
}
|
|
35
31
|
|
|
36
|
-
interface QueryTableProps {
|
|
37
|
-
viewModels?: ActTableViewModel[];
|
|
38
|
-
// defaultPageSize?: number;
|
|
39
|
-
pageInfo: {
|
|
40
|
-
pageNo: number;
|
|
41
|
-
pageSize: number;
|
|
42
|
-
};
|
|
43
|
-
tableProps?: {
|
|
44
|
-
size?: "small" | "middle" | "large";
|
|
45
|
-
clickDisplayTotal?: boolean;
|
|
46
|
-
scrollY?: number;
|
|
47
|
-
};
|
|
48
|
-
primaryColumn?: ColumnConfig;
|
|
49
|
-
columns: any[];
|
|
50
|
-
serverKey?: string;
|
|
51
|
-
queryKey: QueryKey;
|
|
52
|
-
onChangePage: (pageNo: number, pageSize: number) => void;
|
|
53
|
-
onChangeRowSelection?: (
|
|
54
|
-
selectedRows: SelectedRow[],
|
|
55
|
-
selectedDatas: DtmplData[],
|
|
56
|
-
allRowKeys: string[]
|
|
57
|
-
) => void;
|
|
58
|
-
maxSelectedRows?: number;
|
|
59
|
-
selectedRows?: SelectedRow[];
|
|
60
|
-
hiddenRowCodes?: string[];
|
|
61
|
-
viewModel?: string;
|
|
62
|
-
columnConfigs?: FieldConfig[];
|
|
63
|
-
summaryConfigs?: {
|
|
64
|
-
id: string;
|
|
65
|
-
aggFunc: "sum" | "avg" | "groupIsum" | "groupIavg";
|
|
66
|
-
}[];
|
|
67
|
-
subtotalXColumn?: { id: string }[];
|
|
68
|
-
subtotalYColumn?: { id: string }[];
|
|
69
|
-
groupIColumns?: { id: string; title: string; sourceId: string }[]; // 组间合计key
|
|
70
|
-
doSearch?: (params: object) => void;
|
|
71
|
-
sortColumnData?: string[];
|
|
72
|
-
}
|
|
73
32
|
|
|
74
33
|
interface QueryTableStat {
|
|
75
34
|
queryDataCache?: Map<string, CacheData>;
|
|
@@ -112,11 +71,6 @@ class QueryTable extends React.PureComponent<QueryTableProps, QueryTableStat> {
|
|
|
112
71
|
|
|
113
72
|
async componentDidMount() {
|
|
114
73
|
const { queryKey, pageInfo } = this.props;
|
|
115
|
-
// let pageInfo = {
|
|
116
|
-
// pageNo: 1,
|
|
117
|
-
// pageSize: defaultPageSize ? defaultPageSize : 10,
|
|
118
|
-
// virtualEndPageNo: undefined,
|
|
119
|
-
// }
|
|
120
74
|
if (queryKey) {
|
|
121
75
|
await this.loadData(queryKey.key, pageInfo);
|
|
122
76
|
}
|
|
@@ -1028,7 +982,6 @@ class QueryTable extends React.PureComponent<QueryTableProps, QueryTableStat> {
|
|
|
1028
982
|
|
|
1029
983
|
onChange(pagination, filters, sorter, extra) {
|
|
1030
984
|
console.log("params", pagination, filters, sorter, extra);
|
|
1031
|
-
debugger
|
|
1032
985
|
if (extra.action === "sort") {
|
|
1033
986
|
const extParams: Record<string, string> = {};
|
|
1034
987
|
const sortColumnData = JSON.parse(
|
|
@@ -1046,11 +999,6 @@ class QueryTable extends React.PureComponent<QueryTableProps, QueryTableStat> {
|
|
|
1046
999
|
sortColumnData.splice(tgt, 1);
|
|
1047
1000
|
}
|
|
1048
1001
|
|
|
1049
|
-
// if(!sorter.order){
|
|
1050
|
-
// Object.assign(extParams, {
|
|
1051
|
-
// sortColIds: [],
|
|
1052
|
-
// });
|
|
1053
|
-
// }else
|
|
1054
1002
|
if (sorter.order === "ascend") {
|
|
1055
1003
|
Object.assign(extParams, {
|
|
1056
1004
|
sortColIds: [...sortColumnData, sorter.field + "_" + "desc"],
|
|
@@ -1177,6 +1125,191 @@ class QueryTable extends React.PureComponent<QueryTableProps, QueryTableStat> {
|
|
|
1177
1125
|
// current_cols[10].onCell = (_, rowIdx) =>
|
|
1178
1126
|
// this.mergeRowInCol(_, rowIdx, 10, mergeMp, current_cols.length);
|
|
1179
1127
|
|
|
1128
|
+
let summary=(pageData) => {
|
|
1129
|
+
if (
|
|
1130
|
+
!summaryConfigs ||
|
|
1131
|
+
summaryConfigs?.length === 0 ||
|
|
1132
|
+
pageData.length === 0
|
|
1133
|
+
)
|
|
1134
|
+
return <></>;
|
|
1135
|
+
|
|
1136
|
+
const columns = isProSumarryTable
|
|
1137
|
+
? proSummaryTableColumns
|
|
1138
|
+
: this.props.columns;
|
|
1139
|
+
|
|
1140
|
+
const sumConfigs: {
|
|
1141
|
+
sum: { value: string; id: string; columnConfig?: any }[];
|
|
1142
|
+
avg: { value: string; id: string; columnConfig?: any }[];
|
|
1143
|
+
} = { sum: [], avg: [] };
|
|
1144
|
+
|
|
1145
|
+
if (this.getRowSelection()) {
|
|
1146
|
+
sumConfigs["avg"].push({
|
|
1147
|
+
value: "",
|
|
1148
|
+
id: "",
|
|
1149
|
+
columnConfig: { align: "center" },
|
|
1150
|
+
});
|
|
1151
|
+
sumConfigs["sum"].push({
|
|
1152
|
+
value: "",
|
|
1153
|
+
id: "",
|
|
1154
|
+
columnConfig: { align: "center" },
|
|
1155
|
+
});
|
|
1156
|
+
}
|
|
1157
|
+
|
|
1158
|
+
sumConfigs["sum"].push({
|
|
1159
|
+
value: translate("${合计}"),
|
|
1160
|
+
id: "title",
|
|
1161
|
+
columnConfig: { align: "center" },
|
|
1162
|
+
});
|
|
1163
|
+
sumConfigs["avg"].push({
|
|
1164
|
+
value: translate("${均值}"),
|
|
1165
|
+
id: "title",
|
|
1166
|
+
columnConfig: { align: "center" },
|
|
1167
|
+
});
|
|
1168
|
+
|
|
1169
|
+
let sumLen = 0,
|
|
1170
|
+
avgLen = 0;
|
|
1171
|
+
|
|
1172
|
+
for (let i = 0; i < columns.length; i++) {
|
|
1173
|
+
const idx = i,
|
|
1174
|
+
dataIndex = columns[i].dataIndex;
|
|
1175
|
+
if (idx === 0) continue;
|
|
1176
|
+
const sum = { value: "", id: "", columnConfig: columns[i] };
|
|
1177
|
+
const sumConfigIdx = summaryConfigs.findIndex(
|
|
1178
|
+
({ id }) => id === dataIndex
|
|
1179
|
+
);
|
|
1180
|
+
if (sumConfigIdx === -1) {
|
|
1181
|
+
sumConfigs["sum"].push(sum);
|
|
1182
|
+
sumConfigs["avg"].push(sum);
|
|
1183
|
+
continue;
|
|
1184
|
+
}
|
|
1185
|
+
const argFun = summaryConfigs[sumConfigIdx].aggFunc;
|
|
1186
|
+
if (argFun === "sum")
|
|
1187
|
+
sum.value = pageData
|
|
1188
|
+
.reduce(
|
|
1189
|
+
(lastNum, item) =>
|
|
1190
|
+
lastNum.plus(
|
|
1191
|
+
new BigNumber(
|
|
1192
|
+
this.getTableSummaryNumberValue(item[dataIndex])
|
|
1193
|
+
)
|
|
1194
|
+
),
|
|
1195
|
+
new BigNumber(0)
|
|
1196
|
+
)
|
|
1197
|
+
?.toString();
|
|
1198
|
+
if (argFun === "avg")
|
|
1199
|
+
sum.value = pageData
|
|
1200
|
+
.reduce(
|
|
1201
|
+
(lastNum, item) =>
|
|
1202
|
+
lastNum.plus(
|
|
1203
|
+
new BigNumber(
|
|
1204
|
+
this.getTableSummaryNumberValue(item[dataIndex])
|
|
1205
|
+
).div(pageData.length)
|
|
1206
|
+
),
|
|
1207
|
+
new BigNumber(0)
|
|
1208
|
+
)
|
|
1209
|
+
?.toString();
|
|
1210
|
+
|
|
1211
|
+
const hash = (...args) => args.join("-");
|
|
1212
|
+
const hashKey = (data, keys) =>
|
|
1213
|
+
hash(...keys.map((key) => data[key]));
|
|
1214
|
+
|
|
1215
|
+
if (argFun === "groupIsum") {
|
|
1216
|
+
const allKeys = groupIColumns?.map(({ id }) => id);
|
|
1217
|
+
const set = new Set();
|
|
1218
|
+
|
|
1219
|
+
sum.value = pageData
|
|
1220
|
+
.reduce((lastNum, item) => {
|
|
1221
|
+
if (set.has(hashKey(item, allKeys))) return lastNum;
|
|
1222
|
+
set.add(hashKey(item, allKeys));
|
|
1223
|
+
return lastNum.plus(
|
|
1224
|
+
new BigNumber(
|
|
1225
|
+
this.getTableSummaryNumberValue(item[dataIndex])
|
|
1226
|
+
)
|
|
1227
|
+
);
|
|
1228
|
+
}, new BigNumber(0))
|
|
1229
|
+
?.toString();
|
|
1230
|
+
}
|
|
1231
|
+
|
|
1232
|
+
if (argFun === "groupIavg") {
|
|
1233
|
+
const set = new Set();
|
|
1234
|
+
let nums = 0;
|
|
1235
|
+
const allKeys = groupIColumns?.map(({ id }) => id);
|
|
1236
|
+
|
|
1237
|
+
pageData.forEach((item) => {
|
|
1238
|
+
if (set.has(hashKey(item, allKeys))) return;
|
|
1239
|
+
set.add(hashKey(item, allKeys));
|
|
1240
|
+
|
|
1241
|
+
nums++;
|
|
1242
|
+
});
|
|
1243
|
+
|
|
1244
|
+
set.clear();
|
|
1245
|
+
|
|
1246
|
+
sum.value = pageData
|
|
1247
|
+
.reduce((lastNum, item) => {
|
|
1248
|
+
if (set.has(hashKey(item, allKeys))) return lastNum;
|
|
1249
|
+
set.add(hashKey(item, allKeys));
|
|
1250
|
+
return lastNum.plus(
|
|
1251
|
+
new BigNumber(
|
|
1252
|
+
this.getTableSummaryNumberValue(item[dataIndex])
|
|
1253
|
+
).div(nums)
|
|
1254
|
+
);
|
|
1255
|
+
}, new BigNumber(0))
|
|
1256
|
+
?.toString();
|
|
1257
|
+
}
|
|
1258
|
+
|
|
1259
|
+
sum.id = dataIndex;
|
|
1260
|
+
if (argFun === "avg" || argFun === "groupIavg") {
|
|
1261
|
+
sumConfigs["avg"].push(sum);
|
|
1262
|
+
avgLen++;
|
|
1263
|
+
} else sumConfigs["avg"].push({ value: "", id: "" });
|
|
1264
|
+
|
|
1265
|
+
if (argFun === "sum" || argFun === "groupIsum") {
|
|
1266
|
+
sumConfigs["sum"].push(sum);
|
|
1267
|
+
sumLen++;
|
|
1268
|
+
} else sumConfigs["sum"].push({ value: "", id: "" });
|
|
1269
|
+
}
|
|
1270
|
+
|
|
1271
|
+
console.log("sumConfigs", sumConfigs, sumLen, avgLen);
|
|
1272
|
+
|
|
1273
|
+
return (
|
|
1274
|
+
<>
|
|
1275
|
+
{sumLen === 0 ? (
|
|
1276
|
+
<></>
|
|
1277
|
+
) : (
|
|
1278
|
+
<Table.Summary.Row>
|
|
1279
|
+
{sumConfigs["sum"].map(
|
|
1280
|
+
({ id, value, columnConfig }, idx) => (
|
|
1281
|
+
<Table.Summary.Cell
|
|
1282
|
+
align={columnConfig?.align}
|
|
1283
|
+
index={idx}
|
|
1284
|
+
className="zongji"
|
|
1285
|
+
>
|
|
1286
|
+
{value}
|
|
1287
|
+
</Table.Summary.Cell>
|
|
1288
|
+
)
|
|
1289
|
+
)}
|
|
1290
|
+
</Table.Summary.Row>
|
|
1291
|
+
)}
|
|
1292
|
+
{avgLen === 0 ? (
|
|
1293
|
+
<></>
|
|
1294
|
+
) : (
|
|
1295
|
+
<Table.Summary.Row>
|
|
1296
|
+
{sumConfigs["avg"].map(
|
|
1297
|
+
({ id, value, columnConfig }, idx) => (
|
|
1298
|
+
<Table.Summary.Cell
|
|
1299
|
+
align={columnConfig?.align}
|
|
1300
|
+
index={idx}
|
|
1301
|
+
className="zongji"
|
|
1302
|
+
>
|
|
1303
|
+
{value}
|
|
1304
|
+
</Table.Summary.Cell>
|
|
1305
|
+
)
|
|
1306
|
+
)}
|
|
1307
|
+
</Table.Summary.Row>
|
|
1308
|
+
)}
|
|
1309
|
+
</>
|
|
1310
|
+
);
|
|
1311
|
+
}
|
|
1312
|
+
|
|
1180
1313
|
return (
|
|
1181
1314
|
<>
|
|
1182
1315
|
{viewModels.includes("table") ? (
|
|
@@ -1185,8 +1318,6 @@ class QueryTable extends React.PureComponent<QueryTableProps, QueryTableStat> {
|
|
|
1185
1318
|
rowSelection={this.getRowSelection()}
|
|
1186
1319
|
columns={current_cols}
|
|
1187
1320
|
dataSource={originData}
|
|
1188
|
-
//tableLayout={'fixed'}
|
|
1189
|
-
//sticky
|
|
1190
1321
|
scroll={
|
|
1191
1322
|
tableProps.scrollY == -1 || tableProps.scrollY == 0
|
|
1192
1323
|
? null
|
|
@@ -1198,190 +1329,7 @@ class QueryTable extends React.PureComponent<QueryTableProps, QueryTableStat> {
|
|
|
1198
1329
|
bordered
|
|
1199
1330
|
pagination={false}
|
|
1200
1331
|
style={{ display: columns ? "block" : "none" }}
|
|
1201
|
-
summary={
|
|
1202
|
-
if (
|
|
1203
|
-
!summaryConfigs ||
|
|
1204
|
-
summaryConfigs?.length === 0 ||
|
|
1205
|
-
pageData.length === 0
|
|
1206
|
-
)
|
|
1207
|
-
return <></>;
|
|
1208
|
-
|
|
1209
|
-
const columns = isProSumarryTable
|
|
1210
|
-
? proSummaryTableColumns
|
|
1211
|
-
: this.props.columns;
|
|
1212
|
-
|
|
1213
|
-
const sumConfigs: {
|
|
1214
|
-
sum: { value: string; id: string; columnConfig?: any }[];
|
|
1215
|
-
avg: { value: string; id: string; columnConfig?: any }[];
|
|
1216
|
-
} = { sum: [], avg: [] };
|
|
1217
|
-
|
|
1218
|
-
if (this.getRowSelection()) {
|
|
1219
|
-
sumConfigs["avg"].push({
|
|
1220
|
-
value: "",
|
|
1221
|
-
id: "",
|
|
1222
|
-
columnConfig: { align: "center" },
|
|
1223
|
-
});
|
|
1224
|
-
sumConfigs["sum"].push({
|
|
1225
|
-
value: "",
|
|
1226
|
-
id: "",
|
|
1227
|
-
columnConfig: { align: "center" },
|
|
1228
|
-
});
|
|
1229
|
-
}
|
|
1230
|
-
|
|
1231
|
-
sumConfigs["sum"].push({
|
|
1232
|
-
value: translate("${合计}"),
|
|
1233
|
-
id: "title",
|
|
1234
|
-
columnConfig: { align: "center" },
|
|
1235
|
-
});
|
|
1236
|
-
sumConfigs["avg"].push({
|
|
1237
|
-
value: translate("${均值}"),
|
|
1238
|
-
id: "title",
|
|
1239
|
-
columnConfig: { align: "center" },
|
|
1240
|
-
});
|
|
1241
|
-
|
|
1242
|
-
let sumLen = 0,
|
|
1243
|
-
avgLen = 0;
|
|
1244
|
-
|
|
1245
|
-
for (let i = 0; i < columns.length; i++) {
|
|
1246
|
-
const idx = i,
|
|
1247
|
-
dataIndex = columns[i].dataIndex;
|
|
1248
|
-
if (idx === 0) continue;
|
|
1249
|
-
const sum = { value: "", id: "", columnConfig: columns[i] };
|
|
1250
|
-
const sumConfigIdx = summaryConfigs.findIndex(
|
|
1251
|
-
({ id }) => id === dataIndex
|
|
1252
|
-
);
|
|
1253
|
-
if (sumConfigIdx === -1) {
|
|
1254
|
-
sumConfigs["sum"].push(sum);
|
|
1255
|
-
sumConfigs["avg"].push(sum);
|
|
1256
|
-
continue;
|
|
1257
|
-
}
|
|
1258
|
-
const argFun = summaryConfigs[sumConfigIdx].aggFunc;
|
|
1259
|
-
if (argFun === "sum")
|
|
1260
|
-
sum.value = pageData
|
|
1261
|
-
.reduce(
|
|
1262
|
-
(lastNum, item) =>
|
|
1263
|
-
lastNum.plus(
|
|
1264
|
-
new BigNumber(
|
|
1265
|
-
this.getTableSummaryNumberValue(item[dataIndex])
|
|
1266
|
-
)
|
|
1267
|
-
),
|
|
1268
|
-
new BigNumber(0)
|
|
1269
|
-
)
|
|
1270
|
-
?.toString();
|
|
1271
|
-
if (argFun === "avg")
|
|
1272
|
-
sum.value = pageData
|
|
1273
|
-
.reduce(
|
|
1274
|
-
(lastNum, item) =>
|
|
1275
|
-
lastNum.plus(
|
|
1276
|
-
new BigNumber(
|
|
1277
|
-
this.getTableSummaryNumberValue(item[dataIndex])
|
|
1278
|
-
).div(pageData.length)
|
|
1279
|
-
),
|
|
1280
|
-
new BigNumber(0)
|
|
1281
|
-
)
|
|
1282
|
-
?.toString();
|
|
1283
|
-
|
|
1284
|
-
const hash = (...args) => args.join("-");
|
|
1285
|
-
const hashKey = (data, keys) =>
|
|
1286
|
-
hash(...keys.map((key) => data[key]));
|
|
1287
|
-
|
|
1288
|
-
if (argFun === "groupIsum") {
|
|
1289
|
-
const allKeys = groupIColumns?.map(({ id }) => id);
|
|
1290
|
-
const set = new Set();
|
|
1291
|
-
|
|
1292
|
-
sum.value = pageData
|
|
1293
|
-
.reduce((lastNum, item) => {
|
|
1294
|
-
if (set.has(hashKey(item, allKeys))) return lastNum;
|
|
1295
|
-
set.add(hashKey(item, allKeys));
|
|
1296
|
-
return lastNum.plus(
|
|
1297
|
-
new BigNumber(
|
|
1298
|
-
this.getTableSummaryNumberValue(item[dataIndex])
|
|
1299
|
-
)
|
|
1300
|
-
);
|
|
1301
|
-
}, new BigNumber(0))
|
|
1302
|
-
?.toString();
|
|
1303
|
-
}
|
|
1304
|
-
|
|
1305
|
-
if (argFun === "groupIavg") {
|
|
1306
|
-
const set = new Set();
|
|
1307
|
-
let nums = 0;
|
|
1308
|
-
const allKeys = groupIColumns?.map(({ id }) => id);
|
|
1309
|
-
|
|
1310
|
-
pageData.forEach((item) => {
|
|
1311
|
-
if (set.has(hashKey(item, allKeys))) return;
|
|
1312
|
-
set.add(hashKey(item, allKeys));
|
|
1313
|
-
|
|
1314
|
-
nums++;
|
|
1315
|
-
});
|
|
1316
|
-
|
|
1317
|
-
set.clear();
|
|
1318
|
-
|
|
1319
|
-
sum.value = pageData
|
|
1320
|
-
.reduce((lastNum, item) => {
|
|
1321
|
-
if (set.has(hashKey(item, allKeys))) return lastNum;
|
|
1322
|
-
set.add(hashKey(item, allKeys));
|
|
1323
|
-
return lastNum.plus(
|
|
1324
|
-
new BigNumber(
|
|
1325
|
-
this.getTableSummaryNumberValue(item[dataIndex])
|
|
1326
|
-
).div(nums)
|
|
1327
|
-
);
|
|
1328
|
-
}, new BigNumber(0))
|
|
1329
|
-
?.toString();
|
|
1330
|
-
}
|
|
1331
|
-
|
|
1332
|
-
sum.id = dataIndex;
|
|
1333
|
-
if (argFun === "avg" || argFun === "groupIavg") {
|
|
1334
|
-
sumConfigs["avg"].push(sum);
|
|
1335
|
-
avgLen++;
|
|
1336
|
-
} else sumConfigs["avg"].push({ value: "", id: "" });
|
|
1337
|
-
|
|
1338
|
-
if (argFun === "sum" || argFun === "groupIsum") {
|
|
1339
|
-
sumConfigs["sum"].push(sum);
|
|
1340
|
-
sumLen++;
|
|
1341
|
-
} else sumConfigs["sum"].push({ value: "", id: "" });
|
|
1342
|
-
}
|
|
1343
|
-
|
|
1344
|
-
console.log("sumConfigs", sumConfigs, sumLen, avgLen);
|
|
1345
|
-
|
|
1346
|
-
return (
|
|
1347
|
-
<>
|
|
1348
|
-
{sumLen === 0 ? (
|
|
1349
|
-
<></>
|
|
1350
|
-
) : (
|
|
1351
|
-
<Table.Summary.Row>
|
|
1352
|
-
{sumConfigs["sum"].map(
|
|
1353
|
-
({ id, value, columnConfig }, idx) => (
|
|
1354
|
-
<Table.Summary.Cell
|
|
1355
|
-
align={columnConfig?.align}
|
|
1356
|
-
index={idx}
|
|
1357
|
-
className="zongji"
|
|
1358
|
-
>
|
|
1359
|
-
{value}
|
|
1360
|
-
</Table.Summary.Cell>
|
|
1361
|
-
)
|
|
1362
|
-
)}
|
|
1363
|
-
</Table.Summary.Row>
|
|
1364
|
-
)}
|
|
1365
|
-
{avgLen === 0 ? (
|
|
1366
|
-
<></>
|
|
1367
|
-
) : (
|
|
1368
|
-
<Table.Summary.Row>
|
|
1369
|
-
{sumConfigs["avg"].map(
|
|
1370
|
-
({ id, value, columnConfig }, idx) => (
|
|
1371
|
-
<Table.Summary.Cell
|
|
1372
|
-
align={columnConfig?.align}
|
|
1373
|
-
index={idx}
|
|
1374
|
-
className="zongji"
|
|
1375
|
-
>
|
|
1376
|
-
{value}
|
|
1377
|
-
</Table.Summary.Cell>
|
|
1378
|
-
)
|
|
1379
|
-
)}
|
|
1380
|
-
</Table.Summary.Row>
|
|
1381
|
-
)}
|
|
1382
|
-
</>
|
|
1383
|
-
);
|
|
1384
|
-
}}
|
|
1332
|
+
summary={summary}
|
|
1385
1333
|
loading={loading}
|
|
1386
1334
|
components={{
|
|
1387
1335
|
body: {
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import React, {useEffect, useState} from 'react'
|
|
2
|
+
import "./index.css"
|
|
3
|
+
import { ReportData, ReportTableProps} from "../tmpl/interface";
|
|
4
|
+
|
|
5
|
+
import {Table} from "antd";
|
|
6
|
+
import HcserviceV3 from "../tmpl/hcservice-v3";
|
|
7
|
+
import {useLocale} from "../locale/useLocale";
|
|
8
|
+
import ColumnBuilder from "./column/column-builder";
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
// interface ReportTableState {
|
|
13
|
+
// dataSource?:object[],
|
|
14
|
+
// columnConfigs?:ColumnConfig[],
|
|
15
|
+
// loading?: boolean,
|
|
16
|
+
// };
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
const ReportTable=(props:ReportTableProps)=> {
|
|
20
|
+
|
|
21
|
+
const [loading, setLoading] = useState<boolean>(false);
|
|
22
|
+
const [dataSource, setDataSource] = useState<object[]>(undefined);
|
|
23
|
+
const [reportData, setReportData] = useState<ReportData>(undefined);
|
|
24
|
+
|
|
25
|
+
const { getServiceLangStr, translate} = useLocale();
|
|
26
|
+
const {tableProps,columns,queryKey,serverKey,leftFixedCols}=props
|
|
27
|
+
|
|
28
|
+
useEffect( () => {
|
|
29
|
+
const queryData = async () => {
|
|
30
|
+
if (queryKey) {
|
|
31
|
+
await loadData(queryKey.key,serverKey);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
queryData()
|
|
35
|
+
}, [queryKey?.key]);
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
const loadData = async (
|
|
40
|
+
queryKey: string,serverKey:string
|
|
41
|
+
) => {
|
|
42
|
+
setLoading(true);
|
|
43
|
+
let reportData: ReportData = await HcserviceV3.requestQueryReportData(
|
|
44
|
+
serverKey,
|
|
45
|
+
queryKey,getServiceLangStr()
|
|
46
|
+
);
|
|
47
|
+
if (reportData?.key != queryKey) {
|
|
48
|
+
return;
|
|
49
|
+
} else {
|
|
50
|
+
let dataSource: object[] = [];
|
|
51
|
+
if (reportData.entities) {
|
|
52
|
+
reportData.entities.forEach((item, index) => {
|
|
53
|
+
let row = {
|
|
54
|
+
key: item.code,
|
|
55
|
+
code: item.code, //增加code,为了删除操作
|
|
56
|
+
...item.fieldMap,
|
|
57
|
+
index,
|
|
58
|
+
};
|
|
59
|
+
dataSource.push(row);
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
setDataSource(dataSource);
|
|
64
|
+
setReportData(reportData);
|
|
65
|
+
setLoading(false);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
const addColumnOnCell=(current_cols)=>{
|
|
69
|
+
|
|
70
|
+
if(!reportData){
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
const {rowGrids}=reportData
|
|
74
|
+
current_cols.forEach((c) => {
|
|
75
|
+
if(rowGrids){
|
|
76
|
+
c.onCell=(record,index)=>{
|
|
77
|
+
|
|
78
|
+
let rowGrid= rowGrids[record.code] ;
|
|
79
|
+
if(rowGrid){
|
|
80
|
+
return {
|
|
81
|
+
...rowGrid.cellMap[c.dataIndex]
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
let current_cols=reportData?.columnConfigs?ColumnBuilder.buildReportTableColumns({columnConfigs:reportData.columnConfigs,translate,leftFixedCols}):columns ;
|
|
90
|
+
let table_x = 20;
|
|
91
|
+
|
|
92
|
+
current_cols.forEach((c) => {
|
|
93
|
+
table_x = table_x + (c.width ? c.width : 140);
|
|
94
|
+
});
|
|
95
|
+
addColumnOnCell(current_cols);
|
|
96
|
+
|
|
97
|
+
return <Table
|
|
98
|
+
size={tableProps.size ? tableProps.size : undefined}
|
|
99
|
+
loading={loading}
|
|
100
|
+
//rowSelection={this.getRowSelection()}
|
|
101
|
+
columns={current_cols}
|
|
102
|
+
dataSource={dataSource}
|
|
103
|
+
scroll={
|
|
104
|
+
tableProps.scrollY == -1 || tableProps.scrollY == 0
|
|
105
|
+
? null
|
|
106
|
+
: {
|
|
107
|
+
y: tableProps.scrollY,
|
|
108
|
+
x: table_x,
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
bordered
|
|
112
|
+
pagination={false}
|
|
113
|
+
style={{ display: columns ? "block" : "none" }}></Table>
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export default ReportTable;
|
|
@@ -322,6 +322,22 @@ HCDataSource.requestAddDtmplConfig = async function(
|
|
|
322
322
|
return addDtmplConfigMap.get(key);
|
|
323
323
|
};
|
|
324
324
|
|
|
325
|
+
// HCDataSource.requestReportData = async function(
|
|
326
|
+
// serverKey: string,
|
|
327
|
+
// sourceId: string
|
|
328
|
+
// ) {
|
|
329
|
+
// if (!ltmplConfigMap.has(sourceId)) {
|
|
330
|
+
// ltmplConfigMap.set(
|
|
331
|
+
// sourceId,
|
|
332
|
+
// await HcserviceV3.requestLtmplConfig(serverKey, sourceId)
|
|
333
|
+
// );
|
|
334
|
+
// //加载枚举
|
|
335
|
+
// let res: LtmplConfigRes = ltmplConfigMap.get(sourceId);
|
|
336
|
+
// await loadEnumOfLtmplConfig(serverKey, res.ltmplConfig);
|
|
337
|
+
// }
|
|
338
|
+
// return ltmplConfigMap.get(sourceId);
|
|
339
|
+
// };
|
|
340
|
+
|
|
325
341
|
HCDataSource.getEnums = function(mstrucId: string): EnumItem[] {
|
|
326
342
|
//这里是不是后续可以考虑防止串改
|
|
327
343
|
return enumMap.get(mstrucId);
|
|
@@ -208,6 +208,20 @@ export default class HcserviceV3 {
|
|
|
208
208
|
);
|
|
209
209
|
}
|
|
210
210
|
|
|
211
|
+
static async requestQueryReportData(
|
|
212
|
+
serverKey:string,
|
|
213
|
+
queryKey:string,language:string
|
|
214
|
+
){
|
|
215
|
+
let url="/v3/ltmpl/report-data";
|
|
216
|
+
let res = await Super.super({
|
|
217
|
+
url: url,
|
|
218
|
+
serverKey,
|
|
219
|
+
method: "GET",
|
|
220
|
+
query:{queryKey,language},
|
|
221
|
+
});
|
|
222
|
+
return res;
|
|
223
|
+
}
|
|
224
|
+
|
|
211
225
|
static async requestTtmplRootData(
|
|
212
226
|
serverKey: string,
|
|
213
227
|
sourceId: string,
|