@zhubangyun/lowcode-core 6.1.90 → 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 (107) hide show
  1. package/es/components/react-render/index.js +11 -1
  2. package/es/index.js +12 -34
  3. package/es/index.less +11 -0
  4. package/es/init/init.bar-height.d.ts +1 -0
  5. package/es/init/init.bar-height.js +37 -0
  6. package/es/init/init.mobile-class.d.ts +1 -0
  7. package/es/init/init.mobile-class.js +10 -0
  8. package/es/init/init.scroll-size.d.ts +5 -0
  9. package/es/init/init.scroll-size.js +26 -0
  10. package/es/style.js +1 -1
  11. package/es/utils/api/form-api/form-api.assemble-entity.d.ts +2 -0
  12. package/es/utils/api/form-api/form-api.assemble-entity.js +95 -0
  13. package/es/utils/api/form-api/form-api.entity-map.d.ts +12 -0
  14. package/es/utils/api/form-api/form-api.entity-map.js +50 -0
  15. package/es/utils/api/{form-api.utils.d.ts → form-api/form-api.utils.d.ts} +3 -2
  16. package/es/utils/api/{form-api.utils.js → form-api/form-api.utils.js} +41 -8
  17. package/es/utils/api/form-api.d.ts +1 -0
  18. package/es/utils/api/form-api.js +105 -30
  19. package/es/utils/api/index.js +3 -2
  20. package/es/utils/api/rest-api.d.ts +2 -1
  21. package/es/utils/api/schema-api.d.ts +2 -1
  22. package/es/utils/api/schema-api.js +1 -1
  23. package/es/utils/api/schema.util.d.ts +1 -0
  24. package/es/utils/api/schema.util.js +10 -0
  25. package/es/utils/cache/index.d.ts +0 -1
  26. package/es/utils/cache/index.js +58 -35
  27. package/es/utils/cache/index_db_cache.d.ts +9 -0
  28. package/es/utils/cache/index_db_cache.js +7 -0
  29. package/es/utils/common/SingletonInstanceMap.d.ts +2 -2
  30. package/es/utils/common/index.d.ts +1 -1
  31. package/es/utils/common/index.js +5 -1
  32. package/es/utils/data/index.d.ts +3 -1
  33. package/es/utils/data/index.js +10 -3
  34. package/es/utils/page/index.d.ts +1 -0
  35. package/es/utils/page/index.js +10 -6
  36. package/es/utils/page/page-create-element.d.ts +6 -0
  37. package/es/utils/page/page-create-element.js +23 -0
  38. package/es/utils/page/page-form-data-manager-group.js +8 -8
  39. package/es/utils/page/page-form-data-manager.js +8 -8
  40. package/es/utils/page/page-form.js +4 -6
  41. package/es/utils/page/page-layout.d.ts +2 -1
  42. package/es/utils/page/page-layout.js +23 -3
  43. package/es/utils/page/page-render.js +5 -6
  44. package/es/utils/page/page-schema-utils.js +2 -1
  45. package/es/utils/page/page-show.js +4 -4
  46. package/es/utils/page/print-form.d.ts +3 -2
  47. package/es/utils/page/print-form.js +193 -57
  48. package/es/utils/uni-bridge.d.ts +2 -0
  49. package/es/utils/uni-bridge.js +76 -36
  50. package/es/utils/util.common.d.ts +1 -1
  51. package/es/utils/util.common.js +1 -2
  52. package/lib/components/react-render/index.js +11 -1
  53. package/lib/index.js +12 -34
  54. package/lib/index.less +11 -0
  55. package/lib/init/init.bar-height.d.ts +1 -0
  56. package/lib/init/init.bar-height.js +42 -0
  57. package/lib/init/init.mobile-class.d.ts +1 -0
  58. package/lib/init/init.mobile-class.js +14 -0
  59. package/lib/init/init.scroll-size.d.ts +5 -0
  60. package/lib/init/init.scroll-size.js +31 -0
  61. package/lib/style.js +1 -1
  62. package/lib/utils/api/form-api/form-api.assemble-entity.d.ts +2 -0
  63. package/lib/utils/api/form-api/form-api.assemble-entity.js +99 -0
  64. package/lib/utils/api/form-api/form-api.entity-map.d.ts +12 -0
  65. package/lib/utils/api/form-api/form-api.entity-map.js +54 -0
  66. package/lib/utils/api/{form-api.utils.d.ts → form-api/form-api.utils.d.ts} +3 -2
  67. package/lib/utils/api/{form-api.utils.js → form-api/form-api.utils.js} +41 -7
  68. package/lib/utils/api/form-api.d.ts +1 -0
  69. package/lib/utils/api/form-api.js +104 -29
  70. package/lib/utils/api/index.js +3 -2
  71. package/lib/utils/api/rest-api.d.ts +2 -1
  72. package/lib/utils/api/schema-api.d.ts +2 -1
  73. package/lib/utils/api/schema-api.js +1 -1
  74. package/lib/utils/api/schema.util.d.ts +1 -0
  75. package/lib/utils/api/schema.util.js +11 -0
  76. package/lib/utils/cache/index.d.ts +0 -1
  77. package/lib/utils/cache/index.js +57 -34
  78. package/lib/utils/cache/index_db_cache.d.ts +9 -0
  79. package/lib/utils/cache/index_db_cache.js +11 -0
  80. package/lib/utils/common/SingletonInstanceMap.d.ts +2 -2
  81. package/lib/utils/common/index.d.ts +1 -1
  82. package/lib/utils/common/index.js +5 -1
  83. package/lib/utils/data/index.d.ts +3 -1
  84. package/lib/utils/data/index.js +10 -3
  85. package/lib/utils/page/index.d.ts +1 -0
  86. package/lib/utils/page/index.js +13 -7
  87. package/lib/utils/page/page-create-element.d.ts +6 -0
  88. package/lib/utils/page/page-create-element.js +29 -0
  89. package/lib/utils/page/page-form-data-manager-group.js +8 -8
  90. package/lib/utils/page/page-form-data-manager.js +8 -8
  91. package/lib/utils/page/page-form.js +4 -6
  92. package/lib/utils/page/page-layout.d.ts +2 -1
  93. package/lib/utils/page/page-layout.js +23 -3
  94. package/lib/utils/page/page-render.js +5 -6
  95. package/lib/utils/page/page-schema-utils.js +2 -1
  96. package/lib/utils/page/page-show.js +4 -4
  97. package/lib/utils/page/print-form.d.ts +3 -2
  98. package/lib/utils/page/print-form.js +193 -57
  99. package/lib/utils/uni-bridge.d.ts +2 -0
  100. package/lib/utils/uni-bridge.js +76 -36
  101. package/lib/utils/util.common.d.ts +1 -1
  102. package/lib/utils/util.common.js +2 -3
  103. package/package.json +5 -4
  104. package/es/utils/cache/schema.d.ts +0 -6
  105. package/es/utils/cache/schema.js +0 -14
  106. package/lib/utils/cache/schema.d.ts +0 -6
  107. package/lib/utils/cache/schema.js +0 -18
