@zhubangyun/lowcode-core 5.8.291 → 5.10.82

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 (71) hide show
  1. package/es/index.js +1 -0
  2. package/es/utils/api/file-api.d.ts +7 -0
  3. package/es/utils/api/file-api.js +86 -0
  4. package/es/utils/api/form-api.d.ts +1 -0
  5. package/es/utils/api/form-api.js +66 -27
  6. package/es/utils/api/form-api.utils.d.ts +2 -0
  7. package/es/utils/api/form-api.utils.js +82 -113
  8. package/es/utils/api/index.d.ts +5 -5
  9. package/es/utils/api/index.js +7 -67
  10. package/es/utils/api/rest-api.d.ts +6 -2
  11. package/es/utils/api/rest-api.js +64 -34
  12. package/es/utils/api/schema-api.d.ts +2 -0
  13. package/es/utils/api/schema-api.js +33 -0
  14. package/es/utils/api/script-api.d.ts +1 -0
  15. package/es/utils/api/script-api.js +41 -0
  16. package/es/utils/common/LoadPlugins.js +9 -16
  17. package/es/utils/common/index.d.ts +1 -0
  18. package/es/utils/common/index.js +12 -0
  19. package/es/utils/page/index.d.ts +2 -0
  20. package/es/utils/page/index.js +2 -0
  21. package/es/utils/page/page-form-data-manager-group.d.ts +17 -0
  22. package/es/utils/page/page-form-data-manager-group.js +104 -0
  23. package/es/utils/page/page-form-data-manager.d.ts +6 -0
  24. package/es/utils/page/page-form-data-manager.js +24 -79
  25. package/es/utils/page/page-form.d.ts +1 -1
  26. package/es/utils/page/page-form.js +24 -47
  27. package/es/utils/page/page-layout.js +1 -1
  28. package/es/utils/page/page-render.d.ts +10 -0
  29. package/es/utils/page/page-render.js +51 -0
  30. package/es/utils/page/page-schema-utils.d.ts +1 -0
  31. package/es/utils/page/page-schema-utils.js +74 -0
  32. package/es/utils/page/page-show.d.ts +11 -0
  33. package/es/utils/page/page-show.js +82 -0
  34. package/lib/index.js +2 -0
  35. package/lib/utils/api/file-api.d.ts +7 -0
  36. package/lib/utils/api/file-api.js +92 -0
  37. package/lib/utils/api/form-api.d.ts +1 -0
  38. package/lib/utils/api/form-api.js +67 -27
  39. package/lib/utils/api/form-api.utils.d.ts +2 -0
  40. package/lib/utils/api/form-api.utils.js +84 -113
  41. package/lib/utils/api/index.d.ts +5 -5
  42. package/lib/utils/api/index.js +14 -72
  43. package/lib/utils/api/rest-api.d.ts +6 -2
  44. package/lib/utils/api/rest-api.js +64 -34
  45. package/lib/utils/api/schema-api.d.ts +2 -0
  46. package/lib/utils/api/schema-api.js +38 -0
  47. package/lib/utils/api/script-api.d.ts +1 -0
  48. package/lib/utils/api/script-api.js +46 -0
  49. package/lib/utils/common/LoadPlugins.js +9 -16
  50. package/lib/utils/common/index.d.ts +1 -0
  51. package/lib/utils/common/index.js +13 -0
  52. package/lib/utils/page/index.d.ts +2 -0
  53. package/lib/utils/page/index.js +5 -1
  54. package/lib/utils/page/page-form-data-manager-group.d.ts +17 -0
  55. package/lib/utils/page/page-form-data-manager-group.js +111 -0
  56. package/lib/utils/page/page-form-data-manager.d.ts +6 -0
  57. package/lib/utils/page/page-form-data-manager.js +24 -79
  58. package/lib/utils/page/page-form.d.ts +1 -1
  59. package/lib/utils/page/page-form.js +24 -47
  60. package/lib/utils/page/page-layout.js +1 -1
  61. package/lib/utils/page/page-render.d.ts +10 -0
  62. package/lib/utils/page/page-render.js +56 -0
  63. package/lib/utils/page/page-schema-utils.d.ts +1 -0
  64. package/lib/utils/page/page-schema-utils.js +79 -0
  65. package/lib/utils/page/page-show.d.ts +11 -0
  66. package/lib/utils/page/page-show.js +89 -0
  67. package/package.json +1 -1
  68. package/es/utils/common/FormDataHandler.d.ts +0 -45
  69. package/es/utils/common/FormDataHandler.js +0 -410
  70. package/lib/utils/common/FormDataHandler.d.ts +0 -45
  71. package/lib/utils/common/FormDataHandler.js +0 -416
