@ztocwst/rc-pro-materials 0.1.25 → 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.
Files changed (70) 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 +4 -4
  5. package/build/lowcode/index.html +4 -4
  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 -2
  10. package/build/lowcode/render/default/view.js +8 -8
  11. package/build/lowcode/view.css +1 -2
  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 +330 -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 +4 -0
  43. package/lib/components/z-templates-data-common/components/chart-renderer/index.d.ts +14 -0
  44. package/lib/components/z-templates-data-common/components/chart-renderer/index.js +116 -0
  45. package/lib/components/z-templates-data-common/components/custom-renderer/index.d.ts +13 -0
  46. package/lib/components/z-templates-data-common/components/custom-renderer/index.js +167 -0
  47. package/lib/components/z-templates-data-common/components/dim-target/dim-target.helper.d.ts +39 -0
  48. package/lib/components/z-templates-data-common/components/dim-target/dim-target.helper.js +3 -0
  49. package/lib/components/z-templates-data-common/components/dim-target/index.d.ts +16 -0
  50. package/lib/components/z-templates-data-common/components/dim-target/index.js +438 -0
  51. package/lib/components/z-templates-data-common/components/dim-target/index.less +49 -0
  52. package/lib/components/z-templates-data-common/components/dim-target/useUpdateEffect.d.ts +8 -0
  53. package/lib/components/z-templates-data-common/components/dim-target/useUpdateEffect.js +30 -0
  54. package/lib/components/z-templates-data-common/components/link-renderer/index.d.ts +16 -0
  55. package/lib/components/z-templates-data-common/components/link-renderer/index.js +322 -0
  56. package/lib/components/z-templates-data-common/components/link-renderer/index.less +31 -0
  57. package/lib/components/z-templates-data-common/components/table-renderer/index.d.ts +6 -0
  58. package/lib/components/z-templates-data-common/components/table-renderer/index.js +485 -0
  59. package/lib/components/z-templates-data-common/components/table-renderer/table-renderer.helper.d.ts +64 -0
  60. package/lib/components/z-templates-data-common/components/table-renderer/table-renderer.helper.js +228 -0
  61. package/lib/components/z-templates-data-common/data-common.d.ts +102 -0
  62. package/lib/components/z-templates-data-common/data-common.helper.d.ts +61 -0
  63. package/lib/components/z-templates-data-common/data-common.helper.js +349 -0
  64. package/lib/components/z-templates-data-common/data-common.js +147 -0
  65. package/lib/components/z-templates-data-common/index.d.ts +3 -0
  66. package/lib/components/z-templates-data-common/index.js +8 -0
  67. package/lib/index.d.ts +2 -0
  68. package/lib/index.js +4 -2
  69. package/lib/style.js +4 -0
  70. package/package.json +4 -3
