@zhubangyun/lowcode-core 5.10.220 → 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 (71) 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.d.ts +1 -1
  5. package/es/utils/api/form-api.js +70 -66
  6. package/es/utils/api/form-api.utils.d.ts +5 -5
  7. package/es/utils/api/form-api.utils.js +55 -36
  8. package/es/utils/api/index.d.ts +4 -3
  9. package/es/utils/api/index.js +9 -2
  10. package/es/utils/api/rest-api.d.ts +6 -5
  11. package/es/utils/api/rest-api.js +1 -1
  12. package/es/utils/api/schema.util.d.ts +14 -0
  13. package/es/utils/api/schema.util.js +32 -0
  14. package/es/utils/api/script-api.js +1 -1
  15. package/es/utils/api/user-info.d.ts +16 -6
  16. package/es/utils/api/user-info.js +31 -20
  17. package/es/utils/cache/index.d.ts +6 -6
  18. package/es/utils/cache/index.js +56 -24
  19. package/es/utils/cache/schema.d.ts +0 -2
  20. package/es/utils/cache/schema.js +0 -388
  21. package/es/utils/formIds.d.ts +3 -0
  22. package/es/utils/formIds.js +3 -0
  23. package/es/utils/page/index.d.ts +2 -0
  24. package/es/utils/page/index.js +2 -0
  25. package/es/utils/page/page-form-data-manager-group.d.ts +2 -0
  26. package/es/utils/page/page-form-data-manager-group.js +3 -7
  27. package/es/utils/page/page-form-data-manager.d.ts +2 -1
  28. package/es/utils/page/page-form-data-manager.js +1 -0
  29. package/es/utils/page/page-form-group.d.ts +17 -0
  30. package/es/utils/page/page-form-group.js +97 -0
  31. package/es/utils/page/page-form.d.ts +2 -1
  32. package/es/utils/page/page-form.js +3 -3
  33. package/es/utils/page/page-show.d.ts +1 -0
  34. package/es/utils/page/print-form.d.ts +8 -0
  35. package/es/utils/page/print-form.js +147 -0
  36. package/lib/index.less +10 -0
  37. package/lib/utils/api/file-api.d.ts +17 -5
  38. package/lib/utils/api/file-api.js +10 -7
  39. package/lib/utils/api/form-api.d.ts +1 -1
  40. package/lib/utils/api/form-api.js +70 -66
  41. package/lib/utils/api/form-api.utils.d.ts +5 -5
  42. package/lib/utils/api/form-api.utils.js +55 -36
  43. package/lib/utils/api/index.d.ts +4 -3
  44. package/lib/utils/api/index.js +10 -3
  45. package/lib/utils/api/rest-api.d.ts +6 -5
  46. package/lib/utils/api/rest-api.js +1 -1
  47. package/lib/utils/api/schema.util.d.ts +14 -0
  48. package/lib/utils/api/schema.util.js +37 -0
  49. package/lib/utils/api/script-api.js +1 -1
  50. package/lib/utils/api/user-info.d.ts +16 -6
  51. package/lib/utils/api/user-info.js +32 -21
  52. package/lib/utils/cache/index.d.ts +6 -6
  53. package/lib/utils/cache/index.js +57 -24
  54. package/lib/utils/cache/schema.d.ts +0 -2
  55. package/lib/utils/cache/schema.js +0 -390
  56. package/lib/utils/formIds.d.ts +3 -0
  57. package/lib/utils/formIds.js +7 -0
  58. package/lib/utils/page/index.d.ts +2 -0
  59. package/lib/utils/page/index.js +7 -1
  60. package/lib/utils/page/page-form-data-manager-group.d.ts +2 -0
  61. package/lib/utils/page/page-form-data-manager-group.js +3 -7
  62. package/lib/utils/page/page-form-data-manager.d.ts +2 -1
  63. package/lib/utils/page/page-form-data-manager.js +1 -0
  64. package/lib/utils/page/page-form-group.d.ts +17 -0
  65. package/lib/utils/page/page-form-group.js +104 -0
  66. package/lib/utils/page/page-form.d.ts +2 -1
  67. package/lib/utils/page/page-form.js +3 -3
  68. package/lib/utils/page/page-show.d.ts +1 -0
  69. package/lib/utils/page/print-form.d.ts +8 -0
  70. package/lib/utils/page/print-form.js +153 -0
  71. package/package.json +1 -1