@@ -1,416 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- exports.__esModule = true;
5
- exports["default"] = void 0;
6
- var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
7
- var _message2 = _interopRequireDefault(require("antd/lib/message"));
8
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
9
- var _ProcessHandler = require("./ProcessHandler");
10
- var _dayjs = _interopRequireWildcard(require("dayjs"));
11
- var _SubFormInstance = require("./SubFormInstance");
12
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
13
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
14
- 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."); }
15
- 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); }
16
- 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; }
17
- var FormDataHandler = exports["default"] = /*#__PURE__*/function () {
18
- function FormDataHandler(schema) {
19
- this.schema = void 0;
20
- this.name = void 0;
21
- this.fields = [];
22
- this.scripts = void 0;
23
- this.subFormHandlers = [];
24
- this.schema = schema;
25
- this.name = schema.props.name;
26
- this.scripts = schema.props.scripts || [];
27
- var fields = this.fields,
28
- subFormHandlers = this.subFormHandlers;
29
- function loopEach(item) {
30
- if (Array.isArray(item === null || item === void 0 ? void 0 : item.children)) {
31
- for (var _iterator = _createForOfIteratorHelperLoose(item.children), _step; !(_step = _iterator()).done;) {
32
- var child = _step.value;
33
- fields.push(child);
34
- if (child.componentName == "TableField") {
35
- subFormHandlers.push(new FormDataHandler(child));
36
- } else {
37
- loopEach(child);
38
- }
39
- }
40
- }
41
- }
42
- loopEach(schema);
43
- }
44
- var _proto = FormDataHandler.prototype;
45
- _proto.onValuesChange = /*#__PURE__*/function () {
46
- var _onValuesChange = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(options) {
47
- var form, changeValues, _options$depth, depth, isChange, _iterator2, _step2, script, _iterator3, _step3, handler, index, _iterator4, _step4, subChangeValues, subForm;
48
- return _regenerator["default"].wrap(function _callee$(_context) {
49
- while (1) switch (_context.prev = _context.next) {
50
- case 0:
51
- form = options.form, changeValues = options.changeValues, _options$depth = options.depth, depth = _options$depth === void 0 ? 1 : _options$depth;
52
- if (!(depth > 5)) {
53
- _context.next = 3;
54
- break;
55
- }
56
- return _context.abrupt("return");
57
- case 3:
58
- if (changeValues) {
59
- _context.next = 5;
60
- break;
61
- }
62
- return _context.abrupt("return");
63
- case 5:
64
- isChange = Object.keys(changeValues).length == 1;
65
- if (!isChange) {
66
- _context.next = 21;
67
- break;
68
- }
69
- _context.next = 9;
70
- return this.handleLinkage(options);
71
- case 9:
72
- _context.next = 11;
73
- return this.handleFieldValue(options);
74
- case 11:
75
- _context.next = 13;
76
- return this.handleFillTableValues(options);
77
- case 13:
78
- _iterator2 = _createForOfIteratorHelperLoose(this.scripts);
79
- case 14:
80
- if ((_step2 = _iterator2()).done) {
81
- _context.next = 21;
82
- break;
83
- }
84
- script = _step2.value;
85
- if (!(script.timing == "change")) {
86
- _context.next = 19;
87
- break;
88
- }
89
- _context.next = 19;
90
- return (0, _ProcessHandler.exeProcessScript)(options, script);
91
- case 19:
92
- _context.next = 14;
93
- break;
94
- case 21:
95
- _iterator3 = _createForOfIteratorHelperLoose(this.subFormHandlers);
96
- case 22:
97
- if ((_step3 = _iterator3()).done) {
98
- _context.next = 42;
99
- break;
100
- }
101
- handler = _step3.value;
102
- if (handler.name in changeValues) {
103
- _context.next = 26;
104
- break;
105
- }
106
- return _context.abrupt("continue", 40);
107
- case 26:
108
- if (Array.isArray(changeValues[handler.name])) {
109
- _context.next = 28;
110
- break;
111
- }
112
- return _context.abrupt("continue", 40);
113
- case 28:
114
- index = -1;
115
- _iterator4 = _createForOfIteratorHelperLoose(changeValues[handler.name]);
116
- case 30:
117
- if ((_step4 = _iterator4()).done) {
118
- _context.next = 40;
119
- break;
120
- }
121
- subChangeValues = _step4.value;
122
- index++;
123
- if (subChangeValues) {
124
- _context.next = 35;
125
- break;
126
- }
127
- return _context.abrupt("continue", 38);
128
- case 35:
129
- subForm = new _SubFormInstance.SubFormInstance(form, [handler.name, index]);
130
- _context.next = 38;
131
- return handler.onValuesChange({
132
- depth: depth + 1,
133
- form: subForm,
134
- changeValues: subChangeValues
135
- });
136
- case 38:
137
- _context.next = 30;
138
- break;
139
- case 40:
140
- _context.next = 22;
141
- break;
142
- case 42:
143
- case "end":
144
- return _context.stop();
145
- }
146
- }, _callee, this);
147
- }));
148
- function onValuesChange(_x) {
149
- return _onValuesChange.apply(this, arguments);
150
- }
151
- return onValuesChange;
152
- }()
153
- /**
154
- * 处理联动数据
155
- * @private
156
- */
157
- ;
158
- _proto.handleLinkage =
159
- /*#__PURE__*/
160
- function () {
161
- var _handleLinkage = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(options) {
162
- var _iterator5, _step5, field, _field$props, name, label, format, _field$props$defaultV, type, custom, shortcut, formula, linkage;
163
- return _regenerator["default"].wrap(function _callee2$(_context2) {
164
- while (1) switch (_context2.prev = _context2.next) {
165
- case 0:
166
- _iterator5 = _createForOfIteratorHelperLoose(this.fields);
167
- case 1:
168
- if ((_step5 = _iterator5()).done) {
169
- _context2.next = 13;
170
- break;
171
- }
172
- field = _step5.value;
173
- if (field.props.defaultValue) {
174
- _context2.next = 5;
175
- break;
176
- }
177
- return _context2.abrupt("continue", 11);
178
- case 5:
179
- if (!(field.componentName === "TableField")) {
180
- _context2.next = 7;
181
- break;
182
- }
183
- return _context2.abrupt("continue", 11);
184
- case 7:
185
- _field$props = field.props, name = _field$props.name, label = _field$props.label, format = _field$props.format;
186
- _field$props$defaultV = field.props.defaultValue, type = _field$props$defaultV.type, custom = _field$props$defaultV.custom, shortcut = _field$props$defaultV.shortcut, formula = _field$props$defaultV.formula, linkage = _field$props$defaultV.linkage;
187
- if (!(type != "linkage")) {
188
- _context2.next = 11;
189
- break;
190
- }
191
- return _context2.abrupt("continue", 11);
192
- case 11:
193
- _context2.next = 1;
194
- break;
195
- case 13:
196
- case "end":
197
- return _context2.stop();
198
- }
199
- }, _callee2, this);
200
- }));
201
- function handleLinkage(_x2) {
202
- return _handleLinkage.apply(this, arguments);
203
- }
204
- return handleLinkage;
205
- }();
206
- _proto.handleFieldValue = /*#__PURE__*/function () {
207
- var _handleFieldValue = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(options) {
208
- var form, _iterator6, _step6, field, _field$props2, formula, name, label, trim, value, formulaValue;
209
- return _regenerator["default"].wrap(function _callee3$(_context3) {
210
- while (1) switch (_context3.prev = _context3.next) {
211
- case 0:
212
- form = options.form;
213
- _iterator6 = _createForOfIteratorHelperLoose(this.fields);
214
- case 2:
215
- if ((_step6 = _iterator6()).done) {
216
- _context3.next = 12;
217
- break;
218
- }
219
- field = _step6.value;
220
- if (!isTableField(field)) {
221
- _context3.next = 6;
222
- break;
223
- }
224
- return _context3.abrupt("continue", 10);
225
- case 6:
226
- _field$props2 = field.props, formula = _field$props2.formula, name = _field$props2.name, label = _field$props2.label, trim = _field$props2.trim;
227
- value = form.getFieldValue(name);
228
- if (formula) {
229
- try {
230
- formulaValue = eval(formula);
231
- form.setFieldValue(name, formulaValue);
232
- } catch (e) {
233
- console.log("\u6267\u884C'" + label + "'\u8BA1\u7B97\u516C\u5F0F\u5931\u8D25!", formula, e);
234
- }
235
- }
236
- if (trim) {
237
- if (value && typeof value == "string") {
238
- form.setFieldValue(name, value.trim());
239
- }
240
- }
241
- case 10:
242
- _context3.next = 2;
243
- break;
244
- case 12:
245
- case "end":
246
- return _context3.stop();
247
- }
248
- }, _callee3, this);
249
- }));
250
- function handleFieldValue(_x3) {
251
- return _handleFieldValue.apply(this, arguments);
252
- }
253
- return handleFieldValue;
254
- }()
255
- /**
256
- * 处理填充子表
257
- */
258
- ;
259
- _proto.handleFillTableValues =
260
- /*#__PURE__*/
261
- function () {
262
- var _handleFillTableValues = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(options) {
263
- var form, _loop, _iterator7, _step7;
264
- return _regenerator["default"].wrap(function _callee4$(_context5) {
265
- while (1) switch (_context5.prev = _context5.next) {
266
- case 0:
267
- form = options.form;
268
- _loop = /*#__PURE__*/_regenerator["default"].mark(function _loop() {
269
- var _fillTableValues$forE;
270
- var field, _field$props3, name, fillTableValues;
271
- return _regenerator["default"].wrap(function _loop$(_context4) {
272
- while (1) switch (_context4.prev = _context4.next) {
273
- case 0:
274
- field = _step7.value;
275
- if (!isTableField(field)) {
276
- _context4.next = 3;
277
- break;
278
- }
279
- return _context4.abrupt("return", 1);
280
- case 3:
281
- _field$props3 = field.props, name = _field$props3.name, fillTableValues = _field$props3.fillTableValues;
282
- fillTableValues === null || fillTableValues === void 0 ? void 0 : (_fillTableValues$forE = fillTableValues.forEach) === null || _fillTableValues$forE === void 0 ? void 0 : _fillTableValues$forE.call(fillTableValues, function (cfg) {
283
- var table = cfg.split(".")[0];
284
- var tableField = cfg.split(".")[1];
285
- if (table && tableField) {
286
- var _values$table, _values$table$forEach;
287
- var values = form.getFieldsValue();
288
- var value = form.getFieldValue(name);
289
- (_values$table = values[table]) === null || _values$table === void 0 ? void 0 : (_values$table$forEach = _values$table.forEach) === null || _values$table$forEach === void 0 ? void 0 : _values$table$forEach.call(_values$table, function (item, index) {
290
- form.setFieldValue([table, index, tableField], value);
291
- });
292
- }
293
- });
294
- case 5:
295
- case "end":
296
- return _context4.stop();
297
- }
298
- }, _loop);
299
- });
300
- _iterator7 = _createForOfIteratorHelperLoose(this.fields);
301
- case 3:
302
- if ((_step7 = _iterator7()).done) {
303
- _context5.next = 9;
304
- break;
305
- }
306
- return _context5.delegateYield(_loop(), "t0", 5);
307
- case 5:
308
- if (!_context5.t0) {
309
- _context5.next = 7;
310
- break;
311
- }
312
- return _context5.abrupt("continue", 7);
313
- case 7:
314
- _context5.next = 3;
315
- break;
316
- case 9:
317
- case "end":
318
- return _context5.stop();
319
- }
320
- }, _callee4, this);
321
- }));
322
- function handleFillTableValues(_x4) {
323
- return _handleFillTableValues.apply(this, arguments);
324
- }
325
- return handleFillTableValues;
326
- }()
327
- /***
328
- * 创建初期值
329
- * @private
330
- */
331
- ;
332
- _proto.createInitValues =
333
- /*#__PURE__*/
334
- function () {
335
- var _createInitValues = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5() {
336
- var values;
337
- return _regenerator["default"].wrap(function _callee5$(_context6) {
338
- while (1) switch (_context6.prev = _context6.next) {
339
- case 0:
340
- values = {
341
- initial: true,
342
- createdAt: (0, _dayjs["default"])().format("YYYY-MM-DD HH:mm:ss")
343
- };
344
- this.fields.forEach(function (field) {
345
- //没有配置初始值 直接返回
346
- if (!field.props.defaultValue) return;
347
- //子表不处理
348
- if (field.componentName === "TableField") return;
349
- var _field$props4 = field.props,
350
- name = _field$props4.name,
351
- label = _field$props4.label,
352
- format = _field$props4.format;
353
- var _field$props$defaultV2 = field.props.defaultValue,
354
- type = _field$props$defaultV2.type,
355
- custom = _field$props$defaultV2.custom,
356
- shortcut = _field$props$defaultV2.shortcut,
357
- formula = _field$props$defaultV2.formula,
358
- linkage = _field$props$defaultV2.linkage;
359
- var initValue;
360
- switch (type) {
361
- //关联值
362
- case "linkage":
363
- break;
364
- //自定义
365
- case "custom":
366
- initValue = custom;
367
- break;
368
- //公式
369
- case "formula":
370
- try {
371
- initValue = eval(formula);
372
- } catch (e) {
373
- _message2["default"].error("\u8BBE\u7F6E" + label + "\u521D\u59CB\u503C\u5931\u8D25!" + (e === null || e === void 0 ? void 0 : e.message)).then();
374
- }
375
- break;
376
- //快捷方式
377
- case "shortcut":
378
- try {
379
- initValue = eval(shortcut);
380
- } catch (e) {
381
- _message2["default"].error("\u8BBE\u7F6E" + label + "\u521D\u59CB\u503C\u5931\u8D25!" + (e === null || e === void 0 ? void 0 : e.message)).then();
382
- }
383
- break;
384
- }
385
- values[name] = handleValue(initValue, format);
386
- });
387
- return _context6.abrupt("return", values);
388
- case 3:
389
- case "end":
390
- return _context6.stop();
391
- }
392
- }, _callee5, this);
393
- }));
394
- function createInitValues() {
395
- return _createInitValues.apply(this, arguments);
396
- }
397
- return createInitValues;
398
- }();
399
- return FormDataHandler;
400
- }();
401
- function handleValue(value, format) {
402
- if (!format) return value;
403
- if (!value) return value;
404
- if (Array.isArray(value)) {
405
- return value.map(function (v) {
406
- return handleValue(v, format);
407
- });
408
- } else if ((0, _dayjs.isDayjs)(value)) {
409
- return value.format(format);
410
- } else {
411
- return value;
412
- }
413
- }
414
- function isTableField(field) {
415
- return field.componentName === "TableField";
416
- }