@@ -9,20 +9,42 @@ exports.convertSaveData = convertSaveData;
9
9
  exports.dataToLabel = dataToLabel;
10
10
  exports.handleEntityLabel = handleEntityLabel;
11
11
  exports.handleFilterRules = handleFilterRules;
12
+ exports.safeGet = safeGet;
12
13
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
13
- var _data = require("../data");
14
+ var _data = require("../../data");
15
+ var _common = require("../../common");
16
+ var _formApi = require("./form-api.assemble-entity");
17
+ var _util = require("../../util.common");
14
18
  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."); }
15
19
  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; } }
16
20
  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; }
17
21
  var SimpleSerialFieldNames = ["parent", "instance"];
18
22
  function convertSaveData(data) {
19
23
  if (!data) return data;
24
+ var seen = new WeakSet(); // WeakSet 只存储对象,非常适合检测引用
20
25
  return JSON.parse(JSON.stringify(data, function (key, value) {
21
- if (SimpleSerialFieldNames.includes(key)) {
22
- var id = value === null || value === void 0 ? void 0 : value.id;
23
- return id ? {
24
- id: id
25
- } : undefined;
26
+ if (value == null) {
27
+ return null;
28
+ } else if (Array.isArray(value)) {
29
+ return value;
30
+ } else if (typeof value == "object") {
31
+ if (SimpleSerialFieldNames.includes(key)) {
32
+ var id = value === null || value === void 0 ? void 0 : value.id;
33
+ return id ? {
34
+ id: id
35
+ } : undefined;
36
+ } else if (seen.has(value)) {
37
+ if (value.id) {
38
+ return {
39
+ id: value.id
40
+ };
41
+ } else {
42
+ return value;
43
+ }
44
+ } else {
45
+ seen.add(value);
46
+ }
47
+ return value;
26
48
  }
27
49
  return value;
28
50
  }));
@@ -161,7 +183,13 @@ function valueToFormDataArray(value) {
161
183
  }
162
184
  }
163
185
  function assembleAssociationField(data, refs) {
186
+ var start = Date.now();
187
+ if ((0, _common.isLocalhost)() || (0, _util.isTemplateHost)()) {
188
+ (0, _formApi.formApiAssembleEntity)(data, refs);
189
+ return Date.now() - start;
190
+ }
164
191
  assembleAssociationFieldV2(data, refs);
192
+ return Date.now() - start;
165
193
  }
166
194
  function handleFilterRules(filters, options) {
167
195
  var filterNullValue = options.filterNullValue;
@@ -170,13 +198,19 @@ function handleFilterRules(filters, options) {
170
198
  return !!rule;
171
199
  }).map(function (rule) {
172
200
  return (0, _extends2["default"])({}, rule, {
173
- value: (0, _data.transformerId)(rule.value),
201
+ value: (0, _data.transformerId)(rule.value, {
202
+ includeNull: true
203
+ }),
174
204
  rules: handleFilterRules(rule.rules || [], options)
175
205
  });
176
206
  });
177
207
  if (filterNullValue) {
178
208
  cloneRules = cloneRules.filter(function (rule) {
179
209
  if (rule.value == null) {
210
+ var _rule$rules;
211
+ if ((_rule$rules = rule.rules) !== null && _rule$rules !== void 0 && _rule$rules.length) {
212
+ return true;
213
+ }
180
214
  if (rule.operator != "isNull" && rule.operator != "isNotNull") {
181
215
  return false;
182
216
  }
@@ -16,5 +16,6 @@ export declare class RestFormApi<DataType> extends RestApi<DataType> {
16
16
  save(data: DataType, options?: BaseRequestOptions<DataType>): Promise<OneResult<DataType>>;
17
17
  create(data: DataType, options?: BaseRequestOptions<DataType>): Promise<OneResult<DataType>>;
18
18
  update(id: string, data: DataType, options?: BaseRequestOptions<DataType>): Promise<OneResult<DataType>>;
19
+ fieldFilters(searchParams?: RestSearchParams): Promise<ManyResult<DataType>>;
19
20
  serviceUpdate(data: DataType, options?: BaseRequestOptions<DataType>): Promise<import("axios").AxiosResponse<any, any, {}>>;
20
21
  }
@@ -5,11 +5,10 @@ exports.__esModule = true;
5
5
  exports.RestFormApi = void 0;
6
6
  exports.getFormApi = getFormApi;
7
7
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
8
- var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
8
  var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));
10
9
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
11
10
  var _restApi = require("./rest-api");
12
- var _formApi = require("./form-api.utils");
11
+ var _formApi = require("./form-api/form-api.utils");
13
12
  var _cache = require("../cache");
14
13
  var _schemaApi = require("./schema-api");
15
14
  var _common = require("../common");
@@ -17,10 +16,10 @@ function getFormApi(_x, _x2, _x3) {
17
16
  return _getFormApi.apply(this, arguments);
18
17
  }
19
18
  function _getFormApi() {
20
- _getFormApi = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee0(formId, fieldId, mock) {
19
+ _getFormApi = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee1(formId, fieldId, mock) {
21
20
  var key;
22
- return _regenerator["default"].wrap(function (_context0) {
23
- while (1) switch (_context0.prev = _context0.next) {
21
+ return _regenerator["default"].wrap(function (_context1) {
22
+ while (1) switch (_context1.prev = _context1.next) {
24
23
  case 0:
25
24
  if (typeof mock != "boolean") {
26
25
  if (typeof window.__mock == "boolean") {
@@ -30,16 +29,16 @@ function _getFormApi() {
30
29
  key = [formId, fieldId, mock ? "mock" : ""].filter(function (key) {
31
30
  return !!key;
32
31
  }).join("_");
33
- return _context0.abrupt("return", _cache.formApi.getInstance(key, {
32
+ return _context1.abrupt("return", _cache.formApi.getInstance(key, {
34
33
  mock: mock,
35
34
  fieldId: fieldId,
36
35
  formId: formId
37
36
  }));
38
37
  case 1:
39
38
  case "end":
40
- return _context0.stop();
39
+ return _context1.stop();
41
40
  }
42
- }, _callee0);
41
+ }, _callee1);
43
42
  }));
44
43
  return _getFormApi.apply(this, arguments);
45
44
  }
@@ -143,7 +142,7 @@ var RestFormApi = exports.RestFormApi = /*#__PURE__*/function (_RestApi) {
143
142
  _proto.search = /*#__PURE__*/function () {
144
143
  var _search = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee3(searchParams) {
145
144
  var _searchParams, _searchParams2;
146
- var params, config, res, start;
145
+ var params, config, res;
147
146
  return _regenerator["default"].wrap(function (_context3) {
148
147
  while (1) switch (_context3.prev = _context3.next) {
149
148
  case 0:
@@ -167,14 +166,11 @@ var RestFormApi = exports.RestFormApi = /*#__PURE__*/function (_RestApi) {
167
166
  searchParams.searchFields = (0, _formApi.handleFilterRules)(((_searchParams2 = searchParams) === null || _searchParams2 === void 0 ? void 0 : _searchParams2.searchFields) || [], {
168
167
  filterNullValue: true
169
168
  });
170
- config.params = (0, _extends2["default"])({}, params, searchParams);
171
169
  _context3.next = 2;
172
- return this.request.get("search", config);
170
+ return this.request.post("search", searchParams, config);
173
171
  case 2:
174
172
  res = _context3.sent;
175
- //const res = await this.request.post<any, ManyResult<DataType>>("search", searchParams, config);
176
- start = Date.now();
177
- (0, _formApi.assembleAssociationField)(res.data, res.refs);
173
+ res.assembleTime = (0, _formApi.assembleAssociationField)(res.data, res.refs);
178
174
  console.debug("form.search:", res);
179
175
  return _context3.abrupt("return", res);
180
176
  case 3:
@@ -190,22 +186,59 @@ var RestFormApi = exports.RestFormApi = /*#__PURE__*/function (_RestApi) {
190
186
  }();
191
187
  _proto.getById = /*#__PURE__*/function () {
192
188
  var _getById = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee4(id, options) {
193
- var res;
189
+ var searchId, url, res, _t;
194
190
  return _regenerator["default"].wrap(function (_context4) {
195
191
  while (1) switch (_context4.prev = _context4.next) {
196
192
  case 0:
197
- _context4.next = 1;
198
- return _RestApi.prototype.getById.call(this, id, options);
193
+ if (id) {
194
+ _context4.next = 1;
195
+ break;
196
+ }
197
+ return _context4.abrupt("return", {
198
+ success: false,
199
+ message: "数据Id不可为空!"
200
+ });
199
201
  case 1:
202
+ searchId = id;
203
+ if (!id.startsWith("http")) {
204
+ _context4.next = 2;
205
+ break;
206
+ }
207
+ url = new URL(searchId);
208
+ searchId = url.searchParams.get("dataId");
209
+ if (searchId) {
210
+ _context4.next = 2;
211
+ break;
212
+ }
213
+ return _context4.abrupt("return", {
214
+ success: false,
215
+ message: "数据Id不可为空!"
216
+ });
217
+ case 2:
218
+ _context4.prev = 2;
219
+ (0, _common.uuidVersion)(searchId);
220
+ _context4.next = 4;
221
+ break;
222
+ case 3:
223
+ _context4.prev = 3;
224
+ _t = _context4["catch"](2);
225
+ return _context4.abrupt("return", {
226
+ success: false,
227
+ message: "\u975E\u6CD5\u7684\u6570\u636EID:" + searchId
228
+ });
229
+ case 4:
230
+ _context4.next = 5;
231
+ return _RestApi.prototype.getById.call(this, searchId, options);
232
+ case 5:
200
233
  res = _context4.sent;
201
- (0, _formApi.assembleAssociationField)(res.data, res.refs);
202
- console.debug("formApi.getById", res);
234
+ res.assembleTime = (0, _formApi.assembleAssociationField)(res.data, res.refs);
235
+ console.debug("form.getById:", res);
203
236
  return _context4.abrupt("return", res);
204
- case 2:
237
+ case 6:
205
238
  case "end":
206
239
  return _context4.stop();
207
240
  }
208
- }, _callee4, this);
241
+ }, _callee4, this, [[2, 3]]);
209
242
  }));
210
243
  function getById(_x6, _x7) {
211
244
  return _getById.apply(this, arguments);
@@ -236,7 +269,7 @@ var RestFormApi = exports.RestFormApi = /*#__PURE__*/function (_RestApi) {
236
269
  };
237
270
  });
238
271
  }
239
- (0, _formApi.assembleAssociationField)(res.data, res.refs);
272
+ res.assembleTime = (0, _formApi.assembleAssociationField)(res.data, res.refs);
240
273
  console.debug("formApi.labelToValue", res);
241
274
  return _context5.abrupt("return", res);
242
275
  case 3:
@@ -301,30 +334,72 @@ var RestFormApi = exports.RestFormApi = /*#__PURE__*/function (_RestApi) {
301
334
  }
302
335
  return update;
303
336
  }();
304
- _proto.serviceUpdate = /*#__PURE__*/function () {
305
- var _serviceUpdate = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee9(data, options) {
306
- var params;
337
+ _proto.fieldFilters = /*#__PURE__*/function () {
338
+ var _fieldFilters = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee9(searchParams) {
339
+ var _searchParams3, _searchParams4;
340
+ var params, config;
307
341
  return _regenerator["default"].wrap(function (_context9) {
308
342
  while (1) switch (_context9.prev = _context9.next) {
309
343
  case 0:
344
+ searchParams = searchParams || {};
310
345
  params = {
311
346
  formId: this.formId,
312
347
  fieldId: this.fieldId
313
348
  };
314
349
  if (__mock) {
315
- params.mock = true;
316
350
  params.description = (this.title || "表单") + ".\u67E5\u8BE2";
317
351
  }
318
- return _context9.abrupt("return", this.request.post("serviceUpdate", data, {
352
+ config = {
319
353
  params: params
320
- }));
354
+ };
355
+ _context9.next = 1;
356
+ return this.handleRequestConfig(config);
321
357
  case 1:
358
+ searchParams.filterRules = (0, _formApi.handleFilterRules)(((_searchParams3 = searchParams) === null || _searchParams3 === void 0 ? void 0 : _searchParams3.filterRules) || [], {
359
+ filterNullValue: false
360
+ });
361
+ searchParams.searchFields = (0, _formApi.handleFilterRules)(((_searchParams4 = searchParams) === null || _searchParams4 === void 0 ? void 0 : _searchParams4.searchFields) || [], {
362
+ filterNullValue: true
363
+ });
364
+ _context9.next = 2;
365
+ return this.request.post("fieldFilters", searchParams, config);
366
+ case 2:
367
+ return _context9.abrupt("return", _context9.sent);
368
+ case 3:
322
369
  case "end":
323
370
  return _context9.stop();
324
371
  }
325
372
  }, _callee9, this);
326
373
  }));
327
- function serviceUpdate(_x15, _x16) {
374
+ function fieldFilters(_x15) {
375
+ return _fieldFilters.apply(this, arguments);
376
+ }
377
+ return fieldFilters;
378
+ }();
379
+ _proto.serviceUpdate = /*#__PURE__*/function () {
380
+ var _serviceUpdate = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee0(data, options) {
381
+ var params;
382
+ return _regenerator["default"].wrap(function (_context0) {
383
+ while (1) switch (_context0.prev = _context0.next) {
384
+ case 0:
385
+ params = {
386
+ formId: this.formId,
387
+ fieldId: this.fieldId
388
+ };
389
+ if (__mock) {
390
+ params.mock = true;
391
+ params.description = (this.title || "表单") + ".\u67E5\u8BE2";
392
+ }
393
+ return _context0.abrupt("return", this.request.post("serviceUpdate", data, {
394
+ params: params
395
+ }));
396
+ case 1:
397
+ case "end":
398
+ return _context0.stop();
399
+ }
400
+ }, _callee0, this);
401
+ }));
402
+ function serviceUpdate(_x16, _x17) {
328
403
  return _serviceUpdate.apply(this, arguments);
329
404
  }
330
405
  return serviceUpdate;
@@ -45,13 +45,14 @@ function onFulfilled(res) {
45
45
  function onRejected(error) {
46
46
  var _error$response = error.response,
47
47
  status = _error$response.status,
48
- statusText = _error$response.statusText;
48
+ statusText = _error$response.statusText,
49
+ data = _error$response.data;
49
50
  console.error("请求失败!", error);
50
51
  if (status == 400) {
51
52
  return error.response.data || {};
52
53
  }
53
54
  return {
54
55
  success: false,
55
- message: statusText
56
+ message: (data === null || data === void 0 ? void 0 : data.message) || statusText
56
57
  };
57
58
  }
@@ -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>;
@@ -17,7 +17,7 @@ function _getSchema() {
17
17
  while (1) switch (_context.prev = _context.next) {
18
18
  case 0:
19
19
  mock = getMock(mock);
20
- key = mock ? pageId + ":mock" : pageId;
20
+ key = mock ? pageId + "_mock" : pageId;
21
21
  _context.next = 1;
22
22
  return _cache.schema.getInstance(key, {
23
23
  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;
@@ -3,6 +3,7 @@
3
3
  exports.__esModule = true;
4
4
  exports.findFdmSchemas = findFdmSchemas;
5
5
  exports.findFormSchemas = findFormSchemas;
6
+ exports.findLoadRefSchemas = findLoadRefSchemas;
6
7
  exports.forEachSchema = forEachSchema;
7
8
  /**
8
9
  * 遍历schema
@@ -28,6 +29,16 @@ function findFormSchemas(schema) {
28
29
  });
29
30
  return schemas;
30
31
  }
32
+ function findLoadRefSchemas(schema) {
33
+ var schemas = [];
34
+ forEachSchema(schema, function (child) {
35
+ if (["ProcessGroupField"].includes(child.componentName)) {
36
+ schemas.push(child);
37
+ }
38
+ return true;
39
+ });
40
+ return schemas;
41
+ }
31
42
  function findFdmSchemas(schema) {
32
43
  var schemas = [];
33
44
  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;
@@ -9,6 +9,9 @@ var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inh
9
9
  var _SingletonInstanceMap3 = require("../common/SingletonInstanceMap");
10
10
  var _api = require("../api");
11
11
  var _schema = require("../api/schema.util");
12
+ 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."); }
13
+ 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; } }
14
+ 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; }
12
15
  var SchemaCache = exports.SchemaCache = /*#__PURE__*/function (_SingletonInstanceMap) {
13
16
  function SchemaCache() {
14
17
  return _SingletonInstanceMap.apply(this, arguments) || this;
@@ -17,28 +20,24 @@ var SchemaCache = exports.SchemaCache = /*#__PURE__*/function (_SingletonInstanc
17
20
  var _proto = SchemaCache.prototype;
18
21
  _proto.createInstance = /*#__PURE__*/function () {
19
22
  var _createInstance = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee(key, options) {
20
- var mock, pageId, schemaRes, schema, handleCommonSchema, permission, printTemplates, workflow, cloneSchema, _t;
23
+ 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;
21
24
  return _regenerator["default"].wrap(function (_context) {
22
25
  while (1) switch (_context.prev = _context.next) {
23
26
  case 0:
24
27
  mock = options.mock, pageId = options.pageId;
28
+ params = {};
29
+ if (mock) {
30
+ params.mock = mock;
31
+ }
25
32
  _context.next = 1;
26
33
  return _api.apiRequest.get("pages/" + pageId + "/schema", {
27
- params: {
28
- mock: mock
29
- }
34
+ params: params
30
35
  });
31
36
  case 1:
32
37
  schemaRes = _context.sent;
33
- if (schemaRes.succss) {
34
- _context.next = 2;
35
- break;
36
- }
37
- return _context.abrupt("return", schemaRes);
38
- case 2:
39
- schema = schemaRes.data;
40
- if (!(schema != null && typeof schema == "object")) {
41
- _context.next = 8;
38
+ schema = schemaRes === null || schemaRes === void 0 ? void 0 : schemaRes.data;
39
+ if (!schema) {
40
+ _context.next = 9;
42
41
  break;
43
42
  }
44
43
  handleCommonSchema = function handleCommonSchema(schema) {
@@ -51,29 +50,29 @@ var SchemaCache = exports.SchemaCache = /*#__PURE__*/function (_SingletonInstanc
51
50
  permission = null; //处理打印
52
51
  workflow = null;
53
52
  if (location.pathname.startsWith("/print")) {
54
- _context.next = 7;
53
+ _context.next = 6;
55
54
  break;
56
55
  }
57
- _context.next = 3;
56
+ _context.next = 2;
58
57
  return _api.apiRequest.get("pages/" + pageId + "/permission");
59
- case 3:
58
+ case 2:
60
59
  permission = _context.sent.data;
61
60
  if (!((schema === null || schema === void 0 ? void 0 : schema.type) == "form")) {
62
- _context.next = 7;
61
+ _context.next = 6;
63
62
  break;
64
63
  }
65
- _context.prev = 4;
66
- _context.next = 5;
64
+ _context.prev = 3;
65
+ _context.next = 4;
67
66
  return _api.apiRequest.get("pages/" + pageId + "/printTemplates");
68
- case 5:
67
+ case 4:
69
68
  printTemplates = _context.sent.data;
70
- _context.next = 7;
69
+ _context.next = 6;
71
70
  break;
72
- case 6:
73
- _context.prev = 6;
74
- _t = _context["catch"](4);
71
+ case 5:
72
+ _context.prev = 5;
73
+ _t = _context["catch"](3);
75
74
  console.log(_t);
76
- case 7:
75
+ case 6:
77
76
  (0, _schema.findFormSchemas)(schema).forEach(function (formSchema) {
78
77
  handleCommonSchema(formSchema);
79
78
  (0, _schema.findFdmSchemas)(formSchema.fdmSchema).forEach(function (fdmSchema) {
@@ -87,13 +86,43 @@ var SchemaCache = exports.SchemaCache = /*#__PURE__*/function (_SingletonInstanc
87
86
  fdmSchema.props.formElement = cloneSchema;
88
87
  });
89
88
  });
89
+ refs = (0, _schema.findLoadRefSchemas)(schema);
90
+ if (!refs.length) {
91
+ _context.next = 9;
92
+ break;
93
+ }
94
+ _iterator = _createForOfIteratorHelperLoose(refs);
95
+ case 7:
96
+ if ((_step = _iterator()).done) {
97
+ _context.next = 9;
98
+ break;
99
+ }
100
+ ref = _step.value;
101
+ 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;
102
+ if (!(typeof refPageId == "string" && refPageId !== pageId)) {
103
+ _context.next = 8;
104
+ break;
105
+ }
106
+ if (this.valueMap.has(refPageId)) {
107
+ _context.next = 8;
108
+ break;
109
+ }
110
+ _key = mock ? refPageId + "_mock" : refPageId;
111
+ _context.next = 8;
112
+ return this.getInstance(_key, {
113
+ mock: mock,
114
+ pageId: refPageId
115
+ });
90
116
  case 8:
91
- return _context.abrupt("return", schemaRes);
117
+ _context.next = 7;
118
+ break;
92
119
  case 9:
120
+ return _context.abrupt("return", schemaRes);
121
+ case 10:
93
122
  case "end":
94
123
  return _context.stop();
95
124
  }
96
- }, _callee, null, [[4, 6]]);
125
+ }, _callee, this, [[3, 5]]);
97
126
  }));
98
127
  function createInstance(_x, _x2) {
99
128
  return _createInstance.apply(this, arguments);
@@ -105,13 +134,7 @@ var SchemaCache = exports.SchemaCache = /*#__PURE__*/function (_SingletonInstanc
105
134
  var schema = exports.schema = new SchemaCache();
106
135
  var FormApiCache = exports.FormApiCache = /*#__PURE__*/function (_SingletonInstanceMap2) {
107
136
  function FormApiCache() {
108
- var _this;
109
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
110
- args[_key] = arguments[_key];
111
- }
112
- _this = _SingletonInstanceMap2.call.apply(_SingletonInstanceMap2, [this].concat(args)) || this;
113
- _this.apiMap = new Map();
114
- return _this;
137
+ return _SingletonInstanceMap2.apply(this, arguments) || this;
115
138
  }
116
139
  (0, _inheritsLoose2["default"])(FormApiCache, _SingletonInstanceMap2);
117
140
  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,11 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports["default"] = void 0;
5
+ var _dexie = require("dexie");
6
+ var db_cache = new _dexie.Dexie('cache');
7
+ db_cache.version(1).stores({
8
+ page_schemas: 'page_id,schema'
9
+ });
10
+ var page_schemas = db_cache.page_schemas;
11
+ var _default = exports["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,6 +1,6 @@
1
1
  export { loadPlugins } from "./LoadPlugins";
2
2
  export declare function uuid(prefix?: string, separator?: string): string;
3
- export declare function uuidVersion(id: string): number;
3
+ export declare function uuidVersion(id: string): number | false;
4
4
  export declare function toArray(data: any): any[];
5
5
  export declare function isLocalhost(): boolean;
6
6
  export declare function isMobile(): boolean;
@@ -19,7 +19,11 @@ function uuid(prefix, separator) {
19
19
  }).join("");
20
20
  }
21
21
  function uuidVersion(id) {
22
- return (0, _uuid.version)(id);
22
+ try {
23
+ return (0, _uuid.version)(id);
24
+ } catch (e) {
25
+ return false;
26
+ }
23
27
  }
24
28
  function toArray(data) {
25
29
  if (!data) {
@@ -1 +1,3 @@
1
- export declare function transformerId(value: any): any;
1
+ export declare function transformerId(value: any, options?: {
2
+ includeNull?: boolean;
3
+ }): any;
@@ -2,14 +2,21 @@
2
2
 
3
3
  exports.__esModule = true;
4
4
  exports.transformerId = transformerId;
5
- function transformerId(value) {
5
+ function transformerId(value, options) {
6
6
  if (value == null) {
7
7
  return null;
8
8
  }
9
9
  if (Array.isArray(value)) {
10
- return value.map(transformerId).filter(function (value) {
11
- return !!value;
10
+ var values = value.map(function (item) {
11
+ return transformerId(item, options);
12
12
  });
13
+ if (options !== null && options !== void 0 && options.includeNull) {
14
+ return values;
15
+ } else {
16
+ return values.filter(function (v) {
17
+ return !!v;
18
+ });
19
+ }
13
20
  }
14
21
  if (typeof value == "object") {
15
22
  return (value === null || value === void 0 ? void 0 : value.id) || (value === null || value === void 0 ? void 0 : value.value) || value;
@@ -1,3 +1,4 @@
1
+ export { createForm, getSchema } from "./page-create-element";
1
2
  export { print, getFormPrintTemplates } from "./print-form";
2
3
  export { showForm } from "./page-form";
3
4
  export { showFormGroup } from "./page-form-group";