@@ -6,26 +6,41 @@ exports.RestFormApi = void 0;
6
6
  exports.getFormApi = getFormApi;
7
7
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
8
8
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
10
9
  var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));
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");
15
- function getFormApi(formId, fieldId, mock) {
16
- if (typeof mock != "boolean") {
17
- if (typeof window.__mock == "boolean") {
18
- mock = window.__mock;
19
- }
20
- }
21
- var key = [formId, fieldId, mock ? "mock" : ""].filter(function (key) {
22
- return !!key;
23
- }).join("_");
24
- return _cache.formApi.getInstance(key, {
25
- mock: mock,
26
- fieldId: fieldId,
27
- formId: formId
28
- });
14
+ var _schemaApi = require("./schema-api");
15
+ function getFormApi(_x, _x2, _x3) {
16
+ return _getFormApi.apply(this, arguments);
17
+ }
18
+ function _getFormApi() {
19
+ _getFormApi = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee9(formId, fieldId, mock) {
20
+ var key;
21
+ return _regenerator["default"].wrap(function _callee9$(_context9) {
22
+ while (1) switch (_context9.prev = _context9.next) {
23
+ case 0:
24
+ if (typeof mock != "boolean") {
25
+ if (typeof window.__mock == "boolean") {
26
+ mock = window.__mock;
27
+ }
28
+ }
29
+ key = [formId, fieldId, mock ? "mock" : ""].filter(function (key) {
30
+ return !!key;
31
+ }).join("_");
32
+ return _context9.abrupt("return", _cache.formApi.getInstance(key, {
33
+ mock: mock,
34
+ fieldId: fieldId,
35
+ formId: formId
36
+ }));
37
+ case 3:
38
+ case "end":
39
+ return _context9.stop();
40
+ }
41
+ }, _callee9);
42
+ }));
43
+ return _getFormApi.apply(this, arguments);
29
44
  }
30
45
  var RestFormApi = exports.RestFormApi = /*#__PURE__*/function (_RestApi) {
31
46
  function RestFormApi(formId, fieldId, mock) {
@@ -46,56 +61,46 @@ var RestFormApi = exports.RestFormApi = /*#__PURE__*/function (_RestApi) {
46
61
  _proto.initialize = /*#__PURE__*/function () {
47
62
  var _initialize = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
48
63
  var _this2 = this;
49
- var _this$schema$children, _this$schema$children2, res;
64
+ var res, _this$schema, _this$schema$children, _this$schema$children2;
50
65
  return _regenerator["default"].wrap(function _callee$(_context) {
51
66
  while (1) switch (_context.prev = _context.next) {
52
67
  case 0:
53
68
  if (!this.initialized) {
54
- _context.next = 4;
55
- break;
56
- }
57
- return _context.abrupt("return", true);
58
- case 4:
59
- _context.prev = 4;
60
- _context.next = 7;
61
- return (0, _index.getSchema)(this.formId, this.mock);
62
- case 7:
63
- res = _context.sent;
64
- this.schema = res.data;
65
- this.initialized = !!this.schema;
66
- 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;
67
- if (this.fieldId) {
68
- JSON.stringify(this.schema, function (key, value) {
69
- var _value$props;
70
- if (key == "fdmSchema") {
71
- return undefined;
72
- }
73
- if ((value === null || value === void 0 ? void 0 : (_value$props = value.props) === null || _value$props === void 0 ? void 0 : _value$props.fieldId) === _this2.fieldId) {
74
- if (value.props.label) {
75
- _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
+ });
76
88
  }
77
89
  }
78
- return value;
79
- });
90
+ } catch (e) {
91
+ console.log("获取schema失败!", {
92
+ formId: this.formId,
93
+ field: this.fieldId,
94
+ mock: this.mock
95
+ }, e);
96
+ }
80
97
  }
81
- _context.next = 18;
82
- break;
83
- case 14:
84
- _context.prev = 14;
85
- _context.t0 = _context["catch"](4);
86
- console.log("获取schema失败!", {
87
- formId: this.formId,
88
- field: this.fieldId,
89
- mock: this.mock
90
- }, _context.t0);
91
- throw _context.t0;
92
- case 18:
93
98
  return _context.abrupt("return", this.initialized);
94
- case 19:
99
+ case 2:
95
100
  case "end":
96
101
  return _context.stop();
97
102
  }
98
- }, _callee, this, [[4, 14]]);
103
+ }, _callee, this);
99
104
  }));
