@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
@@ -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";
@@ -1,6 +1,7 @@
1
1
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
2
  import _regeneratorRuntime from "@babel/runtime/regenerator";
3
3
  import { uniBridge } from "../uni-bridge";
4
+ export { createForm, getSchema } from "./page-create-element";
4
5
  export { print, getFormPrintTemplates } from "./print-form";
5
6
  export { showForm } from "./page-form";
6
7
  export { showFormGroup } from "./page-form-group";
@@ -55,7 +56,6 @@ function _hideLoading() {
55
56
  return _regeneratorRuntime.wrap(function (_context2) {
56
57
  while (1) switch (_context2.prev = _context2.next) {
57
58
  case 0:
58
- console.log("page.hide.loading");
59
59
  loading = document.getElementById("fullscreen-loading");
60
60
  if (loading) {
61
61
  loading.style.display = "none";
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ export interface PageCreateOptions {
3
+ formId: string;
4
+ }
5
+ export declare function getSchema(pageId: string): import("../api/schema.util").Schema & import("../api/rest-api").IBaseEntity;
6
+ export declare function createForm(options: PageCreateOptions): JSX.Element;
@@ -0,0 +1,23 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
3
+ var _excluded = ["formId"];
4
+ import { getSchemaFromCache } from "../api/schema-api";
5
+ import React from "react";
6
+ import { ReactRender } from "../../components/react-render";
7
+ export function getSchema(pageId) {
8
+ var _getSchemaFromCache;
9
+ return (_getSchemaFromCache = getSchemaFromCache(pageId)) === null || _getSchemaFromCache === void 0 ? void 0 : _getSchemaFromCache.data;
10
+ }
11
+ export function createForm(options) {
12
+ var formId = options.formId,
13
+ restProps = _objectWithoutPropertiesLoose(options, _excluded);
14
+ var schemaRes = getSchemaFromCache(formId, window.__mock);
15
+ if (schemaRes !== null && schemaRes !== void 0 && schemaRes.success) {
16
+ var schema = schemaRes.data;
17
+ return /*#__PURE__*/React.createElement(ReactRender, _extends({
18
+ schema: schema,
19
+ components: window._components || window.components || window.__components
20
+ }, restProps));
21
+ }
22
+ return null;
23
+ }
@@ -23,7 +23,7 @@ export function renderElement(options) {
23
23
  resolve(data || null);
24
24
  },
25
25
  onClose: function onClose() {
26
- resolve(false);
26
+ resolve(null);
27
27
  //等待动画结束
28
28
  setTimeout(function () {
29
29
  root.unmount();
@@ -60,10 +60,11 @@ function compileFilterRules(rules) {
60
60
  if (value === "") {
61
61
  value = "undefined";
62
62
  }
63
- } else if (rule.valueType == "value" || !rule.valueType || typeof value === "object") {
63
+ } else if (rule.valueType == "value" || rule.valueType == "column" || !rule.valueType || typeof value === "object") {
64
64
  value = JSON.stringify(value);
65
65
  }
66
66
  scripts.push("\"key\":\"" + rule.key + "\",");
67
+ scripts.push("\"valueType\":\"" + rule.valueType + "\",");
67
68
  scripts.push("\"operator\":\"" + rule.operator + "\",");
68
69
  scripts.push("\"value\":" + value + ",");
69
70
  }
@@ -4,6 +4,6 @@ interface PrintOptions {
4
4
  mode?: "print" | "export" | "cloud_print";
5
5
  data: any;
6
6
  }
7
- export declare function getFormPrintTemplates(formId: string): Promise<any>;
7
+ export declare function getFormPrintTemplates(formId: string, disableCache?: boolean): Promise<any>;
8
8
  export declare function print(options: PrintOptions): Promise<void>;
9
9
  export {};
@@ -5,15 +5,19 @@ import { apiRequest } from "../api";
5
5
  import { FormIds } from "../formIds";
6
6
  import { hideLoading, showLoading } from "./index";
7
7
  var cache = new Map();
8
- export function getFormPrintTemplates(_x) {
8
+ export function getFormPrintTemplates(_x, _x2) {
9
9
  return _getFormPrintTemplates.apply(this, arguments);
10
10
  }
11
11
  function _getFormPrintTemplates() {
12
- _getFormPrintTemplates = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(formId) {
12
+ _getFormPrintTemplates = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(formId, disableCache) {
13
13
  var res;
14
14
  return _regeneratorRuntime.wrap(function (_context2) {
15
15
  while (1) switch (_context2.prev = _context2.next) {
16
16
  case 0:
17
+ if (disableCache) {
18
+ _context2.next = 1;
19
+ break;
20
+ }
17
21
  if (!cache.has(formId)) {
18
22
  _context2.next = 1;
19
23
  break;
@@ -50,7 +54,7 @@ function _getFormPrintTemplates() {
50
54
  }));
51
55
  return _getFormPrintTemplates.apply(this, arguments);
52
56
  }
53
- export function print(_x2) {
57
+ export function print(_x3) {
54
58
  return _print.apply(this, arguments);
55
59
  }
56
60
  function _print() {
@@ -103,7 +107,7 @@ function _print() {
103
107
  }));
104
108
  return _print.apply(this, arguments);
105
109
  }
106
- function openPrint(_x3, _x4) {
110
+ function openPrint(_x4, _x5) {
107
111
  return _openPrint.apply(this, arguments);
108
112
  }
109
113
  function _openPrint() {
@@ -198,7 +202,7 @@ function _openPrint() {
198
202
  }
199
203
  }, _callee5);
200
204
  }));
201
- return function (_x6, _x7) {
205
+ return function (_x7, _x8) {
202
206
  return _ref.apply(this, arguments);
203
207
  };
204
208
  }()));
@@ -268,7 +272,9 @@ var CloudPrinter = /*#__PURE__*/function () {
268
272
  });
269
273
  case 3:
270
274
  res = _context.sent;
271
- if (!res.success) {
275
+ if (res.success) {
276
+ _message.success(res.message);
277
+ } else {
272
278
  _message.error(res.message);
273
279
  }
274
280
  case 4:
@@ -277,7 +283,7 @@ var CloudPrinter = /*#__PURE__*/function () {
277
283
  }
278
284
  }, _callee, this);
279
285
  }));
280
- function post(_x5) {
286
+ function post(_x6) {
281
287
  return _post.apply(this, arguments);
282
288
  }
283
289
  return post;
@@ -124,13 +124,11 @@ var UniBridge = /*#__PURE__*/function () {
124
124
  case 1:
125
125
  messageId = v7();
126
126
  return _context5.abrupt("return", new Promise(function (resolve, reject) {
127
- console.log("UniBridge.doAction", messageId, action, options);
128
127
  _this.callbacks[messageId] = {
129
128
  resolve: resolve,
130
129
  reject: reject
131
130
  };
132
131
  try {
133
- console.log("postMessage", messageId, action, options);
134
132
  uni.postMessage({
135
133
  data: {
136
134
  action: action,
@@ -157,7 +155,7 @@ var UniBridge = /*#__PURE__*/function () {
157
155
  _proto.receiveMessage = function receiveMessage(message) {
158
156
  var callback = this.callbacks[message.messageId];
159
157
  console.log('客户端收到 UniApp 消息:', JSON.stringify(message));
160
- console.log('客户端收到 UniApp 消息:callbacks', this.callbacks);
158
+ console.log('客户端收到 UniApp 消息:callbacks', JSON.stringify(Object.keys(this.callbacks)), callback);
161
159
  if (callback) {
162
160
  if (message.success) {
163
161
  callback.resolve(message.data);
@@ -1 +1 @@
1
- export declare function isTemplate(): boolean;
1
+ export declare function isTemplateHost(): boolean;
@@ -1,4 +1,3 @@
1
- export function isTemplate() {
2
- return false;
1
+ export function isTemplateHost() {
3
2
  return location.host == "templates.zhiyunhe.com";
4
3
  }
@@ -24,6 +24,10 @@ var ReactRender = exports.ReactRender = /*#__PURE__*/function (_PureComponent) {
24
24
  _proto.render = function render() {
25
25
  var _this2 = this;
26
26
  var components = this.props.components || window._components;
27
+ if (!components.Page) {
28
+ // @ts-ignore
29
+ components["Page"] = Page;
30
+ }
27
31
  return /*#__PURE__*/React.createElement(_reactRenderFactory["default"], (0, _extends2["default"])({
28
32
  key: this.key
29
33
  }, this.props, {
@@ -41,4 +45,10 @@ var ReactRender = exports.ReactRender = /*#__PURE__*/function (_PureComponent) {
41
45
  }));
42
46
  };
43
47
  return ReactRender;
44
- }(_react.PureComponent);
48
+ }(_react.PureComponent);
49
+ function Page(props) {
50
+ return /*#__PURE__*/React.createElement("div", {
51
+ className: "lce-page",
52
+ style: props.style
53
+ }, props.children);
54
+ }
@@ -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,99 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.formApiAssembleEntity = formApiAssembleEntity;
5
+ var _formApi = require("./form-api.entity-map");
6
+ var _formApi2 = require("./form-api.utils");
7
+ 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."); }
8
+ 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; } }
9
+ 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; }
10
+ function formApiAssembleEntity(data, refs) {
11
+ if (!data || !refs) return;
12
+ var dataMap = new _formApi.FormApiEntityMap();
13
+ for (var _iterator = _createForOfIteratorHelperLoose(refs), _step; !(_step = _iterator()).done;) {
14
+ var ref = _step.value;
15
+ ref.label = ref.form.label;
16
+ dataMap.addEntities(ref.data);
17
+ }
18
+ assembleRefs(refs, dataMap);
19
+ var dataArray = Array.isArray(data) ? data : [data];
20
+ assembleData(dataArray, dataMap);
21
+ }
22
+
23
+ /**
24
+ * 装配数据
25
+ */
26
+ function assembleData(data, dataMap) {
27
+ for (var _iterator2 = _createForOfIteratorHelperLoose(data), _step2; !(_step2 = _iterator2()).done;) {
28
+ var item = _step2.value;
29
+ assembleObject(item, dataMap, {
30
+ maxDepth: 5,
31
+ depth: 1
32
+ });
33
+ }
34
+ }
35
+
36
+ /**
37
+ * 装配相关数据
38
+ */
39
+ function assembleRefs(refs, dataMap) {
40
+ for (var _iterator3 = _createForOfIteratorHelperLoose(refs), _step3; !(_step3 = _iterator3()).done;) {
41
+ var ref = _step3.value;
42
+ ref.label = ref.form.label;
43
+ var data = ref.data;
44
+ for (var _iterator4 = _createForOfIteratorHelperLoose(data), _step4; !(_step4 = _iterator4()).done;) {
45
+ var item = _step4.value;
46
+ assembleObject(item, dataMap, {
47
+ maxDepth: 2,
48
+ depth: 1
49
+ });
50
+ }
51
+ }
52
+ }
53
+ function assembleObject(values, dataMap, options) {
54
+ var depth = options.depth,
55
+ maxDepth = options.maxDepth;
56
+ if (options.depth >= options.maxDepth) {
57
+ return;
58
+ }
59
+ if (dataMap.isEntity(values)) {
60
+ handleEntityLabel(values);
61
+ }
62
+ for (var _i = 0, _Object$keys = Object.keys(values); _i < _Object$keys.length; _i++) {
63
+ var key = _Object$keys[_i];
64
+ var value = values[key];
65
+ if (Array.isArray(value)) {
66
+ if (dataMap.needLoad(value[0])) {
67
+ //需要加载的属性
68
+ values[key] = value.map(function (item) {
69
+ if (dataMap.hasEntity(item)) {
70
+ return dataMap.getEntity(item);
71
+ }
72
+ return item;
73
+ });
74
+ } else if (dataMap.isEntity(value[0])) {
75
+ //子表属性
76
+ for (var _iterator5 = _createForOfIteratorHelperLoose(value), _step5; !(_step5 = _iterator5()).done;) {
77
+ var valueElement = _step5.value;
78
+ assembleObject(valueElement, dataMap, {
79
+ maxDepth: maxDepth,
80
+ depth: depth + 1
81
+ });
82
+ }
83
+ }
84
+ } else if (typeof value == "object") {
85
+ if (dataMap.needLoad(value)) {
86
+ if (dataMap.hasEntity(value)) {
87
+ values[key] = dataMap.getEntity(value);
88
+ }
89
+ }
90
+ }
91
+ }
92
+ }
93
+ function handleEntityLabel(data) {
94
+ var _data$form;
95
+ var labelField = data === null || data === void 0 ? void 0 : (_data$form = data.form) === null || _data$form === void 0 ? void 0 : _data$form.labelField;
96
+ if (labelField) {
97
+ data.label = (0, _formApi2.dataToLabel)((0, _formApi2.safeGet)(data, labelField));
98
+ }
99
+ }
@@ -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,54 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.FormApiEntityMap = void 0;
5
+ var FormApiEntityMap = exports.FormApiEntityMap = /*#__PURE__*/function () {
6
+ function FormApiEntityMap() {
7
+ this.dataMap = new Map();
8
+ }
9
+ var _proto = FormApiEntityMap.prototype;
10
+ _proto.hasEntity = function hasEntity(entity) {
11
+ var key = this.createEntityKey(entity);
12
+ return this.dataMap.has(key);
13
+ };
14
+ _proto.getEntity = function getEntity(entity) {
15
+ var key = this.createEntityKey(entity);
16
+ return this.dataMap.get(key);
17
+ };
18
+ _proto.addEntity = function addEntity(entity) {
19
+ var key = this.createEntityKey(entity);
20
+ this.dataMap.set(key, entity);
21
+ };
22
+ _proto.addEntities = function addEntities(entities) {
23
+ var _this = this;
24
+ entities === null || entities === void 0 ? void 0 : entities.forEach(function (item) {
25
+ return _this.addEntity(item);
26
+ });
27
+ };
28
+ _proto.isEntity = function isEntity(value) {
29
+ if (value == null) {
30
+ return false;
31
+ } else if (Array.isArray(value)) {
32
+ return false;
33
+ } else if (typeof value == "object") {
34
+ var _value$form;
35
+ return !!value.id && !!((_value$form = value.form) !== null && _value$form !== void 0 && _value$form.id);
36
+ }
37
+ return false;
38
+ };
39
+ _proto.needLoad = function needLoad(entity) {
40
+ return this.isEntity(entity) && entity._load == false;
41
+ };
42
+ _proto.destroy = function destroy() {
43
+ this.dataMap.clear();
44
+ };
45
+ _proto.createEntityKey = function createEntityKey(entity) {
46
+ var _entity$form, _entity$form2;
47
+ var key = (_entity$form = entity.form) === null || _entity$form === void 0 ? void 0 : _entity$form.id;
48
+ if ((_entity$form2 = entity.form) !== null && _entity$form2 !== void 0 && _entity$form2.fieldId) {
49
+ key += "." + entity.form.fieldId;
50
+ }
51
+ return key + "." + entity.id;
52
+ };
53
+ return FormApiEntityMap;
54
+ }();
@@ -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;
@@ -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
  }
@@ -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");
@@ -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:
@@ -235,8 +231,8 @@ var RestFormApi = exports.RestFormApi = /*#__PURE__*/function (_RestApi) {
235
231
  return _RestApi.prototype.getById.call(this, searchId, options);
236
232
  case 5:
237
233
  res = _context4.sent;
238
- (0, _formApi.assembleAssociationField)(res.data, res.refs);
239
- console.debug("formApi.getById", res);
234
+ res.assembleTime = (0, _formApi.assembleAssociationField)(res.data, res.refs);
235
+ console.debug("form.getById:", res);
240
236
  return _context4.abrupt("return", res);
241
237
  case 6:
242
238
  case "end":
@@ -273,7 +269,7 @@ var RestFormApi = exports.RestFormApi = /*#__PURE__*/function (_RestApi) {
273
269
  };
274
270
  });
275
271
  }
276
- (0, _formApi.assembleAssociationField)(res.data, res.refs);
272
+ res.assembleTime = (0, _formApi.assembleAssociationField)(res.data, res.refs);
277
273
  console.debug("formApi.labelToValue", res);
278
274
  return _context5.abrupt("return", res);
279
275
  case 3:
@@ -341,7 +337,7 @@ var RestFormApi = exports.RestFormApi = /*#__PURE__*/function (_RestApi) {
341
337
  _proto.fieldFilters = /*#__PURE__*/function () {
342
338
  var _fieldFilters = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee9(searchParams) {
343
339
  var _searchParams3, _searchParams4;
344
- var params, config, res;
340
+ var params, config;
345
341
  return _regenerator["default"].wrap(function (_context9) {
346
342
  while (1) switch (_context9.prev = _context9.next) {
347
343
  case 0:
@@ -365,13 +361,10 @@ var RestFormApi = exports.RestFormApi = /*#__PURE__*/function (_RestApi) {
365
361
  searchParams.searchFields = (0, _formApi.handleFilterRules)(((_searchParams4 = searchParams) === null || _searchParams4 === void 0 ? void 0 : _searchParams4.searchFields) || [], {
366
362
  filterNullValue: true
367
363
  });
368
- config.params = (0, _extends2["default"])({}, params, searchParams);
369
364
  _context9.next = 2;
370
- return this.request.get("fieldFilters", config);
365
+ return this.request.post("fieldFilters", searchParams, config);
371
366
  case 2:
372
- res = _context9.sent;
373
- console.debug("form.fieldFilters:", res);
374
- return _context9.abrupt("return", res);
367
+ return _context9.abrupt("return", _context9.sent);
375
368
  case 3:
376
369
  case "end":
377
370
  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>;
@@ -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;