@ztocwst/rc-pro-materials 0.1.26 → 0.1.27
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/build/lowcode/assets-daily.json +11 -11
- package/build/lowcode/assets-dev.json +8 -8
- package/build/lowcode/assets-prod.json +11 -11
- package/build/lowcode/index.js +1 -1
- package/build/lowcode/meta.js +1 -1
- package/build/lowcode/preview.js +5 -5
- package/build/lowcode/render/default/view.css +1 -1
- package/build/lowcode/render/default/view.js +8 -8
- package/build/lowcode/view.css +1 -1
- package/build/lowcode/view.js +9 -9
- package/dist/SCM_Comps.css +1 -1
- package/dist/SCM_Comps.js +9 -9
- package/dist/SCM_Comps.js.map +1 -1
- package/es/components/z-templates-data-common/components/chart-renderer/index.d.ts +14 -0
- package/es/components/z-templates-data-common/components/chart-renderer/index.js +108 -0
- package/es/components/z-templates-data-common/components/custom-renderer/index.d.ts +13 -0
- package/es/components/z-templates-data-common/components/custom-renderer/index.js +161 -0
- package/es/components/z-templates-data-common/components/dim-target/dim-target.helper.d.ts +39 -0
- package/es/components/z-templates-data-common/components/dim-target/dim-target.helper.js +1 -0
- package/es/components/z-templates-data-common/components/dim-target/index.d.ts +16 -0
- package/es/components/z-templates-data-common/components/dim-target/index.js +430 -0
- package/es/components/z-templates-data-common/components/dim-target/index.less +49 -0
- package/es/components/z-templates-data-common/components/dim-target/useUpdateEffect.d.ts +8 -0
- package/es/components/z-templates-data-common/components/dim-target/useUpdateEffect.js +26 -0
- package/es/components/z-templates-data-common/components/link-renderer/index.d.ts +16 -0
- package/es/components/z-templates-data-common/components/link-renderer/index.js +316 -0
- package/es/components/z-templates-data-common/components/link-renderer/index.less +31 -0
- package/es/components/z-templates-data-common/components/table-renderer/index.d.ts +6 -0
- package/es/components/z-templates-data-common/components/table-renderer/index.js +479 -0
- package/es/components/z-templates-data-common/components/table-renderer/table-renderer.helper.d.ts +64 -0
- package/es/components/z-templates-data-common/components/table-renderer/table-renderer.helper.js +219 -0
- package/es/components/z-templates-data-common/data-common.d.ts +102 -0
- package/es/components/z-templates-data-common/data-common.helper.d.ts +61 -0
- package/es/components/z-templates-data-common/data-common.helper.js +330 -0
- package/es/components/z-templates-data-common/data-common.js +141 -0
- package/es/components/z-templates-data-common/index.d.ts +3 -0
- package/es/components/z-templates-data-common/index.js +2 -0
- package/es/index.d.ts +2 -0
- package/es/index.js +1 -0
- package/es/style.js +4 -0
- package/lib/components/z-templates-data-common/components/chart-renderer/index.d.ts +14 -0
- package/lib/components/z-templates-data-common/components/chart-renderer/index.js +116 -0
- package/lib/components/z-templates-data-common/components/custom-renderer/index.d.ts +13 -0
- package/lib/components/z-templates-data-common/components/custom-renderer/index.js +167 -0
- package/lib/components/z-templates-data-common/components/dim-target/dim-target.helper.d.ts +39 -0
- package/lib/components/z-templates-data-common/components/dim-target/dim-target.helper.js +3 -0
- package/lib/components/z-templates-data-common/components/dim-target/index.d.ts +16 -0
- package/lib/components/z-templates-data-common/components/dim-target/index.js +438 -0
- package/lib/components/z-templates-data-common/components/dim-target/index.less +49 -0
- package/lib/components/z-templates-data-common/components/dim-target/useUpdateEffect.d.ts +8 -0
- package/lib/components/z-templates-data-common/components/dim-target/useUpdateEffect.js +30 -0
- package/lib/components/z-templates-data-common/components/link-renderer/index.d.ts +16 -0
- package/lib/components/z-templates-data-common/components/link-renderer/index.js +322 -0
- package/lib/components/z-templates-data-common/components/link-renderer/index.less +31 -0
- package/lib/components/z-templates-data-common/components/table-renderer/index.d.ts +6 -0
- package/lib/components/z-templates-data-common/components/table-renderer/index.js +485 -0
- package/lib/components/z-templates-data-common/components/table-renderer/table-renderer.helper.d.ts +64 -0
- package/lib/components/z-templates-data-common/components/table-renderer/table-renderer.helper.js +228 -0
- package/lib/components/z-templates-data-common/data-common.d.ts +102 -0
- package/lib/components/z-templates-data-common/data-common.helper.d.ts +61 -0
- package/lib/components/z-templates-data-common/data-common.helper.js +349 -0
- package/lib/components/z-templates-data-common/data-common.js +147 -0
- package/lib/components/z-templates-data-common/index.d.ts +3 -0
- package/lib/components/z-templates-data-common/index.js +8 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +4 -2
- package/lib/style.js +4 -0
- package/package.json +3 -3
|
@@ -0,0 +1,479 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _Table from "antd/es/table";
|
|
3
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
4
|
+
function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
5
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
6
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
7
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
8
|
+
import { useRef, useState, useEffect, useImperativeHandle, useContext } from 'react';
|
|
9
|
+
import { ProTable, RcConfigContext } from '@ztocwst/rc-pro';
|
|
10
|
+
import { tableConfigDefault, separator, timeUnit, handleQueryParams, getReportData } from "../../data-common.helper";
|
|
11
|
+
import { handleColumns, handleValueFormat, getDimTargetData } from "./table-renderer.helper";
|
|
12
|
+
import DimTarget from "../dim-target";
|
|
13
|
+
import LinkRenderer from "../link-renderer";
|
|
14
|
+
var TableRenderer = function TableRenderer(props) {
|
|
15
|
+
var _tableOptions$paginat;
|
|
16
|
+
var activeKey = props.activeKey,
|
|
17
|
+
autoLoad = props.autoLoad,
|
|
18
|
+
refreshRate = props.refreshRate,
|
|
19
|
+
dataSetName = props.dataSetName,
|
|
20
|
+
remember = props.remember,
|
|
21
|
+
exporter = props.exporter,
|
|
22
|
+
exportConfig = props.exportConfig,
|
|
23
|
+
dimJson = props.dimJson,
|
|
24
|
+
indexJson = props.indexJson,
|
|
25
|
+
expressions = props.expressions,
|
|
26
|
+
linkPage = props.linkPage,
|
|
27
|
+
queryBind = props.queryBind,
|
|
28
|
+
chartRef = props.chartRef,
|
|
29
|
+
onConfirm = props.onConfirm,
|
|
30
|
+
formatter = props.formatter;
|
|
31
|
+
var dimTargetRef = useRef(null);
|
|
32
|
+
var queryCacheRef = useRef(null);
|
|
33
|
+
var tableRef = useRef(null);
|
|
34
|
+
var _useState = useState(false),
|
|
35
|
+
loading = _useState[0],
|
|
36
|
+
setLoading = _useState[1];
|
|
37
|
+
var _useState2 = useState(tableConfigDefault),
|
|
38
|
+
config = _useState2[0],
|
|
39
|
+
setConfig = _useState2[1];
|
|
40
|
+
/** 维度指标初始数据 */
|
|
41
|
+
var _useState3 = useState(),
|
|
42
|
+
dimTargetValue = _useState3[0],
|
|
43
|
+
setDimTargetValue = _useState3[1];
|
|
44
|
+
/** 合计 数据 */
|
|
45
|
+
var amounted = useRef({});
|
|
46
|
+
var rcProContext = useContext(RcConfigContext);
|
|
47
|
+
var _ref = rcProContext || {},
|
|
48
|
+
BASE_URL = _ref.BASE_URL,
|
|
49
|
+
_ref$tableOptions = _ref.tableOptions,
|
|
50
|
+
tableOptions = _ref$tableOptions === void 0 ? {} : _ref$tableOptions;
|
|
51
|
+
var defaultPageSize = (tableOptions === null || tableOptions === void 0 ? void 0 : (_tableOptions$paginat = tableOptions.pagination) === null || _tableOptions$paginat === void 0 ? void 0 : _tableOptions$paginat.defaultPageSize) || 20;
|
|
52
|
+
var _useState4 = useState(false),
|
|
53
|
+
isLink = _useState4[0],
|
|
54
|
+
setIsLink = _useState4[1];
|
|
55
|
+
var linkChartRef = useRef();
|
|
56
|
+
var timer = null;
|
|
57
|
+
var getDimTargetValues = function getDimTargetValues() {
|
|
58
|
+
var _dimTargetRef$current;
|
|
59
|
+
return (dimTargetRef === null || dimTargetRef === void 0 ? void 0 : (_dimTargetRef$current = dimTargetRef.current) === null || _dimTargetRef$current === void 0 ? void 0 : _dimTargetRef$current.getDimTargetValues()) || {};
|
|
60
|
+
};
|
|
61
|
+
var buttons = [{
|
|
62
|
+
name: '确认',
|
|
63
|
+
action: 'btn',
|
|
64
|
+
props: {
|
|
65
|
+
loading: loading,
|
|
66
|
+
type: 'primary'
|
|
67
|
+
},
|
|
68
|
+
onClick: function onClick() {
|
|
69
|
+
var option = getDimTargetValues();
|
|
70
|
+
handleUpdateColumns(option);
|
|
71
|
+
onConfirm === null || onConfirm === void 0 ? void 0 : onConfirm();
|
|
72
|
+
}
|
|
73
|
+
}, exporter ? {
|
|
74
|
+
action: 'btn',
|
|
75
|
+
name: exportConfig === null || exportConfig === void 0 ? void 0 : exportConfig.name,
|
|
76
|
+
fileConfig: {
|
|
77
|
+
type: 'export',
|
|
78
|
+
params: {
|
|
79
|
+
menuId: exportConfig === null || exportConfig === void 0 ? void 0 : exportConfig.menuId,
|
|
80
|
+
operateType: 'EXPORT'
|
|
81
|
+
},
|
|
82
|
+
request: {
|
|
83
|
+
submit: {
|
|
84
|
+
url: BASE_URL + "/data/forward/v1/bigdata/report/" + dataSetName + "/export",
|
|
85
|
+
method: 'POST',
|
|
86
|
+
formatter: function () {
|
|
87
|
+
var _formatter = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(values) {
|
|
88
|
+
var bigDataBody, _ref2, _ref2$temp, temp;
|
|
89
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
90
|
+
while (1) switch (_context.prev = _context.next) {
|
|
91
|
+
case 0:
|
|
92
|
+
bigDataBody = getBigDataBody();
|
|
93
|
+
_ref2 = values || {}, _ref2$temp = _ref2.temp, temp = _ref2$temp === void 0 ? {} : _ref2$temp;
|
|
94
|
+
return _context.abrupt("return", {
|
|
95
|
+
buttonCode: exportConfig === null || exportConfig === void 0 ? void 0 : exportConfig.code,
|
|
96
|
+
templateId: temp === null || temp === void 0 ? void 0 : temp.value,
|
|
97
|
+
bigDataBody: bigDataBody
|
|
98
|
+
});
|
|
99
|
+
case 3:
|
|
100
|
+
case "end":
|
|
101
|
+
return _context.stop();
|
|
102
|
+
}
|
|
103
|
+
}, _callee);
|
|
104
|
+
}));
|
|
105
|
+
function formatter(_x) {
|
|
106
|
+
return _formatter.apply(this, arguments);
|
|
107
|
+
}
|
|
108
|
+
return formatter;
|
|
109
|
+
}()
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
} : null];
|
|
114
|
+
var summary = function summary() {
|
|
115
|
+
var _getDimTargetValues = getDimTargetValues(),
|
|
116
|
+
_getDimTargetValues$d = _getDimTargetValues.dimension,
|
|
117
|
+
dimension = _getDimTargetValues$d === void 0 ? [] : _getDimTargetValues$d,
|
|
118
|
+
_getDimTargetValues$i = _getDimTargetValues.index,
|
|
119
|
+
index = _getDimTargetValues$i === void 0 ? [] : _getDimTargetValues$i,
|
|
120
|
+
_getDimTargetValues$i2 = _getDimTargetValues.indexSource,
|
|
121
|
+
indexSource = _getDimTargetValues$i2 === void 0 ? [] : _getDimTargetValues$i2;
|
|
122
|
+
var indexAmounted = indexSource === null || indexSource === void 0 ? void 0 : indexSource.filter(function (cur) {
|
|
123
|
+
return cur.amounted;
|
|
124
|
+
});
|
|
125
|
+
if (!indexAmounted.length) return;
|
|
126
|
+
var summaryColumns = ['总计'].concat(dimension, index);
|
|
127
|
+
return /*#__PURE__*/React.createElement(_Table.Summary, {
|
|
128
|
+
fixed: true
|
|
129
|
+
}, /*#__PURE__*/React.createElement(_Table.Summary.Row, null, summaryColumns.map(function (name, idx) {
|
|
130
|
+
var find = indexSource === null || indexSource === void 0 ? void 0 : indexSource.find(function (item) {
|
|
131
|
+
return item.alias === name || item.name === name;
|
|
132
|
+
});
|
|
133
|
+
var dataIndex = find === null || find === void 0 ? void 0 : find.name;
|
|
134
|
+
return /*#__PURE__*/React.createElement(_Table.Summary.Cell, {
|
|
135
|
+
key: idx === null || idx === void 0 ? void 0 : idx.toString(),
|
|
136
|
+
index: idx
|
|
137
|
+
}, !idx ? name : dataIndex ? handleValueFormat(amounted.current[dataIndex], amounted.current, find) : '');
|
|
138
|
+
})));
|
|
139
|
+
};
|
|
140
|
+
var onLink = function onLink(values) {
|
|
141
|
+
var _linkChartRef$current, _linkChartRef$current2;
|
|
142
|
+
var _getDimTargetValues2 = getDimTargetValues(),
|
|
143
|
+
_getDimTargetValues2$ = _getDimTargetValues2.dimension,
|
|
144
|
+
dimension = _getDimTargetValues2$ === void 0 ? [] : _getDimTargetValues2$;
|
|
145
|
+
setIsLink(true);
|
|
146
|
+
(_linkChartRef$current = linkChartRef.current) === null || _linkChartRef$current === void 0 ? void 0 : (_linkChartRef$current2 = _linkChartRef$current.initial) === null || _linkChartRef$current2 === void 0 ? void 0 : _linkChartRef$current2.call(_linkChartRef$current, _extends({}, values, {
|
|
147
|
+
dimension: dimension
|
|
148
|
+
}));
|
|
149
|
+
};
|
|
150
|
+
var handleUpdateColumns = /*#__PURE__*/function () {
|
|
151
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(option) {
|
|
152
|
+
var _tableRef$current;
|
|
153
|
+
var columns;
|
|
154
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
155
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
156
|
+
case 0:
|
|
157
|
+
columns = handleColumns(option, expressions, onLink);
|
|
158
|
+
(_tableRef$current = tableRef.current) === null || _tableRef$current === void 0 ? void 0 : _tableRef$current.updateColumns(columns);
|
|
159
|
+
case 2:
|
|
160
|
+
case "end":
|
|
161
|
+
return _context2.stop();
|
|
162
|
+
}
|
|
163
|
+
}, _callee2);
|
|
164
|
+
}));
|
|
165
|
+
return function handleUpdateColumns(_x2) {
|
|
166
|
+
return _ref3.apply(this, arguments);
|
|
167
|
+
};
|
|
168
|
+
}();
|
|
169
|
+
var getBigDataBody = function getBigDataBody(params) {
|
|
170
|
+
if (params === void 0) {
|
|
171
|
+
params = {};
|
|
172
|
+
}
|
|
173
|
+
var _getDimTargetValues3 = getDimTargetValues(),
|
|
174
|
+
_getDimTargetValues3$ = _getDimTargetValues3.dimension,
|
|
175
|
+
dimension = _getDimTargetValues3$ === void 0 ? [] : _getDimTargetValues3$,
|
|
176
|
+
_getDimTargetValues3$2 = _getDimTargetValues3.dimensionSource,
|
|
177
|
+
dimensionSource = _getDimTargetValues3$2 === void 0 ? [] : _getDimTargetValues3$2,
|
|
178
|
+
_getDimTargetValues3$3 = _getDimTargetValues3.index,
|
|
179
|
+
index = _getDimTargetValues3$3 === void 0 ? [] : _getDimTargetValues3$3,
|
|
180
|
+
_getDimTargetValues3$4 = _getDimTargetValues3.indexSource,
|
|
181
|
+
indexSource = _getDimTargetValues3$4 === void 0 ? [] : _getDimTargetValues3$4;
|
|
182
|
+
|
|
183
|
+
/** 通过 queryBind查看是否有绑定关系 有的话替换成绑定关系中的key 没有则是默认配置的key */
|
|
184
|
+
var queryCache = queryCacheRef.current;
|
|
185
|
+
var query = {};
|
|
186
|
+
var queryKeys = Object.keys(queryCache);
|
|
187
|
+
if (queryKeys !== null && queryKeys !== void 0 && queryKeys.length) {
|
|
188
|
+
queryKeys.forEach(function (k) {
|
|
189
|
+
var _queryBind$find;
|
|
190
|
+
// "键"(有建立绑定关系 取当前数据源参数(paraJson)的"键",没有则是默认查询配置的"键")
|
|
191
|
+
var key = (queryBind === null || queryBind === void 0 ? void 0 : (_queryBind$find = queryBind.find(function (item) {
|
|
192
|
+
return (item === null || item === void 0 ? void 0 : item.currentQueryKey) === k;
|
|
193
|
+
})) === null || _queryBind$find === void 0 ? void 0 : _queryBind$find.sourceQueryKey) || k;
|
|
194
|
+
query[key] = queryCache[k];
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/** 维度收集 */
|
|
199
|
+
var dim = [];
|
|
200
|
+
for (var _iterator = _createForOfIteratorHelperLoose(dimensionSource), _step; !(_step = _iterator()).done;) {
|
|
201
|
+
var cur = _step.value;
|
|
202
|
+
if (dimension.includes(cur.alias || cur.description)) {
|
|
203
|
+
dim.push({
|
|
204
|
+
name: cur.name,
|
|
205
|
+
description: cur.description
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/** 指标收集 */
|
|
211
|
+
var target = [];
|
|
212
|
+
for (var _iterator2 = _createForOfIteratorHelperLoose(indexSource), _step2; !(_step2 = _iterator2()).done;) {
|
|
213
|
+
var _cur = _step2.value;
|
|
214
|
+
if (index.includes(_cur.alias || _cur.name)) {
|
|
215
|
+
target.push({
|
|
216
|
+
description: _cur.name
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
var queryParams = handleQueryParams(query);
|
|
221
|
+
var data = _extends({
|
|
222
|
+
queryParams: queryParams,
|
|
223
|
+
dim: dim,
|
|
224
|
+
target: target
|
|
225
|
+
}, params, {
|
|
226
|
+
pageNum: 1,
|
|
227
|
+
pageSize: defaultPageSize,
|
|
228
|
+
dataSetName: dataSetName
|
|
229
|
+
});
|
|
230
|
+
return formatter ? formatter === null || formatter === void 0 ? void 0 : formatter(data) : data;
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
// 获取数据源
|
|
234
|
+
var getDataSource = /*#__PURE__*/function () {
|
|
235
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(params) {
|
|
236
|
+
var data, _yield$getReportData, success, _yield$getReportData$, result;
|
|
237
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
238
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
239
|
+
case 0:
|
|
240
|
+
if (params === void 0) {
|
|
241
|
+
params = {};
|
|
242
|
+
}
|
|
243
|
+
if (!loading) {
|
|
244
|
+
_context3.next = 3;
|
|
245
|
+
break;
|
|
246
|
+
}
|
|
247
|
+
return _context3.abrupt("return");
|
|
248
|
+
case 3:
|
|
249
|
+
_context3.prev = 3;
|
|
250
|
+
data = getBigDataBody(params);
|
|
251
|
+
setLoading(true);
|
|
252
|
+
_context3.next = 8;
|
|
253
|
+
return getReportData(rcProContext, data);
|
|
254
|
+
case 8:
|
|
255
|
+
_yield$getReportData = _context3.sent;
|
|
256
|
+
success = _yield$getReportData.success;
|
|
257
|
+
_yield$getReportData$ = _yield$getReportData.result;
|
|
258
|
+
result = _yield$getReportData$ === void 0 ? {} : _yield$getReportData$;
|
|
259
|
+
setLoading(false);
|
|
260
|
+
return _context3.abrupt("return", {
|
|
261
|
+
success: success,
|
|
262
|
+
result: result
|
|
263
|
+
});
|
|
264
|
+
case 16:
|
|
265
|
+
_context3.prev = 16;
|
|
266
|
+
_context3.t0 = _context3["catch"](3);
|
|
267
|
+
setLoading(false);
|
|
268
|
+
console.error(_context3.t0);
|
|
269
|
+
case 20:
|
|
270
|
+
case "end":
|
|
271
|
+
return _context3.stop();
|
|
272
|
+
}
|
|
273
|
+
}, _callee3, null, [[3, 16]]);
|
|
274
|
+
}));
|
|
275
|
+
return function getDataSource(_x3) {
|
|
276
|
+
return _ref4.apply(this, arguments);
|
|
277
|
+
};
|
|
278
|
+
}();
|
|
279
|
+
var initial = /*#__PURE__*/function () {
|
|
280
|
+
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(params) {
|
|
281
|
+
var result, dims, targets, option;
|
|
282
|
+
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
283
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
284
|
+
case 0:
|
|
285
|
+
_context4.next = 2;
|
|
286
|
+
return getDimTargetData(rcProContext, _extends({
|
|
287
|
+
dataSetName: dataSetName
|
|
288
|
+
}, params), {
|
|
289
|
+
dimJson: dimJson,
|
|
290
|
+
indexJson: indexJson
|
|
291
|
+
});
|
|
292
|
+
case 2:
|
|
293
|
+
result = _context4.sent;
|
|
294
|
+
if (result) {
|
|
295
|
+
dims = result.dims, targets = result.targets;
|
|
296
|
+
option = {
|
|
297
|
+
dimension: dims === null || dims === void 0 ? void 0 : dims.dimension,
|
|
298
|
+
dimensionSource: dims === null || dims === void 0 ? void 0 : dims.dimensionSource,
|
|
299
|
+
index: targets === null || targets === void 0 ? void 0 : targets.index,
|
|
300
|
+
indexSource: targets === null || targets === void 0 ? void 0 : targets.indexSource
|
|
301
|
+
};
|
|
302
|
+
handleUpdateColumns(option);
|
|
303
|
+
setDimTargetValue(result);
|
|
304
|
+
setConfig(_extends({}, tableConfigDefault, {
|
|
305
|
+
pagination: {
|
|
306
|
+
showSizeChanger: true,
|
|
307
|
+
defaultPageSize: defaultPageSize
|
|
308
|
+
},
|
|
309
|
+
summary: summary,
|
|
310
|
+
request: function request(data) {
|
|
311
|
+
var _data$pagination, _data$pagination2, _data$sorter;
|
|
312
|
+
var pagination = {
|
|
313
|
+
pageNum: (_data$pagination = data.pagination) === null || _data$pagination === void 0 ? void 0 : _data$pagination.current,
|
|
314
|
+
pageSize: (_data$pagination2 = data.pagination) === null || _data$pagination2 === void 0 ? void 0 : _data$pagination2.pageSize
|
|
315
|
+
};
|
|
316
|
+
var orderBy = [];
|
|
317
|
+
if ((_data$sorter = data.sorter) !== null && _data$sorter !== void 0 && _data$sorter.order) {
|
|
318
|
+
var _data$sorter2, _data$sorter3, _data$sorter3$order;
|
|
319
|
+
orderBy.push({
|
|
320
|
+
name: (_data$sorter2 = data.sorter) === null || _data$sorter2 === void 0 ? void 0 : _data$sorter2.field,
|
|
321
|
+
sort: (_data$sorter3 = data.sorter) === null || _data$sorter3 === void 0 ? void 0 : (_data$sorter3$order = _data$sorter3.order) === null || _data$sorter3$order === void 0 ? void 0 : _data$sorter3$order.slice(0, -3)
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
return getDataSource(_extends({}, pagination, {
|
|
325
|
+
orderBy: orderBy
|
|
326
|
+
}));
|
|
327
|
+
}
|
|
328
|
+
}));
|
|
329
|
+
}
|
|
330
|
+
case 4:
|
|
331
|
+
case "end":
|
|
332
|
+
return _context4.stop();
|
|
333
|
+
}
|
|
334
|
+
}, _callee4);
|
|
335
|
+
}));
|
|
336
|
+
return function initial(_x4) {
|
|
337
|
+
return _ref5.apply(this, arguments);
|
|
338
|
+
};
|
|
339
|
+
}();
|
|
340
|
+
useEffect(function () {
|
|
341
|
+
if (dataSetName) {
|
|
342
|
+
initial();
|
|
343
|
+
}
|
|
344
|
+
}, [dataSetName, dimJson, indexJson]);
|
|
345
|
+
var handleClearInterval = function handleClearInterval() {
|
|
346
|
+
if (timer) {
|
|
347
|
+
clearInterval(timer);
|
|
348
|
+
timer = null;
|
|
349
|
+
}
|
|
350
|
+
};
|
|
351
|
+
useEffect(function () {
|
|
352
|
+
var _ref6 = (activeKey === null || activeKey === void 0 ? void 0 : activeKey.split(separator)) || [],
|
|
353
|
+
currentKey = _ref6[0];
|
|
354
|
+
if (currentKey === dataSetName) {
|
|
355
|
+
if (autoLoad) {
|
|
356
|
+
if (refreshRate) {
|
|
357
|
+
handleClearInterval();
|
|
358
|
+
timer = window.setInterval(function () {
|
|
359
|
+
return onConfirm === null || onConfirm === void 0 ? void 0 : onConfirm();
|
|
360
|
+
}, refreshRate * timeUnit);
|
|
361
|
+
} else {
|
|
362
|
+
onConfirm === null || onConfirm === void 0 ? void 0 : onConfirm();
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
} else {
|
|
366
|
+
handleClearInterval();
|
|
367
|
+
}
|
|
368
|
+
return function () {
|
|
369
|
+
handleClearInterval();
|
|
370
|
+
};
|
|
371
|
+
}, [activeKey, autoLoad]);
|
|
372
|
+
var queryChart = /*#__PURE__*/function () {
|
|
373
|
+
var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(value) {
|
|
374
|
+
var _linkChartRef$current3;
|
|
375
|
+
return _regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
376
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
377
|
+
case 0:
|
|
378
|
+
if (isLink) {
|
|
379
|
+
(_linkChartRef$current3 = linkChartRef.current) === null || _linkChartRef$current3 === void 0 ? void 0 : _linkChartRef$current3.queryChart(value);
|
|
380
|
+
} else {
|
|
381
|
+
queryCacheRef.current = value[dataSetName] || value;
|
|
382
|
+
setTimeout( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
|
|
383
|
+
var _tableRef$current2;
|
|
384
|
+
var _getDimTargetValues4, _getDimTargetValues4$, indexSource, indexAmounted, target, _iterator3, _step3, cur, _ref9, success, _ref9$result, result, _result$data, _result$data$, data;
|
|
385
|
+
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
386
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
387
|
+
case 0:
|
|
388
|
+
(_tableRef$current2 = tableRef.current) === null || _tableRef$current2 === void 0 ? void 0 : _tableRef$current2.refreshTable({
|
|
389
|
+
current: 1
|
|
390
|
+
});
|
|
391
|
+
_getDimTargetValues4 = getDimTargetValues(), _getDimTargetValues4$ = _getDimTargetValues4.indexSource, indexSource = _getDimTargetValues4$ === void 0 ? [] : _getDimTargetValues4$;
|
|
392
|
+
indexAmounted = indexSource === null || indexSource === void 0 ? void 0 : indexSource.filter(function (cur) {
|
|
393
|
+
return cur.amounted;
|
|
394
|
+
});
|
|
395
|
+
if (!(indexAmounted !== null && indexAmounted !== void 0 && indexAmounted.length)) {
|
|
396
|
+
_context5.next = 16;
|
|
397
|
+
break;
|
|
398
|
+
}
|
|
399
|
+
target = [];
|
|
400
|
+
for (_iterator3 = _createForOfIteratorHelperLoose(indexAmounted); !(_step3 = _iterator3()).done;) {
|
|
401
|
+
cur = _step3.value;
|
|
402
|
+
target.push({
|
|
403
|
+
description: cur.name
|
|
404
|
+
});
|
|
405
|
+
}
|
|
406
|
+
_context5.next = 8;
|
|
407
|
+
return getDataSource({
|
|
408
|
+
dim: [],
|
|
409
|
+
target: target
|
|
410
|
+
});
|
|
411
|
+
case 8:
|
|
412
|
+
_context5.t0 = _context5.sent;
|
|
413
|
+
if (_context5.t0) {
|
|
414
|
+
_context5.next = 11;
|
|
415
|
+
break;
|
|
416
|
+
}
|
|
417
|
+
_context5.t0 = {};
|
|
418
|
+
case 11:
|
|
419
|
+
_ref9 = _context5.t0;
|
|
420
|
+
success = _ref9.success;
|
|
421
|
+
_ref9$result = _ref9.result;
|
|
422
|
+
result = _ref9$result === void 0 ? {} : _ref9$result;
|
|
423
|
+
if (success) {
|
|
424
|
+
_result$data = result === null || result === void 0 ? void 0 : result.data, _result$data$ = _result$data[0], data = _result$data$ === void 0 ? {} : _result$data$;
|
|
425
|
+
amounted.current = data;
|
|
426
|
+
}
|
|
427
|
+
case 16:
|
|
428
|
+
case "end":
|
|
429
|
+
return _context5.stop();
|
|
430
|
+
}
|
|
431
|
+
}, _callee5);
|
|
432
|
+
})), 200);
|
|
433
|
+
}
|
|
434
|
+
case 1:
|
|
435
|
+
case "end":
|
|
436
|
+
return _context6.stop();
|
|
437
|
+
}
|
|
438
|
+
}, _callee6);
|
|
439
|
+
}));
|
|
440
|
+
return function queryChart(_x5) {
|
|
441
|
+
return _ref7.apply(this, arguments);
|
|
442
|
+
};
|
|
443
|
+
}();
|
|
444
|
+
useImperativeHandle(chartRef, function () {
|
|
445
|
+
return {
|
|
446
|
+
onLink: onLink,
|
|
447
|
+
queryChart: queryChart
|
|
448
|
+
};
|
|
449
|
+
});
|
|
450
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
451
|
+
style: {
|
|
452
|
+
display: !isLink ? 'block' : 'none'
|
|
453
|
+
}
|
|
454
|
+
}, /*#__PURE__*/React.createElement(DimTarget, {
|
|
455
|
+
dimTargetRef: dimTargetRef,
|
|
456
|
+
value: dimTargetValue,
|
|
457
|
+
remember: remember,
|
|
458
|
+
dataSetName: dataSetName,
|
|
459
|
+
buttons: buttons.filter(function (item) {
|
|
460
|
+
return item;
|
|
461
|
+
})
|
|
462
|
+
}), /*#__PURE__*/React.createElement(ProTable, {
|
|
463
|
+
ref: tableRef,
|
|
464
|
+
config: config
|
|
465
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
466
|
+
style: {
|
|
467
|
+
display: isLink ? 'block' : 'none'
|
|
468
|
+
}
|
|
469
|
+
}, /*#__PURE__*/React.createElement(LinkRenderer, {
|
|
470
|
+
chartRef: linkChartRef,
|
|
471
|
+
dimJson: dimJson,
|
|
472
|
+
linkPage: linkPage,
|
|
473
|
+
onConfirm: onConfirm,
|
|
474
|
+
onBack: function onBack() {
|
|
475
|
+
setIsLink(false);
|
|
476
|
+
}
|
|
477
|
+
})));
|
|
478
|
+
};
|
|
479
|
+
export default TableRenderer;
|
package/es/components/z-templates-data-common/components/table-renderer/table-renderer.helper.d.ts
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { TypeChartSettingProps } from '../../data-common';
|
|
2
|
+
import type { linkParamsType } from '../link-renderer';
|
|
3
|
+
import type { DimTargetChangeOptionType } from '../dim-target/dim-target.helper';
|
|
4
|
+
import type { valueType } from '../../data-common.helper';
|
|
5
|
+
export declare const stringTrim: (str: string) => string;
|
|
6
|
+
/**
|
|
7
|
+
* 维度指标数据源处理
|
|
8
|
+
*/
|
|
9
|
+
export declare const handleDimTargetFormat: (dimTargetSource: Pick<TypeChartSettingProps, 'dimJson' | 'indexJson'>, result?: Record<string, any>) => {
|
|
10
|
+
rememberCheck: boolean;
|
|
11
|
+
dims: {
|
|
12
|
+
all: boolean;
|
|
13
|
+
title: string;
|
|
14
|
+
indeterminate: boolean;
|
|
15
|
+
dimension: any[];
|
|
16
|
+
dimensionSource: Omit<import("../../data-common").TypeTargetProps, "amounted" | "enName" | "isFilter">[];
|
|
17
|
+
};
|
|
18
|
+
targets: {
|
|
19
|
+
all: boolean;
|
|
20
|
+
title: string;
|
|
21
|
+
indeterminate: boolean;
|
|
22
|
+
index: any[];
|
|
23
|
+
indexSource: import("../../data-common").TypeTargetProps[];
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* 获取维度指标数据源
|
|
28
|
+
*/
|
|
29
|
+
export declare const getDimTargetData: (rcProContext: any, params: Record<string, any>, dimTargetSource: Pick<TypeChartSettingProps, 'dimJson' | 'indexJson'>) => Promise<{
|
|
30
|
+
rememberCheck: boolean;
|
|
31
|
+
dims: {
|
|
32
|
+
all: boolean;
|
|
33
|
+
title: string;
|
|
34
|
+
indeterminate: boolean;
|
|
35
|
+
dimension: any[];
|
|
36
|
+
dimensionSource: Omit<import("../../data-common").TypeTargetProps, "amounted" | "enName" | "isFilter">[];
|
|
37
|
+
};
|
|
38
|
+
targets: {
|
|
39
|
+
all: boolean;
|
|
40
|
+
title: string;
|
|
41
|
+
indeterminate: boolean;
|
|
42
|
+
index: any[];
|
|
43
|
+
indexSource: import("../../data-common").TypeTargetProps[];
|
|
44
|
+
};
|
|
45
|
+
}>;
|
|
46
|
+
/**
|
|
47
|
+
* 数据渲染格式处理
|
|
48
|
+
*/
|
|
49
|
+
export declare const handleValueFormat: (value: valueType, record: Record<string, any>, find?: Record<string, any>, condition?: any[], onLink?: () => void) => any;
|
|
50
|
+
/**
|
|
51
|
+
* 条件格式
|
|
52
|
+
*/
|
|
53
|
+
export type ExpressionsType = any[] | [];
|
|
54
|
+
/**
|
|
55
|
+
* 根据维度指标获取表格列
|
|
56
|
+
*/
|
|
57
|
+
export declare const handleColumns: (option: DimTargetChangeOptionType, expressions?: ExpressionsType, onLink?: (v: linkParamsType) => void) => {
|
|
58
|
+
title: import("antd/es/checkbox/Group").CheckboxValueType;
|
|
59
|
+
dataIndex: string;
|
|
60
|
+
ellipsis: boolean;
|
|
61
|
+
sorter: any;
|
|
62
|
+
width: any;
|
|
63
|
+
render: (value: valueType, record: Record<string, any>) => any;
|
|
64
|
+
}[];
|