100
105
  function initialize() {
101
106
  return _initialize.apply(this, arguments);
@@ -127,7 +132,7 @@ var RestFormApi = exports.RestFormApi = /*#__PURE__*/function (_RestApi) {
127
132
  }
128
133
  }, _callee2, this);
129
134
  }));
130
- function handleRequestConfig(_x) {
135
+ function handleRequestConfig(_x4) {
131
136
  return _handleRequestConfig.apply(this, arguments);
132
137
  }
133
138
  return handleRequestConfig;
@@ -145,7 +150,7 @@ var RestFormApi = exports.RestFormApi = /*#__PURE__*/function (_RestApi) {
145
150
  fieldId: this.fieldId
146
151
  };
147
152
  if (__mock) {
148
- params.description = "" + this.title;
153
+ params.description = (this.title || "表单") + ".\u67E5\u8BE2";
149
154
  }
150
155
  config = {
151
156
  params: params
@@ -175,14 +180,14 @@ var RestFormApi = exports.RestFormApi = /*#__PURE__*/function (_RestApi) {
175
180
  }
176
181
  }, _callee3, this);
177
182
  }));
178
- function search(_x2) {
183
+ function search(_x5) {
179
184
  return _search.apply(this, arguments);
180
185
  }
181
186
  return search;
182
187
  }();
183
188
  _proto.getById = /*#__PURE__*/function () {
184
189
  var _getById = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(id, options) {
185
- var res, start;
190
+ var res;
186
191
  return _regenerator["default"].wrap(function _callee4$(_context4) {
187
192
  while (1) switch (_context4.prev = _context4.next) {
188
193
  case 0:
@@ -190,17 +195,16 @@ var RestFormApi = exports.RestFormApi = /*#__PURE__*/function (_RestApi) {
190
195
  return _RestApi.prototype.getById.call(this, id, options);
191
196
  case 2:
192
197
  res = _context4.sent;
193
- start = Date.now();
194
198
  (0, _formApi.assembleAssociationField)(res.data, res.refs);
195
199
  console.debug("formApi.getById", res);
196
200
  return _context4.abrupt("return", res);
197
- case 7:
201
+ case 6:
198
202
  case "end":
199
203
  return _context4.stop();
200
204
  }
201
205
  }, _callee4, this);
202
206
  }));
203
- function getById(_x3, _x4) {
207
+ function getById(_x6, _x7) {
204
208
  return _getById.apply(this, arguments);
205
209
  }
206
210
  return getById;
@@ -217,7 +221,7 @@ var RestFormApi = exports.RestFormApi = /*#__PURE__*/function (_RestApi) {
217
221
  }
218
222
  }, _callee5, this);
219
223
  }));
220
- function save(_x5, _x6) {
224
+ function save(_x8, _x9) {
221
225
  return _save.apply(this, arguments);
222
226
  }
223
227
  return save;
@@ -234,7 +238,7 @@ var RestFormApi = exports.RestFormApi = /*#__PURE__*/function (_RestApi) {
234
238
  }
235
239
  }, _callee6, this);
236
240
  }));
237
- function create(_x7, _x8) {
241
+ function create(_x10, _x11) {
238
242
  return _create.apply(this, arguments);
239
243
  }
240
244
  return create;
@@ -251,7 +255,7 @@ var RestFormApi = exports.RestFormApi = /*#__PURE__*/function (_RestApi) {
251
255
  }
252
256
  }, _callee7, this);
253
257
  }));
254
- function update(_x9, _x10, _x11) {
258
+ function update(_x12, _x13, _x14) {
255
259
  return _update.apply(this, arguments);
256
260
  }
257
261
  return update;
@@ -268,7 +272,7 @@ var RestFormApi = exports.RestFormApi = /*#__PURE__*/function (_RestApi) {
268
272
  }
269
273
  }, _callee8, this);
270
274
  }));
