@zhubangyun/lowcode-core 5.12.92 → 6.1.90

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 (98) hide show
  1. package/es/components/load-materials/index.js +44 -28
  2. package/es/components/page-loading/index.js +4 -1
  3. package/es/demo/index.js +8 -8
  4. package/es/index.d.ts +1 -1
  5. package/es/index.js +41 -2
  6. package/es/index.less +10 -0
  7. package/es/style.js +2 -2
  8. package/es/utils/api/file-api.js +21 -21
  9. package/es/utils/api/form-api.d.ts +2 -1
  10. package/es/utils/api/form-api.js +90 -51
  11. package/es/utils/api/form-api.utils.js +5 -4
  12. package/es/utils/api/index.d.ts +2 -2
  13. package/es/utils/api/index.js +1 -0
  14. package/es/utils/api/rest-api.d.ts +3 -1
  15. package/es/utils/api/rest-api.js +207 -125
  16. package/es/utils/api/schema-api.js +5 -5
  17. package/es/utils/api/schema.util.d.ts +3 -3
  18. package/es/utils/api/schema.util.js +17 -12
  19. package/es/utils/api/script-api.js +12 -12
  20. package/es/utils/api/user-info.js +7 -7
  21. package/es/utils/cache/index.js +66 -26
  22. package/es/utils/common/LoadPlugins.js +33 -33
  23. package/es/utils/common/SingletonInstanceMap.js +21 -21
  24. package/es/utils/common/index.d.ts +3 -0
  25. package/es/utils/common/index.js +13 -3
  26. package/es/utils/designer/assets/assets.parse.js +15 -15
  27. package/es/utils/designer/assets/assets.typing.js +6 -0
  28. package/es/utils/designer/engine/index.js +23 -23
  29. package/es/utils/designer/index.js +7 -7
  30. package/es/utils/page/index.js +18 -18
  31. package/es/utils/page/page-form-data-manager-group.js +9 -6
  32. package/es/utils/page/page-form-data-manager.d.ts +1 -0
  33. package/es/utils/page/page-form-data-manager.js +9 -6
  34. package/es/utils/page/page-form-group.d.ts +1 -0
  35. package/es/utils/page/page-form-group.js +8 -7
  36. package/es/utils/page/page-form.d.ts +1 -0
  37. package/es/utils/page/page-form.js +23 -12
  38. package/es/utils/page/page-layout.d.ts +3 -0
  39. package/es/utils/page/page-layout.js +33 -9
  40. package/es/utils/page/page-load-schema.js +20 -28
  41. package/es/utils/page/page-render.js +4 -4
  42. package/es/utils/page/page-show.d.ts +2 -0
  43. package/es/utils/page/page-show.js +8 -3
  44. package/es/utils/page/print-form.js +60 -51
  45. package/es/utils/uni-bridge.d.ts +18 -0
  46. package/es/utils/uni-bridge.js +130 -0
  47. package/es/utils/util.common.d.ts +1 -0
  48. package/es/utils/util.common.js +4 -0
  49. package/lib/components/load-materials/index.js +45 -30
  50. package/lib/components/page-loading/index.js +4 -1
  51. package/lib/demo/index.js +9 -10
  52. package/lib/index.d.ts +1 -1
  53. package/lib/index.js +45 -6
  54. package/lib/index.less +10 -0
  55. package/lib/style.js +2 -2
  56. package/lib/utils/api/file-api.js +21 -21
  57. package/lib/utils/api/form-api.d.ts +2 -1
  58. package/lib/utils/api/form-api.js +90 -51
  59. package/lib/utils/api/form-api.utils.js +5 -4
  60. package/lib/utils/api/index.d.ts +2 -2
  61. package/lib/utils/api/index.js +2 -2
  62. package/lib/utils/api/rest-api.d.ts +3 -1
  63. package/lib/utils/api/rest-api.js +207 -125
  64. package/lib/utils/api/schema-api.js +5 -5
  65. package/lib/utils/api/schema.util.d.ts +3 -3
  66. package/lib/utils/api/schema.util.js +19 -13
  67. package/lib/utils/api/script-api.js +12 -12
  68. package/lib/utils/api/user-info.js +7 -7
  69. package/lib/utils/cache/index.js +65 -25
  70. package/lib/utils/common/LoadPlugins.js +33 -33
  71. package/lib/utils/common/SingletonInstanceMap.js +21 -21
  72. package/lib/utils/common/index.d.ts +3 -0
  73. package/lib/utils/common/index.js +15 -2
  74. package/lib/utils/designer/assets/assets.parse.js +16 -17
  75. package/lib/utils/designer/assets/assets.typing.js +6 -0
  76. package/lib/utils/designer/engine/index.js +23 -23
  77. package/lib/utils/designer/index.js +7 -7
  78. package/lib/utils/index.js +1 -2
  79. package/lib/utils/page/index.js +18 -18
  80. package/lib/utils/page/page-form-data-manager-group.js +10 -8
  81. package/lib/utils/page/page-form-data-manager.d.ts +1 -0
  82. package/lib/utils/page/page-form-data-manager.js +10 -8
  83. package/lib/utils/page/page-form-group.d.ts +1 -0
  84. package/lib/utils/page/page-form-group.js +9 -9
  85. package/lib/utils/page/page-form.d.ts +1 -0
  86. package/lib/utils/page/page-form.js +24 -14
  87. package/lib/utils/page/page-layout.d.ts +3 -0
  88. package/lib/utils/page/page-layout.js +34 -11
  89. package/lib/utils/page/page-load-schema.js +19 -27
  90. package/lib/utils/page/page-render.js +4 -4
  91. package/lib/utils/page/page-show.d.ts +2 -0
  92. package/lib/utils/page/page-show.js +9 -5
  93. package/lib/utils/page/print-form.js +60 -51
  94. package/lib/utils/uni-bridge.d.ts +18 -0
  95. package/lib/utils/uni-bridge.js +135 -0
  96. package/lib/utils/util.common.d.ts +1 -0
  97. package/lib/utils/util.common.js +8 -0
  98. package/package.json +2 -2
