@zhubangyun/lowcode-core 5.10.221 → 5.12.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/es/index.less +10 -0
  2. package/es/utils/api/file-api.d.ts +17 -5
  3. package/es/utils/api/file-api.js +10 -7
  4. package/es/utils/api/form-api.js +33 -44
  5. package/es/utils/api/form-api.utils.d.ts +5 -5
  6. package/es/utils/api/form-api.utils.js +55 -36
  7. package/es/utils/api/index.d.ts +4 -3
  8. package/es/utils/api/index.js +9 -2
  9. package/es/utils/api/rest-api.d.ts +6 -5
  10. package/es/utils/api/rest-api.js +1 -1
  11. package/es/utils/api/schema.util.d.ts +14 -0
  12. package/es/utils/api/schema.util.js +32 -0
  13. package/es/utils/api/script-api.js +1 -1
  14. package/es/utils/api/user-info.d.ts +16 -6
  15. package/es/utils/api/user-info.js +31 -20
  16. package/es/utils/cache/index.js +21 -11
  17. package/es/utils/cache/schema.d.ts +0 -2
  18. package/es/utils/cache/schema.js +0 -388
  19. package/es/utils/formIds.d.ts +3 -0
  20. package/es/utils/formIds.js +3 -0
  21. package/es/utils/page/index.d.ts +2 -0
  22. package/es/utils/page/index.js +2 -0
  23. package/es/utils/page/page-form-data-manager-group.d.ts +2 -0
  24. package/es/utils/page/page-form-data-manager-group.js +3 -7
  25. package/es/utils/page/page-form-data-manager.d.ts +2 -1
  26. package/es/utils/page/page-form-data-manager.js +1 -0
  27. package/es/utils/page/page-form-group.d.ts +17 -0
  28. package/es/utils/page/page-form-group.js +97 -0
  29. package/es/utils/page/page-form.d.ts +2 -1
  30. package/es/utils/page/page-form.js +3 -3
  31. package/es/utils/page/page-render.js +1 -2
  32. package/es/utils/page/page-show.d.ts +1 -0
  33. package/es/utils/page/print-form.d.ts +8 -0
  34. package/es/utils/page/print-form.js +147 -0
  35. package/lib/index.less +10 -0
  36. package/lib/utils/api/file-api.d.ts +17 -5
  37. package/lib/utils/api/file-api.js +10 -7
  38. package/lib/utils/api/form-api.js +33 -44
  39. package/lib/utils/api/form-api.utils.d.ts +5 -5
  40. package/lib/utils/api/form-api.utils.js +55 -36
  41. package/lib/utils/api/index.d.ts +4 -3
  42. package/lib/utils/api/index.js +10 -3
  43. package/lib/utils/api/rest-api.d.ts +6 -5
  44. package/lib/utils/api/rest-api.js +1 -1
  45. package/lib/utils/api/schema.util.d.ts +14 -0
  46. package/lib/utils/api/schema.util.js +37 -0
  47. package/lib/utils/api/script-api.js +1 -1
  48. package/lib/utils/api/user-info.d.ts +16 -6
  49. package/lib/utils/api/user-info.js +32 -21
  50. package/lib/utils/cache/index.js +20 -9
  51. package/lib/utils/cache/schema.d.ts +0 -2
  52. package/lib/utils/cache/schema.js +0 -390
  53. package/lib/utils/formIds.d.ts +3 -0
  54. package/lib/utils/formIds.js +7 -0
  55. package/lib/utils/page/index.d.ts +2 -0
  56. package/lib/utils/page/index.js +7 -1
  57. package/lib/utils/page/page-form-data-manager-group.d.ts +2 -0
  58. package/lib/utils/page/page-form-data-manager-group.js +3 -7
  59. package/lib/utils/page/page-form-data-manager.d.ts +2 -1
  60. package/lib/utils/page/page-form-data-manager.js +1 -0
  61. package/lib/utils/page/page-form-group.d.ts +17 -0
  62. package/lib/utils/page/page-form-group.js +104 -0
  63. package/lib/utils/page/page-form.d.ts +2 -1
  64. package/lib/utils/page/page-form.js +3 -3
  65. package/lib/utils/page/page-render.js +1 -2
  66. package/lib/utils/page/page-show.d.ts +1 -0
  67. package/lib/utils/page/print-form.d.ts +8 -0
  68. package/lib/utils/page/print-form.js +153 -0
  69. package/package.json +1 -1
