@zhubangyun/lowcode-core 5.10.220 → 5.12.10

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.less +10 -0
  2. package/es/utils/api/file-api.d.ts +17 -5
  3. package/es/utils/api/file-api.js +10 -7
  4. package/es/utils/api/form-api.d.ts +1 -1
  5. package/es/utils/api/form-api.js +70 -66
  6. package/es/utils/api/form-api.utils.d.ts +5 -5
  7. package/es/utils/api/form-api.utils.js +55 -36
  8. package/es/utils/api/index.d.ts +4 -3
  9. package/es/utils/api/index.js +9 -2
  10. package/es/utils/api/rest-api.d.ts +6 -5
  11. package/es/utils/api/rest-api.js +1 -1
  12. package/es/utils/api/schema.util.d.ts +14 -0
  13. package/es/utils/api/schema.util.js +32 -0
  14. package/es/utils/api/script-api.js +1 -1
  15. package/es/utils/api/user-info.d.ts +16 -6
  16. package/es/utils/api/user-info.js +31 -20
  17. package/es/utils/cache/index.d.ts +6 -6
  18. package/es/utils/cache/index.js +56 -24
  19. package/es/utils/cache/schema.d.ts +0 -2
  20. package/es/utils/cache/schema.js +0 -388
  21. package/es/utils/formIds.d.ts +3 -0
  22. package/es/utils/formIds.js +3 -0
  23. package/es/utils/page/index.d.ts +2 -0
  24. package/es/utils/page/index.js +2 -0
  25. package/es/utils/page/page-form-data-manager-group.d.ts +2 -0
  26. package/es/utils/page/page-form-data-manager-group.js +3 -7
  27. package/es/utils/page/page-form-data-manager.d.ts +2 -1
  28. package/es/utils/page/page-form-data-manager.js +1 -0
  29. package/es/utils/page/page-form-group.d.ts +17 -0
  30. package/es/utils/page/page-form-group.js +97 -0
  31. package/es/utils/page/page-form.d.ts +2 -1
  32. package/es/utils/page/page-form.js +3 -3
  33. package/es/utils/page/page-show.d.ts +1 -0
  34. package/es/utils/page/print-form.d.ts +8 -0
  35. package/es/utils/page/print-form.js +147 -0
  36. package/lib/index.less +10 -0
  37. package/lib/utils/api/file-api.d.ts +17 -5
  38. package/lib/utils/api/file-api.js +10 -7
  39. package/lib/utils/api/form-api.d.ts +1 -1
  40. package/lib/utils/api/form-api.js +70 -66
  41. package/lib/utils/api/form-api.utils.d.ts +5 -5
  42. package/lib/utils/api/form-api.utils.js +55 -36
  43. package/lib/utils/api/index.d.ts +4 -3
  44. package/lib/utils/api/index.js +10 -3
  45. package/lib/utils/api/rest-api.d.ts +6 -5
  46. package/lib/utils/api/rest-api.js +1 -1
  47. package/lib/utils/api/schema.util.d.ts +14 -0
  48. package/lib/utils/api/schema.util.js +37 -0
  49. package/lib/utils/api/script-api.js +1 -1
  50. package/lib/utils/api/user-info.d.ts +16 -6
  51. package/lib/utils/api/user-info.js +32 -21
  52. package/lib/utils/cache/index.d.ts +6 -6
  53. package/lib/utils/cache/index.js +57 -24
  54. package/lib/utils/cache/schema.d.ts +0 -2
  55. package/lib/utils/cache/schema.js +0 -390
  56. package/lib/utils/formIds.d.ts +3 -0
  57. package/lib/utils/formIds.js +7 -0
  58. package/lib/utils/page/index.d.ts +2 -0
  59. package/lib/utils/page/index.js +7 -1
  60. package/lib/utils/page/page-form-data-manager-group.d.ts +2 -0
  61. package/lib/utils/page/page-form-data-manager-group.js +3 -7
  62. package/lib/utils/page/page-form-data-manager.d.ts +2 -1
  63. package/lib/utils/page/page-form-data-manager.js +1 -0
  64. package/lib/utils/page/page-form-group.d.ts +17 -0
  65. package/lib/utils/page/page-form-group.js +104 -0
  66. package/lib/utils/page/page-form.d.ts +2 -1
  67. package/lib/utils/page/page-form.js +3 -3
  68. package/lib/utils/page/page-show.d.ts +1 -0
  69. package/lib/utils/page/print-form.d.ts +8 -0
  70. package/lib/utils/page/print-form.js +153 -0
  71. package/package.json +1 -1
