@zhubangyun/lowcode-core 6.2.30 → 6.3.20

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 (69) hide show
  1. package/es/components/react-render/index.js +11 -1
  2. package/es/utils/api/form-api/form-api.assemble-entity.d.ts +2 -0
  3. package/es/utils/api/form-api/form-api.assemble-entity.js +95 -0
  4. package/es/utils/api/form-api/form-api.entity-map.d.ts +12 -0
  5. package/es/utils/api/form-api/form-api.entity-map.js +50 -0
  6. package/es/utils/api/{form-api.utils.d.ts → form-api/form-api.utils.d.ts} +3 -2
  7. package/es/utils/api/{form-api.utils.js → form-api/form-api.utils.js} +41 -8
  8. package/es/utils/api/form-api.js +10 -17
  9. package/es/utils/api/rest-api.d.ts +2 -1
  10. package/es/utils/api/schema-api.d.ts +2 -1
  11. package/es/utils/api/schema-api.js +1 -1
  12. package/es/utils/api/schema.util.d.ts +1 -0
  13. package/es/utils/api/schema.util.js +10 -0
  14. package/es/utils/cache/index.d.ts +0 -1
  15. package/es/utils/cache/index.js +58 -35
  16. package/es/utils/cache/index_db_cache.d.ts +9 -0
  17. package/es/utils/cache/index_db_cache.js +7 -0
  18. package/es/utils/common/SingletonInstanceMap.d.ts +2 -2
  19. package/es/utils/data/index.d.ts +3 -1
  20. package/es/utils/data/index.js +10 -3
  21. package/es/utils/page/index.d.ts +1 -0
  22. package/es/utils/page/index.js +1 -1
  23. package/es/utils/page/page-create-element.d.ts +6 -0
  24. package/es/utils/page/page-create-element.js +23 -0
  25. package/es/utils/page/page-render.js +1 -1
  26. package/es/utils/page/page-schema-utils.js +2 -1
  27. package/es/utils/page/print-form.d.ts +1 -1
  28. package/es/utils/page/print-form.js +13 -7
  29. package/es/utils/uni-bridge.js +1 -3
  30. package/es/utils/util.common.d.ts +1 -1
  31. package/es/utils/util.common.js +1 -2
  32. package/lib/components/react-render/index.js +11 -1
  33. package/lib/utils/api/form-api/form-api.assemble-entity.d.ts +2 -0
  34. package/lib/utils/api/form-api/form-api.assemble-entity.js +99 -0
  35. package/lib/utils/api/form-api/form-api.entity-map.d.ts +12 -0
  36. package/lib/utils/api/form-api/form-api.entity-map.js +54 -0
  37. package/lib/utils/api/{form-api.utils.d.ts → form-api/form-api.utils.d.ts} +3 -2
  38. package/lib/utils/api/{form-api.utils.js → form-api/form-api.utils.js} +41 -7
  39. package/lib/utils/api/form-api.js +10 -17
  40. package/lib/utils/api/rest-api.d.ts +2 -1
  41. package/lib/utils/api/schema-api.d.ts +2 -1
  42. package/lib/utils/api/schema-api.js +1 -1
  43. package/lib/utils/api/schema.util.d.ts +1 -0
  44. package/lib/utils/api/schema.util.js +11 -0
  45. package/lib/utils/cache/index.d.ts +0 -1
  46. package/lib/utils/cache/index.js +57 -34
  47. package/lib/utils/cache/index_db_cache.d.ts +9 -0
  48. package/lib/utils/cache/index_db_cache.js +11 -0
  49. package/lib/utils/common/SingletonInstanceMap.d.ts +2 -2
  50. package/lib/utils/data/index.d.ts +3 -1
  51. package/lib/utils/data/index.js +10 -3
  52. package/lib/utils/page/index.d.ts +1 -0
  53. package/lib/utils/page/index.js +4 -2
  54. package/lib/utils/page/page-create-element.d.ts +6 -0
  55. package/lib/utils/page/page-create-element.js +29 -0
  56. package/lib/utils/page/page-render.js +1 -1
  57. package/lib/utils/page/page-schema-utils.js +2 -1
  58. package/lib/utils/page/print-form.d.ts +1 -1
  59. package/lib/utils/page/print-form.js +13 -7
  60. package/lib/utils/uni-bridge.js +1 -3
  61. package/lib/utils/util.common.d.ts +1 -1
  62. package/lib/utils/util.common.js +2 -3
  63. package/package.json +5 -4
  64. package/es/utils/cache/schema.d.ts +0 -6
  65. package/es/utils/cache/schema.js +0 -14
  66. package/es/utils/utils.scrollbar-size.js +0 -0
  67. package/lib/utils/cache/schema.d.ts +0 -6
  68. package/lib/utils/cache/schema.js +0 -18
  69. package/lib/utils/utils.scrollbar-size.js +0 -1