@@ -10,8 +10,9 @@ export interface ShowFormProps {
10
10
  mode?: PageFormModeType;
11
11
  lockMode?: boolean;
12
12
  dataId?: string;
13
- onSubmitOk?: () => void;
13
+ onSubmitOk?: (data: any) => void;
14
14
  onRemoveOk?: () => void;
15
15
  onClose?: () => void | Promise<void>;
16
+ pageRef?: (page: any) => void;
16
17
  }
17
18
  export declare function showForm(options: ShowFormProps): Promise<any>;
@@ -16,7 +16,7 @@ export function showForm(_x) {
16
16
  }
17
17
  function _showForm() {
18
18
  _showForm = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(options) {
19
- var container, onClose, props, _options$form, paths, mode, dataId, params, url, page;
19
+ var container, onClose, props, _options$form, paths, mode, dataId, params, url, _page;
20
20
  return _regeneratorRuntime.wrap(function _callee$(_context) {
21
21
  while (1) switch (_context.prev = _context.next) {
22
22
  case 0:
@@ -35,8 +35,8 @@ function _showForm() {
35
35
  _context.next = 9;
36
36
  return openPage(url, url);
37
37
  case 9:
38
- page = _context.sent;
39
- console.debug("openPage", page);
38
+ _page = _context.sent;
39
+ console.debug("openPage", _page);
40
40
  return _context.abrupt("return");
41
41
  case 12:
42
42
  return _context.abrupt("return", renderElement({
@@ -37,8 +37,7 @@ export function renderElement(options) {
37
37
  }
38
38
  }));
39
39
  root.render(element);
40
- return _context.abrupt("return", element);
41
- case 8:
40
+ case 7:
42
41
  case "end":
43
42
  return _context.stop();
44
43
  }
@@ -4,5 +4,6 @@ export interface ShowPageProps {
4
4
  pageId: string;
5
5
  layout?: PageLayoutType;
6
6
  onClose?: () => void | Promise<void>;
7
+ pageRef?: (page: any) => void;
7
8
  }
8
9
  export declare function show(options: ShowPageProps): Promise<any | any[]>;
@@ -0,0 +1,8 @@
1
+ interface PrintOptions {
2
+ templateId: string;
3
+ mode?: "print" | "export";
4
+ data: any;
5
+ }
6
+ export declare function getFormPrintTemplates(formId: string): Promise<any[]>;
7
+ export declare function print(options: PrintOptions): Promise<void>;
8
+ export {};
@@ -0,0 +1,147 @@
1
+ import _message from "antd/es/message";
2
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
4
+ import { apiRequest } from "../api";
5
+ import { FormIds } from "../formIds";
6
+ import { hideLoading, showLoading } from "./index";
7
+ export function getFormPrintTemplates(_x) {
8
+ return _getFormPrintTemplates.apply(this, arguments);
9
+ }
10
+ function _getFormPrintTemplates() {
11
+ _getFormPrintTemplates = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(formId) {
12
+ var res;
13
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
14
+ while (1) switch (_context.prev = _context.next) {
15
+ case 0:
16
+ _context.next = 2;
17
+ return apiRequest.get("forms/search", {
18
+ params: {
19
+ formId: FormIds.printTemplate,
20
+ filterRules: [{
21
+ key: "page",
22
+ operator: "eq",
23
+ value: formId
24
+ }],
25
+ pageSize: 1000
26
+ }
27
+ });
28
+ case 2:
29
+ res = _context.sent;
30
+ if (!res.success) {
31
+ _context.next = 7;
32
+ break;
33
+ }
34
+ return _context.abrupt("return", res.data);
35
+ case 7:
36
+ return _context.abrupt("return", []);
37
+ case 8:
38
+ case "end":
39
+ return _context.stop();
40
+ }
41
+ }, _callee);
42
+ }));
43
+ return _getFormPrintTemplates.apply(this, arguments);
44
+ }
45
+ export function print(_x2) {
46
+ return _print.apply(this, arguments);
47
+ }
48
+ function _print() {
49
+ _print = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(options) {
50
+ var templateId, iw;
51
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
52
+ while (1) switch (_context2.prev = _context2.next) {
53
+ case 0:
54
+ _context2.prev = 0;
55
+ _context2.next = 3;
56
+ return showLoading();
57
+ case 3:
58
+ templateId = options === null || options === void 0 ? void 0 : options.templateId;
59
+ if (templateId) {
60
+ _context2.next = 7;
61
+ break;
62
+ }
63
+ _message.error("\u6253\u5370\u5931\u8D25!\u6A21\u677Fid\u4E0D\u53EF\u4E3A\u7A7A!");
64
+ return _context2.abrupt("return");
65
+ case 7:
66
+ _context2.next = 9;
67
+ return openPrint(templateId);
68
+ case 9:
69
+ iw = _context2.sent;
70
+ if (iw) {
71
+ _context2.next = 13;
72
+ break;
73
+ }
74
+ _message.error("\u6253\u5370\u5931\u8D25!\u6253\u5370\u7A97\u53E3\u4E0D\u53EF\u4E3A\u7A7A!");
75
+ return _context2.abrupt("return");
76
+ case 13:
77
+ // @ts-ignore
78
+ iw.printOptions = options;
79
+ _context2.next = 19;
80
+ break;
81
+ case 16:
82
+ _context2.prev = 16;
83
+ _context2.t0 = _context2["catch"](0);
84
+ console.log("打印失败", _context2.t0);
85
+ case 19:
86
+ _context2.prev = 19;
87
+ return _context2.finish(19);
88
+ case 21:
89
+ case "end":
90
+ return _context2.stop();
91
+ }
92
+ }, _callee2, null, [[0, 16, 19, 21]]);
93
+ }));
94
+ return _print.apply(this, arguments);
95
+ }
96
+ function openPrint(_x3) {
97
+ return _openPrint.apply(this, arguments);
98
+ }
99
+ function _openPrint() {
100
+ _openPrint = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(templateId) {
101
+ return _regeneratorRuntime.wrap(function _callee4$(_context4) {
102
+ while (1) switch (_context4.prev = _context4.next) {
103
+ case 0:
104
+ return _context4.abrupt("return", new Promise( /*#__PURE__*/function () {
105
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(resolve, reject) {
106
+ var iframe, iframeWindow;
107
+ return _regeneratorRuntime.wrap(function _callee3$(_context3) {
108
+ while (1) switch (_context3.prev = _context3.next) {
109
+ case 0:
110
+ iframe = document.createElement("iframe");
111
+ iframe.src = "/print/" + templateId;
112
+ iframe.style.display = "none";
113
+ document.body.appendChild(iframe);
114
+ iframeWindow = iframe.contentWindow;
115
+ if (iframeWindow) {
116
+ _context3.next = 8;
117
+ break;
118
+ }
119
+ reject("创建Iframe失败!");
120
+ return _context3.abrupt("return");
121
+ case 8:
122
+ iframeWindow.onload = function () {
123
+ resolve(iframeWindow);
124
+ };
125
+ iframeWindow.addEventListener("beforeprint", function () {});
126
+ iframeWindow.addEventListener("afterprint", function () {
127
+ hideLoading();
128
+ iframe.remove();
129
+ });
130
+ case 11:
131
+ case "end":
132
+ return _context3.stop();
133
+ }
134
+ }, _callee3);
135
+ }));
136
+ return function (_x4, _x5) {
137
+ return _ref.apply(this, arguments);
138
+ };
139
+ }()));
140
+ case 1:
141
+ case "end":
142
+ return _context4.stop();
143
+ }
144
+ }, _callee4);
145
+ }));
146
+ return _openPrint.apply(this, arguments);
147
+ }
package/lib/index.less CHANGED
@@ -1,3 +1,13 @@
1
1
  [componentname="Page"] {
2
2
  height: 100%;
3
3
  }