package/es/index.less CHANGED
@@ -1,3 +1,13 @@
1
1
  [componentname="Page"] {
2
2
  height: 100%;
3
3
  }
4
+
5
+ ul {
6
+ margin-bottom: 0;
7
+ padding-left: 0;
8
+ list-style: none;
9
+ }
10
+
11
+ .page-content {
12
+ overflow: hidden;
13
+ }
@@ -1,7 +1,19 @@
1
+ /// <reference types="node" />
1
2
  import { AxiosProgressEvent } from "axios";
2
- export declare function upload(file: any, options?: {
3
- onProgress: (evt: AxiosProgressEvent) => void;
4
- onFinished: () => void;
5
- onError: (e: any) => void;
6
- }): Promise<void>;
3
+ interface File {
4
+ id?: string;
5
+ size?: number;
6
+ name?: string;
7
+ type?: string;
8
+ status?: "done" | "uploading" | "error";
9
+ url: string;
10
+ percent?: number;
11
+ buffer?: Buffer;
12
+ }
13
+ export declare function upload(file: File, options?: {
14
+ onProgress?: (evt: AxiosProgressEvent) => void;
15
+ onFinished?: () => void;
16
+ onError?: (e: any) => void;
17
+ }): Promise<File>;
7
18
  export declare function update(file: any): Promise<void>;
19
+ export {};
@@ -14,10 +14,11 @@ function _upload() {
14
14
  _context.next = 2;
15
15
  break;
16
16
  }
17
- return _context.abrupt("return");
17
+ return _context.abrupt("return", file);
18
18
  case 2:
19
19
  _context.next = 4;
20
20
  return apiRequest.post("files/signature", {
21
+ id: file.id,
21
22
  size: file.size,
22
23
  name: file.name,
23
24
  type: file.type
@@ -35,7 +36,7 @@ function _upload() {
35
36
  file.status = "uploading";
36
37
  _context.prev = 10;
37
38
  _context.next = 13;
38
- return apiRequest.put(ossFile.uploadUrl, file, {
39
+ return apiRequest.put(ossFile.uploadUrl, (file === null || file === void 0 ? void 0 : file.buffer) || file, {
39
40
  headers: {
40
41
  'Content-Type': file.type
41
42
  },
@@ -48,18 +49,20 @@ function _upload() {
48
49
  }
49
50
  });
50
51
  case 13:
52
+ file.status = "done";
51
53
  options === null || options === void 0 ? void 0 : (_options$onFinished = options.onFinished) === null || _options$onFinished === void 0 ? void 0 : _options$onFinished.call(options);
52
- _context.next = 19;
54
+ _context.next = 21;
53
55
  break;
54
- case 16:
55
- _context.prev = 16;
56
+ case 17:
57
+ _context.prev = 17;
56
58
  _context.t0 = _context["catch"](10);
59
+ file.status = "error";
57
60
  options === null || options === void 0 ? void 0 : (_options$onError = options.onError) === null || _options$onError === void 0 ? void 0 : _options$onError.call(options, _context.t0);
58
- case 19:
61
+ case 21:
59
62
  case "end":
60
63
  return _context.stop();
61
64
  }
62
- }, _callee, null, [[10, 16]]);
65
+ }, _callee, null, [[10, 17]]);
63
66
  }));
64
67
  return _upload.apply(this, arguments);
65
68
  }
@@ -1,6 +1,6 @@
1
1
  import { BaseRequestOptions, ManyResult, OneResult, RestApi, RestSearchParams } from "./rest-api";
2
2
  import { AxiosRequestConfig } from "axios";
