@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
@@ -48,14 +48,16 @@ var BaseRestApi = exports.BaseRestApi = /*#__PURE__*/function () {
48
48
  config = {
49
49
  params: params
50
50
  };
51
- (_this$handleRequestCo = this.handleRequestConfig) === null || _this$handleRequestCo === void 0 ? void 0 : _this$handleRequestCo.call(this, config);
52
- _context.next = 9;
51
+ _context.next = 8;
52
+ return (_this$handleRequestCo = this.handleRequestConfig) === null || _this$handleRequestCo === void 0 ? void 0 : _this$handleRequestCo.call(this, config);
53
+ case 8:
54
+ _context.next = 10;
53
55
  return this.request.get("", {
54
56
  params: params
55
57
  });
56
- case 9:
57
- return _context.abrupt("return", _context.sent);
58
58
  case 10:
59
+ return _context.abrupt("return", _context.sent);
60
+ case 11:
59
61
  case "end":
60
62
  return _context.stop();
61
63
  }
@@ -82,27 +84,29 @@ var BaseRestApi = exports.BaseRestApi = /*#__PURE__*/function () {
82
84
  while (1) switch (_context2.prev = _context2.next) {
83
85
  case 0:
84
86
  config = {};
85
- (_this$handleRequestCo2 = this.handleRequestConfig) === null || _this$handleRequestCo2 === void 0 ? void 0 : _this$handleRequestCo2.call(this, config);
86
- _context2.next = 4;
87
+ _context2.next = 3;
88
+ return (_this$handleRequestCo2 = this.handleRequestConfig) === null || _this$handleRequestCo2 === void 0 ? void 0 : _this$handleRequestCo2.call(this, config);
89
+ case 3:
90
+ _context2.next = 5;
87
91
  return this.request.get(String(id), config);
88
- case 4:
92
+ case 5:
89
93
  res = _context2.sent;
90
94
  if (res.success) {
91
- _context2.next = 11;
95
+ _context2.next = 12;
92
96
  break;
93
97
  }
94
98
  this.showError("\u83B7\u53D6{" + id + "}\u5931\u8D25!", res.message).then();
95
- _context2.next = 9;
99
+ _context2.next = 10;
96
100
  return options === null || options === void 0 ? void 0 : (_options$onError = options.onError) === null || _options$onError === void 0 ? void 0 : _options$onError.call(options, res);
97
- case 9:
98
- _context2.next = 13;
101
+ case 10:
102
+ _context2.next = 14;
99
103
  break;
100
- case 11:
101
- _context2.next = 13;
104
+ case 12:
105
+ _context2.next = 14;
102
106
  return options === null || options === void 0 ? void 0 : (_options$onSuccess = options.onSuccess) === null || _options$onSuccess === void 0 ? void 0 : _options$onSuccess.call(options, res);
103
- case 13:
104
- return _context2.abrupt("return", res);
105
107
  case 14:
108
+ return _context2.abrupt("return", res);
109
+ case 15:
106
110
  case "end":
107
111
  return _context2.stop();
108
112
  }
@@ -121,27 +125,29 @@ var BaseRestApi = exports.BaseRestApi = /*#__PURE__*/function () {
121
125
  while (1) switch (_context3.prev = _context3.next) {
122
126
  case 0:
123
127
  config = {};
124
- (_this$handleRequestCo3 = this.handleRequestConfig) === null || _this$handleRequestCo3 === void 0 ? void 0 : _this$handleRequestCo3.call(this, config);
125
- _context3.next = 4;
128
+ _context3.next = 3;
129
+ return (_this$handleRequestCo3 = this.handleRequestConfig) === null || _this$handleRequestCo3 === void 0 ? void 0 : _this$handleRequestCo3.call(this, config);
130
+ case 3:
131
+ _context3.next = 5;
126
132
  return this.request.post("", data, config);
127
- case 4:
133
+ case 5:
128
134
  res = _context3.sent;
129
135
  if (res.success) {
130
- _context3.next = 11;
136
+ _context3.next = 12;
131
137
  break;
132
138
  }
133
139
  this.showError("\u63D0\u4EA4\u5931\u8D25!", res.message).then();
134
- _context3.next = 9;
140
+ _context3.next = 10;
135
141
  return options === null || options === void 0 ? void 0 : (_options$onError2 = options.onError) === null || _options$onError2 === void 0 ? void 0 : _options$onError2.call(options, res);
136
- case 9:
137
- _context3.next = 13;
142
+ case 10:
143
+ _context3.next = 14;
138
144
  break;
139
- case 11:
140
- _context3.next = 13;
145
+ case 12:
146
+ _context3.next = 14;
141
147
  return options === null || options === void 0 ? void 0 : (_options$onSuccess2 = options.onSuccess) === null || _options$onSuccess2 === void 0 ? void 0 : _options$onSuccess2.call(options, res);
142
- case 13:
143
- return _context3.abrupt("return", res);
144
148
  case 14:
149
+ return _context3.abrupt("return", res);
150
+ case 15:
145
151
  case "end":
146
152
  return _context3.stop();
147
153
  }
@@ -166,27 +172,29 @@ var BaseRestApi = exports.BaseRestApi = /*#__PURE__*/function () {
166
172
  while (1) switch (_context4.prev = _context4.next) {
167
173
  case 0:
168
174
  config = {};
169
- (_this$handleRequestCo4 = this.handleRequestConfig) === null || _this$handleRequestCo4 === void 0 ? void 0 : _this$handleRequestCo4.call(this, config);
170
- _context4.next = 4;
175
+ _context4.next = 3;
176
+ return (_this$handleRequestCo4 = this.handleRequestConfig) === null || _this$handleRequestCo4 === void 0 ? void 0 : _this$handleRequestCo4.call(this, config);
177
+ case 3:
178
+ _context4.next = 5;
171
179
  return this.request.post("", data, config);
172
- case 4:
180
+ case 5:
173
181
  res = _context4.sent;
174
182
  if (res.success) {
175
- _context4.next = 11;
183
+ _context4.next = 12;
176
184
  break;
177
185
  }
178
186
  this.showError("\u65B0\u589E\u5931\u8D25!", res.message).then();
179
- _context4.next = 9;
187
+ _context4.next = 10;
180
188
  return options === null || options === void 0 ? void 0 : (_options$onError3 = options.onError) === null || _options$onError3 === void 0 ? void 0 : _options$onError3.call(options, res);
181
- case 9:
182
- _context4.next = 13;
189
+ case 10:
190
+ _context4.next = 14;
183
191
  break;
184
- case 11:
185
- _context4.next = 13;
192
+ case 12:
193
+ _context4.next = 14;
186
194
  return options === null || options === void 0 ? void 0 : (_options$onSuccess3 = options.onSuccess) === null || _options$onSuccess3 === void 0 ? void 0 : _options$onSuccess3.call(options, res);
187
- case 13:
188
- return _context4.abrupt("return", res);
189
195
  case 14:
196
+ return _context4.abrupt("return", res);
197
+ case 15:
190
198
  case "end":
191
199
  return _context4.stop();
192
200
  }
@@ -211,27 +219,29 @@ var BaseRestApi = exports.BaseRestApi = /*#__PURE__*/function () {
211
219
  while (1) switch (_context5.prev = _context5.next) {
212
220
  case 0:
213
221
  config = {};
214
- (_this$handleRequestCo5 = this.handleRequestConfig) === null || _this$handleRequestCo5 === void 0 ? void 0 : _this$handleRequestCo5.call(this, config);
215
- _context5.next = 4;
222
+ _context5.next = 3;
223
+ return (_this$handleRequestCo5 = this.handleRequestConfig) === null || _this$handleRequestCo5 === void 0 ? void 0 : _this$handleRequestCo5.call(this, config);
224
+ case 3:
225
+ _context5.next = 5;
216
226
  return this.request.put(String(id), data, config);
217
- case 4:
227
+ case 5:
218
228
  res = _context5.sent;
219
229
  if (res.success) {
220
- _context5.next = 11;
230
+ _context5.next = 12;
221
231
  break;
222
232
  }
223
233
  this.showError("\u66F4\u65B0\u5931\u8D25!", res.message).then();
224
- _context5.next = 9;
234
+ _context5.next = 10;
225
235
  return options === null || options === void 0 ? void 0 : (_options$onError4 = options.onError) === null || _options$onError4 === void 0 ? void 0 : _options$onError4.call(options, res);
226
- case 9:
227
- _context5.next = 13;
236
+ case 10:
237
+ _context5.next = 14;
228
238
  break;
229
- case 11:
230
- _context5.next = 13;
239
+ case 12:
240
+ _context5.next = 14;
231
241
  return options === null || options === void 0 ? void 0 : (_options$onSuccess4 = options.onSuccess) === null || _options$onSuccess4 === void 0 ? void 0 : _options$onSuccess4.call(options, res);
232
- case 13:
233
- return _context5.abrupt("return", res);
234
242
  case 14:
243
+ return _context5.abrupt("return", res);
244
+ case 15:
235
245
  case "end":
236
246
  return _context5.stop();
237
247
  }
@@ -256,27 +266,29 @@ var BaseRestApi = exports.BaseRestApi = /*#__PURE__*/function () {
256
266
  while (1) switch (_context6.prev = _context6.next) {
257
267
  case 0:
258
268
  config = {};
259
- (_this$handleRequestCo6 = this.handleRequestConfig) === null || _this$handleRequestCo6 === void 0 ? void 0 : _this$handleRequestCo6.call(this, config);
260
- _context6.next = 4;
269
+ _context6.next = 3;
270
+ return (_this$handleRequestCo6 = this.handleRequestConfig) === null || _this$handleRequestCo6 === void 0 ? void 0 : _this$handleRequestCo6.call(this, config);
271
+ case 3:
272
+ _context6.next = 5;
261
273
  return this.request["delete"](String(id), config);
262
- case 4:
274
+ case 5:
263
275
  res = _context6.sent;
264
276
  if (res.success) {
265
- _context6.next = 11;
277
+ _context6.next = 12;
266
278
  break;
267
279
  }
268
280
  this.showError("\u5220\u9664{" + id + "}\u5931\u8D25!", res.message).then();
269
- _context6.next = 9;
281
+ _context6.next = 10;
270
282
  return options === null || options === void 0 ? void 0 : (_options$onError5 = options.onError) === null || _options$onError5 === void 0 ? void 0 : _options$onError5.call(options, res);
271
- case 9:
272
- _context6.next = 13;
283
+ case 10:
284
+ _context6.next = 14;
273
285
  break;
274
- case 11:
275
- _context6.next = 13;
286
+ case 12:
287
+ _context6.next = 14;
276
288
  return options === null || options === void 0 ? void 0 : (_options$onSuccess5 = options.onSuccess) === null || _options$onSuccess5 === void 0 ? void 0 : _options$onSuccess5.call(options, res);
277
- case 13:
278
- return _context6.abrupt("return", res);
279
289
  case 14:
290
+ return _context6.abrupt("return", res);
291
+ case 15:
280
292
  case "end":
281
293
  return _context6.stop();
282
294
  }
@@ -313,7 +325,21 @@ var RestApi = exports.RestApi = /*#__PURE__*/function (_BaseRestApi2) {
313
325
  }
314
326
  (0, _inheritsLoose2["default"])(RestApi, _BaseRestApi2);
315
327
  var _proto2 = RestApi.prototype;
316
- _proto2.handleRequestConfig = function handleRequestConfig(config) {};
328
+ _proto2.handleRequestConfig = /*#__PURE__*/function () {
329
+ var _handleRequestConfig = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee8(config) {
330
+ return _regenerator["default"].wrap(function _callee8$(_context8) {
331
+ while (1) switch (_context8.prev = _context8.next) {
332
+ case 0:
333
+ case "end":
334
+ return _context8.stop();
335
+ }
336
+ }, _callee8);
337
+ }));
338
+ function handleRequestConfig(_x17) {
339
+ return _handleRequestConfig.apply(this, arguments);
340
+ }
341
+ return handleRequestConfig;
342
+ }();
317
343
  return RestApi;
318
344
  }(BaseRestApi);
319
345
  /**
@@ -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>;
@@ -4,17 +4,37 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  exports.__esModule = true;
5
5
  exports.loadUserInfo = loadUserInfo;
6
6
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
7
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
7
8
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
9
+ var _index = require("./index");
8
10
  function loadUserInfo() {
9
11
  return _loadUserInfo.apply(this, arguments);
10
12
  }
11
13
  function _loadUserInfo() {
12
14
  _loadUserInfo = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
15
+ var res;
13
16
  return _regenerator["default"].wrap(function _callee$(_context) {
14
17
  while (1) switch (_context.prev = _context.next) {
15
18
  case 0:
16
- return _context.abrupt("return", {});
17
- case 1:
19
+ if (!window.userInfo) {
20
+ _context.next = 4;
21
+ break;
22
+ }
23
+ return _context.abrupt("return", (0, _extends2["default"])({}, window.userInfo));
24
+ case 4:
25
+ _context.next = 6;
26
+ return _index.apiRequest.get("userInfo");
27
+ case 6:
28
+ res = _context.sent;
29
+ if (!res.success) {
30
+ _context.next = 12;
31
+ break;
32
+ }
33
+ window.userInfo = res.data;
34
+ return _context.abrupt("return", (0, _extends2["default"])({}, res.data));
35
+ case 12:
36
+ return _context.abrupt("return", false);
37
+ case 13:
18
38
  case "end":
19
39
  return _context.stop();
20
40
  }
@@ -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>>;
@@ -2,15 +2,18 @@
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
4
  exports.__esModule = true;
5
+ exports.apiRequest = void 0;
5
6
  exports.getFormApi = getFormApi;
6
7
  exports.getSchema = getSchema;
7
- exports.request = void 0;
8
+ exports.loadUserInfo = void 0;
8
9
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
10
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
10
11
  var _axios = _interopRequireDefault(require("axios"));
11
12
  var _Request = require("./Request");
12
13
  var _cache = require("../cache");
13
- var request = exports.request = _axios["default"].create({
14
+ var _UserInfo = require("./UserInfo");
15
+ exports.loadUserInfo = _UserInfo.loadUserInfo;
16
+ var apiRequest = exports.apiRequest = _axios["default"].create({
14
17
  baseURL: "/api",
15
18
  // 基础URL
16
19
  timeout: 10000,
@@ -19,22 +22,30 @@ var request = exports.request = _axios["default"].create({
19
22
  'Content-Type': 'application/json;charset=UTF-8'
20
23
  }
21
24
  });
22
- request.interceptors.response.use(_Request.onFulfilled, _Request.onRejected);
25
+ apiRequest.interceptors.response.use(_Request.onFulfilled, _Request.onRejected);
23
26
  function getSchema(_x, _x2) {
24
27
  return _getSchema.apply(this, arguments);
25
28
  }
26
29
  function _getSchema() {
27
- _getSchema = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(schemaId, mock) {
30
+ _getSchema = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(pageId, mock) {
28
31
  var key;
29
32
  return _regenerator["default"].wrap(function _callee$(_context) {
30
33
  while (1) switch (_context.prev = _context.next) {
31
34
  case 0:
32
- key = mock ? schemaId + "_mock" : schemaId;
33
- _context.next = 3;
34
- return _cache.schema.getInstance(key);
35
- case 3:
36
- return _context.abrupt("return", _context.sent);
35
+ if (typeof mock != "boolean") {
36
+ if (typeof window.__mock == "boolean") {
37
+ mock = window.__mock;
38
+ }
39
+ }
40
+ key = mock ? pageId + "_mock" : pageId;
41
+ _context.next = 4;
42
+ return _cache.schema.getInstance(key, {
43
+ mock: mock,
44
+ pageId: pageId
45
+ });
37
46
  case 4:
47
+ return _context.abrupt("return", _context.sent);
48
+ case 5:
38
49
  case "end":
39
50
  return _context.stop();
40
51
  }
@@ -42,11 +53,11 @@ function _getSchema() {
42
53
  }));
43
54
  return _getSchema.apply(this, arguments);
44
55
  }
45
- function getFormApi(_x3, _x4) {
56
+ function getFormApi(_x3, _x4, _x5) {
46
57
  return _getFormApi.apply(this, arguments);
47
58
  }
48
59
  function _getFormApi() {
49
- _getFormApi = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(schemaId, mock) {
60
+ _getFormApi = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(formId, fieldId, mock) {
50
61
  var key;
51
62
  return _regenerator["default"].wrap(function _callee2$(_context2) {
52
63
  while (1) switch (_context2.prev = _context2.next) {
@@ -56,9 +67,13 @@ function _getFormApi() {
56
67
  mock = window.__mock;
57
68
  }
58
69
  }
59
- key = !!mock ? schemaId + "_mock" : schemaId;
70
+ key = !!mock ? formId + "_mock" : formId;
60
71
  _context2.next = 4;
61
- return _cache.formApi.getInstance(key);
72
+ return _cache.formApi.getInstance(key, {
73
+ mock: mock,
74
+ fieldId: fieldId,
75
+ formId: formId
76
+ });
62
77
  case 4:
63
78
  return _context2.abrupt("return", _context2.sent);
64
79
  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;
@@ -7,8 +7,9 @@ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"))
7
7
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
8
8
  var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));
9
9
  var _SingletonInstanceMap3 = require("../common/SingletonInstanceMap");
10
- var _api = require("../api");
11
10
  var _form = require("../form/form.api");
11
+ var _schema = require("./schema");
12
+ var _api = require("../api");
12
13
  var SchemaCache = exports.SchemaCache = /*#__PURE__*/function (_SingletonInstanceMap) {
13
14
  function SchemaCache() {
14
15
  return _SingletonInstanceMap.apply(this, arguments) || this;
@@ -16,28 +17,31 @@ var SchemaCache = exports.SchemaCache = /*#__PURE__*/function (_SingletonInstanc
16
17
  (0, _inheritsLoose2["default"])(SchemaCache, _SingletonInstanceMap);
17
18
  var _proto = SchemaCache.prototype;
18
19
  _proto.createInstance = /*#__PURE__*/function () {
19
- var _createInstance = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(key) {
20
- var mock, pageId;
20
+ var _createInstance = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(key, options) {
21
+ var mock, pageId, res;
21
22
  return _regenerator["default"].wrap(function _callee$(_context) {
22
23
  while (1) switch (_context.prev = _context.next) {
23
24
  case 0:
24
- mock = key.endsWith("_mock");
25
- pageId = key.replace("_mock", "");
26
- _context.next = 4;
27
- return _api.request.get("pages/" + pageId + "/schema", {
25
+ mock = options.mock, pageId = options.pageId;
26
+ _context.next = 3;
27
+ return _api.apiRequest.get("pages/" + pageId + "/schema", {
28
28
  params: {
29
29
  mock: mock
30
30
  }
31
31
  });
32
- case 4:
33
- return _context.abrupt("return", _context.sent);
34
- case 5:
32
+ case 3:
33
+ res = _context.sent;
34
+ if (res.success) {
35
+ (0, _schema.handleFormSchema)(res.data);
36
+ }
37
+ return _context.abrupt("return", res);
38
+ case 6:
35
39
  case "end":
36
40
  return _context.stop();
37
41
  }
38
42
  }, _callee);
39
43
  }));
40
- function createInstance(_x) {
44
+ function createInstance(_x, _x2) {
41
45
  return _createInstance.apply(this, arguments);
42
46
  }
43
47
  return createInstance;
@@ -52,14 +56,16 @@ var FormApiCache = exports.FormApiCache = /*#__PURE__*/function (_SingletonInsta
52
56
  (0, _inheritsLoose2["default"])(FormApiCache, _SingletonInstanceMap2);
53
57
  var _proto2 = FormApiCache.prototype;
54
58
  _proto2.createInstance = /*#__PURE__*/function () {
55
- var _createInstance2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(key) {
56
- var mock, formId, formApi;
59
+ var _createInstance2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(key, options) {
60
+ var _options, formId, fieldId, mock, formApi;
57
61
  return _regenerator["default"].wrap(function _callee2$(_context2) {
58
62
  while (1) switch (_context2.prev = _context2.next) {
59
63
  case 0:
60
- mock = key.endsWith("_mock");
61
- formId = key.replace("_mock", "");
62
- formApi = new _form.RestFormApi(formId, mock);
64
+ if (options === void 0) {
65
+ options = {};
66
+ }
67
+ _options = options, formId = _options.formId, fieldId = _options.fieldId, mock = _options.mock;
68
+ formApi = new _form.RestFormApi(formId, fieldId, mock);
63
69
  _context2.next = 5;
64
70
  return formApi.initialize();
65
71
  case 5:
@@ -70,7 +76,7 @@ var FormApiCache = exports.FormApiCache = /*#__PURE__*/function (_SingletonInsta
70
76
  }
71
77
  }, _callee2);
72
78
  }));
73
- function createInstance(_x2) {
79
+ function createInstance(_x3, _x4) {
74
80
  return _createInstance2.apply(this, arguments);
75
81
  }
76
82
  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,47 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.forEachFormSchema = forEachFormSchema;
5
+ exports.handleFormSchema = handleFormSchema;
6
+ function handleFormSchema(schema) {
7
+ var fdmItems = [];
8
+ var fieldIdMap = new Map();
9
+ forEachFormSchema(schema, function (field) {
10
+ if (field.fdmSchema) {
11
+ fdmItems.push(field);
12
+ }
13
+ if (field.props.fieldId) {
14
+ //删除children防止循环
15
+ var copyField = JSON.parse(JSON.stringify(field));
16
+ delete copyField.children;
17
+ fieldIdMap.set(field.props.fieldId, copyField);
18
+ }
19
+ return true;
20
+ });
21
+ fdmItems.forEach(function (fdmField) {
22
+ forEachFormSchema(fdmField.fdmSchema, function (field) {
23
+ var _field$props;
24
+ var findSchema = fieldIdMap.get((_field$props = field.props) === null || _field$props === void 0 ? void 0 : _field$props.fieldId);
25
+ if (findSchema) {
26
+ field.componentName = findSchema.componentName;
27
+ Object.assign(field.props, findSchema.props);
28
+ }
29
+ return true;
30
+ });
31
+ });
32
+ }
33
+
34
+ /**
35
+ * 遍历schema
36
+ * @param schema
37
+ * @param callback 返回true 继续往下遍历
38
+ */
39
+ function forEachFormSchema(schema, callback) {
40
+ var _schema$children;
41
+ 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) {
42
+ var ctn = callback(child, index, children);
43
+ if (ctn) {
44
+ forEachFormSchema(child, callback);
45
+ }
46
+ });
47
+ }
@@ -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
  }
@@ -12,7 +12,7 @@ var SingletonInstanceMap = exports.SingletonInstanceMap = /*#__PURE__*/function
12
12
  }
13
13
  var _proto = SingletonInstanceMap.prototype;
14
14
  _proto.getInstance = /*#__PURE__*/function () {
15
- var _getInstance = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(key) {
15
+ var _getInstance = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(key, options) {
16
16
  var self, value;
17
17
  return _regenerator["default"].wrap(function _callee2$(_context2) {
18
18
  while (1) switch (_context2.prev = _context2.next) {
@@ -33,19 +33,19 @@ var SingletonInstanceMap = exports.SingletonInstanceMap = /*#__PURE__*/function
33
33
  return _regenerator["default"].wrap(function _callee$(_context) {
34
34
  while (1) switch (_context.prev = _context.next) {
35
35
  case 0:
36
- resolve(self.getInstance(key));
36
+ resolve(self.getInstance(key, options));
37
37
  case 1:
38
38
  case "end":
39
39
  return _context.stop();
40
40
  }
41
41
  }, _callee);
42
- })), 1000);
42
+ })), 500);
43
43
  }));
44
44
  case 9:
45
45
  _context2.prev = 9;
46
46
  this.lockMap.set(key, true);
47
47
  _context2.next = 13;
48
- return this.createInstance(key);
48
+ return this.createInstance(key, options);
49
49
  case 13:
50
50
  value = _context2.sent;
51
51
  this.valueMap.set(key, value);
@@ -65,7 +65,7 @@ var SingletonInstanceMap = exports.SingletonInstanceMap = /*#__PURE__*/function
65
65
  }
66
66
  }, _callee2, this, [[9, 19, 22, 25]]);
67
67
  }));
68
- function getInstance(_x) {
68
+ function getInstance(_x, _x2) {
69
69
  return _getInstance.apply(this, arguments);
70
70
  }
71
71
  return getInstance;
@@ -42,7 +42,7 @@ var BaseAssets = {
42
42
  utils: [],
43
43
  "components": [],
44
44
  "sort": {
45
- "categoryList": ["布局", "通用", "导航", "数据录入", "数据展示", "反馈", "大屏组件", "图表", "基础元素", "表格类", "表单详情类", "帮助类", "对话框类", "业务类", "引导", "信息输入", "信息展示", "信息反馈", "布局容器类", "增强组件", "工具组件"],
45
+ "categoryList": ["布局", "通用", "导航", "数据录入", "数据展示", "反馈", "大屏组件", "图表", "基础元素", "表格类", "表单详情类", "帮助类", "对话框类", "业务类", "引导", "信息输入", "信息展示", "信息反馈", "布局容器类", "增强组件", "工具组件", "普通", "范围", "高级"],
46
46
  "groupList": ["", "原子组件", "精选组件", "增强分组", "图表组件", "默认分组"]
47
47
  }
48
48
  };