4
+
5
+ ul {
6
+ margin-bottom: 0;
7
+ padding-left: 0;
8
+ list-style: none;
9
+ }
10
+
11
+ .page-content {
12
+ overflow: hidden;
13
+ }
@@ -1,7 +1,19 @@
1
+ /// <reference types="node" />
1
2
  import { AxiosProgressEvent } from "axios";
2
- export declare function upload(file: any, options?: {
3
- onProgress: (evt: AxiosProgressEvent) => void;
4
- onFinished: () => void;
5
- onError: (e: any) => void;
6
- }): Promise<void>;
3
+ interface File {
4
+ id?: string;
5
+ size?: number;
6
+ name?: string;
7
+ type?: string;
8
+ status?: "done" | "uploading" | "error";
9
+ url: string;
10
+ percent?: number;
11
+ buffer?: Buffer;
12
+ }
13
+ export declare function upload(file: File, options?: {
14
+ onProgress?: (evt: AxiosProgressEvent) => void;
15
+ onFinished?: () => void;
16
+ onError?: (e: any) => void;
17
+ }): Promise<File>;
7
18
  export declare function update(file: any): Promise<void>;
19
+ export {};
@@ -20,10 +20,11 @@ function _upload() {
20
20
  _context.next = 2;
21
21
  break;
22
22
  }