3
- export declare function getFormApi(formId: string, fieldId?: string, mock?: boolean): RestFormApi<any>;
3
+ export declare function getFormApi(formId: string, fieldId?: string, mock?: boolean): Promise<RestFormApi<any>>;
4
4
  export declare class RestFormApi<DataType> extends RestApi<DataType> {
5
5
  private readonly formId;
6
6
  private readonly fieldId?;
@@ -1,25 +1,40 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
- import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
2
  import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
3
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
4
4
  import _regeneratorRuntime from "@babel/runtime/regenerator";
5
5
  import { RestApi } from "./rest-api";
6
- import { getSchema } from "./index";
7
6
  import { assembleAssociationField, convertSaveData, handleFilterRules } from "./form-api.utils";
8
7
  import { formApi } from "../cache";
9
- export function getFormApi(formId, fieldId, mock) {
10
- if (typeof mock != "boolean") {
11
- if (typeof window.__mock == "boolean") {
12
- mock = window.__mock;
13
- }
14
- }
15
- var key = [formId, fieldId, mock ? "mock" : ""].filter(function (key) {
16
- return !!key;
17
- }).join("_");
18
- return formApi.getInstance(key, {
19
- mock: mock,
20
- fieldId: fieldId,
21
- formId: formId
22
- });
8
+ import { getSchemaFromCache } from "./schema-api";
9
+ export function getFormApi(_x, _x2, _x3) {
10
+ return _getFormApi.apply(this, arguments);
11
+ }
12
+ function _getFormApi() {
13
+ _getFormApi = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(formId, fieldId, mock) {
14
+ var key;
15
+ return _regeneratorRuntime.wrap(function _callee9$(_context9) {
16
+ while (1) switch (_context9.prev = _context9.next) {
17
+ case 0:
18
+ if (typeof mock != "boolean") {
19
+ if (typeof window.__mock == "boolean") {
20
+ mock = window.__mock;
21
+ }
22
+ }
23
+ key = [formId, fieldId, mock ? "mock" : ""].filter(function (key) {
24
+ return !!key;
25
+ }).join("_");
26
+ return _context9.abrupt("return", formApi.getInstance(key, {
27
+ mock: mock,
28
+ fieldId: fieldId,
29
+ formId: formId
30
+ }));
31
+ case 3:
32
+ case "end":
33
+ return _context9.stop();
34
+ }
35
+ }, _callee9);
36
+ }));
37
+ return _getFormApi.apply(this, arguments);
23
38
  }
