@ztocwst/rc-pro-materials 0.1.26 → 0.1.28

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.
Files changed (74) hide show
  1. package/build/lowcode/assets-daily.json +11 -11
  2. package/build/lowcode/assets-dev.json +8 -8
  3. package/build/lowcode/assets-prod.json +11 -11
  4. package/build/lowcode/designer.html +2 -2
  5. package/build/lowcode/index.html +2 -2
  6. package/build/lowcode/index.js +1 -1
  7. package/build/lowcode/meta.js +1 -1
  8. package/build/lowcode/preview.js +5 -5
  9. package/build/lowcode/render/default/view.css +1 -1
  10. package/build/lowcode/render/default/view.js +8 -8
  11. package/build/lowcode/view.css +1 -1
  12. package/build/lowcode/view.js +9 -9
  13. package/dist/SCM_Comps.css +1 -1
  14. package/dist/SCM_Comps.js +9 -9
  15. package/dist/SCM_Comps.js.map +1 -1
  16. package/es/components/z-templates-data-common/components/chart-renderer/index.d.ts +14 -0
  17. package/es/components/z-templates-data-common/components/chart-renderer/index.js +108 -0
  18. package/es/components/z-templates-data-common/components/custom-renderer/index.d.ts +13 -0
  19. package/es/components/z-templates-data-common/components/custom-renderer/index.js +161 -0
  20. package/es/components/z-templates-data-common/components/dim-target/dim-target.helper.d.ts +39 -0
  21. package/es/components/z-templates-data-common/components/dim-target/dim-target.helper.js +1 -0
  22. package/es/components/z-templates-data-common/components/dim-target/index.d.ts +16 -0
  23. package/es/components/z-templates-data-common/components/dim-target/index.js +430 -0
  24. package/es/components/z-templates-data-common/components/dim-target/index.less +49 -0
  25. package/es/components/z-templates-data-common/components/dim-target/useUpdateEffect.d.ts +8 -0
  26. package/es/components/z-templates-data-common/components/dim-target/useUpdateEffect.js +26 -0
  27. package/es/components/z-templates-data-common/components/link-renderer/index.d.ts +16 -0
  28. package/es/components/z-templates-data-common/components/link-renderer/index.js +316 -0
  29. package/es/components/z-templates-data-common/components/link-renderer/index.less +31 -0
  30. package/es/components/z-templates-data-common/components/table-renderer/index.d.ts +6 -0
  31. package/es/components/z-templates-data-common/components/table-renderer/index.js +479 -0
  32. package/es/components/z-templates-data-common/components/table-renderer/table-renderer.helper.d.ts +64 -0
  33. package/es/components/z-templates-data-common/components/table-renderer/table-renderer.helper.js +219 -0
  34. package/es/components/z-templates-data-common/data-common.d.ts +102 -0
  35. package/es/components/z-templates-data-common/data-common.helper.d.ts +61 -0
  36. package/es/components/z-templates-data-common/data-common.helper.js +332 -0
  37. package/es/components/z-templates-data-common/data-common.js +141 -0
  38. package/es/components/z-templates-data-common/index.d.ts +3 -0
  39. package/es/components/z-templates-data-common/index.js +2 -0
  40. package/es/index.d.ts +2 -0
  41. package/es/index.js +1 -0
  42. package/es/style.js +8 -0
  43. package/es/utils/rcProRequest.d.ts +2 -0
  44. package/es/utils/rcProRequest.js +30 -0
  45. package/lib/components/z-templates-data-common/components/chart-renderer/index.d.ts +14 -0
  46. package/lib/components/z-templates-data-common/components/chart-renderer/index.js +116 -0
  47. package/lib/components/z-templates-data-common/components/custom-renderer/index.d.ts +13 -0
  48. package/lib/components/z-templates-data-common/components/custom-renderer/index.js +167 -0
  49. package/lib/components/z-templates-data-common/components/dim-target/dim-target.helper.d.ts +39 -0
  50. package/lib/components/z-templates-data-common/components/dim-target/dim-target.helper.js +3 -0
  51. package/lib/components/z-templates-data-common/components/dim-target/index.d.ts +16 -0
  52. package/lib/components/z-templates-data-common/components/dim-target/index.js +438 -0
  53. package/lib/components/z-templates-data-common/components/dim-target/index.less +49 -0
  54. package/lib/components/z-templates-data-common/components/dim-target/useUpdateEffect.d.ts +8 -0
  55. package/lib/components/z-templates-data-common/components/dim-target/useUpdateEffect.js +30 -0
  56. package/lib/components/z-templates-data-common/components/link-renderer/index.d.ts +16 -0
  57. package/lib/components/z-templates-data-common/components/link-renderer/index.js +322 -0
  58. package/lib/components/z-templates-data-common/components/link-renderer/index.less +31 -0
  59. package/lib/components/z-templates-data-common/components/table-renderer/index.d.ts +6 -0
  60. package/lib/components/z-templates-data-common/components/table-renderer/index.js +485 -0
  61. package/lib/components/z-templates-data-common/components/table-renderer/table-renderer.helper.d.ts +64 -0
  62. package/lib/components/z-templates-data-common/components/table-renderer/table-renderer.helper.js +228 -0
  63. package/lib/components/z-templates-data-common/data-common.d.ts +102 -0
  64. package/lib/components/z-templates-data-common/data-common.helper.d.ts +61 -0
  65. package/lib/components/z-templates-data-common/data-common.helper.js +350 -0
  66. package/lib/components/z-templates-data-common/data-common.js +147 -0
  67. package/lib/components/z-templates-data-common/index.d.ts +3 -0
  68. package/lib/components/z-templates-data-common/index.js +8 -0
  69. package/lib/index.d.ts +2 -0
  70. package/lib/index.js +4 -2
  71. package/lib/style.js +4 -0
  72. package/lib/utils/rcProRequest.d.ts +2 -0
  73. package/lib/utils/rcProRequest.js +36 -0
  74. package/package.json +3 -3