23
- return _context.abrupt("return");
23
+ return _context.abrupt("return", file);
24
24
  case 2:
25
25
  _context.next = 4;
26
26
  return _index.apiRequest.post("files/signature", {
27
+ id: file.id,
27
28
  size: file.size,
28
29
  name: file.name,
29
30
  type: file.type
@@ -41,7 +42,7 @@ function _upload() {
41
42
  file.status = "uploading";
42
43
  _context.prev = 10;
43
44
  _context.next = 13;
44
- return _index.apiRequest.put(ossFile.uploadUrl, file, {
45
+ return _index.apiRequest.put(ossFile.uploadUrl, (file === null || file === void 0 ? void 0 : file.buffer) || file, {
45
46
  headers: {
46
47
  'Content-Type': file.type
47
48
  },
@@ -54,18 +55,20 @@ function _upload() {
54
55
  }
55
56
  });
56
57
  case 13:
58
+ file.status = "done";
57
59
  options === null || options === void 0 ? void 0 : (_options$onFinished = options.onFinished) === null || _options$onFinished === void 0 ? void 0 : _options$onFinished.call(options);
58
- _context.next = 19;
60
+ _context.next = 21;
59
61
  break;
60
- case 16:
61
- _context.prev = 16;
62
+ case 17:
63
+ _context.prev = 17;
62
64
  _context.t0 = _context["catch"](10);
65
+ file.status = "error";
63
66
  options === null || options === void 0 ? void 0 : (_options$onError = options.onError) === null || _options$onError === void 0 ? void 0 : _options$onError.call(options, _context.t0);
64
- case 19:
67
+ case 21:
65
68
  case "end":
66
69
  return _context.stop();
67
70
  }
68
- }, _callee, null, [[10, 16]]);
71
+ }, _callee, null, [[10, 17]]);
69
72
  }));
70
73
  return _upload.apply(this, arguments);
71
74
  }
@@ -9,9 +9,9 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
9
9
  var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));
10
10
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
11
11
  var _restApi = require("./rest-api");
12
- var _index = require("./index");
13
12
  var _formApi = require("./form-api.utils");
14
13
  var _cache = require("../cache");
14
+ var _schemaApi = require("./schema-api");
15
15
  function getFormApi(_x, _x2, _x3) {
16
16
  return _getFormApi.apply(this, arguments);
17
17
  }
