@zhubangyun/lowcode-core 5.8.290 → 5.10.81
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.
- package/es/index.js +1 -0
- package/es/utils/api/file-api.d.ts +7 -0
- package/es/utils/api/file-api.js +86 -0
- package/es/utils/api/form-api.d.ts +1 -0
- package/es/utils/api/form-api.js +66 -27
- package/es/utils/api/form-api.utils.d.ts +2 -0
- package/es/utils/api/form-api.utils.js +82 -113
- package/es/utils/api/index.d.ts +5 -5
- package/es/utils/api/index.js +7 -67
- package/es/utils/api/rest-api.d.ts +6 -2
- package/es/utils/api/rest-api.js +64 -34
- package/es/utils/api/schema-api.d.ts +2 -0
- package/es/utils/api/schema-api.js +33 -0
- package/es/utils/api/script-api.d.ts +1 -0
- package/es/utils/api/script-api.js +41 -0
- package/es/utils/cache/schema.js +15 -9
- package/es/utils/common/LoadPlugins.js +9 -16
- package/es/utils/common/index.d.ts +1 -0
- package/es/utils/common/index.js +12 -0
- package/es/utils/page/index.d.ts +1 -0
- package/es/utils/page/index.js +1 -0
- package/es/utils/page/page-form-data-manager-group.d.ts +17 -0
- package/es/utils/page/page-form-data-manager-group.js +104 -0
- package/es/utils/page/page-form-data-manager.d.ts +6 -0
- package/es/utils/page/page-form-data-manager.js +24 -79
- package/es/utils/page/page-form.d.ts +1 -1
- package/es/utils/page/page-form.js +24 -47
- package/es/utils/page/page-layout.js +1 -1
- package/es/utils/page/page-render.d.ts +10 -0
- package/es/utils/page/page-render.js +51 -0
- package/es/utils/page/page-schema-utils.d.ts +1 -0
- package/es/utils/page/page-schema-utils.js +74 -0
- package/lib/index.js +2 -0
- package/lib/utils/api/file-api.d.ts +7 -0
- package/lib/utils/api/file-api.js +92 -0
- package/lib/utils/api/form-api.d.ts +1 -0
- package/lib/utils/api/form-api.js +67 -27
- package/lib/utils/api/form-api.utils.d.ts +2 -0
- package/lib/utils/api/form-api.utils.js +84 -113
- package/lib/utils/api/index.d.ts +5 -5
- package/lib/utils/api/index.js +14 -72
- package/lib/utils/api/rest-api.d.ts +6 -2
- package/lib/utils/api/rest-api.js +64 -34
- package/lib/utils/api/schema-api.d.ts +2 -0
- package/lib/utils/api/schema-api.js +38 -0
- package/lib/utils/api/script-api.d.ts +1 -0
- package/lib/utils/api/script-api.js +46 -0
- package/lib/utils/cache/schema.js +15 -9
- package/lib/utils/common/LoadPlugins.js +9 -16
- package/lib/utils/common/index.d.ts +1 -0
- package/lib/utils/common/index.js +13 -0
- package/lib/utils/page/index.d.ts +1 -0
- package/lib/utils/page/index.js +3 -1
- package/lib/utils/page/page-form-data-manager-group.d.ts +17 -0
- package/lib/utils/page/page-form-data-manager-group.js +111 -0
- package/lib/utils/page/page-form-data-manager.d.ts +6 -0
- package/lib/utils/page/page-form-data-manager.js +24 -79
- package/lib/utils/page/page-form.d.ts +1 -1
- package/lib/utils/page/page-form.js +24 -47
- package/lib/utils/page/page-layout.js +1 -1
- package/lib/utils/page/page-render.d.ts +10 -0
- package/lib/utils/page/page-render.js +56 -0
- package/lib/utils/page/page-schema-utils.d.ts +1 -0
- package/lib/utils/page/page-schema-utils.js +79 -0
- package/package.json +1 -1
- package/es/utils/common/FormDataHandler.d.ts +0 -45
- package/es/utils/common/FormDataHandler.js +0 -410
- package/lib/utils/common/FormDataHandler.d.ts +0 -45
- package/lib/utils/common/FormDataHandler.js +0 -416
|
@@ -3,12 +3,48 @@
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
exports.__esModule = true;
|
|
5
5
|
exports.RestFormApi = void 0;
|
|
6
|
+
exports.getFormApi = getFormApi;
|
|
6
7
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
7
|
-
var
|
|
8
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
8
9
|
var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));
|
|
10
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
9
11
|
var _restApi = require("./rest-api");
|
|
10
12
|
var _index = require("./index");
|
|
11
13
|
var _formApi = require("./form-api.utils");
|
|
14
|
+
var _cache = require("../cache");
|
|
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
|
+
_context9.next = 4;
|
|
33
|
+
return _cache.formApi.getInstance(key, {
|
|
34
|
+
mock: mock,
|
|
35
|
+
fieldId: fieldId,
|
|
36
|
+
formId: formId
|
|
37
|
+
});
|
|
38
|
+
case 4:
|
|
39
|
+
return _context9.abrupt("return", _context9.sent);
|
|
40
|
+
case 5:
|
|
41
|
+
case "end":
|
|
42
|
+
return _context9.stop();
|
|
43
|
+
}
|
|
44
|
+
}, _callee9);
|
|
45
|
+
}));
|
|
46
|
+
return _getFormApi.apply(this, arguments);
|
|
47
|
+
}
|
|
12
48
|
var RestFormApi = exports.RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
13
49
|
function RestFormApi(formId, fieldId, mock) {
|
|
14
50
|
var _this;
|
|
@@ -93,7 +129,9 @@ var RestFormApi = exports.RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
|
93
129
|
return this.initialize();
|
|
94
130
|
case 2:
|
|
95
131
|
config.params = config.params || {};
|
|
96
|
-
|
|
132
|
+
if (__mock) {
|
|
133
|
+
config.params.description = "" + this.title;
|
|
134
|
+
}
|
|
97
135
|
config.params.formId = this.formId;
|
|
98
136
|
if (this.fieldId) {
|
|
99
137
|
config.params.fieldId = this.fieldId;
|
|
@@ -107,7 +145,7 @@ var RestFormApi = exports.RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
|
107
145
|
}
|
|
108
146
|
}, _callee2, this);
|
|
109
147
|
}));
|
|
110
|
-
function handleRequestConfig(
|
|
148
|
+
function handleRequestConfig(_x4) {
|
|
111
149
|
return _handleRequestConfig.apply(this, arguments);
|
|
112
150
|
}
|
|
113
151
|
return handleRequestConfig;
|
|
@@ -115,49 +153,52 @@ var RestFormApi = exports.RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
|
115
153
|
_proto.search = /*#__PURE__*/function () {
|
|
116
154
|
var _search = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(searchParams) {
|
|
117
155
|
var _searchParams, _searchParams2;
|
|
118
|
-
var config, res
|
|
156
|
+
var params, config, res;
|
|
119
157
|
return _regenerator["default"].wrap(function _callee3$(_context3) {
|
|
120
158
|
while (1) switch (_context3.prev = _context3.next) {
|
|
121
159
|
case 0:
|
|
122
160
|
searchParams = searchParams || {};
|
|
161
|
+
params = {
|
|
162
|
+
formId: this.formId,
|
|
163
|
+
fieldId: this.fieldId
|
|
164
|
+
};
|
|
165
|
+
if (__mock) {
|
|
166
|
+
params.description = "" + this.title;
|
|
167
|
+
}
|
|
123
168
|
config = {
|
|
124
|
-
params:
|
|
125
|
-
description: this.title + "\u67E5\u8BE2",
|
|
126
|
-
formId: this.formId,
|
|
127
|
-
fieldId: this.fieldId
|
|
128
|
-
}
|
|
169
|
+
params: params
|
|
129
170
|
};
|
|
130
|
-
_context3.next =
|
|
171
|
+
_context3.next = 6;
|
|
131
172
|
return this.handleRequestConfig(config);
|
|
132
|
-
case
|
|
173
|
+
case 6:
|
|
133
174
|
searchParams.filterRules = (0, _formApi.handleFilterRules)(((_searchParams = searchParams) === null || _searchParams === void 0 ? void 0 : _searchParams.filterRules) || [], {
|
|
134
175
|
filterNullValue: false
|
|
135
176
|
});
|
|
136
177
|
searchParams.searchFields = (0, _formApi.handleFilterRules)(((_searchParams2 = searchParams) === null || _searchParams2 === void 0 ? void 0 : _searchParams2.searchFields) || [], {
|
|
137
178
|
filterNullValue: true
|
|
138
179
|
});
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
180
|
+
config.params = (0, _extends2["default"])({}, params, searchParams);
|
|
181
|
+
_context3.next = 11;
|
|
182
|
+
return this.request.get("search", config);
|
|
183
|
+
case 11:
|
|
142
184
|
res = _context3.sent;
|
|
143
|
-
start = Date.now();
|
|
144
185
|
(0, _formApi.assembleAssociationField)(res.data, res.refs);
|
|
145
|
-
console.debug("form.search:"
|
|
186
|
+
console.debug("form.search:", res);
|
|
146
187
|
return _context3.abrupt("return", res);
|
|
147
|
-
case
|
|
188
|
+
case 15:
|
|
148
189
|
case "end":
|
|
149
190
|
return _context3.stop();
|
|
150
191
|
}
|
|
151
192
|
}, _callee3, this);
|
|
152
193
|
}));
|
|
153
|
-
function search(
|
|
194
|
+
function search(_x5) {
|
|
154
195
|
return _search.apply(this, arguments);
|
|
155
196
|
}
|
|
156
197
|
return search;
|
|
157
198
|
}();
|
|
158
199
|
_proto.getById = /*#__PURE__*/function () {
|
|
159
200
|
var _getById = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(id, options) {
|
|
160
|
-
var res
|
|
201
|
+
var res;
|
|
161
202
|
return _regenerator["default"].wrap(function _callee4$(_context4) {
|
|
162
203
|
while (1) switch (_context4.prev = _context4.next) {
|
|
163
204
|
case 0:
|
|
@@ -165,17 +206,16 @@ var RestFormApi = exports.RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
|
165
206
|
return _RestApi.prototype.getById.call(this, id, options);
|
|
166
207
|
case 2:
|
|
167
208
|
res = _context4.sent;
|
|
168
|
-
start = Date.now();
|
|
169
209
|
(0, _formApi.assembleAssociationField)(res.data, res.refs);
|
|
170
|
-
console.debug("
|
|
210
|
+
console.debug("form.getById:", res);
|
|
171
211
|
return _context4.abrupt("return", res);
|
|
172
|
-
case
|
|
212
|
+
case 6:
|
|
173
213
|
case "end":
|
|
174
214
|
return _context4.stop();
|
|
175
215
|
}
|
|
176
216
|
}, _callee4, this);
|
|
177
217
|
}));
|
|
178
|
-
function getById(
|
|
218
|
+
function getById(_x6, _x7) {
|
|
179
219
|
return _getById.apply(this, arguments);
|
|
180
220
|
}
|
|
181
221
|
return getById;
|
|
@@ -192,7 +232,7 @@ var RestFormApi = exports.RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
|
192
232
|
}
|
|
193
233
|
}, _callee5, this);
|
|
194
234
|
}));
|
|
195
|
-
function save(
|
|
235
|
+
function save(_x8, _x9) {
|
|
196
236
|
return _save.apply(this, arguments);
|
|
197
237
|
}
|
|
198
238
|
return save;
|
|
@@ -209,7 +249,7 @@ var RestFormApi = exports.RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
|
209
249
|
}
|
|
210
250
|
}, _callee6, this);
|
|
211
251
|
}));
|
|
212
|
-
function create(
|
|
252
|
+
function create(_x10, _x11) {
|
|
213
253
|
return _create.apply(this, arguments);
|
|
214
254
|
}
|
|
215
255
|
return create;
|
|
@@ -226,7 +266,7 @@ var RestFormApi = exports.RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
|
226
266
|
}
|
|
227
267
|
}, _callee7, this);
|
|
228
268
|
}));
|
|
229
|
-
function update(
|
|
269
|
+
function update(_x12, _x13, _x14) {
|
|
230
270
|
return _update.apply(this, arguments);
|
|
231
271
|
}
|
|
232
272
|
return update;
|
|
@@ -243,7 +283,7 @@ var RestFormApi = exports.RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
|
243
283
|
}
|
|
244
284
|
}, _callee8, this);
|
|
245
285
|
}));
|
|
246
|
-
function serviceUpdate(
|
|
286
|
+
function serviceUpdate(_x15, _x16) {
|
|
247
287
|
return _serviceUpdate.apply(this, arguments);
|
|
248
288
|
}
|
|
249
289
|
return serviceUpdate;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { BaseType, FilterRule, Refs } from "./rest-api";
|
|
2
2
|
export declare function convertSaveData(data: any): any;
|
|
3
|
+
export declare function handleEntityLabel(data: BaseType | BaseType[]): void;
|
|
4
|
+
export declare function dataToLabel(value: any): any;
|
|
3
5
|
export declare function assembleAssociationFieldV2(data: BaseType | BaseType[], refs?: Refs): void;
|
|
4
6
|
export declare function assembleAssociationFieldDataV2(data: BaseType | BaseType[], dataMap: Map<string, BaseType>): void;
|
|
5
7
|
export declare function assembleAssociationField(data: BaseType | BaseType[], refs?: Refs): void;
|
|
@@ -6,6 +6,8 @@ exports.assembleAssociationField = assembleAssociationField;
|
|
|
6
6
|
exports.assembleAssociationFieldDataV2 = assembleAssociationFieldDataV2;
|
|
7
7
|
exports.assembleAssociationFieldV2 = assembleAssociationFieldV2;
|
|
8
8
|
exports.convertSaveData = convertSaveData;
|
|
9
|
+
exports.dataToLabel = dataToLabel;
|
|
10
|
+
exports.handleEntityLabel = handleEntityLabel;
|
|
9
11
|
exports.handleFilterRules = handleFilterRules;
|
|
10
12
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
13
|
var _data = require("../data");
|
|
@@ -16,40 +18,85 @@ function convertSaveData(data) {
|
|
|
16
18
|
if (!data) return data;
|
|
17
19
|
return JSON.parse(JSON.stringify(data, function (key, value) {
|
|
18
20
|
if (key == "parent") {
|
|
19
|
-
|
|
21
|
+
var id = value === null || value === void 0 ? void 0 : value.id;
|
|
22
|
+
return id ? {
|
|
23
|
+
id: id
|
|
24
|
+
} : undefined;
|
|
20
25
|
}
|
|
21
26
|
return value;
|
|
22
27
|
}));
|
|
23
28
|
}
|
|
24
29
|
function getDataKey(data) {
|
|
25
|
-
var
|
|
26
|
-
if (data
|
|
30
|
+
var _data$form, _data$form2;
|
|
31
|
+
if (!data) {
|
|
32
|
+
return "undefined";
|
|
33
|
+
}
|
|
34
|
+
var key = (_data$form = data.form) === null || _data$form === void 0 ? void 0 : _data$form.id;
|
|
35
|
+
if ((_data$form2 = data.form) !== null && _data$form2 !== void 0 && _data$form2.fieldId) {
|
|
27
36
|
key += "." + data.form.fieldId;
|
|
28
37
|
}
|
|
29
38
|
return key + "." + data.id;
|
|
30
39
|
}
|
|
40
|
+
function handleEntityLabel(data) {
|
|
41
|
+
if (!Array.isArray(data)) {
|
|
42
|
+
data = [data];
|
|
43
|
+
}
|
|
44
|
+
for (var _iterator = _createForOfIteratorHelperLoose(data), _step; !(_step = _iterator()).done;) {
|
|
45
|
+
var _item$form;
|
|
46
|
+
var item = _step.value;
|
|
47
|
+
var labelField = (_item$form = item.form) === null || _item$form === void 0 ? void 0 : _item$form.labelField;
|
|
48
|
+
if (labelField) {
|
|
49
|
+
// @ts-ignore
|
|
50
|
+
var value = item[labelField];
|
|
51
|
+
item.label = dataToLabel(value);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
function dataToLabel(value) {
|
|
56
|
+
if (value == null) {
|
|
57
|
+
return "";
|
|
58
|
+
}
|
|
59
|
+
if (Array.isArray(value)) {
|
|
60
|
+
return value.map(dataToLabel).filter(function (value) {
|
|
61
|
+
return !!value;
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
if (typeof value == "object") {
|
|
65
|
+
return (value === null || value === void 0 ? void 0 : value.label) || (value === null || value === void 0 ? void 0 : value.id) || value.label || "";
|
|
66
|
+
}
|
|
67
|
+
if (typeof value == "string") {
|
|
68
|
+
return value;
|
|
69
|
+
}
|
|
70
|
+
if (typeof value == "number") {
|
|
71
|
+
return value;
|
|
72
|
+
}
|
|
73
|
+
return (value === null || value === void 0 ? void 0 : value.id) || value.value || value;
|
|
74
|
+
}
|
|
31
75
|
function assembleAssociationFieldV2(data, refs) {
|
|
32
76
|
if (!data || !refs) return;
|
|
33
77
|
var dataMap = new Map();
|
|
34
|
-
for (var
|
|
35
|
-
var ref =
|
|
36
|
-
for (var
|
|
37
|
-
var datum =
|
|
38
|
-
|
|
39
|
-
|
|
78
|
+
for (var _iterator2 = _createForOfIteratorHelperLoose(refs), _step2; !(_step2 = _iterator2()).done;) {
|
|
79
|
+
var ref = _step2.value;
|
|
80
|
+
for (var _iterator4 = _createForOfIteratorHelperLoose(ref.data), _step4; !(_step4 = _iterator4()).done;) {
|
|
81
|
+
var datum = _step4.value;
|
|
82
|
+
if (datum) {
|
|
83
|
+
var key = getDataKey(datum);
|
|
84
|
+
dataMap.set(key, datum);
|
|
85
|
+
}
|
|
40
86
|
}
|
|
41
87
|
}
|
|
42
88
|
|
|
43
89
|
//组装refs的关联属性
|
|
44
|
-
for (var
|
|
45
|
-
var item =
|
|
46
|
-
for (var _i2 = 0, _Object$
|
|
47
|
-
var _key = _Object$
|
|
90
|
+
for (var _iterator3 = _createForOfIteratorHelperLoose(dataMap.values()), _step3; !(_step3 = _iterator3()).done;) {
|
|
91
|
+
var item = _step3.value;
|
|
92
|
+
for (var _i2 = 0, _Object$keys2 = Object.keys(item); _i2 < _Object$keys2.length; _i2++) {
|
|
93
|
+
var _key = _Object$keys2[_i2];
|
|
48
94
|
// @ts-ignore
|
|
49
95
|
var value = item[_key];
|
|
50
96
|
assembleAssociationFieldDataV2(value, dataMap);
|
|
51
97
|
}
|
|
52
98
|
}
|
|
99
|
+
handleEntityLabel([].concat(dataMap.values()));
|
|
53
100
|
function loopAssembleAssociation(value) {
|
|
54
101
|
if (Array.isArray(value)) {
|
|
55
102
|
value.forEach(function (item) {
|
|
@@ -57,125 +104,49 @@ function assembleAssociationFieldV2(data, refs) {
|
|
|
57
104
|
});
|
|
58
105
|
} else if (value !== null && value !== void 0 && value.id) {
|
|
59
106
|
assembleAssociationFieldDataV2(value, dataMap);
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
107
|
+
for (var _i = 0, _Object$keys = Object.keys(value); _i < _Object$keys.length; _i++) {
|
|
108
|
+
var key = _Object$keys[_i];
|
|
109
|
+
// @ts-ignore
|
|
110
|
+
var subValues = value[key];
|
|
63
111
|
if (typeof subValues == "object") {
|
|
112
|
+
if (key == "parent") {
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
64
115
|
loopAssembleAssociation(subValues);
|
|
65
116
|
}
|
|
66
117
|
}
|
|
67
118
|
}
|
|
68
119
|
}
|
|
69
120
|
loopAssembleAssociation(data);
|
|
121
|
+
handleEntityLabel(data);
|
|
70
122
|
}
|
|
71
123
|
function assembleAssociationFieldDataV2(data, dataMap) {
|
|
72
124
|
if (data == null) {
|
|
73
125
|
return;
|
|
74
126
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
var key = getDataKey(data);
|
|
84
|
-
var value = dataMap.get(key);
|
|
85
|
-
if (value) {
|
|
86
|
-
Object.assign(data, value);
|
|
127
|
+
try {
|
|
128
|
+
if (Array.isArray(data)) {
|
|
129
|
+
data.forEach(function (item) {
|
|
130
|
+
return assembleAssociationFieldDataV2(item, dataMap);
|
|
131
|
+
});
|
|
132
|
+
} else {
|
|
133
|
+
var _data$form3;
|
|
134
|
+
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) {
|
|
87
135
|
delete data._load;
|
|
136
|
+
var key = getDataKey(data);
|
|
137
|
+
var value = dataMap.get(key);
|
|
138
|
+
if (value) {
|
|
139
|
+
Object.assign(data, value);
|
|
140
|
+
delete data._load;
|
|
141
|
+
}
|
|
88
142
|
}
|
|
89
143
|
}
|
|
144
|
+
} catch (e) {
|
|
145
|
+
console.log("装配对象失败", data, dataMap);
|
|
90
146
|
}
|
|
91
147
|
}
|
|
92
148
|
function assembleAssociationField(data, refs) {
|
|
93
149
|
assembleAssociationFieldV2(data, refs);
|
|
94
|
-
return;
|
|
95
|
-
if (!data || !refs) return;
|
|
96
|
-
var fieldIdDataMap = new Map();
|
|
97
|
-
for (var _iterator4 = _createForOfIteratorHelperLoose(refs), _step4; !(_step4 = _iterator4()).done;) {
|
|
98
|
-
var ref = _step4.value;
|
|
99
|
-
var dataMap = new Map();
|
|
100
|
-
for (var _iterator7 = _createForOfIteratorHelperLoose(ref.data), _step7; !(_step7 = _iterator7()).done;) {
|
|
101
|
-
var datum = _step7.value;
|
|
102
|
-
dataMap.set(datum.id, datum);
|
|
103
|
-
}
|
|
104
|
-
for (var _iterator8 = _createForOfIteratorHelperLoose(ref.fieldIds), _step8; !(_step8 = _iterator8()).done;) {
|
|
105
|
-
var fieldId = _step8.value;
|
|
106
|
-
fieldIdDataMap.set(fieldId + "Id", dataMap);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
//组装refs的关联属性
|
|
110
|
-
for (var _iterator5 = _createForOfIteratorHelperLoose(refs), _step5; !(_step5 = _iterator5()).done;) {
|
|
111
|
-
var _ref = _step5.value;
|
|
112
|
-
var key = _ref.form.id;
|
|
113
|
-
if (_ref.form.fieldId) {
|
|
114
|
-
key += "." + _ref.form.fieldId;
|
|
115
|
-
}
|
|
116
|
-
assembleAssociationFieldValue(_ref.data, fieldIdDataMap, key);
|
|
117
|
-
}
|
|
118
|
-
function loopAssembleAssociation(values) {
|
|
119
|
-
if (!Array.isArray(values)) {
|
|
120
|
-
if (values !== null && values !== void 0 && values.id) {
|
|
121
|
-
loopAssembleAssociation([values]);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
if (Array.isArray(values)) {
|
|
125
|
-
var _values$;
|
|
126
|
-
if ((_values$ = values[0]) !== null && _values$ !== void 0 && _values$.id) {
|
|
127
|
-
assembleAssociationFieldValue(values, fieldIdDataMap);
|
|
128
|
-
//处理子表
|
|
129
|
-
for (var _iterator6 = _createForOfIteratorHelperLoose(values), _step6; !(_step6 = _iterator6()).done;) {
|
|
130
|
-
var value = _step6.value;
|
|
131
|
-
for (var _i3 = 0, _Object$values2 = Object.values(value); _i3 < _Object$values2.length; _i3++) {
|
|
132
|
-
var subValues = _Object$values2[_i3];
|
|
133
|
-
if (Array.isArray(subValues)) {
|
|
134
|
-
loopAssembleAssociation(subValues);
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
loopAssembleAssociation(data);
|
|
142
|
-
}
|
|
143
|
-
function assembleAssociationFieldValue(data, fieldIdDataMap, prefixKey) {
|
|
144
|
-
var arrayData = [];
|
|
145
|
-
if (Array.isArray(data)) {
|
|
146
|
-
arrayData = data;
|
|
147
|
-
} else if (typeof data == "object") {
|
|
148
|
-
arrayData = [data];
|
|
149
|
-
}
|
|
150
|
-
for (var _iterator9 = _createForOfIteratorHelperLoose(arrayData), _step9; !(_step9 = _iterator9()).done;) {
|
|
151
|
-
var item = _step9.value;
|
|
152
|
-
var _loop = function _loop() {
|
|
153
|
-
var fieldIdName = _Object$keys2[_i4];
|
|
154
|
-
var fieldIdKey = fieldIdName;
|
|
155
|
-
if (prefixKey) {
|
|
156
|
-
fieldIdKey = prefixKey + "." + fieldIdName;
|
|
157
|
-
}
|
|
158
|
-
var dataMap = fieldIdDataMap.get(fieldIdKey);
|
|
159
|
-
if (dataMap) {
|
|
160
|
-
var fieldIdValue = item[fieldIdName];
|
|
161
|
-
var fieldValue = null;
|
|
162
|
-
if (Array.isArray(fieldIdValue)) {
|
|
163
|
-
// @ts-ignore
|
|
164
|
-
fieldValue = fieldIdValue.map(function (id) {
|
|
165
|
-
return dataMap.get(id);
|
|
166
|
-
}).filter(function (v) {
|
|
167
|
-
return !!v;
|
|
168
|
-
});
|
|
169
|
-
} else if (typeof fieldIdValue == "string") {
|
|
170
|
-
fieldValue = dataMap.get(fieldIdValue);
|
|
171
|
-
}
|
|
172
|
-
item[fieldIdName.slice(0, -2)] = fieldValue;
|
|
173
|
-
}
|
|
174
|
-
};
|
|
175
|
-
for (var _i4 = 0, _Object$keys2 = Object.keys(item); _i4 < _Object$keys2.length; _i4++) {
|
|
176
|
-
_loop();
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
150
|
}
|
|
180
151
|
function handleFilterRules(filters, options) {
|
|
181
152
|
var filterNullValue = options.filterNullValue;
|
package/lib/utils/api/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { OneResult } from "./rest-api";
|
|
2
1
|
export { RestApi } from "./rest-api";
|
|
3
|
-
|
|
2
|
+
export { getFormApi, RestFormApi } from "./form-api";
|
|
3
|
+
export { getSchema } from "./schema-api";
|
|
4
4
|
export { loadUserInfo } from "./user-info";
|
|
5
|
-
export
|
|
5
|
+
export * as files from "./file-api";
|
|
6
|
+
export * as scrips from "./script-api";
|
|
6
7
|
export declare const apiRequest: import("axios").AxiosInstance;
|
|
7
|
-
export declare
|
|
8
|
-
export declare function getFormApi(formId: string, fieldId?: string, mock?: boolean): Promise<RestFormApi<any>>;
|
|
8
|
+
export declare const request: <T = any, R = import("axios").AxiosResponse<T, any>, D = any>(config: import("axios").AxiosRequestConfig<D>) => Promise<R>;
|
|
9
9
|
export declare function onFulfilled(res: any): any;
|
|
10
10
|
export declare function onRejected(error: any): any;
|
package/lib/utils/api/index.js
CHANGED
|
@@ -2,22 +2,26 @@
|
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
exports.__esModule = true;
|
|
5
|
-
exports.apiRequest = exports.RestFormApi = exports.RestApi = void 0;
|
|
6
|
-
exports.getFormApi = getFormApi;
|
|
7
|
-
exports.getSchema = getSchema;
|
|
8
|
-
exports.loadUserInfo = void 0;
|
|
5
|
+
exports.loadUserInfo = exports.getSchema = exports.getFormApi = exports.files = exports.apiRequest = exports.RestFormApi = exports.RestApi = void 0;
|
|
9
6
|
exports.onFulfilled = onFulfilled;
|
|
10
7
|
exports.onRejected = onRejected;
|
|
11
|
-
|
|
12
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
8
|
+
exports.scrips = exports.request = void 0;
|
|
13
9
|
var _axios = _interopRequireDefault(require("axios"));
|
|
14
|
-
var _cache = require("../cache");
|
|
15
10
|
var _restApi = require("./rest-api");
|
|
16
11
|
exports.RestApi = _restApi.RestApi;
|
|
17
|
-
var _userInfo = require("./user-info");
|
|
18
|
-
exports.loadUserInfo = _userInfo.loadUserInfo;
|
|
19
12
|
var _formApi = require("./form-api");
|
|
13
|
+
exports.getFormApi = _formApi.getFormApi;
|
|
20
14
|
exports.RestFormApi = _formApi.RestFormApi;
|
|
15
|
+
var _schemaApi = require("./schema-api");
|
|
16
|
+
exports.getSchema = _schemaApi.getSchema;
|
|
17
|
+
var _userInfo = require("./user-info");
|
|
18
|
+
exports.loadUserInfo = _userInfo.loadUserInfo;
|
|
19
|
+
var _files = _interopRequireWildcard(require("./file-api"));
|
|
20
|
+
exports.files = _files;
|
|
21
|
+
var _scrips = _interopRequireWildcard(require("./script-api"));
|
|
22
|
+
exports.scrips = _scrips;
|
|
23
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
24
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
|
21
25
|
var apiRequest = exports.apiRequest = _axios["default"].create({
|
|
22
26
|
baseURL: "/api",
|
|
23
27
|
// 基础URL
|
|
@@ -28,69 +32,7 @@ var apiRequest = exports.apiRequest = _axios["default"].create({
|
|
|
28
32
|
}
|
|
29
33
|
});
|
|
30
34
|
apiRequest.interceptors.response.use(onFulfilled, onRejected);
|
|
31
|
-
|
|
32
|
-
return _getSchema.apply(this, arguments);
|
|
33
|
-
}
|
|
34
|
-
function _getSchema() {
|
|
35
|
-
_getSchema = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(pageId, mock) {
|
|
36
|
-
var key;
|
|
37
|
-
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
38
|
-
while (1) switch (_context.prev = _context.next) {
|
|
39
|
-
case 0:
|
|
40
|
-
if (typeof mock != "boolean") {
|
|
41
|
-
if (typeof window.__mock == "boolean") {
|
|
42
|
-
mock = window.__mock;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
key = mock ? pageId + "_mock" : pageId;
|
|
46
|
-
_context.next = 4;
|
|
47
|
-
return _cache.schema.getInstance(key, {
|
|
48
|
-
mock: mock,
|
|
49
|
-
pageId: pageId
|
|
50
|
-
});
|
|
51
|
-
case 4:
|
|
52
|
-
return _context.abrupt("return", _context.sent);
|
|
53
|
-
case 5:
|
|
54
|
-
case "end":
|
|
55
|
-
return _context.stop();
|
|
56
|
-
}
|
|
57
|
-
}, _callee);
|
|
58
|
-
}));
|
|
59
|
-
return _getSchema.apply(this, arguments);
|
|
60
|
-
}
|
|
61
|
-
function getFormApi(_x3, _x4, _x5) {
|
|
62
|
-
return _getFormApi.apply(this, arguments);
|
|
63
|
-
}
|
|
64
|
-
function _getFormApi() {
|
|
65
|
-
_getFormApi = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(formId, fieldId, mock) {
|
|
66
|
-
var key;
|
|
67
|
-
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
68
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
69
|
-
case 0:
|
|
70
|
-
if (typeof mock != "boolean") {
|
|
71
|
-
if (typeof window.__mock == "boolean") {
|
|
72
|
-
mock = window.__mock;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
key = [formId, fieldId, mock ? "mock" : ""].filter(function (key) {
|
|
76
|
-
return !!key;
|
|
77
|
-
}).join("_");
|
|
78
|
-
_context2.next = 4;
|
|
79
|
-
return _cache.formApi.getInstance(key, {
|
|
80
|
-
mock: mock,
|
|
81
|
-
fieldId: fieldId,
|
|
82
|
-
formId: formId
|
|
83
|
-
});
|
|
84
|
-
case 4:
|
|
85
|
-
return _context2.abrupt("return", _context2.sent);
|
|
86
|
-
case 5:
|
|
87
|
-
case "end":
|
|
88
|
-
return _context2.stop();
|
|
89
|
-
}
|
|
90
|
-
}, _callee2);
|
|
91
|
-
}));
|
|
92
|
-
return _getFormApi.apply(this, arguments);
|
|
93
|
-
}
|
|
35
|
+
var request = exports.request = apiRequest.request;
|
|
94
36
|
function onFulfilled(res) {
|
|
95
37
|
return res.data;
|
|
96
38
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AxiosInstance, AxiosRequestConfig } from "axios";
|
|
2
|
+
export declare type ValueType = "value" | "field" | "express";
|
|
2
3
|
export interface RestApiOptions {
|
|
3
4
|
/**
|
|
4
5
|
* 超时时间
|
|
@@ -12,9 +13,10 @@ export interface RestApiOptions {
|
|
|
12
13
|
}
|
|
13
14
|
export interface FilterRule {
|
|
14
15
|
connector?: "and" | "or";
|
|
15
|
-
key
|
|
16
|
+
key?: string;
|
|
16
17
|
operator?: OperatorType;
|
|
17
|
-
|
|
18
|
+
valueType?: ValueType;
|
|
19
|
+
value?: any;
|
|
18
20
|
rules?: FilterRule[];
|
|
19
21
|
}
|
|
20
22
|
export declare type OperatorType = "eq" | "ne" | "gt" | "goe" | "lt" | "loe" | "like" | "notLike" | "in" | "notIn" | "isNull" | "isNotNull" | "between" | "notBetween";
|
|
@@ -87,6 +89,7 @@ export interface BaseType {
|
|
|
87
89
|
id: string;
|
|
88
90
|
fieldId?: string;
|
|
89
91
|
label: string;
|
|
92
|
+
labelField: string;
|
|
90
93
|
};
|
|
91
94
|
_load?: boolean;
|
|
92
95
|
}
|
|
@@ -95,6 +98,7 @@ export interface BaseType {
|
|
|
95
98
|
*/
|
|
96
99
|
export interface BaseResult<DataType> {
|
|
97
100
|
success: boolean;
|
|
101
|
+
requestId?: string;
|
|
98
102
|
message?: string;
|
|
99
103
|
refs?: Refs;
|
|
100
104
|
}
|