@@ -3,24 +3,37 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
3
3
  import React, { useEffect, useState } from "react";
4
4
  import { PageLoading } from "../page-loading";
5
5
  import { loadPlugins } from "../../utils/common";
6
+ function getInit() {
7
+ if (window._components) {
8
+ return true;
9
+ }
10
+ if (window.AntdProMaterial) {
11
+ setComponents();
12
+ return true;
13
+ }
14
+ return false;
15
+ }
6
16
  export function LoadMaterials(props) {
7
- var _useState = useState(false),
17
+ var _useState = useState(getInit()),
8
18
  init = _useState[0],
9
19
  setInit = _useState[1];
10
20
  useEffect(function () {
11
21
  initialize().then();
12
22
  }, []);
13
- if (window._components) {
14
- return props.children;
15
- }
16
23
  function initialize() {
17
24
  return _initialize.apply(this, arguments);
18
25
  }
19
26
  function _initialize() {
20
- _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
21
- return _regeneratorRuntime.wrap(function _callee$(_context) {
27
+ _initialize = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
28
+ return _regeneratorRuntime.wrap(function (_context) {
22
29
  while (1) switch (_context.prev = _context.next) {
23
30
  case 0:
31
+ if (!init) {
32
+ _context.next = 1;
33
+ break;
34
+ }
35
+ return _context.abrupt("return");
36
+ case 1:
24
37
  _context.next = 2;
25
38
  return loadMaterials();
26
39
  case 2:
@@ -45,41 +58,44 @@ function loadMaterials() {
45
58
  return _loadMaterials.apply(this, arguments);
46
59
  }
47
60
  function _loadMaterials() {
48
- _loadMaterials = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
49
- var components, urls;
50
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
61
+ _loadMaterials = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
62
+ var urls;
63
+ return _regeneratorRuntime.wrap(function (_context2) {
51
64
  while (1) switch (_context2.prev = _context2.next) {
52
65
  case 0:
53
- components = {};
54
66
  if (!window._components) {
55
- _context2.next = 3;
67
+ _context2.next = 1;
56
68
  break;
57
69
  }
58
70
  return _context2.abrupt("return");
59
- case 3:
60
- urls = ["prop-types/15.8.1/prop-types.min.js", "lodash/4.17.15/lodash.min.js", "dayjs/dayjs.min.js", "antd/latest/reset.css", "antd/latest/antd.min.js", "antdIcon/1.0.0/antdIcon.min.js", "lowcode/core/index.js", "lowcode/core/index.css", "lowcode/materials/root/view.js", "lowcode/materials/root/view.css", "lowcode/materials/antd/view.js", "lowcode/materials/antd/view.css", "lowcode/materials/antd-pro/view.js", "lowcode/materials/antd-pro/view.css", "lowcode/icon-font/app/iconfont.js"];
61
- _context2.next = 6;
71
+ case 1:
72
+ urls = ["prop-types/15.8.1/prop-types.min.js", "lodash/4.17.15/lodash.min.js", "dayjs/dayjs.min.js", "antdIcon/1.0.0/antdIcon.min.js", "lowcode/core/index.js", "lowcode/core/index.css", "lowcode/materials/root/view.js", "lowcode/materials/root/view.css", "lowcode/materials/antd/view.js", "lowcode/materials/antd/view.css", "lowcode/materials/antd-pro/view.js", "lowcode/materials/antd-pro/view.css", "lowcode/icon-font/app/iconfont.js"];
73
+ _context2.next = 2;
62
74
  return loadPlugins(urls.map(function (url) {
63
75
  return "https://cdn.zhiyunhe.com/plugin/" + url;
64
76
  }));
65
- case 6:
66
- ["RootMaterial", "AntdMaterial", "AntdProMaterial"].forEach(function (lib) {
67
- var data = window[lib];
68
- if (data) {
69
- Object.entries(data).forEach(function (_ref) {
70
- var key = _ref[0],
71
- value = _ref[1];
72
- // @ts-ignore
73
- components[key] = value;
74
- });
75
- }
76
- });
77
- window._components = components;
78
- case 8:
77
+ case 2:
78
+ setComponents();
79
+ case 3:
79
80
  case "end":
80
81
  return _context2.stop();
81
82
  }
82
83
  }, _callee2);
83
84
  }));
84
85
  return _loadMaterials.apply(this, arguments);
86
+ }
87
+ function setComponents() {
88
+ var components = {};
89
+ ["RootMaterial", "AntdMaterial", "AntdProMaterial"].forEach(function (lib) {
90
+ var data = window[lib];
91
+ if (data) {
92
+ Object.entries(data).forEach(function (_ref) {
93
+ var key = _ref[0],
94
+ value = _ref[1];
95
+ // @ts-ignore
96
+ components[key] = value;
97
+ });
98
+ }
99
+ });
100
+ window._components = components;
85
101
  }
@@ -1,14 +1,17 @@
1
1
  import "./index.less";
2
+ import { useEffect } from "react";
2
3
  export function PageLoading(props) {
3
4
  var loading = props.loading,
4
5
  _props$background = props.background,
5
6
  background = _props$background === void 0 ? "#f1f1f1" : _props$background,
6
7
  children = props.children;
8
+ useEffect(function () {}, [loading]);
7
9
  return /*#__PURE__*/React.createElement("div", {
8
10
  className: "page-loading-wrapper",
9
11
  style: {
10
12
  width: "100%",
11
- height: "100%"
13
+ height: "100%",
14
+ background: "rgba(0,0,0,0)"
12
15
  }
13
16
  }, children, loading && /*#__PURE__*/React.createElement("div", {
14
17
  className: "page-loading",
package/es/demo/index.js CHANGED
@@ -8,17 +8,17 @@ console.log(utils);
8
8
  function App() {
9
9
  var ref = useRef();
10
10
  useEffect(function () {
11
- utils.designer.initEngine().then( /*#__PURE__*/function () {
12
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(engine) {
13
- return _regeneratorRuntime.wrap(function _callee$(_context) {
11
+ utils.designer.initEngine().then(/*#__PURE__*/function () {
12
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(engine) {
13
+ return _regeneratorRuntime.wrap(function (_context) {
14
14
  while (1) switch (_context.prev = _context.next) {
15
15
  case 0:
16
- _context.next = 2;
16
+ _context.next = 1;
17
17
  return engine.injectAssets([]);
18
- case 2:
19
- _context.next = 4;
18
+ case 1:
19
+ _context.next = 2;
20
20
  return engine.init(ref.current, Schema);
21
- case 4:
21
+ case 2:
22
22
  case "end":
23
23
  return _context.stop();
24
24
  }
@@ -37,4 +37,4 @@ function App() {
37
37
  }
38
38
  }));
39
39
  }
40
- ReactDOM.render( /*#__PURE__*/React.createElement(App, null), document.getElementById('root'));
40
+ ReactDOM.render(/*#__PURE__*/React.createElement(App, null), document.getElementById('root'));
package/es/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import "./index.less";
2
- import utils from "./utils";
3
2
  import * as lodash from "lodash";
4
3
  export { LoadMaterials } from "./components/load-materials";
5
4
  export { PageLoading } from "./components/page-loading";
6
5
  export { RestApi, RestFormApi, apiRequest } from "./utils/api";
7
6
  export { Layout } from "./components/layout";
8
7
  export { ReactRender } from "./components/react-render";
8
+ import utils from "./utils/index";
9
9
  export { utils, lodash };
package/es/index.js CHANGED
@@ -1,5 +1,6 @@
1
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
1
3
  import "./index.less";
2
- import utils from "./utils";
3
4
  import { ReactRender } from "./components/react-render";
4
5
  import * as lodash from "lodash";
5
6
  export { LoadMaterials } from "./components/load-materials";
@@ -7,7 +8,8 @@ export { PageLoading } from "./components/page-loading";
7
8
  export { RestApi, RestFormApi, apiRequest } from "./utils/api";
8
9
  export { Layout } from "./components/layout";
9
10
  export { ReactRender } from "./components/react-render";
10
-
11
+ import utils from "./utils/index";
12
+ import { uniBridge } from "./utils/uni-bridge";
11
13
  // @ts-ignore
12
14
  window.__ReactRender = ReactRender;
13
15
  // @ts-ignore
@@ -20,4 +22,41 @@ if (!window.utils) {
20
22
  // @ts-ignore
21
23
  window.utils = utils;
22
24
  }
25
+ window.isMobile = utils.common.isMobile();
26
+ if (window.isMobile) {
27
+ var classList = window.document.body.classList;
28
+ if (!classList.contains("mobile")) {
29
+ classList.add("mobile");
30
+ }
31
+ }
32
+ var bar_height_key = "bar_height";
33
+ // @ts-ignore
34
+ utils.uniBridge = uniBridge;
35
+ // @ts-ignore
36
+ window.uniBridge = uniBridge;
37
+ window.addEventListener("load", function () {
38
+ setTimeout(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
39
+ var height;
40
+ return _regeneratorRuntime.wrap(function (_context) {
41
+ while (1) switch (_context.prev = _context.next) {
42
+ case 0:
43
+ _context.next = 1;
44
+ return uniBridge.getBarHeight();
45
+ case 1:
46
+ height = _context.sent;
47
+ localStorage.setItem(bar_height_key, height);
48
+ updateBarHeight();
49
+ case 2:
50
+ case "end":
51
+ return _context.stop();
52
+ }
53
+ }, _callee);
54
+ })), 100);
55
+ });
56
+ function updateBarHeight() {
57
+ if (localStorage.getItem(bar_height_key)) {
58
+ document.documentElement.style.setProperty('--bar-height', localStorage.getItem(bar_height_key));
59
+ }
60
+ }
61
+ updateBarHeight();
23
62
  export { utils, lodash };
package/es/index.less CHANGED
@@ -11,3 +11,13 @@ ul {
11
11
  .page-content {
12
12
  overflow: hidden;
13
13
  }
14
+
15
+ .print-iframe {
16
+ position: fixed;
17
+ z-index: -1;
18
+ top: 0;
19
+ left: 0;
20
+ width: 100vw;
21
+ height: 100vh;
22
+ background: white;
23
+ }
package/es/style.js CHANGED
@@ -1,9 +1,9 @@
1
+ import 'antd/es/config-provider/style';
2
+
1
3
  import 'antd/es/notification/style';
2
4
  import 'antd/es/modal/style';
3
5
  import 'antd/es/message/style';
4
6
  import 'antd/es/typography/style';
5
7
  import 'antd/es/drawer/style';
6
8
  import 'antd/es/result/style';
7
- import 'antd/es/config-provider/style';
8
-
9
9
  import './index.less';
@@ -5,18 +5,18 @@ export function upload(_x, _x2) {
5
5
  return _upload.apply(this, arguments);
6
6
  }
7
7
  function _upload() {
8
- _upload = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(file, options) {
9
- var res, ossFile, _options$onFinished, _options$onError;
10
- return _regeneratorRuntime.wrap(function _callee$(_context) {
8
+ _upload = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(file, options) {
9
+ var res, ossFile, _options$onFinished, _options$onError, _t;
10
+ return _regeneratorRuntime.wrap(function (_context) {
11
11
  while (1) switch (_context.prev = _context.next) {
12
12
  case 0:
13
13
  if (file) {
14
- _context.next = 2;
14
+ _context.next = 1;
15
15
  break;
16
16
  }
17
17
  return _context.abrupt("return", file);
18
- case 2:
19
- _context.next = 4;
18
+ case 1:
19
+ _context.next = 2;
20
20
  return apiRequest.post("files/signature", {
21
21
  id: file.id,
22
22
  size: file.size,
@@ -27,15 +27,15 @@ function _upload() {
27
27
  type: "oss"
28
28
  }
29
29
  });
30
- case 4:
30
+ case 2:
31
31
  res = _context.sent;
32
32
  ossFile = res.data;
33
33
  file.id = ossFile.id;
34
34
  file.url = ossFile.url;
35
35
  file.percent = 0;
36
36
  file.status = "uploading";
37
- _context.prev = 10;
38
- _context.next = 13;
37
+ _context.prev = 3;
38
+ _context.next = 4;
39
39
  return apiRequest.put(ossFile.uploadUrl, (file === null || file === void 0 ? void 0 : file.buffer) || file, {
40
40
  headers: {
41
41
  'Content-Type': file.type
@@ -48,21 +48,21 @@ function _upload() {
48
48
  options === null || options === void 0 ? void 0 : (_options$onProgress = options.onProgress) === null || _options$onProgress === void 0 ? void 0 : _options$onProgress.call(options, evt);
49
49
  }
50
50
  });
51
- case 13:
51
+ case 4:
52
52
  file.status = "done";
53
53
  options === null || options === void 0 ? void 0 : (_options$onFinished = options.onFinished) === null || _options$onFinished === void 0 ? void 0 : _options$onFinished.call(options);
54
- _context.next = 21;
54
+ _context.next = 6;
55
55
  break;
56
- case 17:
57
- _context.prev = 17;
58
- _context.t0 = _context["catch"](10);
56
+ case 5:
57
+ _context.prev = 5;
58
+ _t = _context["catch"](3);
59
59
  file.status = "error";
60
- options === null || options === void 0 ? void 0 : (_options$onError = options.onError) === null || _options$onError === void 0 ? void 0 : _options$onError.call(options, _context.t0);
61
- case 21:
60
+ options === null || options === void 0 ? void 0 : (_options$onError = options.onError) === null || _options$onError === void 0 ? void 0 : _options$onError.call(options, _t);
61
+ case 6:
62
62
  case "end":
63
63
  return _context.stop();
64
64
  }
65
- }, _callee, null, [[10, 17]]);
65
+ }, _callee, null, [[3, 5]]);
66
66
  }));
67
67
  return _upload.apply(this, arguments);
68
68
  }
@@ -70,16 +70,16 @@ export function update(_x3) {
70
70
  return _update.apply(this, arguments);
71
71
  }
72
72
  function _update() {
73
- _update = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(file) {
74
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
73
+ _update = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(file) {
74
+ return _regeneratorRuntime.wrap(function (_context2) {
75
75
  while (1) switch (_context2.prev = _context2.next) {
76
76
  case 0:
77
- _context2.next = 2;
77
+ _context2.next = 1;
78
78
  return apiRequest.post("files/update", {
79
79
  id: file.id,
80
80
  fileName: file.fileName
81
81
  });
82
- case 2:
82
+ case 1:
83
83
  case "end":
84
84
  return _context2.stop();
85
85
  }
@@ -12,8 +12,9 @@ export declare class RestFormApi<DataType> extends RestApi<DataType> {
12
12
  handleRequestConfig(config: AxiosRequestConfig): Promise<void>;
13
13
  search(searchParams?: RestSearchParams): Promise<ManyResult<DataType>>;
14
14
  getById(id: string, options?: BaseRequestOptions<DataType>): Promise<OneResult<DataType>>;
15
+ labelToValue(data: any[], options?: any): Promise<ManyResult<DataType>>;
15
16
  save(data: DataType, options?: BaseRequestOptions<DataType>): Promise<OneResult<DataType>>;
16
17
  create(data: DataType, options?: BaseRequestOptions<DataType>): Promise<OneResult<DataType>>;
17
18
  update(id: string, data: DataType, options?: BaseRequestOptions<DataType>): Promise<OneResult<DataType>>;
18
- serviceUpdate(data: DataType, options?: BaseRequestOptions<DataType>): Promise<import("axios").AxiosResponse<any, any>>;
19
+ serviceUpdate(data: DataType, options?: BaseRequestOptions<DataType>): Promise<import("axios").AxiosResponse<any, any, {}>>;
19
20
  }
@@ -6,14 +6,15 @@ import { RestApi } from "./rest-api";
6
6
  import { assembleAssociationField, convertSaveData, handleFilterRules } from "./form-api.utils";
7
7
  import { formApi } from "../cache";
8
8
  import { getSchemaFromCache } from "./schema-api";
9
+ import { uuid } from "../common";
9
10
  export function getFormApi(_x, _x2, _x3) {
10
11
  return _getFormApi.apply(this, arguments);
11
12
  }
12
13
  function _getFormApi() {
13
- _getFormApi = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(formId, fieldId, mock) {
14
+ _getFormApi = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee0(formId, fieldId, mock) {
14
15
  var key;
15
- return _regeneratorRuntime.wrap(function _callee9$(_context9) {
16
- while (1) switch (_context9.prev = _context9.next) {
16
+ return _regeneratorRuntime.wrap(function (_context0) {
17
+ while (1) switch (_context0.prev = _context0.next) {
17
18
  case 0:
18
19
  if (typeof mock != "boolean") {
19
20
  if (typeof window.__mock == "boolean") {
@@ -23,16 +24,16 @@ function _getFormApi() {
23
24
  key = [formId, fieldId, mock ? "mock" : ""].filter(function (key) {
24
25
  return !!key;
25
26
  }).join("_");
26
- return _context9.abrupt("return", formApi.getInstance(key, {
27
+ return _context0.abrupt("return", formApi.getInstance(key, {
27
28
  mock: mock,
28
29
  fieldId: fieldId,
29
30
  formId: formId
30
31
  }));
31
- case 3:
32
+ case 1:
32
33
  case "end":
33
- return _context9.stop();
34
+ return _context0.stop();
34
35
  }
35
- }, _callee9);
36
+ }, _callee0);
36
37
  }));
37
38
  return _getFormApi.apply(this, arguments);
38
39
  }
@@ -55,10 +56,10 @@ export var RestFormApi = /*#__PURE__*/function (_RestApi) {
55
56
  _inheritsLoose(RestFormApi, _RestApi);
56
57
  var _proto = RestFormApi.prototype;
57
58
  _proto.initialize = /*#__PURE__*/function () {
58
- var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
59
+ var _initialize = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
59
60
  var _this2 = this;
60
61
  var res, _this$schema, _this$schema$children, _this$schema$children2;
61
- return _regeneratorRuntime.wrap(function _callee$(_context) {
62
+ return _regeneratorRuntime.wrap(function (_context) {
62
63
  while (1) switch (_context.prev = _context.next) {
63
64
  case 0:
64
65
  if (!this.initialized) {
@@ -92,7 +93,7 @@ export var RestFormApi = /*#__PURE__*/function (_RestApi) {
92
93
  }
93
94
  }
94
95
  return _context.abrupt("return", this.initialized);
95
- case 2:
96
+ case 1:
96
97
  case "end":
97
98
  return _context.stop();
98
99
  }
@@ -104,13 +105,13 @@ export var RestFormApi = /*#__PURE__*/function (_RestApi) {
104
105
  return initialize;
105
106
  }();
106
107
  _proto.handleRequestConfig = /*#__PURE__*/function () {
107
- var _handleRequestConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(config) {
108
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
108
+ var _handleRequestConfig = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(config) {
109
+ return _regeneratorRuntime.wrap(function (_context2) {
109
110
  while (1) switch (_context2.prev = _context2.next) {
110
111
  case 0:
111
- _context2.next = 2;
112
+ _context2.next = 1;
112
113
  return this.initialize();
113
- case 2:
114
+ case 1:
114
115
  config.params = config.params || {};
115
116
  if (__mock) {
116
117
  config.params.description = "" + this.title;
@@ -122,7 +123,7 @@ export var RestFormApi = /*#__PURE__*/function (_RestApi) {
122
123
  if (this.mock) {
123
124
  config.params.mock = this.mock;
124
125
  }
125
- case 7:
126
+ case 2:
126
127
  case "end":
127
128
  return _context2.stop();
128
129
  }
@@ -134,10 +135,10 @@ export var RestFormApi = /*#__PURE__*/function (_RestApi) {
134
135
  return handleRequestConfig;
135
136
  }();
136
137
  _proto.search = /*#__PURE__*/function () {
137
- var _search = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(searchParams) {
138
+ var _search = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(searchParams) {
138
139
  var _searchParams, _searchParams2;
139
140
  var params, config, res, start;
140
- return _regeneratorRuntime.wrap(function _callee3$(_context3) {
141
+ return _regeneratorRuntime.wrap(function (_context3) {
141
142
  while (1) switch (_context3.prev = _context3.next) {
142
143
  case 0:
143
144
  searchParams = searchParams || {};
@@ -151,9 +152,9 @@ export var RestFormApi = /*#__PURE__*/function (_RestApi) {
151
152
  config = {
152
153
  params: params
153
154
  };
154
- _context3.next = 6;
155
+ _context3.next = 1;
155
156
  return this.handleRequestConfig(config);
156
- case 6:
157
+ case 1:
157
158
  searchParams.filterRules = handleFilterRules(((_searchParams = searchParams) === null || _searchParams === void 0 ? void 0 : _searchParams.filterRules) || [], {
158
159
  filterNullValue: false
159
160
  });
@@ -161,16 +162,16 @@ export var RestFormApi = /*#__PURE__*/function (_RestApi) {
161
162
  filterNullValue: true
162
163
  });
163
164
  config.params = _extends({}, params, searchParams);
164
- _context3.next = 11;
165
+ _context3.next = 2;
165
166
  return this.request.get("search", config);
166
- case 11:
167
+ case 2:
167
168
  res = _context3.sent;
168
169
  //const res = await this.request.post<any, ManyResult<DataType>>("search", searchParams, config);
169
170
  start = Date.now();
170
171
  assembleAssociationField(res.data, res.refs);
171
172
  console.debug("form.search:", res);
172
173
  return _context3.abrupt("return", res);
173
- case 16:
174
+ case 3:
174
175
  case "end":
175
176
  return _context3.stop();
176
177
  }
@@ -182,19 +183,19 @@ export var RestFormApi = /*#__PURE__*/function (_RestApi) {
182
183
  return search;
183
184
  }();
184
185
  _proto.getById = /*#__PURE__*/function () {
185
- var _getById = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(id, options) {
186
+ var _getById = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4(id, options) {
186
187
  var res;
187
- return _regeneratorRuntime.wrap(function _callee4$(_context4) {
188
+ return _regeneratorRuntime.wrap(function (_context4) {
188
189
  while (1) switch (_context4.prev = _context4.next) {
189
190
  case 0:
190
- _context4.next = 2;
191
+ _context4.next = 1;
191
192
  return _RestApi.prototype.getById.call(this, id, options);
192
- case 2:
193
+ case 1:
193
194
  res = _context4.sent;
194
195
  assembleAssociationField(res.data, res.refs);
195
196
  console.debug("formApi.getById", res);
196
197
  return _context4.abrupt("return", res);
197
- case 6:
198
+ case 2:
198
199
  case "end":
199
200
  return _context4.stop();
200
201
  }
@@ -205,51 +206,89 @@ export var RestFormApi = /*#__PURE__*/function (_RestApi) {
205
206
  }
206
207
  return getById;
207
208
  }();
208
- _proto.save = /*#__PURE__*/function () {
209
- var _save = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(data, options) {
210
- return _regeneratorRuntime.wrap(function _callee5$(_context5) {
209
+ _proto.labelToValue = /*#__PURE__*/function () {
210
+ var _labelToValue = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee5(data, options) {
211
+ var _this3 = this;
212
+ var config, res;
213
+ return _regeneratorRuntime.wrap(function (_context5) {
211
214
  while (1) switch (_context5.prev = _context5.next) {
212
215
  case 0:
213
- return _context5.abrupt("return", _RestApi.prototype.save.call(this, convertSaveData(data), options));
216
+ config = {};
217
+ _context5.next = 1;
218
+ return this.handleRequestConfig(config);
214
219
  case 1:
220
+ _context5.next = 2;
221
+ return this.request.post("labelToValue", data, config);
222
+ case 2:
223
+ res = _context5.sent;
224
+ if (Array.isArray(res.data)) {
225
+ res.data.forEach(function (item) {
226
+ item.id = uuid();
227
+ item.form = {
228
+ id: _this3.formId,
229
+ fieldId: _this3.fieldId
230
+ };
231
+ });
232
+ }
233
+ assembleAssociationField(res.data, res.refs);
234
+ console.debug("formApi.labelToValue", res);
235
+ return _context5.abrupt("return", res);
236
+ case 3:
215
237
  case "end":
216
238
  return _context5.stop();
217
239
  }
218
240
  }, _callee5, this);
219
241
  }));
220
- function save(_x8, _x9) {
221
- return _save.apply(this, arguments);
242
+ function labelToValue(_x8, _x9) {
243
+ return _labelToValue.apply(this, arguments);
222
244
  }
223
- return save;
245
+ return labelToValue;
224
246
  }();
225
- _proto.create = /*#__PURE__*/function () {
226
- var _create = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(data, options) {
227
- return _regeneratorRuntime.wrap(function _callee6$(_context6) {
247
+ _proto.save = /*#__PURE__*/function () {
248
+ var _save = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee6(data, options) {
249
+ return _regeneratorRuntime.wrap(function (_context6) {
228
250
  while (1) switch (_context6.prev = _context6.next) {
229
251
  case 0:
230
- return _context6.abrupt("return", _RestApi.prototype.create.call(this, convertSaveData(data), options));
252
+ return _context6.abrupt("return", _RestApi.prototype.save.call(this, convertSaveData(data), options));
231
253
  case 1:
232
254
  case "end":
233
255
  return _context6.stop();
234
256
  }
235
257
  }, _callee6, this);
236
258
  }));
259
+ function save(_x0, _x1) {
260
+ return _save.apply(this, arguments);
261
+ }
262
+ return save;
263
+ }();
264
+ _proto.create = /*#__PURE__*/function () {
265
+ var _create = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee7(data, options) {
266
+ return _regeneratorRuntime.wrap(function (_context7) {
267
+ while (1) switch (_context7.prev = _context7.next) {
268
+ case 0:
269
+ return _context7.abrupt("return", _RestApi.prototype.create.call(this, convertSaveData(data), options));
270
+ case 1:
271
+ case "end":
272
+ return _context7.stop();
273
+ }
274
+ }, _callee7, this);
275
+ }));
237
276
  function create(_x10, _x11) {
238
277
  return _create.apply(this, arguments);
239
278
  }
240
279
  return create;
241
280
  }();
242
281
  _proto.update = /*#__PURE__*/function () {
243
- var _update = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(id, data, options) {
244
- return _regeneratorRuntime.wrap(function _callee7$(_context7) {
245
- while (1) switch (_context7.prev = _context7.next) {
282
+ var _update = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee8(id, data, options) {
283
+ return _regeneratorRuntime.wrap(function (_context8) {
284
+ while (1) switch (_context8.prev = _context8.next) {
246
285
  case 0:
247
- return _context7.abrupt("return", _RestApi.prototype.update.call(this, id, convertSaveData(data), options));
286
+ return _context8.abrupt("return", _RestApi.prototype.update.call(this, id, convertSaveData(data), options));
248
287
  case 1:
249
288
  case "end":
250
- return _context7.stop();
289
+ return _context8.stop();
251
290
  }
252
- }, _callee7, this);
291
+ }, _callee8, this);
253
292
  }));
254
293
  function update(_x12, _x13, _x14) {
255
294
  return _update.apply(this, arguments);
@@ -257,10 +296,10 @@ export var RestFormApi = /*#__PURE__*/function (_RestApi) {
257
296
  return update;
258
297
  }();
259
298
  _proto.serviceUpdate = /*#__PURE__*/function () {
260
- var _serviceUpdate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(data, options) {
299
+ var _serviceUpdate = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee9(data, options) {
261
300
  var params;
262
- return _regeneratorRuntime.wrap(function _callee8$(_context8) {
263
- while (1) switch (_context8.prev = _context8.next) {
301
+ return _regeneratorRuntime.wrap(function (_context9) {
302
+ while (1) switch (_context9.prev = _context9.next) {
264
303
  case 0:
265
304
  params = {
266
305
  formId: this.formId,
@@ -270,14 +309,14 @@ export var RestFormApi = /*#__PURE__*/function (_RestApi) {
270
309
  params.mock = true;
271
310
  params.description = (this.title || "表单") + ".\u67E5\u8BE2";
272
311
  }
273
- return _context8.abrupt("return", this.request.post("serviceUpdate", data, {
312
+ return _context9.abrupt("return", this.request.post("serviceUpdate", data, {
274
313
  params: params
275
314
  }));
276
- case 3:
315
+ case 1:
277
316
  case "end":
278
- return _context8.stop();
317
+ return _context9.stop();
279
318
  }
280
- }, _callee8, this);
319
+ }, _callee9, this);
281
320
  }));
282
321
  function serviceUpdate(_x15, _x16) {
283
322
  return _serviceUpdate.apply(this, arguments);