24
39
  export var RestFormApi = /*#__PURE__*/function (_RestApi) {
25
40
  function RestFormApi(formId, fieldId, mock) {
@@ -40,56 +55,46 @@ export var RestFormApi = /*#__PURE__*/function (_RestApi) {
40
55
  _proto.initialize = /*#__PURE__*/function () {
41
56
  var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
42
57
  var _this2 = this;
43
- var _this$schema$children, _this$schema$children2, res;
58
+ var res, _this$schema, _this$schema$children, _this$schema$children2;
44
59
  return _regeneratorRuntime.wrap(function _callee$(_context) {
45
60
  while (1) switch (_context.prev = _context.next) {
46
61
  case 0:
47
62
  if (!this.initialized) {
48
- _context.next = 4;
49
- break;
50
- }
51
- return _context.abrupt("return", true);
52
- case 4:
53
- _context.prev = 4;
54
- _context.next = 7;
55
- return getSchema(this.formId, this.mock);
56
- case 7:
57
- res = _context.sent;
58
- this.schema = res.data;
59
- this.initialized = !!this.schema;
60
- this.title = (_this$schema$children = this.schema.children[0]) === null || _this$schema$children === void 0 ? void 0 : (_this$schema$children2 = _this$schema$children.props) === null || _this$schema$children2 === void 0 ? void 0 : _this$schema$children2.label;
61
- if (this.fieldId) {
62
- JSON.stringify(this.schema, function (key, value) {
63
- var _value$props;
64
- if (key == "fdmSchema") {
65
- return undefined;
66
- }
67
- if ((value === null || value === void 0 ? void 0 : (_value$props = value.props) === null || _value$props === void 0 ? void 0 : _value$props.fieldId) === _this2.fieldId) {
68
- if (value.props.label) {
69
- _this2.title += "." + value.props.label;
63
+ try {
64
+ res = getSchemaFromCache(this.formId, this.mock);
65
+ this.schema = res === null || res === void 0 ? void 0 : res.data;
66
+ this.initialized = !!this.schema;
67
+ if (this.initialized) {
68
+ this.title = (_this$schema = this.schema) === null || _this$schema === void 0 ? void 0 : (_this$schema$children = _this$schema.children[0]) === null || _this$schema$children === void 0 ? void 0 : (_this$schema$children2 = _this$schema$children.props) === null || _this$schema$children2 === void 0 ? void 0 : _this$schema$children2.label;
69
+ if (this.fieldId) {
70
+ JSON.stringify(this.schema, function (key, value) {
71
+ var _value$props;
72
+ if (key == "fdmSchema") {
73
+ return undefined;
74
+ }
75
+ if ((value === null || value === void 0 ? void 0 : (_value$props = value.props) === null || _value$props === void 0 ? void 0 : _value$props.fieldId) === _this2.fieldId) {
76
+ if (value.props.label) {
77
+ _this2.title += "." + value.props.label;
78
+ }
79
+ }
80
+ return value;
81
+ });
70
82
  }
71
83
  }
72
- return value;
73
- });
84
+ } catch (e) {
85
+ console.log("获取schema失败!", {
86
+ formId: this.formId,
87
+ field: this.fieldId,
88
+ mock: this.mock
89
+ }, e);
90
+ }
74
91
  }
75
- _context.next = 18;
76
- break;
77
- case 14:
78
- _context.prev = 14;
79
- _context.t0 = _context["catch"](4);
80
- console.log("获取schema失败!", {
81
- formId: this.formId,
82
- field: this.fieldId,
83
- mock: this.mock
84
- }, _context.t0);
85
- throw _context.t0;
86
- case 18:
87
92
  return _context.abrupt("return", this.initialized);
88
- case 19:
93
+ case 2:
89
94
  case "end":
90
95
  return _context.stop();
91
96
  }
92
- }, _callee, this, [[4, 14]]);
97
+ }, _callee, this);
93
98
  }));
94
99
  function initialize() {
95
100
  return _initialize.apply(this, arguments);
@@ -121,7 +126,7 @@ export var RestFormApi = /*#__PURE__*/function (_RestApi) {
121
126
  }
122
127
  }, _callee2, this);
123
128
  }));
124
- function handleRequestConfig(_x) {
129
+ function handleRequestConfig(_x4) {
125
130
  return _handleRequestConfig.apply(this, arguments);
126
131
  }
127
132
  return handleRequestConfig;
@@ -139,7 +144,7 @@ export var RestFormApi = /*#__PURE__*/function (_RestApi) {
139
144
  fieldId: this.fieldId
140
145
  };
141
146
  if (__mock) {
142
- params.description = "" + this.title;
147
+ params.description = (this.title || "表单") + ".\u67E5\u8BE2";
143
148
  }
144
149
  config = {
145
150
  params: params
@@ -169,14 +174,14 @@ export var RestFormApi = /*#__PURE__*/function (_RestApi) {
169
174
  }
170
175
  }, _callee3, this);
171
176
  }));
172
- function search(_x2) {
177
+ function search(_x5) {
173
178
  return _search.apply(this, arguments);
174
179
  }
175
180
  return search;
176
181
  }();
177
182
  _proto.getById = /*#__PURE__*/function () {
178
183
  var _getById = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(id, options) {
179
- var res, start;
184
+ var res;
180
185
  return _regeneratorRuntime.wrap(function _callee4$(_context4) {
181
186
  while (1) switch (_context4.prev = _context4.next) {
182
187
  case 0:
@@ -184,17 +189,16 @@ export var RestFormApi = /*#__PURE__*/function (_RestApi) {
184
189
  return _RestApi.prototype.getById.call(this, id, options);
185
190
  case 2:
186
191
  res = _context4.sent;
187
- start = Date.now();
188
192
  assembleAssociationField(res.data, res.refs);
189
193
  console.debug("formApi.getById", res);
190
194
  return _context4.abrupt("return", res);
191
- case 7:
195
+ case 6:
192
196
  case "end":
193
197
  return _context4.stop();
194
198
  }
195
199
  }, _callee4, this);
196
200
  }));