@@ -61,56 +61,46 @@ var RestFormApi = exports.RestFormApi = /*#__PURE__*/function (_RestApi) {
61
61
  _proto.initialize = /*#__PURE__*/function () {
62
62
  var _initialize = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
63
63
  var _this2 = this;
64
- var _this$schema$children, _this$schema$children2, res;
64
+ var res, _this$schema, _this$schema$children, _this$schema$children2;
65
65
  return _regenerator["default"].wrap(function _callee$(_context) {
66
66
  while (1) switch (_context.prev = _context.next) {
67
67
  case 0:
68
68
  if (!this.initialized) {
69
- _context.next = 4;
70
- break;
71
- }
72
- return _context.abrupt("return", true);
73
- case 4:
74
- _context.prev = 4;
75
- _context.next = 7;
76
- return (0, _index.getSchema)(this.formId, this.mock);
77
- case 7:
78
- res = _context.sent;
79
- this.schema = res.data;
80
- this.initialized = !!this.schema;
81
- this.title = (_this$schema$children = this.schema.children[0]) === null || _this$schema$children === void 0 ? void 0 : (_this$schema$children2 = _this$schema$children.props) === null || _this$schema$children2 === void 0 ? void 0 : _this$schema$children2.label;
82
- if (this.fieldId) {
83
- JSON.stringify(this.schema, function (key, value) {
84
- var _value$props;
85
- if (key == "fdmSchema") {
86
- return undefined;
87
- }
88
- if ((value === null || value === void 0 ? void 0 : (_value$props = value.props) === null || _value$props === void 0 ? void 0 : _value$props.fieldId) === _this2.fieldId) {
89
- if (value.props.label) {
90
- _this2.title += "." + value.props.label;
69
+ try {
70
+ res = (0, _schemaApi.getSchemaFromCache)(this.formId, this.mock);
71
+ this.schema = res === null || res === void 0 ? void 0 : res.data;
72
+ this.initialized = !!this.schema;
73
+ if (this.initialized) {
74
+ this.title = (_this$schema = this.schema) === null || _this$schema === void 0 ? void 0 : (_this$schema$children = _this$schema.children[0]) === null || _this$schema$children === void 0 ? void 0 : (_this$schema$children2 = _this$schema$children.props) === null || _this$schema$children2 === void 0 ? void 0 : _this$schema$children2.label;
75
+ if (this.fieldId) {
76
+ JSON.stringify(this.schema, function (key, value) {
77
+ var _value$props;
78
+ if (key == "fdmSchema") {
79
+ return undefined;
80
+ }
81
+ if ((value === null || value === void 0 ? void 0 : (_value$props = value.props) === null || _value$props === void 0 ? void 0 : _value$props.fieldId) === _this2.fieldId) {
82
+ if (value.props.label) {
83
+ _this2.title += "." + value.props.label;
84
+ }
85
+ }
86
+ return value;
87
+ });
91
88
  }
92
89
  }
93
- return value;
94
- });
90
+ } catch (e) {
91
+ console.log("获取schema失败!", {
92
+ formId: this.formId,
93
+ field: this.fieldId,
94
+ mock: this.mock
95
+ }, e);
96
+ }
95
97
  }
96
- _context.next = 18;
97
- break;
98
- case 14:
99
- _context.prev = 14;
100
- _context.t0 = _context["catch"](4);
101
- console.log("获取schema失败!", {
102
- formId: this.formId,
103
- field: this.fieldId,
104
- mock: this.mock
105
- }, _context.t0);
106
- throw _context.t0;
107
- case 18:
108
98
  return _context.abrupt("return", this.initialized);
109
- case 19:
99
+ case 2:
110
100
  case "end":
111
101
  return _context.stop();
112
102
  }
113
- }, _callee, this, [[4, 14]]);
103
+ }, _callee, this);
114
104
  }));
