@zhubangyun/lowcode-core 5.4.21 → 5.4.102

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 (90) hide show
  1. package/es/index.d.ts +0 -1
  2. package/es/index.js +0 -1
  3. package/es/style.js +4 -4
  4. package/es/utils/api/RestApi.d.ts +1 -1
  5. package/es/utils/api/RestApi.js +86 -60
  6. package/es/utils/{common → api}/UserInfo.d.ts +1 -1
  7. package/es/utils/api/UserInfo.js +39 -0
  8. package/es/utils/api/index.d.ts +4 -3
  9. package/es/utils/api/index.js +25 -12
  10. package/es/utils/cache/index.d.ts +12 -4
  11. package/es/utils/cache/index.js +23 -17
  12. package/es/utils/cache/schema.d.ts +29 -0
  13. package/es/utils/cache/schema.js +42 -0
  14. package/es/utils/common/SingletonInstanceMap.d.ts +3 -3
  15. package/es/utils/common/SingletonInstanceMap.js +5 -5
  16. package/es/utils/designer/assets/assets.data.base.js +1 -1
  17. package/es/utils/form/form.api.d.ts +4 -9
  18. package/es/utils/form/form.api.js +14 -135
  19. package/es/utils/index.d.ts +2 -0
  20. package/es/utils/index.js +2 -0
  21. package/es/utils/page/index.d.ts +1 -0
  22. package/es/utils/page/index.js +1 -0
  23. package/es/utils/page/page.form.d.ts +14 -0
  24. package/es/utils/page/page.form.js +66 -0
  25. package/es/utils/page/page.layout.d.ts +15 -0
  26. package/es/utils/page/page.layout.js +56 -0
  27. package/es/utils/page/page.load-schema.d.ts +4 -0
  28. package/es/utils/page/page.load-schema.js +37 -0
  29. package/es/utils/page/page.render.d.ts +2 -0
  30. package/es/utils/page/page.render.js +6 -0
  31. package/lib/index.d.ts +0 -1
  32. package/lib/index.js +1 -3
  33. package/lib/style.js +4 -4
  34. package/lib/utils/api/RestApi.d.ts +1 -1
  35. package/lib/utils/api/RestApi.js +86 -60
  36. package/lib/utils/{common → api}/UserInfo.d.ts +1 -1
  37. package/lib/utils/{common → api}/UserInfo.js +22 -2
  38. package/lib/utils/api/index.d.ts +4 -3
  39. package/lib/utils/api/index.js +28 -13
  40. package/lib/utils/cache/index.d.ts +12 -4
  41. package/lib/utils/cache/index.js +23 -17
  42. package/lib/utils/cache/schema.d.ts +29 -0
  43. package/lib/utils/cache/schema.js +47 -0
  44. package/lib/utils/common/SingletonInstanceMap.d.ts +3 -3
  45. package/lib/utils/common/SingletonInstanceMap.js +5 -5
  46. package/lib/utils/designer/assets/assets.data.base.js +1 -1
  47. package/lib/utils/form/form.api.d.ts +4 -9
  48. package/lib/utils/form/form.api.js +14 -135
  49. package/lib/utils/index.d.ts +2 -0
  50. package/lib/utils/index.js +2 -0
  51. package/lib/utils/page/index.d.ts +1 -0
  52. package/lib/utils/page/index.js +6 -0
  53. package/lib/utils/page/page.form.d.ts +14 -0
  54. package/lib/utils/page/page.form.js +71 -0
  55. package/lib/utils/page/page.layout.d.ts +15 -0
  56. package/lib/utils/page/page.layout.js +63 -0
  57. package/lib/utils/page/page.load-schema.d.ts +4 -0
  58. package/lib/utils/page/page.load-schema.js +42 -0
  59. package/lib/utils/page/page.render.d.ts +2 -0
  60. package/lib/utils/page/page.render.js +10 -0
  61. package/package.json +1 -1
  62. package/es/components/schema-render/components/assets.d.ts +0 -32
  63. package/es/components/schema-render/components/assets.js +0 -53
  64. package/es/components/schema-render/components/demo-schema.d.ts +0 -85
  65. package/es/components/schema-render/components/demo-schema.js +0 -107
  66. package/es/components/schema-render/components/schema-render-base.d.ts +0 -43
  67. package/es/components/schema-render/components/schema-render-base.js +0 -142
  68. package/es/components/schema-render/components/schema-render-layout.d.ts +0 -6
  69. package/es/components/schema-render/components/schema-render-layout.js +0 -46
  70. package/es/components/schema-render/index.d.ts +0 -31
  71. package/es/components/schema-render/index.js +0 -46
  72. package/es/utils/common/SubFormInstance.d.ts +0 -26
  73. package/es/utils/common/SubFormInstance.js +0 -100
  74. package/es/utils/common/UserInfo.js +0 -19
  75. package/es/utils/form/form.process.js +0 -0
  76. package/lib/components/schema-render/components/assets.d.ts +0 -32
  77. package/lib/components/schema-render/components/assets.js +0 -57
  78. package/lib/components/schema-render/components/demo-schema.d.ts +0 -85
  79. package/lib/components/schema-render/components/demo-schema.js +0 -111
  80. package/lib/components/schema-render/components/schema-render-base.d.ts +0 -43
  81. package/lib/components/schema-render/components/schema-render-base.js +0 -149
  82. package/lib/components/schema-render/components/schema-render-layout.d.ts +0 -6
  83. package/lib/components/schema-render/components/schema-render-layout.js +0 -51
  84. package/lib/components/schema-render/index.d.ts +0 -31
  85. package/lib/components/schema-render/index.js +0 -53
  86. package/lib/utils/common/SubFormInstance.d.ts +0 -26
  87. package/lib/utils/common/SubFormInstance.js +0 -105
  88. package/lib/utils/form/form.process.js +0 -1
  89. /package/es/utils/{form/form.handler.js → page/page.utils.js} +0 -0
  90. /package/lib/utils/{form/form.handler.js → page/page.utils.js} +0 -0