@@ -0,0 +1,330 @@
1
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
+ import _extends from "@babel/runtime/helpers/extends";
3
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
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
+ /** table config */
8
+ export var tableConfigDefault = {
9
+ manual: true,
10
+ toolBars: false,
11
+ hideDefRowSelection: true,
12
+ columns: []
13
+ };
14
+
15
+ /** 字符串拼接分割符 */
16
+ export var separator = '***';
17
+
18
+ /** 时间单位 */
19
+ export var timeUnit = 60 * 1000;
20
+
21
+ /** 介于 前闭后开 */
22
+ export var BETWEEN = '<=,<';
23
+ /** 数据类型 */
24
+
25
+ /**
26
+ * 计算宽
27
+ * @param length
28
+ * @param width
29
+ */
30
+ export var computeWidth = function computeWidth(length, width) {
31
+ if (width === void 0) {
32
+ width = 40;
33
+ }
34
+ return length * width;
35
+ };
36
+
37
+ /**
38
+ * 获取最大宽
39
+ * @param strArr
40
+ */
41
+ export var getMaxWidth = function getMaxWidth(strArr) {
42
+ if (!(strArr !== null && strArr !== void 0 && strArr.length)) return 0;
43
+ var arr = strArr.map(function (s) {
44
+ var _s$toString;
45
+ return s === null || s === void 0 ? void 0 : (_s$toString = s.toString()) === null || _s$toString === void 0 ? void 0 : _s$toString.length;
46
+ });
47
+ var length = Math.max.apply(null, arr);
48
+ return computeWidth(length, 14);
49
+ };
50
+
51
+ /**
52
+ * 处理 QueryParams 去除空字符串
53
+ */
54
+ export var handleQueryParams = function handleQueryParams(query) {
55
+ var queryParams = _extends({}, query);
56
+ Object.keys(query).forEach(function (k) {
57
+ if (query[k] === '') {
58
+ queryParams[k] = undefined;
59
+ }
60
+ });
61
+ return queryParams;
62
+ };
63
+
64
+ /**
65
+ * 处理数据千分位
66
+ */
67
+ export var handleThousand = function handleThousand(value) {
68
+ if (!Number.isNaN(value) && value) {
69
+ if (String(value).indexOf('.') !== -1) {
70
+ var _String$split = String(value).split('.'),
71
+ start = _String$split[0],
72
+ end = _String$split[1];
73
+ var begin = start.toString().replace(/(\d)(?=(?:\d{3})+$)/g, '$1,');
74
+ return [begin, end].join('.');
75
+ } else {
76
+ return value.toString().replace(/(\d)(?=(?:\d{3})+$)/g, '$1,');
77
+ }
78
+ } else {
79
+ return value;
80
+ }
81
+ };
82
+
83
+ /**
84
+ * 保留几位小数点
85
+ */
86
+ export var handleDecimal = function handleDecimal(value, decimal) {
87
+ if (decimal === void 0) {
88
+ decimal = 2;
89
+ }
90
+ if (value === null || value === undefined) return;
91
+ return Number(value).toFixed(decimal);
92
+ };
93
+
94
+ /**
95
+ * 百分比转化
96
+ */
97
+ export var handlePercent = function handlePercent(value, decimal, unit) {
98
+ if (decimal === void 0) {
99
+ decimal = 2;
100
+ }
101
+ if (unit === void 0) {
102
+ unit = 100;
103
+ }
104
+ if (value === null || value === undefined) return;
105
+ return (Number(value) * unit).toFixed(decimal) + "%";
106
+ };
107
+
108
+ /**
109
+ * link外链处理
110
+ */
111
+ export var handleLink = function handleLink(value, onLink) {
112
+ if (value === null || value === undefined) return;
113
+ return /*#__PURE__*/React.createElement("a", {
114
+ href: "javascript:void(0);",
115
+ onClick: onLink
116
+ }, value);
117
+ };
118
+
119
+ /**
120
+ * 条件格式设置
121
+ * @param value 处理前的值
122
+ * @param handledValue 被处理后的值 可能会是link标签
123
+ */
124
+ export var handleCondition = function handleCondition(value, handledValue, conditions) {
125
+ if (value === null || value === undefined) return;
126
+ var val = handledValue;
127
+ for (var _iterator = _createForOfIteratorHelperLoose(conditions), _step; !(_step = _iterator()).done;) {
128
+ var cur = _step.value;
129
+ var condition = cur === null || cur === void 0 ? void 0 : cur.condition;
130
+ if ((condition === null || condition === void 0 ? void 0 : condition.type) === BETWEEN) {
131
+ var _condition$type;
132
+ var _condition$type$split = condition === null || condition === void 0 ? void 0 : (_condition$type = condition.type) === null || _condition$type === void 0 ? void 0 : _condition$type.split(','),
133
+ start = _condition$type$split[0],
134
+ end = _condition$type$split[1];
135
+ if (eval("" + (condition === null || condition === void 0 ? void 0 : condition.start) + start + value) && eval("" + value + end + (condition === null || condition === void 0 ? void 0 : condition.end))) {
136
+ var style = {
137
+ color: cur === null || cur === void 0 ? void 0 : cur.fontColor,
138
+ background: cur === null || cur === void 0 ? void 0 : cur.backgroundColor
139
+ };
140
+ val = /*#__PURE__*/React.createElement("div", {
141
+ style: style
142
+ }, handledValue);
143
+ }
144
+ } else if (eval("" + value + (condition === null || condition === void 0 ? void 0 : condition.type) + (condition === null || condition === void 0 ? void 0 : condition.value))) {
145
+ var _style = {
146
+ color: cur === null || cur === void 0 ? void 0 : cur.fontColor,
147
+ background: cur === null || cur === void 0 ? void 0 : cur.backgroundColor
148
+ };
149
+ val = /*#__PURE__*/React.createElement("div", {
150
+ style: _style
151
+ }, handledValue);
152
+ }
153
+ }
154
+ return val;
155
+ };
156
+
157
+ // mock
158
+ var token = 'scm:tenant:token:2:104:33A6E5D6F29E319C975B503D2B2E0E7B';
159
+
160
+ /** 获取维度指标 */
161
+ export var getDimTarget = /*#__PURE__*/function () {
162
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(rcProContext, params) {
163
+ var _ref2, materialsRequest, env, res, _res;
164
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
165
+ while (1) switch (_context.prev = _context.next) {
166
+ case 0:
167
+ _ref2 = rcProContext || {}, materialsRequest = _ref2.materialsRequest, env = _ref2.env; // 供应链里由子应用透传
168
+ if (!materialsRequest) {
169
+ _context.next = 6;
170
+ break;
171
+ }
172
+ _context.next = 4;
173
+ return materialsRequest("/data/forward/v1/bigdata/report/view/query/" + params.dataSetName, {
174
+ method: 'POST',
175
+ data: {
176
+ bigDataBody: _extends({
177
+ env: env
178
+ }, params)
179
+ }
180
+ });
181
+ case 4:
182
+ res = _context.sent;
183
+ return _context.abrupt("return", res);
184
+ case 6:
185
+ _context.prev = 6;
186
+ _context.next = 9;
187
+ return fetch("http://scm.gateway.dev.ztyc.com/data/forward/v1/bigdata/report/view/query/" + params.dataSetName, {
188
+ method: 'POST',
189
+ body: JSON.stringify({
190
+ bigDataBody: _extends({
191
+ env: 'dev'
192
+ }, params)
193
+ }),
194
+ headers: {
195
+ 'Content-Type': 'application/json',
196
+ token: token
197
+ }
198
+ });
199
+ case 9:
200
+ _res = _context.sent;
201
+ _context.next = 12;
202
+ return _res.json();
203
+ case 12:
204
+ return _context.abrupt("return", _context.sent);
205
+ case 15:
206
+ _context.prev = 15;
207
+ _context.t0 = _context["catch"](6);
208
+ return _context.abrupt("return", {});
209
+ case 18:
210
+ case "end":
211
+ return _context.stop();
212
+ }
213
+ }, _callee, null, [[6, 15]]);
214
+ }));
215
+ return function getDimTarget(_x, _x2) {
216
+ return _ref.apply(this, arguments);
217
+ };
218
+ }();
219
+
220
+ /** 获取报表数据 */
221
+ export var getReportData = /*#__PURE__*/function () {
222
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(rcProContext, params) {
223
+ var _ref4, materialsRequest, env, res, _res2;
224
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
225
+ while (1) switch (_context2.prev = _context2.next) {
226
+ case 0:
227
+ _ref4 = rcProContext || {}, materialsRequest = _ref4.materialsRequest, env = _ref4.env; // 供应链里由子应用透传
228
+ if (!materialsRequest) {
229
+ _context2.next = 6;
230
+ break;
231
+ }
232
+ _context2.next = 4;
233
+ return materialsRequest("/data/forward/v1/bigdata/report/" + params.dataSetName, {
234
+ method: 'POST',
235
+ data: {
236
+ bigDataBody: _extends({
237
+ env: env
238
+ }, params)
239
+ }
240
+ });
241
+ case 4:
242
+ res = _context2.sent;
243
+ return _context2.abrupt("return", res);
244
+ case 6:
245
+ _context2.prev = 6;
246
+ _context2.next = 9;
247
+ return fetch("http://scm.gateway.dev.ztyc.com/data/forward/v1/bigdata/report/" + params.dataSetName, {
248
+ method: 'POST',
249
+ body: JSON.stringify({
250
+ bigDataBody: _extends({
251
+ env: 'dev'
252
+ }, params)
253
+ }),
254
+ headers: {
255
+ 'Content-Type': 'application/json',
256
+ token: token
257
+ }
258
+ });
259
+ case 9:
260
+ _res2 = _context2.sent;
261
+ _context2.next = 12;
262
+ return _res2.json();
263
+ case 12:
264
+ return _context2.abrupt("return", _context2.sent);
265
+ case 15:
266
+ _context2.prev = 15;
267
+ _context2.t0 = _context2["catch"](6);
268
+ return _context2.abrupt("return", {});
269
+ case 18:
270
+ case "end":
271
+ return _context2.stop();
272
+ }
273
+ }, _callee2, null, [[6, 15]]);
274
+ }));
275
+ return function getReportData(_x3, _x4) {
276
+ return _ref3.apply(this, arguments);
277
+ };
278
+ }();
279
+
280
+ /** 记住勾选 */
281
+ export var saveDimTarget = /*#__PURE__*/function () {
282
+ var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(rcProContext, params) {
283
+ var _ref6, materialsRequest, res, _res3;
284
+ return _regeneratorRuntime.wrap(function _callee3$(_context3) {
285
+ while (1) switch (_context3.prev = _context3.next) {
286
+ case 0:
287
+ _ref6 = rcProContext || {}, materialsRequest = _ref6.materialsRequest; // 供应链里由子应用透传
288
+ if (!materialsRequest) {
289
+ _context3.next = 6;
290
+ break;
291
+ }
292
+ _context3.next = 4;
293
+ return materialsRequest("/data/forward/v1/bigdata/report/view/save", {
294
+ method: 'POST',
295
+ data: params
296
+ });
297
+ case 4:
298
+ res = _context3.sent;
299
+ return _context3.abrupt("return", res);
300
+ case 6:
301
+ _context3.prev = 6;
302
+ _context3.next = 9;
303
+ return fetch("http://scm.gateway.dev.ztyc.com/data/forward/v1/bigdata/report/view/save", {
304
+ method: 'POST',
305
+ body: JSON.stringify(_extends({}, params)),
306
+ headers: {
307
+ 'Content-Type': 'application/json',
308
+ token: token
309
+ }
310
+ });
311
+ case 9:
312
+ _res3 = _context3.sent;
313
+ _context3.next = 12;
314
+ return _res3.json();
315
+ case 12:
316
+ return _context3.abrupt("return", _context3.sent);
317
+ case 15:
318
+ _context3.prev = 15;
319
+ _context3.t0 = _context3["catch"](6);
320
+ return _context3.abrupt("return", {});
321
+ case 18:
322
+ case "end":
323
+ return _context3.stop();
324
+ }
325
+ }, _callee3, null, [[6, 15]]);
326
+ }));
327
+ return function saveDimTarget(_x5, _x6) {
328
+ return _ref5.apply(this, arguments);
329
+ };
330
+ }();
@@ -0,0 +1,141 @@
1
+ import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
2
+ import _extends from "@babel/runtime/helpers/extends";
3
+ import _message from "antd/es/message";
4
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
5
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
6
+ import React, { useRef, useImperativeHandle } from 'react';
7
+ import { ProFormRender } from '@ztocwst/rc-pro';
8
+ import ChartRenderer from "./components/chart-renderer";
9
+
10
+ /** 指标配置 */
11
+
12
+ /** 表格相关配置 */
13
+
14
+ var ZTemplatesDataCommon = /*#__PURE__*/React.forwardRef(function (props, ref) {
15
+ var querySetting = props.querySetting,
16
+ _unsafe_MixedSetter_chartSetting_select = props._unsafe_MixedSetter_chartSetting_select;
17
+ var chartSetting = props.chartSetting;
18
+ var formRef = useRef();
19
+ var chartRenderRef = useRef();
20
+ // todo 不知道meta里是哪里配置有问题,出现_unsafe_MixedSetter...
21
+ // if (
22
+ // _unsafe_MixedSetter_chartSetting_select &&
23
+ // typeof _unsafe_MixedSetter_chartSetting_select === 'object'
24
+ // ) {
25
+ // chartSetting = _unsafe_MixedSetter_chartSetting_select;
26
+ // }
27
+ console.log(chartSetting);
28
+ var onFinish = function onFinish(values) {
29
+ chartRenderRef.current.queryChart(values);
30
+ };
31
+ var onConfirm = /*#__PURE__*/function () {
32
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
33
+ var _yield$formRef$curren, _formRef$current, _formRef$current$vali, values;
34
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
35
+ while (1) switch (_context.prev = _context.next) {
36
+ case 0:
37
+ _context.prev = 0;
38
+ _context.next = 3;
39
+ return (_formRef$current = formRef.current) === null || _formRef$current === void 0 ? void 0 : (_formRef$current$vali = _formRef$current.validateFieldsReturnFormatValue) === null || _formRef$current$vali === void 0 ? void 0 : _formRef$current$vali.call(_formRef$current);
40
+ case 3:
41
+ _context.t1 = _yield$formRef$curren = _context.sent;
42
+ _context.t0 = _context.t1 !== null;
43
+ if (!_context.t0) {
44
+ _context.next = 7;
45
+ break;
46
+ }
47
+ _context.t0 = _yield$formRef$curren !== void 0;
48
+ case 7:
49
+ if (!_context.t0) {
50
+ _context.next = 11;
51
+ break;
52
+ }
53
+ _context.t2 = _yield$formRef$curren;
54
+ _context.next = 12;
55
+ break;
56
+ case 11:
57
+ _context.t2 = {};
58
+ case 12:
59
+ values = _context.t2;
60
+ chartRenderRef.current.queryChart(values);
61
+ _context.next = 19;
62
+ break;
63
+ case 16:
64
+ _context.prev = 16;
65
+ _context.t3 = _context["catch"](0);
66
+ console.error(_context.t3);
67
+ case 19:
68
+ case "end":
69
+ return _context.stop();
70
+ }
71
+ }, _callee, null, [[0, 16]]);
72
+ }));
73
+ return function onConfirm() {
74
+ return _ref.apply(this, arguments);
75
+ };
76
+ }();
77
+ var onLink = function onLink(values) {
78
+ var _chartRenderRef$curre, _chartRenderRef$curre2;
79
+ return (_chartRenderRef$curre = chartRenderRef.current) === null || _chartRenderRef$curre === void 0 ? void 0 : (_chartRenderRef$curre2 = _chartRenderRef$curre.onLink) === null || _chartRenderRef$curre2 === void 0 ? void 0 : _chartRenderRef$curre2.call(_chartRenderRef$curre, values);
80
+ };
81
+ useImperativeHandle(ref, function () {
82
+ return {
83
+ onLink: onLink
84
+ };
85
+ });
86
+ return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(ProFormRender, _extends({}, querySetting, {
87
+ formRef: formRef,
88
+ onValuesChange: function onValuesChange(changeValues) {},
89
+ onFinish: /*#__PURE__*/function () {
90
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(formatData) {
91
+ var _querySetting$onFinis;
92
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
93
+ while (1) switch (_context2.prev = _context2.next) {
94
+ case 0:
95
+ _context2.prev = 0;
96
+ _context2.next = 3;
97
+ return (_querySetting$onFinis = querySetting.onFinish) === null || _querySetting$onFinis === void 0 ? void 0 : _querySetting$onFinis.call(querySetting, formatData);
98
+ case 3:
99
+ _context2.next = 5;
100
+ return onFinish === null || onFinish === void 0 ? void 0 : onFinish(formatData);
101
+ case 5:
102
+ _context2.next = 10;
103
+ break;
104
+ case 7:
105
+ _context2.prev = 7;
106
+ _context2.t0 = _context2["catch"](0);
107
+ _message.error(_context2.t0);
108
+ case 10:
109
+ case "end":
110
+ return _context2.stop();
111
+ }
112
+ }, _callee2, null, [[0, 7]]);
113
+ }));
114
+ return function (_x) {
115
+ return _ref2.apply(this, arguments);
116
+ };
117
+ }()
118
+ })), /*#__PURE__*/React.createElement(ChartRenderer, {
119
+ chartSetting: chartSetting,
120
+ chartRenderRef: chartRenderRef,
121
+ onConfirm: onConfirm
122
+ }));
123
+ });
124
+ var ZTemplatesDataCommonContainer = /*#__PURE__*/function (_React$Component) {
125
+ _inheritsLoose(ZTemplatesDataCommonContainer, _React$Component);
126
+ function ZTemplatesDataCommonContainer(props) {
127
+ var _this;
128
+ _this = _React$Component.call(this, props) || this;
129
+ _this.chartRef = void 0;
130
+ _this.chartRef = /*#__PURE__*/React.createRef();
131
+ return _this;
132
+ }
133
+ var _proto = ZTemplatesDataCommonContainer.prototype;
134
+ _proto.render = function render() {
135
+ return /*#__PURE__*/React.createElement(ZTemplatesDataCommon, _extends({}, this.props, {
136
+ ref: this.chartRef
137
+ }));
138
+ };
139
+ return ZTemplatesDataCommonContainer;
140
+ }(React.Component);
141
+ export { ZTemplatesDataCommonContainer as default };
@@ -0,0 +1,3 @@
1
+ import ZTemplatesDataCommon from './data-common';
2
+ export type { TypeZTemplatesDataCommonProps } from './data-common';
3
+ export default ZTemplatesDataCommon;
@@ -0,0 +1,2 @@
1
+ import ZTemplatesDataCommon from "./data-common";
2
+ export default ZTemplatesDataCommon;
package/es/index.d.ts CHANGED
@@ -33,3 +33,5 @@ export { default as ZPointerBlock } from './components/z-pointer-block';
33
33
  export type { TypeZPointerBlockProps } from './components/z-pointer-block';