@@ -19,6 +19,10 @@ export var ReactRender = /*#__PURE__*/function (_PureComponent) {
19
19
  _proto.render = function render() {
20
20
  var _this2 = this;
21
21
  var components = this.props.components || window._components;
22
+ if (!components.Page) {
23
+ // @ts-ignore
24
+ components["Page"] = Page;
25
+ }
22
26
  return /*#__PURE__*/React.createElement(ReactRenderFactory, _extends({
23
27
  key: this.key
24
28
  }, this.props, {
@@ -36,4 +40,10 @@ export var ReactRender = /*#__PURE__*/function (_PureComponent) {
36
40
  }));
37
41
  };
38
42
  return ReactRender;
39
- }(PureComponent);
43
+ }(PureComponent);
44
+ function Page(props) {
45
+ return /*#__PURE__*/React.createElement("div", {
46
+ className: "lce-page",
47
+ style: props.style
48
+ }, props.children);
49
+ }
@@ -0,0 +1,2 @@
1
+ import { IBaseEntity, Refs } from "../rest-api";
2
+ export declare function formApiAssembleEntity(data: IBaseEntity | IBaseEntity[], refs?: Refs): void;
@@ -0,0 +1,95 @@
1
+ function _createForOfIteratorHelperLoose(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (t) return (t = t.call(r)).next.bind(t); if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var o = 0; return function () { return o >= r.length ? { done: !0 } : { done: !1, value: r[o++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
2
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
3
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
4
+ import { FormApiEntityMap } from "./form-api.entity-map";
5
+ import { dataToLabel, safeGet } from "./form-api.utils";
6
+ export function formApiAssembleEntity(data, refs) {
7
+ if (!data || !refs) return;
8
+ var dataMap = new FormApiEntityMap();
9
+ for (var _iterator = _createForOfIteratorHelperLoose(refs), _step; !(_step = _iterator()).done;) {
10
+ var ref = _step.value;
11
+ ref.label = ref.form.label;
12
+ dataMap.addEntities(ref.data);
13
+ }
14
+ assembleRefs(refs, dataMap);
15
+ var dataArray = Array.isArray(data) ? data : [data];
16
+ assembleData(dataArray, dataMap);
17
+ }
18
+
19
+ /**
20
+ * 装配数据
21
+ */
22
+ function assembleData(data, dataMap) {
23
+ for (var _iterator2 = _createForOfIteratorHelperLoose(data), _step2; !(_step2 = _iterator2()).done;) {
24
+ var item = _step2.value;
25
+ assembleObject(item, dataMap, {
26
+ maxDepth: 5,
27
+ depth: 1
28
+ });
29
+ }
30
+ }
31
+
32
+ /**
33
+ * 装配相关数据
34
+ */
35
+ function assembleRefs(refs, dataMap) {
36
+ for (var _iterator3 = _createForOfIteratorHelperLoose(refs), _step3; !(_step3 = _iterator3()).done;) {
37
+ var ref = _step3.value;
38
+ ref.label = ref.form.label;
39
+ var data = ref.data;
40
+ for (var _iterator4 = _createForOfIteratorHelperLoose(data), _step4; !(_step4 = _iterator4()).done;) {
41
+ var item = _step4.value;
42
+ assembleObject(item, dataMap, {
43
+ maxDepth: 2,
44
+ depth: 1
45
+ });
46
+ }
47
+ }
48
+ }
49
+ function assembleObject(values, dataMap, options) {
50
+ var depth = options.depth,
51
+ maxDepth = options.maxDepth;
52
+ if (options.depth >= options.maxDepth) {
53
+ return;
54
+ }
55
+ if (dataMap.isEntity(values)) {
56
+ handleEntityLabel(values);
57
+ }
58
+ for (var _i = 0, _Object$keys = Object.keys(values); _i < _Object$keys.length; _i++) {
59
+ var key = _Object$keys[_i];
60
+ var value = values[key];
61
+ if (Array.isArray(value)) {
62
+ if (dataMap.needLoad(value[0])) {
63
+ //需要加载的属性
64
+ values[key] = value.map(function (item) {
65
+ if (dataMap.hasEntity(item)) {
66
+ return dataMap.getEntity(item);
67
+ }
68
+ return item;
69
+ });
70
+ } else if (dataMap.isEntity(value[0])) {
71
+ //子表属性
72
+ for (var _iterator5 = _createForOfIteratorHelperLoose(value), _step5; !(_step5 = _iterator5()).done;) {
73
+ var valueElement = _step5.value;
74
+ assembleObject(valueElement, dataMap, {
75
+ maxDepth: maxDepth,
76
+ depth: depth + 1
77
+ });
78
+ }
79
+ }
80
+ } else if (typeof value == "object") {
81
+ if (dataMap.needLoad(value)) {
82
+ if (dataMap.hasEntity(value)) {
83
+ values[key] = dataMap.getEntity(value);
84
+ }
85
+ }
86
+ }
87
+ }
88
+ }
89
+ function handleEntityLabel(data) {
90
+ var _data$form;
91
+ var labelField = data === null || data === void 0 ? void 0 : (_data$form = data.form) === null || _data$form === void 0 ? void 0 : _data$form.labelField;
92
+ if (labelField) {
93
+ data.label = dataToLabel(safeGet(data, labelField));
94
+ }
95
+ }
@@ -0,0 +1,12 @@
1
+ import { IBaseEntity } from "../rest-api";
2
+ export declare class FormApiEntityMap {
3
+ dataMap: Map<string, IBaseEntity>;
4
+ hasEntity(entity: IBaseEntity): boolean;
5
+ getEntity(entity: IBaseEntity): IBaseEntity;
6
+ addEntity(entity: IBaseEntity): void;
7
+ addEntities(entities: IBaseEntity[]): void;
8
+ isEntity(value: any): boolean;
9
+ needLoad(entity: IBaseEntity): boolean;
10
+ destroy(): void;
11
+ private createEntityKey;
12
+ }
@@ -0,0 +1,50 @@
1
+ export var FormApiEntityMap = /*#__PURE__*/function () {
2
+ function FormApiEntityMap() {
3
+ this.dataMap = new Map();
4
+ }
5
+ var _proto = FormApiEntityMap.prototype;
6
+ _proto.hasEntity = function hasEntity(entity) {
7
+ var key = this.createEntityKey(entity);
8
+ return this.dataMap.has(key);
9
+ };
10
+ _proto.getEntity = function getEntity(entity) {
11
+ var key = this.createEntityKey(entity);
12
+ return this.dataMap.get(key);
13
+ };
14
+ _proto.addEntity = function addEntity(entity) {
15
+ var key = this.createEntityKey(entity);
16
+ this.dataMap.set(key, entity);
17
+ };
18
+ _proto.addEntities = function addEntities(entities) {
19
+ var _this = this;
20
+ entities === null || entities === void 0 ? void 0 : entities.forEach(function (item) {
21
+ return _this.addEntity(item);
22
+ });
23
+ };
24
+ _proto.isEntity = function isEntity(value) {
25
+ if (value == null) {
26
+ return false;
27
+ } else if (Array.isArray(value)) {
28
+ return false;
29
+ } else if (typeof value == "object") {
30
+ var _value$form;
31
+ return !!value.id && !!((_value$form = value.form) !== null && _value$form !== void 0 && _value$form.id);
32
+ }
33
+ return false;
34
+ };
35
+ _proto.needLoad = function needLoad(entity) {
36
+ return this.isEntity(entity) && entity._load == false;
37
+ };
38
+ _proto.destroy = function destroy() {
39
+ this.dataMap.clear();
40
+ };
41
+ _proto.createEntityKey = function createEntityKey(entity) {
42
+ var _entity$form, _entity$form2;
43
+ var key = (_entity$form = entity.form) === null || _entity$form === void 0 ? void 0 : _entity$form.id;
44
+ if ((_entity$form2 = entity.form) !== null && _entity$form2 !== void 0 && _entity$form2.fieldId) {
45
+ key += "." + entity.form.fieldId;
46
+ }
47
+ return key + "." + entity.id;
48
+ };
49
+ return FormApiEntityMap;
50
+ }();
@@ -1,4 +1,4 @@
1
- import { FilterRule, IBaseEntity, Refs } from "./rest-api";
1
+ import { FilterRule, IBaseEntity, Refs } from "../rest-api";
2
2
  export declare function convertSaveData(data: any): any;
3
3
  export declare function dataToLabel(value: any): any;
4
4
  export declare function assembleAssociationFieldV2(data: IBaseEntity | IBaseEntity[], refs?: Refs): void;
@@ -9,7 +9,8 @@ export declare function assembleAssociationFieldV2(data: IBaseEntity | IBaseEnti
9
9
  */
10
10
  export declare function assembleAssociationFieldDataV2(data: IBaseEntity | IBaseEntity[], dataMap: Map<string, IBaseEntity>): void;
11
11
  export declare function handleEntityLabel(data: IBaseEntity | IBaseEntity[]): void;
12
- export declare function assembleAssociationField(data: IBaseEntity | IBaseEntity[], refs?: Refs): void;
12
+ export declare function assembleAssociationField(data: IBaseEntity | IBaseEntity[], refs?: Refs): number;
13
13
  export declare function handleFilterRules(filters: FilterRule[], options: {
14
14
  filterNullValue: boolean;
15
15
  }): FilterRule[];
16
+ export declare function safeGet(value: any, key: string | null): any;
@@ -2,16 +2,37 @@ import _extends from "@babel/runtime/helpers/extends";
2
2
  function _createForOfIteratorHelperLoose(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (t) return (t = t.call(r)).next.bind(t); if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var o = 0; return function () { return o >= r.length ? { done: !0 } : { done: !1, value: r[o++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
3
  function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
4
4
  function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
5
- import { transformerId } from "../data";
5
+ import { transformerId } from "../../data";
6
+ import { isLocalhost } from "../../common";
7
+ import { formApiAssembleEntity } from "./form-api.assemble-entity";
8
+ import { isTemplateHost } from "../../util.common";
6
9
  var SimpleSerialFieldNames = ["parent", "instance"];
7
10
  export function convertSaveData(data) {
8
11
  if (!data) return data;
12
+ var seen = new WeakSet(); // WeakSet 只存储对象,非常适合检测引用
9
13
  return JSON.parse(JSON.stringify(data, function (key, value) {
10
- if (SimpleSerialFieldNames.includes(key)) {
11
- var id = value === null || value === void 0 ? void 0 : value.id;
12
- return id ? {
13
- id: id
14
- } : undefined;
14
+ if (value == null) {
15
+ return null;
16
+ } else if (Array.isArray(value)) {
17
+ return value;
18
+ } else if (typeof value == "object") {
19
+ if (SimpleSerialFieldNames.includes(key)) {
20
+ var id = value === null || value === void 0 ? void 0 : value.id;
21
+ return id ? {
22
+ id: id
23
+ } : undefined;
24
+ } else if (seen.has(value)) {
25
+ if (value.id) {
26
+ return {
27
+ id: value.id
28
+ };
29
+ } else {
30
+ return value;
31
+ }
32
+ } else {
33
+ seen.add(value);
34
+ }
35
+ return value;
15
36
  }
16
37
  return value;
17
38
  }));
@@ -150,7 +171,13 @@ function valueToFormDataArray(value) {
150
171
  }
151
172
  }
152
173
  export function assembleAssociationField(data, refs) {
174
+ var start = Date.now();
175
+ if (isLocalhost() || isTemplateHost()) {
176
+ formApiAssembleEntity(data, refs);
177
+ return Date.now() - start;
178
+ }
153
179
  assembleAssociationFieldV2(data, refs);
180
+ return Date.now() - start;
154
181
  }
155
182
  export function handleFilterRules(filters, options) {
156
183
  var filterNullValue = options.filterNullValue;
@@ -159,13 +186,19 @@ export function handleFilterRules(filters, options) {
159
186
  return !!rule;
160
187
  }).map(function (rule) {
161
188
  return _extends({}, rule, {
162
- value: transformerId(rule.value),
189
+ value: transformerId(rule.value, {
190
+ includeNull: true
191
+ }),
163
192
  rules: handleFilterRules(rule.rules || [], options)
164
193
  });
165
194
  });
166
195
  if (filterNullValue) {
167
196
  cloneRules = cloneRules.filter(function (rule) {
168
197
  if (rule.value == null) {
198
+ var _rule$rules;
199
+ if ((_rule$rules = rule.rules) !== null && _rule$rules !== void 0 && _rule$rules.length) {
200
+ return true;
201
+ }
169
202
  if (rule.operator != "isNull" && rule.operator != "isNotNull") {
170
203
  return false;
171
204
  }
@@ -181,7 +214,7 @@ export function handleFilterRules(filters, options) {
181
214
  return undefined;
182
215
  }
183
216
  }
184
- function safeGet(value, key) {
217
+ export function safeGet(value, key) {
185
218
  if (typeof value !== "object") {
186
219
  return null;
187
220
  }
@@ -1,9 +1,8 @@
1
- import _extends from "@babel/runtime/helpers/extends";
2
1
  import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
3
2
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
4
3
  import _regeneratorRuntime from "@babel/runtime/regenerator";
5
4
  import { RestApi } from "./rest-api";
6
- import { assembleAssociationField, convertSaveData, handleFilterRules } from "./form-api.utils";
5
+ import { assembleAssociationField, convertSaveData, handleFilterRules } from "./form-api/form-api.utils";
7
6
  import { formApi } from "../cache";
8
7
  import { getSchemaFromCache } from "./schema-api";
9
8
  import { uuid, uuidVersion } from "../common";
@@ -137,7 +136,7 @@ export var RestFormApi = /*#__PURE__*/function (_RestApi) {
137
136
  _proto.search = /*#__PURE__*/function () {
138
137
  var _search = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(searchParams) {
139
138
  var _searchParams, _searchParams2;
140
- var params, config, res, start;
139
+ var params, config, res;
141
140
  return _regeneratorRuntime.wrap(function (_context3) {
142
141
  while (1) switch (_context3.prev = _context3.next) {
143
142
  case 0:
@@ -161,14 +160,11 @@ export var RestFormApi = /*#__PURE__*/function (_RestApi) {
161
160
  searchParams.searchFields = handleFilterRules(((_searchParams2 = searchParams) === null || _searchParams2 === void 0 ? void 0 : _searchParams2.searchFields) || [], {
162
161
  filterNullValue: true
163
162
  });
164
- config.params = _extends({}, params, searchParams);
165
163
  _context3.next = 2;
166
- return this.request.get("search", config);
164
+ return this.request.post("search", searchParams, config);
167
165
  case 2:
168
166
  res = _context3.sent;
169
- //const res = await this.request.post<any, ManyResult<DataType>>("search", searchParams, config);
170
- start = Date.now();
171
- assembleAssociationField(res.data, res.refs);
167
+ res.assembleTime = assembleAssociationField(res.data, res.refs);
172
168
  console.debug("form.search:", res);
173
169
  return _context3.abrupt("return", res);
174
170
  case 3:
@@ -229,8 +225,8 @@ export var RestFormApi = /*#__PURE__*/function (_RestApi) {
229
225
  return _RestApi.prototype.getById.call(this, searchId, options);
230
226
  case 5:
231
227
  res = _context4.sent;
232
- assembleAssociationField(res.data, res.refs);
233
- console.debug("formApi.getById", res);
228
+ res.assembleTime = assembleAssociationField(res.data, res.refs);
229
+ console.debug("form.getById:", res);
234
230
  return _context4.abrupt("return", res);
235
231
  case 6:
236
232
  case "end":
@@ -267,7 +263,7 @@ export var RestFormApi = /*#__PURE__*/function (_RestApi) {
267
263
  };
268
264
  });
269
265
  }
270
- assembleAssociationField(res.data, res.refs);
266
+ res.assembleTime = assembleAssociationField(res.data, res.refs);
271
267
  console.debug("formApi.labelToValue", res);
272
268
  return _context5.abrupt("return", res);
273
269
  case 3:
@@ -335,7 +331,7 @@ export var RestFormApi = /*#__PURE__*/function (_RestApi) {
335
331
  _proto.fieldFilters = /*#__PURE__*/function () {
336
332
  var _fieldFilters = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee9(searchParams) {
337
333
  var _searchParams3, _searchParams4;
338
- var params, config, res;
334
+ var params, config;
339
335
  return _regeneratorRuntime.wrap(function (_context9) {
340
336
  while (1) switch (_context9.prev = _context9.next) {
341
337
  case 0:
@@ -359,13 +355,10 @@ export var RestFormApi = /*#__PURE__*/function (_RestApi) {
359
355
  searchParams.searchFields = handleFilterRules(((_searchParams4 = searchParams) === null || _searchParams4 === void 0 ? void 0 : _searchParams4.searchFields) || [], {
360
356
  filterNullValue: true
361
357
  });
362
- config.params = _extends({}, params, searchParams);
363
358
  _context9.next = 2;
364
- return this.request.get("fieldFilters", config);
359
+ return this.request.post("fieldFilters", searchParams, config);
365
360
  case 2:
366
- res = _context9.sent;
367
- console.debug("form.fieldFilters:", res);
368
- return _context9.abrupt("return", res);
361
+ return _context9.abrupt("return", _context9.sent);
369
362
  case 3:
370
363
  case "end":
371
364
  return _context9.stop();
@@ -1,5 +1,5 @@
1
1
  import { AxiosInstance, AxiosRequestConfig } from "axios";
2
- export type ValueType = "value" | "field" | "express";
2
+ export type ValueType = "value" | "field" | "express" | "column";
3
3
  export interface RestApiOptions {
4
4
  /**
5
5
  * 超时时间
@@ -106,6 +106,7 @@ export interface BaseResult<DataType> {
106
106
  success: boolean;
107
107
  message?: string;
108
108
  requestId: string;
109
+ assembleTime: number;
109
110
  refs?: Refs;
110
111
  }
111
112
  export interface Ref {
@@ -1,3 +1,4 @@
1
1
  import { OneResult } from "./rest-api";
2
+ import { Schema } from "./schema.util";
2
3
  export declare function getSchema(pageId: string, mock?: boolean): Promise<OneResult<any>>;
3
- export declare function getSchemaFromCache(pageId?: string, mock?: boolean): any;
4
+ export declare function getSchemaFromCache(pageId?: string, mock?: boolean): OneResult<Schema>;
@@ -11,7 +11,7 @@ function _getSchema() {
11
11
  while (1) switch (_context.prev = _context.next) {
12
12
  case 0:
13
13
  mock = getMock(mock);
14
- key = mock ? pageId + ":mock" : pageId;
14
+ key = mock ? pageId + "_mock" : pageId;
15
15
  _context.next = 1;
16
16
  return schema.getInstance(key, {
17
17
  mock: mock,
@@ -5,6 +5,7 @@
5
5
  */
6
6
  export declare function forEachSchema(schema: Schema, callback: (child: Schema, index: number, children: any[]) => boolean): void;
7
7
  export declare function findFormSchemas(schema: Schema): Schema[];
8
+ export declare function findLoadRefSchemas(schema: Schema): Schema[];
8
9
  export declare function findFdmSchemas(schema?: Schema): Schema[];
9
10
  export interface Schema {
10
11
  componentName: string;
@@ -22,6 +22,16 @@ export function findFormSchemas(schema) {
22
22
  });
23
23
  return schemas;
24
24
  }
25
+ export function findLoadRefSchemas(schema) {
26
+ var schemas = [];
27
+ forEachSchema(schema, function (child) {
28
+ if (["ProcessGroupField"].includes(child.componentName)) {
29
+ schemas.push(child);
30
+ }
31
+ return true;
32
+ });
33
+ return schemas;
34
+ }
25
35
  export function findFdmSchemas(schema) {
26
36
  var schemas = [];
27
37
  if (!schema) {
@@ -12,7 +12,6 @@ export declare class FormApiCache extends SingletonInstanceMap<RestFormApi<any>,
12
12
  fieldId?: string;
13
13
  mock?: boolean;
14
14
  }> {
15
- apiMap: Map<string, RestFormApi<any>>;
16
15
  createInstance(key: string, options?: any): Promise<RestFormApi<any>>;
17
16
  }
18
17
  export declare const formApi: FormApiCache;
@@ -1,9 +1,12 @@
1
1
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
2
  import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
3
3
  import _regeneratorRuntime from "@babel/runtime/regenerator";
4
+ function _createForOfIteratorHelperLoose(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (t) return (t = t.call(r)).next.bind(t); if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var o = 0; return function () { return o >= r.length ? { done: !0 } : { done: !1, value: r[o++] }; }; } 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(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
6
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
4
7
  import { SingletonInstanceMap } from "../common/SingletonInstanceMap";
5
8
  import { apiRequest, RestFormApi } from "../api";
6
- import { findFdmSchemas, findFormSchemas } from "../api/schema.util";
9
+ import { findFdmSchemas, findFormSchemas, findLoadRefSchemas } from "../api/schema.util";
7
10
  export var SchemaCache = /*#__PURE__*/function (_SingletonInstanceMap) {
8
11
  function SchemaCache() {
9
12
  return _SingletonInstanceMap.apply(this, arguments) || this;
@@ -12,28 +15,24 @@ export var SchemaCache = /*#__PURE__*/function (_SingletonInstanceMap) {
12
15
  var _proto = SchemaCache.prototype;
13
16
  _proto.createInstance = /*#__PURE__*/function () {
14
17
  var _createInstance = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(key, options) {
15
- var mock, pageId, schemaRes, schema, handleCommonSchema, permission, printTemplates, workflow, cloneSchema, _t;
18
+ var mock, pageId, params, schemaRes, schema, handleCommonSchema, permission, printTemplates, workflow, cloneSchema, refs, _iterator, _step, _ref$props, _ref$props$fieldProps, _ref$props$fieldProps2, ref, refPageId, _key, _t;
16
19
  return _regeneratorRuntime.wrap(function (_context) {
17
20
  while (1) switch (_context.prev = _context.next) {
18
21
  case 0:
19
22
  mock = options.mock, pageId = options.pageId;
23
+ params = {};
24
+ if (mock) {
25
+ params.mock = mock;
26
+ }
20
27
  _context.next = 1;
21
28
  return apiRequest.get("pages/" + pageId + "/schema", {
22
- params: {
23
- mock: mock
24
- }
29
+ params: params
25
30
  });
26
31
  case 1:
27
32
  schemaRes = _context.sent;
28
- if (schemaRes.succss) {
29
- _context.next = 2;
30
- break;
31
- }
32
- return _context.abrupt("return", schemaRes);
33
- case 2:
34
- schema = schemaRes.data;
35
- if (!(schema != null && typeof schema == "object")) {
36
- _context.next = 8;
33
+ schema = schemaRes === null || schemaRes === void 0 ? void 0 : schemaRes.data;
34
+ if (!schema) {
35
+ _context.next = 9;
37
36
  break;
38
37
  }
39
38
  handleCommonSchema = function handleCommonSchema(schema) {
@@ -46,29 +45,29 @@ export var SchemaCache = /*#__PURE__*/function (_SingletonInstanceMap) {
46
45
  permission = null; //处理打印
47
46
  workflow = null;
48
47
  if (location.pathname.startsWith("/print")) {
49
- _context.next = 7;
48
+ _context.next = 6;
50
49
  break;
51
50
  }
52
- _context.next = 3;
51
+ _context.next = 2;
53
52
  return apiRequest.get("pages/" + pageId + "/permission");
54
- case 3:
53
+ case 2:
55
54
  permission = _context.sent.data;
56
55
  if (!((schema === null || schema === void 0 ? void 0 : schema.type) == "form")) {
57
- _context.next = 7;
56
+ _context.next = 6;
58
57
  break;
59
58
  }
60
- _context.prev = 4;
61
- _context.next = 5;
59
+ _context.prev = 3;
60
+ _context.next = 4;
62
61
  return apiRequest.get("pages/" + pageId + "/printTemplates");
63
- case 5:
62
+ case 4:
64
63
  printTemplates = _context.sent.data;
65
- _context.next = 7;
64
+ _context.next = 6;
66
65
  break;
67
- case 6:
68
- _context.prev = 6;
69
- _t = _context["catch"](4);
66
+ case 5:
67
+ _context.prev = 5;
68
+ _t = _context["catch"](3);
70
69
  console.log(_t);
71
- case 7:
70
+ case 6:
72
71
  findFormSchemas(schema).forEach(function (formSchema) {
73
72
  handleCommonSchema(formSchema);
74
73
  findFdmSchemas(formSchema.fdmSchema).forEach(function (fdmSchema) {
@@ -82,13 +81,43 @@ export var SchemaCache = /*#__PURE__*/function (_SingletonInstanceMap) {
82
81
  fdmSchema.props.formElement = cloneSchema;
83
82
  });
84
83
  });
84
+ refs = findLoadRefSchemas(schema);
85
+ if (!refs.length) {
86
+ _context.next = 9;
87
+ break;
88
+ }
89
+ _iterator = _createForOfIteratorHelperLoose(refs);
90
+ case 7:
91
+ if ((_step = _iterator()).done) {
92
+ _context.next = 9;
93
+ break;
94
+ }
95
+ ref = _step.value;
96
+ refPageId = (_ref$props = ref.props) === null || _ref$props === void 0 ? void 0 : (_ref$props$fieldProps = _ref$props.fieldProps) === null || _ref$props$fieldProps === void 0 ? void 0 : (_ref$props$fieldProps2 = _ref$props$fieldProps.associationForm) === null || _ref$props$fieldProps2 === void 0 ? void 0 : _ref$props$fieldProps2.id;
97
+ if (!(typeof refPageId == "string" && refPageId !== pageId)) {
98
+ _context.next = 8;
99
+ break;
100
+ }
101
+ if (this.valueMap.has(refPageId)) {
102
+ _context.next = 8;
103
+ break;
104
+ }
105
+ _key = mock ? refPageId + "_mock" : refPageId;
106
+ _context.next = 8;
107
+ return this.getInstance(_key, {
108
+ mock: mock,
109
+ pageId: refPageId
110
+ });
85
111
  case 8:
86
- return _context.abrupt("return", schemaRes);
112
+ _context.next = 7;
113
+ break;
87
114
  case 9:
115
+ return _context.abrupt("return", schemaRes);
116
+ case 10:
88
117
  case "end":
89
118
  return _context.stop();
90
119
  }
91
- }, _callee, null, [[4, 6]]);
120
+ }, _callee, this, [[3, 5]]);
92
121
  }));
93
122
  function createInstance(_x, _x2) {
94
123
  return _createInstance.apply(this, arguments);
@@ -100,13 +129,7 @@ export var SchemaCache = /*#__PURE__*/function (_SingletonInstanceMap) {
100
129
  export var schema = new SchemaCache();
101
130
  export var FormApiCache = /*#__PURE__*/function (_SingletonInstanceMap2) {
102
131
  function FormApiCache() {
103
- var _this;
104
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
105
- args[_key] = arguments[_key];
106
- }
107
- _this = _SingletonInstanceMap2.call.apply(_SingletonInstanceMap2, [this].concat(args)) || this;
108
- _this.apiMap = new Map();
109
- return _this;
132
+ return _SingletonInstanceMap2.apply(this, arguments) || this;
110
133
  }
111
134
  _inheritsLoose(FormApiCache, _SingletonInstanceMap2);
112
135
  var _proto2 = FormApiCache.prototype;
@@ -0,0 +1,9 @@
1
+ import { Dexie, type EntityTable } from "dexie";
2
+ export interface Friend {
3
+ page_id: string;
4
+ schema: any;
5
+ }
6
+ declare const db_cache: Dexie & {
7
+ page_schemas: EntityTable<Friend, 'page_id'>;
8
+ };
9
+ export default db_cache;
@@ -0,0 +1,7 @@
1
+ import { Dexie } from "dexie";
2
+ var db_cache = new Dexie('cache');
3
+ db_cache.version(1).stores({
4
+ page_schemas: 'page_id,schema'
5
+ });
6
+ var page_schemas = db_cache.page_schemas;
7
+ export default db_cache;
@@ -1,6 +1,6 @@
1
1
  export declare abstract class SingletonInstanceMap<Value, Options> {
2
- private readonly valueMap;
3
- private readonly lockMap;
2
+ protected readonly valueMap: Map<string, Value>;
3
+ protected readonly lockMap: Map<string, boolean>;
4
4
  getInstance(key: string, options: Options): Promise<Value>;
5
5
  get(key: string): Value;
6
6
  clear(): void;
@@ -1 +1,3 @@
1
- export declare function transformerId(value: any): any;
1
+ export declare function transformerId(value: any, options?: {
2
+ includeNull?: boolean;
3
+ }): any;
@@ -1,11 +1,18 @@
1
- export function transformerId(value) {
1
+ export function transformerId(value, options) {
2
2
  if (value == null) {
3
3
  return null;
4
4
  }
5
5
  if (Array.isArray(value)) {
6
- return value.map(transformerId).filter(function (value) {
7
- return !!value;
6
+ var values = value.map(function (item) {
7
+ return transformerId(item, options);
8
8
  });
9
+ if (options !== null && options !== void 0 && options.includeNull) {
10
+ return values;
11
+ } else {
12
+ return values.filter(function (v) {
13
+ return !!v;
14
+ });
15
+ }
9
16
  }
10
17
  if (typeof value == "object") {
11
18
  return (value === null || value === void 0 ? void 0 : value.id) || (value === null || value === void 0 ? void 0 : value.value) || value;