115
105
  function initialize() {
116
106
  return _initialize.apply(this, arguments);
@@ -160,7 +150,7 @@ var RestFormApi = exports.RestFormApi = /*#__PURE__*/function (_RestApi) {
160
150
  fieldId: this.fieldId
161
151
  };
162
152
  if (__mock) {
163
- params.description = "" + this.title;
153
+ params.description = (this.title || "表单") + ".\u67E5\u8BE2";
164
154
  }
165
155
  config = {
166
156
  params: params
@@ -197,7 +187,7 @@ var RestFormApi = exports.RestFormApi = /*#__PURE__*/function (_RestApi) {
197
187
  }();
198
188
  _proto.getById = /*#__PURE__*/function () {
199
189
  var _getById = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(id, options) {
200
- var res, start;
190
+ var res;
201
191
  return _regenerator["default"].wrap(function _callee4$(_context4) {
202
192
  while (1) switch (_context4.prev = _context4.next) {
203
193
  case 0:
@@ -205,11 +195,10 @@ var RestFormApi = exports.RestFormApi = /*#__PURE__*/function (_RestApi) {
205
195
  return _RestApi.prototype.getById.call(this, id, options);
206
196
  case 2:
207
197
  res = _context4.sent;
208
- start = Date.now();
209
198
  (0, _formApi.assembleAssociationField)(res.data, res.refs);
210
199
  console.debug("formApi.getById", res);
211
200
  return _context4.abrupt("return", res);
212
- case 7:
201
+ case 6:
213
202
  case "end":
214
203
  return _context4.stop();
215
204
  }
@@ -1,15 +1,15 @@
1
- import { BaseType, FilterRule, Refs } from "./rest-api";
1
+ import { FilterRule, IBaseEntity, Refs } from "./rest-api";
2
2
  export declare function convertSaveData(data: any): any;
3
- export declare function handleEntityLabel(data: BaseType | BaseType[]): void;
4
3
  export declare function dataToLabel(value: any): any;
5
- export declare function assembleAssociationFieldV2(data: BaseType | BaseType[], refs?: Refs): void;
4
+ export declare function assembleAssociationFieldV2(data: IBaseEntity | IBaseEntity[], refs?: Refs): void;
6
5
  /**
7
6
  * 加载字段
8
7
  * @param data
9
8
  * @param dataMap
10
9
  */
11
- export declare function assembleAssociationFieldDataV2(data: BaseType | BaseType[], dataMap: Map<string, BaseType>): void;
12
- export declare function assembleAssociationField(data: BaseType | BaseType[], refs?: Refs): void;
10
+ export declare function assembleAssociationFieldDataV2(data: IBaseEntity | IBaseEntity[], dataMap: Map<string, IBaseEntity>): void;
11
+ export declare function handleEntityLabel(data: IBaseEntity | IBaseEntity[]): void;
12
+ export declare function assembleAssociationField(data: IBaseEntity | IBaseEntity[], refs?: Refs): void;
13
13
  export declare function handleFilterRules(filters: FilterRule[], options: {
14
14
  filterNullValue: boolean;
15
15
  }): FilterRule[];
@@ -34,21 +34,6 @@ function getDataKey(data) {
34
34
  }
35
35
  return key + "." + data.id;
36
36
  }
37
- function handleEntityLabel(data) {
38
- if (!Array.isArray(data)) {
39
- data = [data];
40
- }
41
- for (var _iterator = _createForOfIteratorHelperLoose(data), _step; !(_step = _iterator()).done;) {
42
- var _item$form;
43
- var item = _step.value;
44
- var labelField = (_item$form = item.form) === null || _item$form === void 0 ? void 0 : _item$form.labelField;
45
- if (labelField) {
46
- // @ts-ignore
47
- var value = safeGet(item, labelField);
48
- item.label = dataToLabel(value);
49
- }
50
- }
51
- }
52
37
  function dataToLabel(value) {
53
38
  if (value == null) {
54
39
  return "";
@@ -72,44 +57,44 @@ function dataToLabel(value) {
72
57
  function assembleAssociationFieldV2(data, refs) {
73
58
  if (!data || !refs) return;
74
59
  var dataMap = new Map();
75
- for (var _iterator2 = _createForOfIteratorHelperLoose(refs), _step2; !(_step2 = _iterator2()).done;) {
76
- var ref = _step2.value;
77
- for (var _iterator4 = _createForOfIteratorHelperLoose(ref.data), _step4; !(_step4 = _iterator4()).done;) {
78
- var datum = _step4.value;
60
+ for (var _iterator = _createForOfIteratorHelperLoose(refs), _step; !(_step = _iterator()).done;) {
61
+ var ref = _step.value;
62
+ ref.label = ref.form.label;
63
+ for (var _iterator3 = _createForOfIteratorHelperLoose(ref.data), _step3; !(_step3 = _iterator3()).done;) {
64
+ var datum = _step3.value;
79
65
  var key = getDataKey(datum);
80
66
  dataMap.set(key, datum);
81
67
  }
82
68
  }
83
-
84
69
  //组装refs的关联属性
85
- for (var _iterator3 = _createForOfIteratorHelperLoose(dataMap.values()), _step3; !(_step3 = _iterator3()).done;) {
86
- var item = _step3.value;
70
+ for (var _iterator2 = _createForOfIteratorHelperLoose(dataMap.values()), _step2; !(_step2 = _iterator2()).done;) {
71
+ var item = _step2.value;
87
72
  for (var _i2 = 0, _Object$keys = Object.keys(item); _i2 < _Object$keys.length; _i2++) {
88
73
  var _key = _Object$keys[_i2];
89
- // @ts-ignore
90
74
  var value = item[_key];
91
75
  assembleAssociationFieldDataV2(value, dataMap);
92
76
  }
93
77
  }
94
- handleEntityLabel([].concat(dataMap.values()));
95
78
  function loopAssembleAssociation(value) {
79
+ var _value$form;
96
80
  if (Array.isArray(value)) {
97
81
  value.forEach(function (item) {
98
82
  return loopAssembleAssociation(item);
99
83
  });
100
- } else if (value !== null && value !== void 0 && value.id) {
101
- handleEntityLabel(value);
84
+ } else if (value !== null && value !== void 0 && value.id && (_value$form = value.form) !== null && _value$form !== void 0 && _value$form.id) {
85
+ if (value._load) return;
102
86
  assembleAssociationFieldDataV2(value, dataMap);
103
- //处理子表
104
87
  for (var _i = 0, _Object$values = Object.values(value); _i < _Object$values.length; _i++) {
105
88
  var subValues = _Object$values[_i];
106
- if (typeof subValues == "object") {
89
+ if (subValues !== null && typeof subValues == "object") {
107
90
  loopAssembleAssociation(subValues);
108
91
  }
109
92
  }
110
93
  }
111
94
  }
112
95
  loopAssembleAssociation(data);
96
+ handleEntityLabel(data);
97
+ dataMap.clear();
113
98
  }
114
99
 
115
100
  /**
@@ -118,28 +103,62 @@ function assembleAssociationFieldV2(data, refs) {
118
103
  * @param dataMap
119
104
  */
120
105
  function assembleAssociationFieldDataV2(data, dataMap) {
121
- if (data == null) {
122
- return;
123
- }
106
+ if (data == null || typeof data != "object") return;
124
107
  if (Array.isArray(data)) {
125
108
  data.forEach(function (item) {
126
109
  return assembleAssociationFieldDataV2(item, dataMap);
127
110
  });
128
111
  } else {
129
- if (data._load == false) {
112
+ if (!data._load) {
130
113
  var _data$form3;
131
- if (data !== null && data !== void 0 && (_data$form3 = data.form) !== null && _data$form3 !== void 0 && _data$form3.id && data !== null && data !== void 0 && data.id) {
132
- delete data._load;
114
+ if (data !== null && data !== void 0 && data.id && data !== null && data !== void 0 && (_data$form3 = data.form) !== null && _data$form3 !== void 0 && _data$form3.id) {
133
115
  var key = getDataKey(data);
134
116
  var value = dataMap.get(key);
135
117
  if (value) {
136
- Object.assign(data, value);
137
- delete data._load;
118
+ Object.assign(data, JSON.parse(JSON.stringify(value)));
138
119
  }
120
+ data._load = true;
139
121
  }
140
122
  }
141
123
  }
142
124
  }
125
+ function handleEntityLabel(data) {
126
+ if (Array.isArray(data)) {
127
+ data.forEach(function (item) {
128
+ return handleEntityLabel(item);
129
+ });
130
+ } else if (typeof data == "object") {
131
+ var form = data === null || data === void 0 ? void 0 : data.form;
132
+ if (form) {
133
+ var labelField = form === null || form === void 0 ? void 0 : form.labelField;
134
+ if (labelField) {
135
+ // @ts-ignore
136
+ var label = safeGet(data, labelField);
137
+ data.label = dataToLabel(label);
138
+ }
139
+ for (var _i3 = 0, _Object$keys2 = Object.keys(data); _i3 < _Object$keys2.length; _i3++) {
140
+ var key = _Object$keys2[_i3];
141
+ // @ts-ignore
142
+ handleEntityLabel(data[key]);
143
+ }
144
+ }
145
+ }
146
+ }
147
+ function valueToFormDataArray(value) {
148
+ if (typeof value == null || typeof value !== "object") {
149
+ return [];
150
+ }
151
+ if (Array.isArray(value)) {
152
+ return value === null || value === void 0 ? void 0 : value.filter(function (item) {
153
+ var _item$form;
154
+ return (item === null || item === void 0 ? void 0 : item.id) && (item === null || item === void 0 ? void 0 : (_item$form = item.form) === null || _item$form === void 0 ? void 0 : _item$form.id);
155
+ });
156
+ } else if (typeof value == "object" && value !== null) {
157
+ return valueToFormDataArray([value]);
158
+ } else {
159
+ return [];
160
+ }
161
+ }
143
162
  function assembleAssociationField(data, refs) {
144
163
  assembleAssociationFieldV2(data, refs);
145
164
  }
@@ -1,10 +1,11 @@
1
1
  export { RestApi } from "./rest-api";
2
2
  export { getFormApi, RestFormApi } from "./form-api";
3
+ import { AxiosResponse } from "axios/index";
3
4
  export { getSchema } from "./schema-api";
4
- export { loadUserInfo } from "./user-info";
5
+ export { getUserinfo } from "./user-info";
5
6
  export * as files from "./file-api";
6
7
  export * as scrips from "./script-api";
7
8
  export declare const apiRequest: import("axios").AxiosInstance;
8
- export declare const request: <T = any, R = import("axios").AxiosResponse<T, any>, D = any>(config: import("axios").AxiosRequestConfig<D>) => Promise<R>;
9
- export declare function onFulfilled(res: any): any;
9
+ export declare const request: <T = any, R = AxiosResponse<T, any>, D = any>(config: import("axios").AxiosRequestConfig<D>) => Promise<R>;
10
+ export declare function onFulfilled(res: AxiosResponse): any;
10
11
  export declare function onRejected(error: any): any;
@@ -2,7 +2,7 @@
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
4
  exports.__esModule = true;
5
- exports.loadUserInfo = exports.getSchema = exports.getFormApi = exports.files = exports.apiRequest = exports.RestFormApi = exports.RestApi = void 0;
5
+ exports.getUserinfo = exports.getSchema = exports.getFormApi = exports.files = exports.apiRequest = exports.RestFormApi = exports.RestApi = void 0;
6
6
  exports.onFulfilled = onFulfilled;
7
7
  exports.onRejected = onRejected;
8
8
  exports.scrips = exports.request = void 0;
@@ -15,7 +15,7 @@ exports.RestFormApi = _formApi.RestFormApi;
15
15
  var _schemaApi = require("./schema-api");
16
16
  exports.getSchema = _schemaApi.getSchema;
17
17
  var _userInfo = require("./user-info");
18
- exports.loadUserInfo = _userInfo.loadUserInfo;
18
+ exports.getUserinfo = _userInfo.getUserinfo;
19
19
  var _files = _interopRequireWildcard(require("./file-api"));
20
20
  exports.files = _files;
21
21
  var _scrips = _interopRequireWildcard(require("./script-api"));
@@ -25,7 +25,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
25
25
  var apiRequest = exports.apiRequest = _axios["default"].create({
26
26
  baseURL: "/api",
27
27
  // 基础URL
28
- timeout: 10000,
28
+ timeout: 600000,
29
29
  // 请求超时时间(毫秒)
30
30
  headers: {
31
31
  'Content-Type': 'application/json;charset=UTF-8'
@@ -34,6 +34,13 @@ var apiRequest = exports.apiRequest = _axios["default"].create({
34
34
  apiRequest.interceptors.response.use(onFulfilled, onRejected);
35
35
  var request = exports.request = apiRequest.request;
36
36
  function onFulfilled(res) {
37
+ if (typeof res.data == "object") {
38
+ if ("success" in res.data) {
39
+ if (res.headers["Request-Id"]) {
40
+ res.data.requestId = res.headers["Request-Id"];
41
+ }
42
+ }
43
+ }
37
44
  return res.data;
38
45
  }
39
46
  function onRejected(error) {