@@ -0,0 +1,316 @@
1
+ import _Radio from "antd/es/radio";
2
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
+ import _extends from "@babel/runtime/helpers/extends";
4
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
5
+ import { useEffect, useState, useRef, useContext, useImperativeHandle } from 'react';
6
+ import { ProTable, RcConfigContext } from '@ztocwst/rc-pro';
7
+ import { ArrowLeftOutlined } from '@ant-design/icons';
8
+ import { tableConfigDefault, separator, timeUnit, getMaxWidth, handleQueryParams, getReportData } from "../../data-common.helper";
9
+ import { handleDimTargetFormat, handleColumns } from "../table-renderer/table-renderer.helper";
10
+ import "./index.less";
11
+ var linkStateDefault = {
12
+ dataSetName: '',
13
+ autoLoad: false,
14
+ refreshRate: 0
15
+ };
16
+ var LinkRenderer = function LinkRenderer(props) {
17
+ var _tableOptions$paginat, _linkPage$filter;
18
+ var dimJson = props.dimJson,
19
+ linkPage = props.linkPage,
20
+ chartRef = props.chartRef,
21
+ onConfirm = props.onConfirm,
22
+ formatter = props.formatter,
23
+ onBack = props.onBack;
24
+ var rcProContext = useContext(RcConfigContext);
25
+ var _ref = rcProContext || {},
26
+ _ref$tableOptions = _ref.tableOptions,
27
+ tableOptions = _ref$tableOptions === void 0 ? {} : _ref$tableOptions;
28
+ var defaultPageSize = (tableOptions === null || tableOptions === void 0 ? void 0 : (_tableOptions$paginat = tableOptions.pagination) === null || _tableOptions$paginat === void 0 ? void 0 : _tableOptions$paginat.defaultPageSize) || 20;
29
+ var _useState = useState(linkStateDefault),
30
+ linkState = _useState[0],
31
+ setLinkState = _useState[1];
32
+ var tableRef = useRef(null);
33
+ var queryCacheRef = useRef(null);
34
+ var timer = null;
35
+ var handleClearInterval = function handleClearInterval() {
36
+ if (timer) {
37
+ clearInterval(timer);
38
+ timer = null;
39
+ }
40
+ };
41
+ useEffect(function () {
42
+ var dataSetName = linkState.dataSetName,
43
+ autoLoad = linkState.autoLoad,
44
+ refreshRate = linkState.refreshRate;
45
+ if (dataSetName) {
46
+ if (autoLoad) {
47
+ if (refreshRate) {
48
+ handleClearInterval();
49
+ timer = window.setInterval(function () {
50
+ return onConfirm === null || onConfirm === void 0 ? void 0 : onConfirm();
51
+ }, refreshRate * timeUnit);
52
+ } else {
53
+ onConfirm === null || onConfirm === void 0 ? void 0 : onConfirm();
54
+ }
55
+ }
56
+ } else {
57
+ handleClearInterval();
58
+ }
59
+ return function () {
60
+ handleClearInterval();
61
+ };
62
+ }, [linkState.dataSetName, linkState.autoLoad]);
63
+
64
+ // 获取表头
65
+ var handleGetColumns = function handleGetColumns(stateParams) {
66
+ var index = stateParams.index;
67
+ // 通过数据源接口名找到数据源配置
68
+ var find = linkPage[index];
69
+ var _ref2 = handleDimTargetFormat(find) || {},
70
+ targets = _ref2.targets;
71
+ var option = {
72
+ dimension: [],
73
+ dimensionSource: [],
74
+ index: (targets === null || targets === void 0 ? void 0 : targets.index) || [],
75
+ indexSource: (targets === null || targets === void 0 ? void 0 : targets.indexSource) || []
76
+ };
77
+ return handleColumns(option);
78
+ };
79
+ var handleUpdateColumns = function handleUpdateColumns(stateParams) {
80
+ var _tableRef$current;
81
+ var columns = handleGetColumns(_extends({}, stateParams));
82
+ // 更新表头
83
+ (_tableRef$current = tableRef.current) === null || _tableRef$current === void 0 ? void 0 : _tableRef$current.updateColumns(columns);
84
+ };
85
+ var getDataSource = /*#__PURE__*/function () {
86
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(params) {
87
+ var _dimJson$data;
88
+ var dataSetName, index, dimension, record, columns, queryBind, queryCache, query, queryKeys, recordKeys, dim, queryParams, data, queryData;
89
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
90
+ while (1) switch (_context.prev = _context.next) {
91
+ case 0:
92
+ if (params === void 0) {
93
+ params = {};
94
+ }
95
+ dataSetName = linkState.dataSetName, index = linkState.index, dimension = linkState.dimension, record = linkState.record;
96
+ columns = handleGetColumns(_extends({}, linkState));
97
+ /** 查看queryBind是否有 当前查询条件和当前数据源参数(paraJson)建立绑定关系;有的话替换成绑定关系中的"键",没有则是默认查询配置的"键",上一级数据源的维度 "值" 或 当前查询条件的"值"入参 */
98
+ queryBind = linkPage[index].queryBind;
99
+ queryCache = queryCacheRef.current;
100
+ query = {};
101
+ queryKeys = Object.keys(queryCache);
102
+ if (queryKeys !== null && queryKeys !== void 0 && queryKeys.length) {
103
+ queryKeys.forEach(function (k) {
104
+ var _queryBind$find;
105
+ // "键"(有建立绑定关系 取当前数据源参数(paraJson)的"键",没有则是默认查询配置的"键")
106
+ var key = (queryBind === null || queryBind === void 0 ? void 0 : (_queryBind$find = queryBind.find(function (item) {
107
+ return (item === null || item === void 0 ? void 0 : item.currentQueryKey) === k;
108
+ })) === null || _queryBind$find === void 0 ? void 0 : _queryBind$find.sourceQueryKey) || k;
109
+ // "值"(当前查询条件的"值")
110
+ query[key] = queryCache[k];
111
+ });
112
+ }
113
+ recordKeys = Object.keys(record || {});
114
+ if (recordKeys.length) {
115
+ recordKeys.forEach(function (k) {
116
+ var _queryBind$find2;
117
+ // 查看是否有绑定关联关系
118
+ var key = queryBind === null || queryBind === void 0 ? void 0 : (_queryBind$find2 = queryBind.find(function (item) {
119
+ return (item === null || item === void 0 ? void 0 : item.parentDimKey) === k;
120
+ })) === null || _queryBind$find2 === void 0 ? void 0 : _queryBind$find2.sourceQueryKey;
121
+ if (key) {
122
+ // "值"(有建立绑定关系 取上一级数据源的维度的"值")
123
+ query[key] = record[k];
124
+ }
125
+ });
126
+ }
127
+ if (dimJson !== null && dimJson !== void 0 && (_dimJson$data = dimJson.data) !== null && _dimJson$data !== void 0 && _dimJson$data.length) {
128
+ dim = dimension === null || dimension === void 0 ? void 0 : dimension.map(function (description) {
129
+ var _dimJson$data2, _dimJson$data2$find;
130
+ return {
131
+ description: description,
132
+ name: (_dimJson$data2 = dimJson.data) === null || _dimJson$data2 === void 0 ? void 0 : (_dimJson$data2$find = _dimJson$data2.find(function (item) {
133
+ return item.description === description;
134
+ })) === null || _dimJson$data2$find === void 0 ? void 0 : _dimJson$data2$find.name
135
+ };
136
+ });
137
+ }
138
+ queryParams = handleQueryParams(query);
139
+ data = _extends({
140
+ pageNum: 1,
141
+ pageSize: defaultPageSize
142
+ }, params, {
143
+ queryParams: queryParams,
144
+ dim: dim,
145
+ target: columns.map(function (item) {
146
+ return {
147
+ description: item.dataIndex
148
+ };
149
+ }),
150
+ dataSetName: dataSetName
151
+ });
152
+ queryData = formatter ? formatter === null || formatter === void 0 ? void 0 : formatter(data) : data;
153
+ return _context.abrupt("return", getReportData(rcProContext, queryData).then(function (_ref4) {
154
+ var success = _ref4.success,
155
+ _ref4$result = _ref4.result,
156
+ result = _ref4$result === void 0 ? {} : _ref4$result;
157
+ return {
158
+ success: success,
159
+ result: result
160
+ };
161
+ }));
162
+ case 15:
163
+ case "end":
164
+ return _context.stop();
165
+ }
166
+ }, _callee);
167
+ }));
168
+ return function getDataSource(_x) {
169
+ return _ref3.apply(this, arguments);
170
+ };
171
+ }();
172
+
173
+ /** 初始linkState */
174
+ var initial = function initial(state) {
175
+ var _ref5 = state || {},
176
+ dataSetName = _ref5.dataSetName;
177
+ /** 二级页未配置 或 自定义dataSetName配错 直接返回 */
178
+ var Length = linkPage === null || linkPage === void 0 ? void 0 : linkPage.length;
179
+ var isHave = linkPage === null || linkPage === void 0 ? void 0 : linkPage.some(function (item) {
180
+ return item.dataSetName === dataSetName;
181
+ });
182
+ if (!Length || !isHave) return;
183
+
184
+ /** 可以传入二级页下标 */
185
+ var index = state.index || 0;
186
+ /** 检查传入二级下标 是否为数字 */
187
+ var isNumber = typeof index === 'number';
188
+
189
+ /** 收集二级页title 计算宽度 */
190
+ var linkTitle = [];
191
+ for (var i = 0; i < Length; i++) {
192
+ var item = linkPage[i];
193
+ // 找到相同的
194
+ if (item.dataSetName === dataSetName) {
195
+ linkTitle.push(item.title);
196
+ }
197
+ }
198
+ var width = getMaxWidth(linkTitle);
199
+
200
+ /** 二级页出现重复相同的时候 索引未配置正确 取dataSetName 出现最近一次下标 防止报错 */
201
+ if (!isNumber || isNumber && (index < 0 || index >= Length)) {
202
+ for (var _i = 0; _i < Length; _i++) {
203
+ var _item = linkPage[_i];
204
+ if (_item.dataSetName === dataSetName) {
205
+ index = _i;
206
+ break;
207
+ }
208
+ }
209
+ }
210
+ var _linkPage$index = linkPage[index],
211
+ title = _linkPage$index.title,
212
+ autoLoad = _linkPage$index.autoLoad,
213
+ refreshRate = _linkPage$index.refreshRate;
214
+ var stateData = _extends({}, state, {
215
+ width: width,
216
+ index: index,
217
+ title: title,
218
+ autoLoad: autoLoad,
219
+ refreshRate: refreshRate
220
+ });
221
+ /** 当前进入与上次进入link页不同时需要清空数据 */
222
+ var isSource = "" + stateData.dataSetName + separator + index === "" + linkState.dataSetName + separator + (linkState === null || linkState === void 0 ? void 0 : linkState.index);
223
+ var isSame = JSON.stringify(stateData === null || stateData === void 0 ? void 0 : stateData.record) === JSON.stringify(linkState === null || linkState === void 0 ? void 0 : linkState.record);
224
+ if (!isSource || !isSame) {
225
+ var _tableRef$current2, _tableRef$current2$up;
226
+ (_tableRef$current2 = tableRef.current) === null || _tableRef$current2 === void 0 ? void 0 : (_tableRef$current2$up = _tableRef$current2.updateDataSource) === null || _tableRef$current2$up === void 0 ? void 0 : _tableRef$current2$up.call(_tableRef$current2, []);
227
+ }
228
+ handleUpdateColumns(stateData);
229
+ setLinkState(stateData);
230
+ };
231
+ var queryChart = function queryChart(value) {
232
+ var _tableRef$current3;
233
+ queryCacheRef.current = value;
234
+ (_tableRef$current3 = tableRef.current) === null || _tableRef$current3 === void 0 ? void 0 : _tableRef$current3.refreshTable({
235
+ current: 1
236
+ });
237
+ };
238
+ useImperativeHandle(chartRef, function () {
239
+ return {
240
+ initial: initial,
241
+ queryChart: queryChart
242
+ };
243
+ });
244
+
245
+ /** 切换link */
246
+ var handleLinkChange = function handleLinkChange(event) {
247
+ var value = event.target.value;
248
+ // dataSetName 可能会重复配置 所以使用 dataSetName + 分隔符 + index
249
+ var _ref6 = (value === null || value === void 0 ? void 0 : value.split(separator)) || [],
250
+ dataSetName = _ref6[0],
251
+ index = _ref6[1];
252
+ var _linkPage$index2 = linkPage[index],
253
+ title = _linkPage$index2.title,
254
+ autoLoad = _linkPage$index2.autoLoad,
255
+ refreshRate = _linkPage$index2.refreshRate;
256
+ var stateData = _extends({}, linkState, {
257
+ dataSetName: dataSetName,
258
+ index: index,
259
+ title: title,
260
+ autoLoad: autoLoad,
261
+ refreshRate: refreshRate
262
+ });
263
+ handleUpdateColumns(stateData);
264
+ setLinkState(stateData);
265
+ };
266
+ return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
267
+ className: "link-head"
268
+ }, /*#__PURE__*/React.createElement("div", {
269
+ className: "link-title"
270
+ }, /*#__PURE__*/React.createElement(ArrowLeftOutlined, {
271
+ className: "arrow-left",
272
+ onClick: onBack
273
+ }), /*#__PURE__*/React.createElement("span", null, linkState === null || linkState === void 0 ? void 0 : linkState.title)), (linkPage === null || linkPage === void 0 ? void 0 : (_linkPage$filter = linkPage.filter(function (field) {
274
+ return (field === null || field === void 0 ? void 0 : field.dataSetName) === linkState.dataSetName;
275
+ })) === null || _linkPage$filter === void 0 ? void 0 : _linkPage$filter.length) <= 1 ? null : /*#__PURE__*/React.createElement(_Radio.Group, {
276
+ value: "" + (linkState === null || linkState === void 0 ? void 0 : linkState.title) + separator + linkState.index,
277
+ onChange: handleLinkChange
278
+ }, linkPage === null || linkPage === void 0 ? void 0 : linkPage.map(function (field, index) {
279
+ return (field === null || field === void 0 ? void 0 : field.dataSetName) === linkState.dataSetName ? /*#__PURE__*/React.createElement(_Radio.Button, {
280
+ value: "" + (field === null || field === void 0 ? void 0 : field.dataSetName) + separator + index.toString(),
281
+ key: "" + (field === null || field === void 0 ? void 0 : field.dataSetName) + separator + index.toString()
282
+ }, /*#__PURE__*/React.createElement("div", {
283
+ style: {
284
+ textAlign: 'center',
285
+ width: linkState.width
286
+ }
287
+ }, field === null || field === void 0 ? void 0 : field.title)) : null;
288
+ }))), /*#__PURE__*/React.createElement(ProTable, {
289
+ ref: tableRef,
290
+ config: _extends({}, tableConfigDefault, {
291
+ pagination: {
292
+ showSizeChanger: true,
293
+ defaultPageSize: defaultPageSize
294
+ },
295
+ request: function request(data) {
296
+ var _data$pagination, _data$pagination2, _data$sorter;
297
+ var pagination = {
298
+ pageNum: (_data$pagination = data.pagination) === null || _data$pagination === void 0 ? void 0 : _data$pagination.current,
299
+ pageSize: (_data$pagination2 = data.pagination) === null || _data$pagination2 === void 0 ? void 0 : _data$pagination2.pageSize
300
+ };
301
+ var orderBy = [];
302
+ if ((_data$sorter = data.sorter) !== null && _data$sorter !== void 0 && _data$sorter.order) {
303
+ var _data$sorter2, _data$sorter3, _data$sorter3$order;
304
+ orderBy.push({
305
+ name: (_data$sorter2 = data.sorter) === null || _data$sorter2 === void 0 ? void 0 : _data$sorter2.field,
306
+ 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)
307
+ });
308
+ }
309
+ return getDataSource(_extends({}, pagination, {
310
+ orderBy: orderBy
311
+ }));
312
+ }
313
+ })
314
+ }));
315
+ };
316
+ export default LinkRenderer;
@@ -0,0 +1,31 @@
1
+ .link-head {
2
+ display: flex;
3
+ align-items: center;
4
+ margin: 12px 0;
5
+ .ant-radio-group {
6
+ flex: 1;
7
+ overflow-x: auto;
8
+ display: flex;
9
+ }
10
+
11
+ .link-title {
12
+ display: flex;
13
+ align-items: center;
14
+ margin-right: 12px;
15
+ font-weight: 600;
16
+ font-size: 20px;
17
+ color: #333;
18
+ white-space: nowrap;
19
+ }
20
+
21
+ .arrow-left {
22
+ margin-right: 5px;
23
+ font-size: 20px;
24
+ cursor: pointer;
25
+ }
26
+
27
+ // .link-label {
28
+ // display: flex;
29
+ // align-items: center;
30
+ // }
31
+ }
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ import type { TypeChartSettingProps } from '../../data-common';
3
+ declare const TableRenderer: (props: TypeChartSettingProps & {
4
+ activeKey: string;
5
+ }) => import("react").JSX.Element;
6
+ export default TableRenderer;