197
- function getById(_x3, _x4) {
201
+ function getById(_x6, _x7) {
198
202
  return _getById.apply(this, arguments);
199
203
  }
200
204
  return getById;
@@ -211,7 +215,7 @@ export var RestFormApi = /*#__PURE__*/function (_RestApi) {
211
215
  }
212
216
  }, _callee5, this);
213
217
  }));
214
- function save(_x5, _x6) {
218
+ function save(_x8, _x9) {
215
219
  return _save.apply(this, arguments);
216
220
  }
217
221
  return save;
@@ -228,7 +232,7 @@ export var RestFormApi = /*#__PURE__*/function (_RestApi) {
228
232
  }
229
233
  }, _callee6, this);
230
234
  }));
231
- function create(_x7, _x8) {
235
+ function create(_x10, _x11) {
232
236
  return _create.apply(this, arguments);
233
237
  }
234
238
  return create;
@@ -245,7 +249,7 @@ export var RestFormApi = /*#__PURE__*/function (_RestApi) {
245
249
  }
246
250
  }, _callee7, this);
247
251
  }));
248
- function update(_x9, _x10, _x11) {
252
+ function update(_x12, _x13, _x14) {
249
253
  return _update.apply(this, arguments);
250
254
  }
251
255
  return update;
@@ -262,7 +266,7 @@ export var RestFormApi = /*#__PURE__*/function (_RestApi) {
262
266
  }
263
267
  }, _callee8, this);
264
268
  }));
265
- function serviceUpdate(_x12, _x13) {
269
+ function serviceUpdate(_x15, _x16) {
266
270
  return _serviceUpdate.apply(this, arguments);
267
271
  }
268
272
  return serviceUpdate;
@@ -1,15 +1,15 @@
1
- import { BaseType, FilterRule, Refs } from "./rest-api";
1
+ import { FilterRule, IBaseEntity, Refs } from "./rest-api";
2
2
  export declare function convertSaveData(data: any): any;
3
- export declare function handleEntityLabel(data: BaseType | BaseType[]): void;
4
3
  export declare function dataToLabel(value: any): any;
5
- export declare function assembleAssociationFieldV2(data: BaseType | BaseType[], refs?: Refs): void;
4
+ export declare function assembleAssociationFieldV2(data: IBaseEntity | IBaseEntity[], refs?: Refs): void;
6
5
  /**
7
6
  * 加载字段
8
7
  * @param data
9
8
  * @param dataMap
10
9
  */
11
- export declare function assembleAssociationFieldDataV2(data: BaseType | BaseType[], dataMap: Map<string, BaseType>): void;
12
- export declare function assembleAssociationField(data: BaseType | BaseType[], refs?: Refs): void;
10
+ export declare function assembleAssociationFieldDataV2(data: IBaseEntity | IBaseEntity[], dataMap: Map<string, IBaseEntity>): void;
11
+ export declare function handleEntityLabel(data: IBaseEntity | IBaseEntity[]): void;
12
+ export declare function assembleAssociationField(data: IBaseEntity | IBaseEntity[], refs?: Refs): void;
13
13
  export declare function handleFilterRules(filters: FilterRule[], options: {
14
14
  filterNullValue: boolean;
15
15
  }): FilterRule[];
@@ -23,21 +23,6 @@ function getDataKey(data) {
23
23
  }
24
24
  return key + "." + data.id;
25
25
  }