34
34
  export { default as ZAggBlock } from './components/z-agg-block';
35
35
  export type { TypeAggBlockProps } from './components/z-agg-block';
36
+ export { default as ZTemplatesDataCommon } from './components/z-templates-data-common';
37
+ export type { TypeZTemplatesDataCommonProps } from './components/z-templates-data-common';
package/es/index.js CHANGED
@@ -20,6 +20,7 @@ export { default as ZProProvider } from "./components/z-pro-provider";
20
20
  export { default as ZPointerBlock } from "./components/z-pointer-block";
21
21
  // 聚合指标
22
22
  export { default as ZAggBlock } from "./components/z-agg-block";
23
+ export { default as ZTemplatesDataCommon } from "./components/z-templates-data-common";
23
24
 
24
25
  // const bizCssPrefix = 'bizpack';
25
26
 
package/es/style.js CHANGED
@@ -12,4 +12,8 @@ import 'antd/es/table/style';
12
12
  import 'antd/es/typography/style';
13
13
  import 'antd/es/row/style';
14
14
  import 'antd/es/col/style';
15
+ import 'antd/es/message/style';
16
+ import 'antd/es/tabs/style';
17
+ import 'antd/es/checkbox/style';
18
+ import 'antd/es/radio/style';
15
19
  import './index.scss';