271
- function serviceUpdate(_x12, _x13) {
275
+ function serviceUpdate(_x15, _x16) {
272
276
  return _serviceUpdate.apply(this, arguments);
273
277
  }
274
278
  return serviceUpdate;
@@ -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) {
@@ -60,7 +60,7 @@ export declare class RestApi<DataType> extends BaseRestApi<DataType> {
60
60
  constructor(uri: string, options?: RestApiOptions);
61
61
  handleRequestConfig(config: AxiosRequestConfig): Promise<void>;
62
62
  }
63
- export interface BaseType {
63
+ export interface IBaseEntity {
64
64
  /**
65
65
  * 对象id
66
66
  */
@@ -103,19 +103,20 @@ export interface BaseResult<DataType> {
103
103
  refs?: Refs;
104
104
  }
105
105
  export interface Ref {
106
+ label: string;
106
107
  form: {
107
108
  id: string;
108
109
  fieldId?: string;
110
+ label: string;
109
111
  };
110
- fieldIds: string[];
111
- data: BaseType[];
112
+ data: IBaseEntity[];
112
113
  }
113
114
  export type Refs = Ref[];
114
115
  export interface OneResult<DataType> extends BaseResult<DataType> {
115
- data: DataType & BaseType;
116
+ data: DataType & IBaseEntity;
116
117
  }
117
118
  export interface ManyResult<DataType> extends BaseResult<DataType> {
118
- data: (DataType & BaseType)[];
119
+ data: (DataType & IBaseEntity)[];
119
120
  total: number;
120
121
  }
121
122
  export interface BaseRequestOptions<DataType> {
@@ -23,7 +23,7 @@ var BaseRestApi = exports.BaseRestApi = /*#__PURE__*/function () {
23
23
  this.request = _axios["default"].create({
24
24
  baseURL: "/api/" + uri,
25
25
  // 基础URL
26
- timeout: 10000,
26
+ timeout: 60000,
27
27
  // 请求超时时间(毫秒)
28
28
  headers: {
29
29
  'Content-Type': 'application/json;charset=UTF-8'
@@ -0,0 +1,14 @@
1
+ /**
2
+ * 遍历schema
3
+ * @param schema
4
+ * @param callback 返回true 继续往下遍历
5
+ */
6
+ export declare function forEachSchema(schema: Schema, callback: (child: Schema, index: number, children: any[]) => boolean): void;
7
+ export declare function forEachFormSchema(schema: Schema, fdm: boolean, callback: (child: Schema) => void): void;
8
+ interface Schema {
9
+ componentName: string;
10
+ props: any;
11
+ children?: Schema[];
12
+ fdmSchema?: Schema;
13
+ }
14
+ export {};
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.forEachFormSchema = forEachFormSchema;
5
+ exports.forEachSchema = forEachSchema;
6
+ /**
7
+ * 遍历schema
8
+ * @param schema
9
+ * @param callback 返回true 继续往下遍历
10
+ */
11
+ function forEachSchema(schema, callback) {
12
+ var _schema$children;
13
+ 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) {
14
+ var ctn = callback(child, index, children);
15
+ if (ctn) {
16
+ forEachSchema(child, callback);
17
+ }
18
+ });
19
+ }
20
+ function forEachFormSchema(schema, fdm, callback) {
21
+ forEachSchema(schema, function (child) {
22
+ if (["PageForm", "SubFormField"].includes(child.componentName)) {
23
+ callback(child);
24
+ if (fdm) {
25
+ if (child.fdmSchema) {
26
+ forEachSchema(child.fdmSchema, function (fdmChild) {
27
+ if (fdmChild.componentName == "PageFdm") {
28
+ callback(child);
29
+ }
30
+ return true;
31
+ });
32
+ }
33
+ }
34
+ }
35
+ return true;
36
+ });
37
+ }
@@ -17,7 +17,7 @@ function _loadDts() {
17
17
  case 0:
18
18
  _context.prev = 0;
19
19
  _context.next = 3;
20
- return (0, _index.getFormApi)("form_bea7fcc6376c4461965237056f970fb7");
20
+ return (0, _index.getFormApi)("c40772eb-864b-42bb-ae31-9921d8ede97f");
21
21
  case 3:
22
22
  api = _context.sent;
23
23
  _context.next = 6;
@@ -1,9 +1,19 @@
1
- export interface UserInfo {
2
- userId: string;
3
- userName: string;
1
+ import { IBaseEntity } from "./rest-api";
2
+ export interface Userinfo {
3
+ id: string;
4
+ label: string;
5
+ username: string;
4
6
  staffId: string;
5
7
  staffName: string;
6
- roleIds: string[];
7
- deptIds: string[];
8
+ form: {
9
+ id: string;
10
+ };
11
+ depts: IBaseEntity[];
12
+ roles: IBaseEntity[];
13
+ corp: {
14
+ id: string;
15
+ name: string;
16
+ shortName: string;
17
+ };
8
18
  }
9
- export declare function loadUserInfo(): Promise<UserInfo | false>;
19
+ export declare function getUserinfo(): Promise<Userinfo | null>;