@zhubangyun/lowcode-core 5.8.291 → 5.10.81

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