@@ -0,0 +1,14 @@
1
+ import React from 'react';
2
+ import type { TypeZTemplatesDataCommonProps } from '../../data-common';
3
+ import type { linkParamsType } from '../link-renderer';
4
+ export interface ChartRendererProps {
5
+ chartSetting?: Pick<TypeZTemplatesDataCommonProps, 'chartSetting'>;
6
+ chartRenderRef?: React.Ref<{
7
+ onLink: (v: linkParamsType) => void;
8
+ queryChart: (v: Record<string, any>, d: string | undefined) => void;
9
+ }>;
10
+ /** 确认 */
11
+ onConfirm?: () => void;
12
+ }
13
+ declare const ChartRenderer: ({ chartRenderRef, chartSetting, onConfirm }: ChartRendererProps) => JSX.Element | Pick<TypeZTemplatesDataCommonProps, "chartSetting">;
14
+ export default ChartRenderer;
@@ -0,0 +1,116 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ exports.__esModule = true;
5
+ exports["default"] = void 0;
6
+ var _tabs = _interopRequireDefault(require("antd/lib/tabs"));
7
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
8
+ var _react = _interopRequireWildcard(require("react"));
9
+ var _dataCommon = require("../../data-common.helper");
10
+ var _tableRenderer = _interopRequireDefault(require("../table-renderer"));
11
+ var _customRenderer = _interopRequireDefault(require("../custom-renderer"));
12
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
13
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
14
+ var ChartRenderer = function ChartRenderer(_ref) {
15
+ var chartRenderRef = _ref.chartRenderRef,
16
+ chartSetting = _ref.chartSetting,
17
+ onConfirm = _ref.onConfirm;
18
+ var isObject = Object.prototype.toString.call(chartSetting) === '[object Object]';
19
+ var isArray = Array.isArray(chartSetting);
20
+ var _chartRef = (0, _react.useRef)({});
21
+ var _useState = (0, _react.useState)(),
22
+ activeKey = _useState[0],
23
+ setActiveKey = _useState[1];
24
+ var onLink = function onLink(values) {
25
+ if (isObject && ! /*#__PURE__*/_react["default"].isValidElement(chartSetting) || isArray && !chartSetting.every(function (e) {
26
+ return /*#__PURE__*/_react["default"].isValidElement(e);
27
+ })) {
28
+ var _chartRef$current$act, _chartRef$current$act2;
29
+ (_chartRef$current$act = _chartRef.current[activeKey]) === null || _chartRef$current$act === void 0 ? void 0 : (_chartRef$current$act2 = _chartRef$current$act.onLink) === null || _chartRef$current$act2 === void 0 ? void 0 : _chartRef$current$act2.call(_chartRef$current$act, values);
30
+ }
31
+ };
32
+ var queryChart = function queryChart(values) {
33
+ if (isObject && ! /*#__PURE__*/_react["default"].isValidElement(chartSetting) || isArray && !chartSetting.every(function (e) {
34
+ return /*#__PURE__*/_react["default"].isValidElement(e);
35
+ })) {
36
+ var _chartRef$current$act3, _chartRef$current$act4;
37
+ (_chartRef$current$act3 = _chartRef.current[activeKey]) === null || _chartRef$current$act3 === void 0 ? void 0 : (_chartRef$current$act4 = _chartRef$current$act3.queryChart) === null || _chartRef$current$act4 === void 0 ? void 0 : _chartRef$current$act4.call(_chartRef$current$act3, values);
38
+ }
39
+ };
40
+ (0, _react.useEffect)(function () {
41
+ if (isObject && ! /*#__PURE__*/_react["default"].isValidElement(chartSetting)) {
42
+ setActiveKey(chartSetting === null || chartSetting === void 0 ? void 0 : chartSetting.dataSetName);
43
+ }
44
+ if (isArray && !chartSetting.every(function (e) {
45
+ return /*#__PURE__*/_react["default"].isValidElement(e);
46
+ })) {
47
+ if (chartSetting.length) {
48
+ var index = 0;
49
+ var item = chartSetting[index];
50
+ setActiveKey("" + (item === null || item === void 0 ? void 0 : item.dataSetName) + _dataCommon.separator + index);
51
+ }
52
+ }
53
+ }, []);
54
+ var handleTabsChange = function handleTabsChange(key) {
55
+ return setActiveKey(key);
56
+ };
57
+ (0, _react.useImperativeHandle)(chartRenderRef, function () {
58
+ return {
59
+ onLink: onLink,
60
+ queryChart: queryChart
61
+ };
62
+ });
63
+
64
+ // react子节点
65
+ if ( /*#__PURE__*/_react["default"].isValidElement(chartSetting)) {
66
+ return chartSetting;
67
+ }
68
+
69
+ // 多个react子节点
70
+ if (isArray && chartSetting.every(function (e) {
71
+ return /*#__PURE__*/_react["default"].isValidElement(e);
72
+ })) {
73
+ return chartSetting;
74
+ }
75
+
76
+ // 普通列表json对象
77
+ if (isObject) {
78
+ return /*#__PURE__*/_react["default"].createElement(_tableRenderer["default"], (0, _extends2["default"])({}, chartSetting, {
79
+ activeKey: activeKey,
80
+ chartRef: function chartRef(ref) {
81
+ _chartRef.current[chartSetting === null || chartSetting === void 0 ? void 0 : chartSetting.dataSetName] = ref;
82
+ },
83
+ onConfirm: onConfirm
84
+ }));
85
+ }
86
+
87
+ // 数组
88
+ if (isArray && !chartSetting.every(function (e) {
89
+ return /*#__PURE__*/_react["default"].isValidElement(e);
90
+ })) {
91
+ return /*#__PURE__*/_react["default"].createElement(_tabs["default"], {
92
+ activeKey: activeKey,
93
+ onChange: handleTabsChange
94
+ }, chartSetting.map(function (e, i) {
95
+ return /*#__PURE__*/_react["default"].createElement(_tabs["default"].TabPane, {
96
+ tab: "" + ((e === null || e === void 0 ? void 0 : e.title) || ''),
97
+ key: "" + (e === null || e === void 0 ? void 0 : e.dataSetName) + _dataCommon.separator + i.toString()
98
+ }, e !== null && e !== void 0 && e.custom ? /*#__PURE__*/_react["default"].createElement(_customRenderer["default"], (0, _extends2["default"])({}, e, {
99
+ activeKey: activeKey,
100
+ chartRef: function chartRef(ref) {
101
+ _chartRef.current["" + (e === null || e === void 0 ? void 0 : e.dataSetName) + _dataCommon.separator + i] = ref;
102
+ },
103
+ onConfirm: onConfirm
104
+ })) : /*#__PURE__*/_react["default"].createElement(_tableRenderer["default"], (0, _extends2["default"])({}, e, {
105
+ activeKey: activeKey,
106
+ chartRef: function chartRef(ref) {
107
+ _chartRef.current["" + (e === null || e === void 0 ? void 0 : e.dataSetName) + _dataCommon.separator + i] = ref;
108
+ },
109
+ onConfirm: onConfirm
110
+ })));
111
+ }));
112
+ }
113
+ return null;
114
+ };
115
+ var _default = ChartRenderer;
116
+ exports["default"] = _default;
@@ -0,0 +1,13 @@
1
+ /// <reference types="react" />
2
+ import type { TypeChartSettingProps } from '../../data-common';
3
+ import type { linkParamsType } from '../link-renderer';
4
+ declare const CustomRenderer: (props: TypeChartSettingProps & {
5
+ activeKey: string;
6
+ custom: boolean;
7
+ child: (p: any) => React.ReactNode;
8
+ chartRef?: import("react").Ref<{
9
+ onLink: (v: linkParamsType) => void;
10
+ queryChart: (v: Record<string, any>, d: string | undefined) => void;
11
+ }>;
12
+ }) => import("react").JSX.Element;
13
+ export default CustomRenderer;