package/es/index.d.ts CHANGED
@@ -2,6 +2,5 @@ import utils from "./utils";
2
2
  export { RestApi } from "./utils/api/RestApi";
3
3
  export { RestFormApi } from "./utils/form/form.api";
4
4
  export { Layout } from "./components/layout";
5
- export { SchemaRender } from "./components/schema-render";
6
5
  export { ReactRender } from "./components/react-render";
7
6
  export { utils };
package/es/index.js CHANGED
@@ -2,7 +2,6 @@ import utils from "./utils";
2
2
  export { RestApi } from "./utils/api/RestApi";
3
3
  export { RestFormApi } from "./utils/form/form.api";
4
4
  export { Layout } from "./components/layout";
5
- export { SchemaRender } from "./components/schema-render";
6
5
  export { ReactRender } from "./components/react-render";
7
6
  // @ts-ignore
8
7
  window.utils = utils;
package/es/style.js CHANGED
@@ -1,5 +1,5 @@
1
- import 'antd/es/result/style';
2
- import 'antd/es/config-provider/style';
3
-
4
1
  import 'antd/es/drawer/style';
5
- import 'antd/es/modal/style';
2
+ import 'antd/es/modal/style';
3
+ import 'antd/es/result/style';
4
+ import 'antd/es/spin/style';
5
+ import 'antd/es/config-provider/style';
@@ -39,7 +39,7 @@ export declare abstract class BaseRestApi<DataType> {
39
39
  }
40
40
  export declare class RestApi<DataType> extends BaseRestApi<DataType> {
41
41
  constructor(uri: string, options?: RestApiOptions);
42
- handleRequestConfig(config: AxiosRequestConfig): void;
42
+ handleRequestConfig(config: AxiosRequestConfig): Promise<void>;
43
43
  }