26
- export function handleEntityLabel(data) {
27
- if (!Array.isArray(data)) {
28
- data = [data];
29
- }
30
- for (var _iterator = _createForOfIteratorHelperLoose(data), _step; !(_step = _iterator()).done;) {
31
- var _item$form;
32
- var item = _step.value;
33
- var labelField = (_item$form = item.form) === null || _item$form === void 0 ? void 0 : _item$form.labelField;
34
- if (labelField) {
35
- // @ts-ignore
36
- var value = safeGet(item, labelField);
37
- item.label = dataToLabel(value);
38
- }
39
- }
40
- }
41
26
  export function dataToLabel(value) {
42
27
  if (value == null) {
43
28
  return "";
@@ -61,44 +46,44 @@ export function dataToLabel(value) {
61
46
  export function assembleAssociationFieldV2(data, refs) {
62
47
  if (!data || !refs) return;
63
48
  var dataMap = new Map();
64
- for (var _iterator2 = _createForOfIteratorHelperLoose(refs), _step2; !(_step2 = _iterator2()).done;) {
65
- var ref = _step2.value;
66
- for (var _iterator4 = _createForOfIteratorHelperLoose(ref.data), _step4; !(_step4 = _iterator4()).done;) {
67
- var datum = _step4.value;
49
+ for (var _iterator = _createForOfIteratorHelperLoose(refs), _step; !(_step = _iterator()).done;) {
50
+ var ref = _step.value;
51
+ ref.label = ref.form.label;
52
+ for (var _iterator3 = _createForOfIteratorHelperLoose(ref.data), _step3; !(_step3 = _iterator3()).done;) {
53
+ var datum = _step3.value;
68
54
  var key = getDataKey(datum);
69
55
  dataMap.set(key, datum);
70
56
  }
71
57
  }
72
-
73
58
  //组装refs的关联属性
74
- for (var _iterator3 = _createForOfIteratorHelperLoose(dataMap.values()), _step3; !(_step3 = _iterator3()).done;) {
75
- var item = _step3.value;
59
+ for (var _iterator2 = _createForOfIteratorHelperLoose(dataMap.values()), _step2; !(_step2 = _iterator2()).done;) {
60
+ var item = _step2.value;
76
61
  for (var _i2 = 0, _Object$keys = Object.keys(item); _i2 < _Object$keys.length; _i2++) {
77
62
  var _key = _Object$keys[_i2];
78
- // @ts-ignore
79
63
  var value = item[_key];
80
64
  assembleAssociationFieldDataV2(value, dataMap);
81
65
  }
82
66
  }
83
- handleEntityLabel([].concat(dataMap.values()));
84
67
  function loopAssembleAssociation(value) {
68
+ var _value$form;
85
69
  if (Array.isArray(value)) {
86
70
  value.forEach(function (item) {
87
71
  return loopAssembleAssociation(item);
88
72
  });
89
- } else if (value !== null && value !== void 0 && value.id) {
90
- handleEntityLabel(value);
73
+ } else if (value !== null && value !== void 0 && value.id && (_value$form = value.form) !== null && _value$form !== void 0 && _value$form.id) {
74
+ if (value._load) return;
91
75
  assembleAssociationFieldDataV2(value, dataMap);
92
- //处理子表
93
76
  for (var _i = 0, _Object$values = Object.values(value); _i < _Object$values.length; _i++) {
94
77
  var subValues = _Object$values[_i];
95
- if (typeof subValues == "object") {
78
+ if (subValues !== null && typeof subValues == "object") {
96
79
  loopAssembleAssociation(subValues);
97
80
  }
98
81
  }
99
82
  }
100
83
  }
101
84
  loopAssembleAssociation(data);
85
+ handleEntityLabel(data);
86
+ dataMap.clear();
102
87
  }
103
88
 
104
89
  /**
@@ -107,28 +92,62 @@ export function assembleAssociationFieldV2(data, refs) {
107
92
  * @param dataMap
108
93
  */
109
94
  export function assembleAssociationFieldDataV2(data, dataMap) {
110
- if (data == null) {
111
- return;
112
- }
95
+ if (data == null || typeof data != "object") return;
113
96
  if (Array.isArray(data)) {
114
97
  data.forEach(function (item) {
115
98
  return assembleAssociationFieldDataV2(item, dataMap);
116
99
  });
117
100
  } else {
118
- if (data._load == false) {
101
+ if (!data._load) {
119
102
  var _data$form3;
120
- if (data !== null && data !== void 0 && (_data$form3 = data.form) !== null && _data$form3 !== void 0 && _data$form3.id && data !== null && data !== void 0 && data.id) {
121
- delete data._load;
103
+ if (data !== null && data !== void 0 && data.id && data !== null && data !== void 0 && (_data$form3 = data.form) !== null && _data$form3 !== void 0 && _data$form3.id) {
122
104
  var key = getDataKey(data);
123
105
  var value = dataMap.get(key);
124
106
  if (value) {
125
- Object.assign(data, value);
126
- delete data._load;
107
+ Object.assign(data, JSON.parse(JSON.stringify(value)));
127
108
  }
109
+ data._load = true;
128
110
  }
129
111
  }
130
112
  }
131
113
  }
114
+ export function handleEntityLabel(data) {
115
+ if (Array.isArray(data)) {
116
+ data.forEach(function (item) {
117
+ return handleEntityLabel(item);
118
+ });
119
+ } else if (typeof data == "object") {
120
+ var form = data === null || data === void 0 ? void 0 : data.form;
121
+ if (form) {
122
+ var labelField = form === null || form === void 0 ? void 0 : form.labelField;
123
+ if (labelField) {
124
+ // @ts-ignore
125
+ var label = safeGet(data, labelField);
126
+ data.label = dataToLabel(label);
127
+ }
128
+ for (var _i3 = 0, _Object$keys2 = Object.keys(data); _i3 < _Object$keys2.length; _i3++) {
129
+ var key = _Object$keys2[_i3];
130
+ // @ts-ignore
131
+ handleEntityLabel(data[key]);
132
+ }
133
+ }
134
+ }
135
+ }
136
+ function valueToFormDataArray(value) {
137
+ if (typeof value == null || typeof value !== "object") {
138
+ return [];
139
+ }
140
+ if (Array.isArray(value)) {
141
+ return value === null || value === void 0 ? void 0 : value.filter(function (item) {
142
+ var _item$form;
143
+ return (item === null || item === void 0 ? void 0 : item.id) && (item === null || item === void 0 ? void 0 : (_item$form = item.form) === null || _item$form === void 0 ? void 0 : _item$form.id);
144
+ });
145
+ } else if (typeof value == "object" && value !== null) {
146
+ return valueToFormDataArray([value]);
147
+ } else {
148
+ return [];
149
+ }
150
+ }
132
151
  export function assembleAssociationField(data, refs) {
133
152
  assembleAssociationFieldV2(data, refs);
134
153
  }
@@ -1,10 +1,11 @@
1
1
  export { RestApi } from "./rest-api";
2
2
  export { getFormApi, RestFormApi } from "./form-api";
3
+ import { AxiosResponse } from "axios/index";
3
4
  export { getSchema } from "./schema-api";
4
- export { loadUserInfo } from "./user-info";
5
+ export { getUserinfo } from "./user-info";
5
6
  export * as files from "./file-api";
6
7
  export * as scrips from "./script-api";
7
8
  export declare const apiRequest: import("axios").AxiosInstance;
8
- export declare const request: <T = any, R = import("axios").AxiosResponse<T, any>, D = any>(config: import("axios").AxiosRequestConfig<D>) => Promise<R>;
9
- export declare function onFulfilled(res: any): any;
9
+ export declare const request: <T = any, R = AxiosResponse<T, any>, D = any>(config: import("axios").AxiosRequestConfig<D>) => Promise<R>;
10
+ export declare function onFulfilled(res: AxiosResponse): any;
10
11
  export declare function onRejected(error: any): any;
@@ -2,7 +2,7 @@ import axios from "axios";
2
2
  export { RestApi } from "./rest-api";
3
3
  export { getFormApi, RestFormApi } from "./form-api";
4
4
  export { getSchema } from "./schema-api";
5
- export { loadUserInfo } from "./user-info";
5
+ export { getUserinfo } from "./user-info";
6
6
  import * as _files from "./file-api";
7
7
  export { _files as files };
8
8
  import * as _scrips from "./script-api";
@@ -10,7 +10,7 @@ export { _scrips as scrips };
10
10
  export var apiRequest = axios.create({
11
11
  baseURL: "/api",
12
12
  // 基础URL
13
- timeout: 10000,
13
+ timeout: 600000,
14
14
  // 请求超时时间(毫秒)
15
15
  headers: {
16
16
  'Content-Type': 'application/json;charset=UTF-8'
@@ -19,6 +19,13 @@ export var apiRequest = axios.create({
19
19
  apiRequest.interceptors.response.use(onFulfilled, onRejected);
20
20
  export var request = apiRequest.request;
21
21
  export function onFulfilled(res) {
22
+ if (typeof res.data == "object") {
23
+ if ("success" in res.data) {
24
+ if (res.headers["Request-Id"]) {
25
+ res.data.requestId = res.headers["Request-Id"];
26
+ }
27
+ }
28
+ }
22
29
  return res.data;
23
30
  }
24
31
  export function onRejected(error) {
@@ -60,7 +60,7 @@ export declare class RestApi<DataType> extends BaseRestApi<DataType> {
60
60
  constructor(uri: string, options?: RestApiOptions);
61
61
  handleRequestConfig(config: AxiosRequestConfig): Promise<void>;
62
62
  }
63
- export interface BaseType {
63
+ export interface IBaseEntity {
64
64
  /**
65
65
  * 对象id
66
66
  */
@@ -103,19 +103,20 @@ export interface BaseResult<DataType> {
103
103
  refs?: Refs;
104
104
  }
105
105
  export interface Ref {
106
+ label: string;
106
107
  form: {
107
108
  id: string;
108
109
  fieldId?: string;
110
+ label: string;
109
111
  };
110
- fieldIds: string[];
111
- data: BaseType[];
112
+ data: IBaseEntity[];
112
113
  }
113
114
  export type Refs = Ref[];
114
115
  export interface OneResult<DataType> extends BaseResult<DataType> {
115
- data: DataType & BaseType;
116
+ data: DataType & IBaseEntity;
116
117
  }
117
118
  export interface ManyResult<DataType> extends BaseResult<DataType> {
118
- data: (DataType & BaseType)[];
119
+ data: (DataType & IBaseEntity)[];
119
120
  total: number;
120
121
  }
121
122
  export interface BaseRequestOptions<DataType> {
@@ -18,7 +18,7 @@ export var BaseRestApi = /*#__PURE__*/function () {
18
18
  this.request = axios.create({
19
19
  baseURL: "/api/" + uri,
20
20
  // 基础URL
21
- timeout: 10000,
21
+ timeout: 60000,
22
22
  // 请求超时时间(毫秒)
23
23
  headers: {
24
24
  'Content-Type': 'application/json;charset=UTF-8'
@@ -0,0 +1,14 @@
1
+ /**
2
+ * 遍历schema
3
+ * @param schema
4
+ * @param callback 返回true 继续往下遍历
5
+ */
6
+ export declare function forEachSchema(schema: Schema, callback: (child: Schema, index: number, children: any[]) => boolean): void;
7
+ export declare function forEachFormSchema(schema: Schema, fdm: boolean, callback: (child: Schema) => void): void;
8
+ interface Schema {
9
+ componentName: string;
10
+ props: any;
11
+ children?: Schema[];
12
+ fdmSchema?: Schema;
13
+ }
14
+ export {};
@@ -0,0 +1,32 @@
1
+ /**
2
+ * 遍历schema
3
+ * @param schema
4
+ * @param callback 返回true 继续往下遍历
5
+ */
6
+ export function forEachSchema(schema, callback) {
7
+ var _schema$children;
8
+ schema === null || schema === void 0 ? void 0 : (_schema$children = schema.children) === null || _schema$children === void 0 ? void 0 : _schema$children.forEach(function (child, index, children) {
9
+ var ctn = callback(child, index, children);
10
+ if (ctn) {
11
+ forEachSchema(child, callback);
12
+ }
13
+ });
14
+ }
15
+ export function forEachFormSchema(schema, fdm, callback) {
16
+ forEachSchema(schema, function (child) {
17
+ if (["PageForm", "SubFormField"].includes(child.componentName)) {
18
+ callback(child);
19
+ if (fdm) {
20
+ if (child.fdmSchema) {
21
+ forEachSchema(child.fdmSchema, function (fdmChild) {
22
+ if (fdmChild.componentName == "PageFdm") {
23
+ callback(child);
24
+ }
25
+ return true;
26
+ });
27
+ }
28
+ }
29
+ }
30
+ return true;
31
+ });
32
+ }
@@ -12,7 +12,7 @@ function _loadDts() {
12
12
  case 0:
13
13
  _context.prev = 0;
14
14
  _context.next = 3;
15
- return getFormApi("form_bea7fcc6376c4461965237056f970fb7");
15
+ return getFormApi("c40772eb-864b-42bb-ae31-9921d8ede97f");
16
16
  case 3:
17
17
  api = _context.sent;
18
18
  _context.next = 6;