44
44
  export interface BaseType {
45
45
  /**
@@ -43,14 +43,16 @@ export var BaseRestApi = /*#__PURE__*/function () {
43
43
  config = {
44
44
  params: params
45
45
  };
46
- (_this$handleRequestCo = this.handleRequestConfig) === null || _this$handleRequestCo === void 0 ? void 0 : _this$handleRequestCo.call(this, config);
47
- _context.next = 9;
46
+ _context.next = 8;
47
+ return (_this$handleRequestCo = this.handleRequestConfig) === null || _this$handleRequestCo === void 0 ? void 0 : _this$handleRequestCo.call(this, config);
48
+ case 8:
49
+ _context.next = 10;
48
50
  return this.request.get("", {
49
51
  params: params
50
52
  });
51
- case 9:
52
- return _context.abrupt("return", _context.sent);
53
53
  case 10:
54
+ return _context.abrupt("return", _context.sent);
55
+ case 11:
54
56
  case "end":
55
57
  return _context.stop();
56
58
  }
@@ -77,27 +79,29 @@ export var BaseRestApi = /*#__PURE__*/function () {
77
79
  while (1) switch (_context2.prev = _context2.next) {
78
80
  case 0:
79
81
  config = {};
80
- (_this$handleRequestCo2 = this.handleRequestConfig) === null || _this$handleRequestCo2 === void 0 ? void 0 : _this$handleRequestCo2.call(this, config);
81
- _context2.next = 4;
82
+ _context2.next = 3;
83
+ return (_this$handleRequestCo2 = this.handleRequestConfig) === null || _this$handleRequestCo2 === void 0 ? void 0 : _this$handleRequestCo2.call(this, config);
84
+ case 3:
85
+ _context2.next = 5;
82
86
  return this.request.get(String(id), config);
83
- case 4:
87
+ case 5:
84
88
  res = _context2.sent;
85
89
  if (res.success) {
86
- _context2.next = 11;
90
+ _context2.next = 12;
87
91
  break;
88
92
  }
89
93
  this.showError("\u83B7\u53D6{" + id + "}\u5931\u8D25!", res.message).then();
90
- _context2.next = 9;
94
+ _context2.next = 10;
91
95
  return options === null || options === void 0 ? void 0 : (_options$onError = options.onError) === null || _options$onError === void 0 ? void 0 : _options$onError.call(options, res);
92
- case 9:
93
- _context2.next = 13;
96
+ case 10:
97
+ _context2.next = 14;
94
98
  break;
95
- case 11:
96
- _context2.next = 13;
99
+ case 12:
100
+ _context2.next = 14;
97
101
  return options === null || options === void 0 ? void 0 : (_options$onSuccess = options.onSuccess) === null || _options$onSuccess === void 0 ? void 0 : _options$onSuccess.call(options, res);
98
- case 13:
99
- return _context2.abrupt("return", res);
100
102
  case 14:
103
+ return _context2.abrupt("return", res);
104
+ case 15:
101
105
  case "end":
102
106
  return _context2.stop();
103
107
  }
@@ -116,27 +120,29 @@ export var BaseRestApi = /*#__PURE__*/function () {
116
120
  while (1) switch (_context3.prev = _context3.next) {
117
121
  case 0:
118
122
  config = {};
119
- (_this$handleRequestCo3 = this.handleRequestConfig) === null || _this$handleRequestCo3 === void 0 ? void 0 : _this$handleRequestCo3.call(this, config);
120
- _context3.next = 4;
123
+ _context3.next = 3;
124
+ return (_this$handleRequestCo3 = this.handleRequestConfig) === null || _this$handleRequestCo3 === void 0 ? void 0 : _this$handleRequestCo3.call(this, config);
125
+ case 3:
126
+ _context3.next = 5;
121
127
  return this.request.post("", data, config);
122
- case 4:
128
+ case 5:
123
129
  res = _context3.sent;
124
130
  if (res.success) {
125
- _context3.next = 11;
131
+ _context3.next = 12;
126
132
  break;
127
133
  }
128
134
  this.showError("\u63D0\u4EA4\u5931\u8D25!", res.message).then();
129
- _context3.next = 9;
135
+ _context3.next = 10;
130
136
  return options === null || options === void 0 ? void 0 : (_options$onError2 = options.onError) === null || _options$onError2 === void 0 ? void 0 : _options$onError2.call(options, res);
131
- case 9:
132
- _context3.next = 13;
137
+ case 10:
138
+ _context3.next = 14;
133
139
  break;
134
- case 11:
135
- _context3.next = 13;
140
+ case 12:
141
+ _context3.next = 14;
136
142
  return options === null || options === void 0 ? void 0 : (_options$onSuccess2 = options.onSuccess) === null || _options$onSuccess2 === void 0 ? void 0 : _options$onSuccess2.call(options, res);
137
- case 13:
138
- return _context3.abrupt("return", res);
139
143
  case 14:
144
+ return _context3.abrupt("return", res);
145
+ case 15:
140
146
  case "end":
141
147
  return _context3.stop();
142
148
  }
@@ -161,27 +167,29 @@ export var BaseRestApi = /*#__PURE__*/function () {
161
167
  while (1) switch (_context4.prev = _context4.next) {
162
168
  case 0:
163
169
  config = {};
164
- (_this$handleRequestCo4 = this.handleRequestConfig) === null || _this$handleRequestCo4 === void 0 ? void 0 : _this$handleRequestCo4.call(this, config);
165
- _context4.next = 4;
170
+ _context4.next = 3;
171
+ return (_this$handleRequestCo4 = this.handleRequestConfig) === null || _this$handleRequestCo4 === void 0 ? void 0 : _this$handleRequestCo4.call(this, config);
172
+ case 3:
173
+ _context4.next = 5;
166
174
  return this.request.post("", data, config);
167
- case 4:
175
+ case 5:
168
176
  res = _context4.sent;
169
177
  if (res.success) {
170
- _context4.next = 11;
178
+ _context4.next = 12;
171
179
  break;
172
180
  }
173
181
  this.showError("\u65B0\u589E\u5931\u8D25!", res.message).then();
174
- _context4.next = 9;
182
+ _context4.next = 10;
175
183
  return options === null || options === void 0 ? void 0 : (_options$onError3 = options.onError) === null || _options$onError3 === void 0 ? void 0 : _options$onError3.call(options, res);
176
- case 9:
177
- _context4.next = 13;
184
+ case 10:
185
+ _context4.next = 14;
178
186
  break;
179
- case 11:
180
- _context4.next = 13;
187
+ case 12:
188
+ _context4.next = 14;
181
189
  return options === null || options === void 0 ? void 0 : (_options$onSuccess3 = options.onSuccess) === null || _options$onSuccess3 === void 0 ? void 0 : _options$onSuccess3.call(options, res);
182
- case 13:
183
- return _context4.abrupt("return", res);
184
190
  case 14:
191
+ return _context4.abrupt("return", res);
192
+ case 15:
185
193
  case "end":
186
194
  return _context4.stop();
187
195
  }
@@ -206,27 +214,29 @@ export var BaseRestApi = /*#__PURE__*/function () {
206
214
  while (1) switch (_context5.prev = _context5.next) {
207
215
  case 0:
208
216
  config = {};
209
- (_this$handleRequestCo5 = this.handleRequestConfig) === null || _this$handleRequestCo5 === void 0 ? void 0 : _this$handleRequestCo5.call(this, config);
210
- _context5.next = 4;
217
+ _context5.next = 3;
218
+ return (_this$handleRequestCo5 = this.handleRequestConfig) === null || _this$handleRequestCo5 === void 0 ? void 0 : _this$handleRequestCo5.call(this, config);
219
+ case 3:
220
+ _context5.next = 5;
211
221
  return this.request.put(String(id), data, config);
212
- case 4:
222
+ case 5:
213
223
  res = _context5.sent;
214
224
  if (res.success) {
215
- _context5.next = 11;
225
+ _context5.next = 12;
216
226
  break;
217
227
  }
218
228
  this.showError("\u66F4\u65B0\u5931\u8D25!", res.message).then();
219
- _context5.next = 9;
229
+ _context5.next = 10;
220
230
  return options === null || options === void 0 ? void 0 : (_options$onError4 = options.onError) === null || _options$onError4 === void 0 ? void 0 : _options$onError4.call(options, res);
221
- case 9:
222
- _context5.next = 13;
231
+ case 10:
232
+ _context5.next = 14;
223
233
  break;
224
- case 11:
225
- _context5.next = 13;
234
+ case 12:
235
+ _context5.next = 14;
226
236
  return options === null || options === void 0 ? void 0 : (_options$onSuccess4 = options.onSuccess) === null || _options$onSuccess4 === void 0 ? void 0 : _options$onSuccess4.call(options, res);
227
- case 13:
228
- return _context5.abrupt("return", res);
229
237
  case 14:
238
+ return _context5.abrupt("return", res);
239
+ case 15:
230
240
  case "end":
231
241
  return _context5.stop();
232
242
  }
@@ -251,27 +261,29 @@ export var BaseRestApi = /*#__PURE__*/function () {
251
261
  while (1) switch (_context6.prev = _context6.next) {
252
262
  case 0:
253
263
  config = {};
254
- (_this$handleRequestCo6 = this.handleRequestConfig) === null || _this$handleRequestCo6 === void 0 ? void 0 : _this$handleRequestCo6.call(this, config);
255
- _context6.next = 4;
264
+ _context6.next = 3;
265
+ return (_this$handleRequestCo6 = this.handleRequestConfig) === null || _this$handleRequestCo6 === void 0 ? void 0 : _this$handleRequestCo6.call(this, config);
266
+ case 3:
267
+ _context6.next = 5;
256
268
  return this.request["delete"](String(id), config);
257
- case 4:
269
+ case 5:
258
270
  res = _context6.sent;
259
271
  if (res.success) {
260
- _context6.next = 11;
272
+ _context6.next = 12;
261
273
  break;
262
274
  }
263
275
  this.showError("\u5220\u9664{" + id + "}\u5931\u8D25!", res.message).then();
264
- _context6.next = 9;
276
+ _context6.next = 10;
265
277
  return options === null || options === void 0 ? void 0 : (_options$onError5 = options.onError) === null || _options$onError5 === void 0 ? void 0 : _options$onError5.call(options, res);
266
- case 9:
267
- _context6.next = 13;
278
+ case 10:
279
+ _context6.next = 14;
268
280
  break;
269
- case 11:
270
- _context6.next = 13;
281
+ case 12:
282
+ _context6.next = 14;
271
283
  return options === null || options === void 0 ? void 0 : (_options$onSuccess5 = options.onSuccess) === null || _options$onSuccess5 === void 0 ? void 0 : _options$onSuccess5.call(options, res);
272
- case 13:
273
- return _context6.abrupt("return", res);
274
284
  case 14:
285
+ return _context6.abrupt("return", res);
286
+ case 15:
275
287
  case "end":
276
288
  return _context6.stop();
277
289
  }
@@ -308,7 +320,21 @@ export var RestApi = /*#__PURE__*/function (_BaseRestApi2) {
308
320
  }
309
321
  _inheritsLoose(RestApi, _BaseRestApi2);
310
322
  var _proto2 = RestApi.prototype;
311
- _proto2.handleRequestConfig = function handleRequestConfig(config) {};
323
+ _proto2.handleRequestConfig = /*#__PURE__*/function () {
324
+ var _handleRequestConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(config) {
325
+ return _regeneratorRuntime.wrap(function _callee8$(_context8) {
326
+ while (1) switch (_context8.prev = _context8.next) {
327
+ case 0:
328
+ case "end":
329
+ return _context8.stop();
330
+ }
331
+ }, _callee8);
332
+ }));
333
+ function handleRequestConfig(_x17) {
334
+ return _handleRequestConfig.apply(this, arguments);
335
+ }
336
+ return handleRequestConfig;
337
+ }();
312
338
  return RestApi;
313
339
  }(BaseRestApi);
314
340
 
@@ -6,4 +6,4 @@ export interface UserInfo {
6
6
  roleIds: string[];
7
7
  deptIds: string[];
8
8
  }
9
- export declare function loadUserInfo(): Promise<UserInfo>;
9
+ export declare function loadUserInfo(): Promise<UserInfo | false>;
@@ -0,0 +1,39 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
4
+ import { apiRequest } from "./index";
5
+ export function loadUserInfo() {
6
+ return _loadUserInfo.apply(this, arguments);
7
+ }
8
+ function _loadUserInfo() {
9
+ _loadUserInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
10
+ var res;
11
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
12
+ while (1) switch (_context.prev = _context.next) {
13
+ case 0:
14
+ if (!window.userInfo) {
15
+ _context.next = 4;
16
+ break;
17
+ }
18
+ return _context.abrupt("return", _extends({}, window.userInfo));
19
+ case 4:
20
+ _context.next = 6;
21
+ return apiRequest.get("userInfo");
22
+ case 6:
23
+ res = _context.sent;
24
+ if (!res.success) {
25
+ _context.next = 12;
26
+ break;
27
+ }
28
+ window.userInfo = res.data;
29
+ return _context.abrupt("return", _extends({}, res.data));
30
+ case 12:
31
+ return _context.abrupt("return", false);
32
+ case 13:
33
+ case "end":
34
+ return _context.stop();
35
+ }
36
+ }, _callee);
37
+ }));
38
+ return _loadUserInfo.apply(this, arguments);
39
+ }
@@ -1,5 +1,6 @@
1
1
  import { OneResult } from "./RestApi";
2
2
  import { RestFormApi } from "../form/form.api";
3
- export declare const request: import("axios").AxiosInstance;
4
- export declare function getSchema(schemaId: string, mock?: boolean): Promise<OneResult<any>>;
5
- export declare function getFormApi(schemaId: string, mock?: boolean): Promise<RestFormApi<any>>;
3
+ export { loadUserInfo } from "./UserInfo";
4
+ export declare const apiRequest: import("axios").AxiosInstance;
5
+ export declare function getSchema(pageId: string, mock?: boolean): Promise<OneResult<any>>;
6
+ export declare function getFormApi(formId: string, fieldId?: string, mock?: boolean): Promise<RestFormApi<any>>;
@@ -3,7 +3,8 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
3
3
  import axios from "axios";
4
4
  import { onFulfilled, onRejected } from "./Request";
5
5
  import { formApi, schema } from "../cache";
6
- export var request = axios.create({
6
+ export { loadUserInfo } from "./UserInfo";
7
+ export var apiRequest = axios.create({
7
8
  baseURL: "/api",
8
9
  // 基础URL
9
10
  timeout: 10000,
@@ -12,22 +13,30 @@ export var request = axios.create({
12
13
  'Content-Type': 'application/json;charset=UTF-8'
13
14
  }
14
15
  });
15
- request.interceptors.response.use(onFulfilled, onRejected);
16
+ apiRequest.interceptors.response.use(onFulfilled, onRejected);
16
17
  export function getSchema(_x, _x2) {
17
18
  return _getSchema.apply(this, arguments);
18
19
  }
19
20
  function _getSchema() {
20
- _getSchema = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(schemaId, mock) {
21
+ _getSchema = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(pageId, mock) {
21
22
  var key;
22
23
  return _regeneratorRuntime.wrap(function _callee$(_context) {
23
24
  while (1) switch (_context.prev = _context.next) {
24
25
  case 0:
25
- key = mock ? schemaId + "_mock" : schemaId;
26
- _context.next = 3;
27
- return schema.getInstance(key);
28
- case 3:
29
- return _context.abrupt("return", _context.sent);
26
+ if (typeof mock != "boolean") {
27
+ if (typeof window.__mock == "boolean") {
28
+ mock = window.__mock;
29
+ }
30
+ }
31
+ key = mock ? pageId + "_mock" : pageId;
32
+ _context.next = 4;
33
+ return schema.getInstance(key, {
34
+ mock: mock,
35
+ pageId: pageId
36
+ });
30
37
  case 4:
38
+ return _context.abrupt("return", _context.sent);
39
+ case 5:
31
40
  case "end":
32
41
  return _context.stop();
33
42
  }
@@ -35,11 +44,11 @@ function _getSchema() {
35
44
  }));
36
45
  return _getSchema.apply(this, arguments);
37
46
  }
38
- export function getFormApi(_x3, _x4) {
47
+ export function getFormApi(_x3, _x4, _x5) {
39
48
  return _getFormApi.apply(this, arguments);
40
49
  }
41
50
  function _getFormApi() {
42
- _getFormApi = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(schemaId, mock) {
51
+ _getFormApi = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(formId, fieldId, mock) {
43
52
  var key;
44
53
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
45
54
  while (1) switch (_context2.prev = _context2.next) {
@@ -49,9 +58,13 @@ function _getFormApi() {
49
58
  mock = window.__mock;
50
59
  }
51
60
  }
52
- key = !!mock ? schemaId + "_mock" : schemaId;
61
+ key = !!mock ? formId + "_mock" : formId;
53
62
  _context2.next = 4;
54
- return formApi.getInstance(key);
63
+ return formApi.getInstance(key, {
64
+ mock: mock,
65
+ fieldId: fieldId,
66
+ formId: formId
67
+ });
55
68
  case 4:
56
69
  return _context2.abrupt("return", _context2.sent);
57
70
  case 5:
@@ -1,9 +1,17 @@
1
1
  import { SingletonInstanceMap } from "../common/SingletonInstanceMap";
2
- export declare class SchemaCache extends SingletonInstanceMap<any> {
3
- createInstance(key: string): Promise<any>;
2
+ import { RestFormApi } from "../form/form.api";
3
+ export declare class SchemaCache extends SingletonInstanceMap<any, {
4
+ mock?: boolean;
5
+ pageId: string;
6
+ }> {
7
+ createInstance(key: string, options: any): Promise<any>;
4
8
  }
5
9
  export declare const schema: SchemaCache;
6
- export declare class FormApiCache extends SingletonInstanceMap<any> {
7
- createInstance(key: string): Promise<any>;
10
+ export declare class FormApiCache extends SingletonInstanceMap<RestFormApi<any>, {
11
+ formId: string;
12
+ fieldId?: string;
13
+ mock?: boolean;
14
+ }> {
15
+ createInstance(key: string, options?: any): Promise<RestFormApi<any>>;
8
16
  }
9
17
  export declare const formApi: FormApiCache;
@@ -2,8 +2,9 @@ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
2
  import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
3
3
  import _regeneratorRuntime from "@babel/runtime/regenerator";
4
4
  import { SingletonInstanceMap } from "../common/SingletonInstanceMap";
5
- import { request } from "../api";
6
5
  import { RestFormApi } from "../form/form.api";
6
+ import { handleFormSchema } from "./schema";
7
+ import { apiRequest } from "../api";
7
8
  export var SchemaCache = /*#__PURE__*/function (_SingletonInstanceMap) {
8
9
  function SchemaCache() {
9
10
  return _SingletonInstanceMap.apply(this, arguments) || this;
@@ -11,28 +12,31 @@ export var SchemaCache = /*#__PURE__*/function (_SingletonInstanceMap) {
11
12
  _inheritsLoose(SchemaCache, _SingletonInstanceMap);
12
13
  var _proto = SchemaCache.prototype;
13
14
  _proto.createInstance = /*#__PURE__*/function () {
14
- var _createInstance = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(key) {
15
- var mock, pageId;
15
+ var _createInstance = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(key, options) {
16
+ var mock, pageId, res;
16
17
  return _regeneratorRuntime.wrap(function _callee$(_context) {
17
18
  while (1) switch (_context.prev = _context.next) {
18
19
  case 0:
19
- mock = key.endsWith("_mock");
20
- pageId = key.replace("_mock", "");
21
- _context.next = 4;
22
- return request.get("pages/" + pageId + "/schema", {
20
+ mock = options.mock, pageId = options.pageId;
21
+ _context.next = 3;
22
+ return apiRequest.get("pages/" + pageId + "/schema", {
23
23
  params: {
24
24
  mock: mock
25
25
  }
26
26
  });
27
- case 4:
28
- return _context.abrupt("return", _context.sent);
29
- case 5:
27
+ case 3:
28
+ res = _context.sent;
29
+ if (res.success) {
30
+ handleFormSchema(res.data);
31
+ }
32
+ return _context.abrupt("return", res);
33
+ case 6:
30
34
  case "end":
31
35
  return _context.stop();
32
36
  }
33
37
  }, _callee);
34
38
  }));
35
- function createInstance(_x) {
39
+ function createInstance(_x, _x2) {
36
40
  return _createInstance.apply(this, arguments);
37
41
  }
38
42
  return createInstance;
@@ -47,14 +51,16 @@ export var FormApiCache = /*#__PURE__*/function (_SingletonInstanceMap2) {
47
51
  _inheritsLoose(FormApiCache, _SingletonInstanceMap2);
48
52
  var _proto2 = FormApiCache.prototype;
49
53
  _proto2.createInstance = /*#__PURE__*/function () {
50
- var _createInstance2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(key) {
51
- var mock, formId, formApi;
54
+ var _createInstance2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(key, options) {
55
+ var _options, formId, fieldId, mock, formApi;
52
56
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
53
57
  while (1) switch (_context2.prev = _context2.next) {
54
58
  case 0:
55
- mock = key.endsWith("_mock");
56
- formId = key.replace("_mock", "");
57
- formApi = new RestFormApi(formId, mock);
59
+ if (options === void 0) {
60
+ options = {};
61
+ }
62
+ _options = options, formId = _options.formId, fieldId = _options.fieldId, mock = _options.mock;
63
+ formApi = new RestFormApi(formId, fieldId, mock);
58
64
  _context2.next = 5;
59
65
  return formApi.initialize();
60
66
  case 5:
@@ -65,7 +71,7 @@ export var FormApiCache = /*#__PURE__*/function (_SingletonInstanceMap2) {
65
71
  }
66
72
  }, _callee2);
67
73
  }));
68
- function createInstance(_x2) {
74
+ function createInstance(_x3, _x4) {
69
75
  return _createInstance2.apply(this, arguments);
70
76
  }
71
77
  return createInstance;
@@ -0,0 +1,29 @@
1
+ export declare function handleFormSchema(schema: FormSchema): void;
2
+ /**
3
+ * 遍历schema
4
+ * @param schema
5
+ * @param callback 返回true 继续往下遍历
6
+ */
7
+ export declare function forEachFormSchema(schema: FormSchema, callback: (child: FormSchema, index: number, children: any[]) => boolean): void;
8
+ export interface FormSchema {
9
+ id?: string;
10
+ componentName: string;
11
+ formId?: string;
12
+ tableName?: string;
13
+ schemaName?: string;
14
+ columnName?: string;
15
+ fdmSchema?: FormSchema;
16
+ props: FormSchemaProps;
17
+ children?: FormSchema[];
18
+ }
19
+ export interface FormSchemaProps {
20
+ fieldId: string;
21
+ label: string;
22
+ fieldSchema?: any;
23
+ columnName: string;
24
+ array: boolean;
25
+ associationForm: {
26
+ id: string;
27
+ fieldId: string;
28
+ };
29
+ }
@@ -0,0 +1,42 @@
1
+ export function handleFormSchema(schema) {
2
+ var fdmItems = [];
3
+ var fieldIdMap = new Map();
4
+ forEachFormSchema(schema, function (field) {
5
+ if (field.fdmSchema) {
6
+ fdmItems.push(field);
7
+ }
8
+ if (field.props.fieldId) {
9
+ //删除children防止循环
10
+ var copyField = JSON.parse(JSON.stringify(field));
11
+ delete copyField.children;
12
+ fieldIdMap.set(field.props.fieldId, copyField);
13
+ }
14
+ return true;
15
+ });
16
+ fdmItems.forEach(function (fdmField) {
17
+ forEachFormSchema(fdmField.fdmSchema, function (field) {
18
+ var _field$props;
19
+ var findSchema = fieldIdMap.get((_field$props = field.props) === null || _field$props === void 0 ? void 0 : _field$props.fieldId);
20
+ if (findSchema) {
21
+ field.componentName = findSchema.componentName;
22
+ Object.assign(field.props, findSchema.props);
23
+ }
24
+ return true;
25
+ });
26
+ });
27
+ }
28
+
29
+ /**
30
+ * 遍历schema
31
+ * @param schema
32
+ * @param callback 返回true 继续往下遍历
33
+ */
34
+ export function forEachFormSchema(schema, callback) {
35
+ var _schema$children;
36
+ schema === null || schema === void 0 ? void 0 : (_schema$children = schema.children) === null || _schema$children === void 0 ? void 0 : _schema$children.forEach(function (child, index, children) {
37
+ var ctn = callback(child, index, children);
38
+ if (ctn) {
39
+ forEachFormSchema(child, callback);
40
+ }
41
+ });
42
+ }
@@ -1,7 +1,7 @@
1
- export declare abstract class SingletonInstanceMap<Value> {
1
+ export declare abstract class SingletonInstanceMap<Value, Options> {
2
2
  private readonly valueMap;
3
3
  private readonly lockMap;
4
- getInstance(key: string): Promise<Value>;
4
+ getInstance(key: string, options: Options): Promise<Value>;
5
5
  clear(): void;
6
- abstract createInstance(key: string): Promise<Value>;
6
+ abstract createInstance(key: string, options: Options): Promise<Value>;
7
7
  }
@@ -7,7 +7,7 @@ export var SingletonInstanceMap = /*#__PURE__*/function () {
7
7
  }
8
8
  var _proto = SingletonInstanceMap.prototype;
9
9
  _proto.getInstance = /*#__PURE__*/function () {
10
- var _getInstance = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(key) {
10
+ var _getInstance = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(key, options) {
11
11
  var self, value;
12
12
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
13
13
  while (1) switch (_context2.prev = _context2.next) {
@@ -28,19 +28,19 @@ export var SingletonInstanceMap = /*#__PURE__*/function () {
28
28
  return _regeneratorRuntime.wrap(function _callee$(_context) {
29
29
  while (1) switch (_context.prev = _context.next) {
30
30
  case 0:
31
- resolve(self.getInstance(key));
31
+ resolve(self.getInstance(key, options));
32
32
  case 1:
33
33
  case "end":
34
34
  return _context.stop();
35
35
  }
36
36
  }, _callee);
37
- })), 1000);
37
+ })), 500);
38
38
  }));
39
39
  case 9:
40
40
  _context2.prev = 9;
41
41
  this.lockMap.set(key, true);
42
42
  _context2.next = 13;
43
- return this.createInstance(key);
43
+ return this.createInstance(key, options);
44
44
  case 13:
45
45
  value = _context2.sent;
46
46
  this.valueMap.set(key, value);
@@ -60,7 +60,7 @@ export var SingletonInstanceMap = /*#__PURE__*/function () {
60
60
  }
61
61
  }, _callee2, this, [[9, 19, 22, 25]]);
62
62
  }));
63
- function getInstance(_x) {
63
+ function getInstance(_x, _x2) {
64
64
  return _getInstance.apply(this, arguments);
65
65
  }
66
66
  return getInstance;