@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
package/es/index.js
CHANGED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AxiosProgressEvent } from "axios";
|
|
2
|
+
export declare function upload(file: any, options?: {
|
|
3
|
+
onProgress: (evt: AxiosProgressEvent) => void;
|
|
4
|
+
onFinished: () => void;
|
|
5
|
+
onError: (e: any) => void;
|
|
6
|
+
}): Promise<void>;
|
|
7
|
+
export declare function update(file: any): Promise<void>;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
3
|
+
import { apiRequest } from "./index";
|
|
4
|
+
export function upload(_x, _x2) {
|
|
5
|
+
return _upload.apply(this, arguments);
|
|
6
|
+
}
|
|
7
|
+
function _upload() {
|
|
8
|
+
_upload = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(file, options) {
|
|
9
|
+
var res, ossFile, _options$onFinished, _options$onError;
|
|
10
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
11
|
+
while (1) switch (_context.prev = _context.next) {
|
|
12
|
+
case 0:
|
|
13
|
+
if (file) {
|
|
14
|
+
_context.next = 2;
|
|
15
|
+
break;
|
|
16
|
+
}
|
|
17
|
+
return _context.abrupt("return");
|
|
18
|
+
case 2:
|
|
19
|
+
_context.next = 4;
|
|
20
|
+
return apiRequest.post("files/signature", {
|
|
21
|
+
size: file.size,
|
|
22
|
+
name: file.name,
|
|
23
|
+
type: file.type
|
|
24
|
+
}, {
|
|
25
|
+
params: {
|
|
26
|
+
type: "oss"
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
case 4:
|
|
30
|
+
res = _context.sent;
|
|
31
|
+
ossFile = res.data;
|
|
32
|
+
file.id = ossFile.id;
|
|
33
|
+
file.url = ossFile.url;
|
|
34
|
+
file.percent = 0;
|
|
35
|
+
file.status = "uploading";
|
|
36
|
+
_context.prev = 10;
|
|
37
|
+
_context.next = 13;
|
|
38
|
+
return apiRequest.put(ossFile.uploadUrl, file, {
|
|
39
|
+
headers: {
|
|
40
|
+
'Content-Type': file.type
|
|
41
|
+
},
|
|
42
|
+
onUploadProgress: function onUploadProgress(evt) {
|
|
43
|
+
var _options$onProgress;
|
|
44
|
+
if (evt.total) {
|
|
45
|
+
file.percent = Math.round(evt.loaded * 100 / evt.total);
|
|
46
|
+
}
|
|
47
|
+
options === null || options === void 0 ? void 0 : (_options$onProgress = options.onProgress) === null || _options$onProgress === void 0 ? void 0 : _options$onProgress.call(options, evt);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
case 13:
|
|
51
|
+
options === null || options === void 0 ? void 0 : (_options$onFinished = options.onFinished) === null || _options$onFinished === void 0 ? void 0 : _options$onFinished.call(options);
|
|
52
|
+
_context.next = 19;
|
|
53
|
+
break;
|
|
54
|
+
case 16:
|
|
55
|
+
_context.prev = 16;
|
|
56
|
+
_context.t0 = _context["catch"](10);
|
|
57
|
+
options === null || options === void 0 ? void 0 : (_options$onError = options.onError) === null || _options$onError === void 0 ? void 0 : _options$onError.call(options, _context.t0);
|
|
58
|
+
case 19:
|
|
59
|
+
case "end":
|
|
60
|
+
return _context.stop();
|
|
61
|
+
}
|
|
62
|
+
}, _callee, null, [[10, 16]]);
|
|
63
|
+
}));
|
|
64
|
+
return _upload.apply(this, arguments);
|
|
65
|
+
}
|
|
66
|
+
export function update(_x3) {
|
|
67
|
+
return _update.apply(this, arguments);
|
|
68
|
+
}
|
|
69
|
+
function _update() {
|
|
70
|
+
_update = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(file) {
|
|
71
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
72
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
73
|
+
case 0:
|
|
74
|
+
_context2.next = 2;
|
|
75
|
+
return apiRequest.post("files/update", {
|
|
76
|
+
id: file.id,
|
|
77
|
+
fileName: file.fileName
|
|
78
|
+
});
|
|
79
|
+
case 2:
|
|
80
|
+
case "end":
|
|
81
|
+
return _context2.stop();
|
|
82
|
+
}
|
|
83
|
+
}, _callee2);
|
|
84
|
+
}));
|
|
85
|
+
return _update.apply(this, arguments);
|
|
86
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { BaseRequestOptions, ManyResult, OneResult, RestApi, RestSearchParams } from "./rest-api";
|
|
2
2
|
import { AxiosRequestConfig } from "axios";
|
|
3
|
+
export declare function getFormApi(formId: string, fieldId?: string, mock?: boolean): Promise<RestFormApi<any>>;
|
|
3
4
|
export declare class RestFormApi<DataType> extends RestApi<DataType> {
|
|
4
5
|
private readonly formId;
|
|
5
6
|
private readonly fieldId?;
|
package/es/utils/api/form-api.js
CHANGED
|
@@ -1,9 +1,44 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
|
|
3
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
3
4
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
4
5
|
import { RestApi } from "./rest-api";
|
|
5
6
|
import { getSchema } from "./index";
|
|
6
7
|
import { assembleAssociationField, convertSaveData, handleFilterRules } from "./form-api.utils";
|
|
8
|
+
import { formApi } from "../cache";
|
|
9
|
+
export function getFormApi(_x, _x2, _x3) {
|
|
10
|
+
return _getFormApi.apply(this, arguments);
|
|
11
|
+
}
|
|
12
|
+
function _getFormApi() {
|
|
13
|
+
_getFormApi = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(formId, fieldId, mock) {
|
|
14
|
+
var key;
|
|
15
|
+
return _regeneratorRuntime.wrap(function _callee9$(_context9) {
|
|
16
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
17
|
+
case 0:
|
|
18
|
+
if (typeof mock != "boolean") {
|
|
19
|
+
if (typeof window.__mock == "boolean") {
|
|
20
|
+
mock = window.__mock;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
key = [formId, fieldId, mock ? "mock" : ""].filter(function (key) {
|
|
24
|
+
return !!key;
|
|
25
|
+
}).join("_");
|
|
26
|
+
_context9.next = 4;
|
|
27
|
+
return formApi.getInstance(key, {
|
|
28
|
+
mock: mock,
|
|
29
|
+
fieldId: fieldId,
|
|
30
|
+
formId: formId
|
|
31
|
+
});
|
|
32
|
+
case 4:
|
|
33
|
+
return _context9.abrupt("return", _context9.sent);
|
|
34
|
+
case 5:
|
|
35
|
+
case "end":
|
|
36
|
+
return _context9.stop();
|
|
37
|
+
}
|
|
38
|
+
}, _callee9);
|
|
39
|
+
}));
|
|
40
|
+
return _getFormApi.apply(this, arguments);
|
|
41
|
+
}
|
|
7
42
|
export var RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
8
43
|
function RestFormApi(formId, fieldId, mock) {
|
|
9
44
|
var _this;
|
|
@@ -88,7 +123,9 @@ export var RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
|
88
123
|
return this.initialize();
|
|
89
124
|
case 2:
|
|
90
125
|
config.params = config.params || {};
|
|
91
|
-
|
|
126
|
+
if (__mock) {
|
|
127
|
+
config.params.description = "" + this.title;
|
|
128
|
+
}
|
|
92
129
|
config.params.formId = this.formId;
|
|
93
130
|
if (this.fieldId) {
|
|
94
131
|
config.params.fieldId = this.fieldId;
|
|
@@ -102,7 +139,7 @@ export var RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
|
102
139
|
}
|
|
103
140
|
}, _callee2, this);
|
|
104
141
|
}));
|
|
105
|
-
function handleRequestConfig(
|
|
142
|
+
function handleRequestConfig(_x4) {
|
|
106
143
|
return _handleRequestConfig.apply(this, arguments);
|
|
107
144
|
}
|
|
108
145
|
return handleRequestConfig;
|
|
@@ -110,49 +147,52 @@ export var RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
|
110
147
|
_proto.search = /*#__PURE__*/function () {
|
|
111
148
|
var _search = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(searchParams) {
|
|
112
149
|
var _searchParams, _searchParams2;
|
|
113
|
-
var config, res
|
|
150
|
+
var params, config, res;
|
|
114
151
|
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
115
152
|
while (1) switch (_context3.prev = _context3.next) {
|
|
116
153
|
case 0:
|
|
117
154
|
searchParams = searchParams || {};
|
|
155
|
+
params = {
|
|
156
|
+
formId: this.formId,
|
|
157
|
+
fieldId: this.fieldId
|
|
158
|
+
};
|
|
159
|
+
if (__mock) {
|
|
160
|
+
params.description = "" + this.title;
|
|
161
|
+
}
|
|
118
162
|
config = {
|
|
119
|
-
params:
|
|
120
|
-
description: this.title + "\u67E5\u8BE2",
|
|
121
|
-
formId: this.formId,
|
|
122
|
-
fieldId: this.fieldId
|
|
123
|
-
}
|
|
163
|
+
params: params
|
|
124
164
|
};
|
|
125
|
-
_context3.next =
|
|
165
|
+
_context3.next = 6;
|
|
126
166
|
return this.handleRequestConfig(config);
|
|
127
|
-
case
|
|
167
|
+
case 6:
|
|
128
168
|
searchParams.filterRules = handleFilterRules(((_searchParams = searchParams) === null || _searchParams === void 0 ? void 0 : _searchParams.filterRules) || [], {
|
|
129
169
|
filterNullValue: false
|
|
130
170
|
});
|
|
131
171
|
searchParams.searchFields = handleFilterRules(((_searchParams2 = searchParams) === null || _searchParams2 === void 0 ? void 0 : _searchParams2.searchFields) || [], {
|
|
132
172
|
filterNullValue: true
|
|
133
173
|
});
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
174
|
+
config.params = _extends({}, params, searchParams);
|
|
175
|
+
_context3.next = 11;
|
|
176
|
+
return this.request.get("search", config);
|
|
177
|
+
case 11:
|
|
137
178
|
res = _context3.sent;
|
|
138
|
-
start = Date.now();
|
|
139
179
|
assembleAssociationField(res.data, res.refs);
|
|
140
|
-
console.debug("form.search:"
|
|
180
|
+
console.debug("form.search:", res);
|
|
141
181
|
return _context3.abrupt("return", res);
|
|
142
|
-
case
|
|
182
|
+
case 15:
|
|
143
183
|
case "end":
|
|
144
184
|
return _context3.stop();
|
|
145
185
|
}
|
|
146
186
|
}, _callee3, this);
|
|
147
187
|
}));
|
|
148
|
-
function search(
|
|
188
|
+
function search(_x5) {
|
|
149
189
|
return _search.apply(this, arguments);
|
|
150
190
|
}
|
|
151
191
|
return search;
|
|
152
192
|
}();
|
|
153
193
|
_proto.getById = /*#__PURE__*/function () {
|
|
154
194
|
var _getById = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(id, options) {
|
|
155
|
-
var res
|
|
195
|
+
var res;
|
|
156
196
|
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
157
197
|
while (1) switch (_context4.prev = _context4.next) {
|
|
158
198
|
case 0:
|
|
@@ -160,17 +200,16 @@ export var RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
|
160
200
|
return _RestApi.prototype.getById.call(this, id, options);
|
|
161
201
|
case 2:
|
|
162
202
|
res = _context4.sent;
|
|
163
|
-
start = Date.now();
|
|
164
203
|
assembleAssociationField(res.data, res.refs);
|
|
165
|
-
console.debug("
|
|
204
|
+
console.debug("form.getById:", res);
|
|
166
205
|
return _context4.abrupt("return", res);
|
|
167
|
-
case
|
|
206
|
+
case 6:
|
|
168
207
|
case "end":
|
|
169
208
|
return _context4.stop();
|
|
170
209
|
}
|
|
171
210
|
}, _callee4, this);
|
|
172
211
|
}));
|
|
173
|
-
function getById(
|
|
212
|
+
function getById(_x6, _x7) {
|
|
174
213
|
return _getById.apply(this, arguments);
|
|
175
214
|
}
|
|
176
215
|
return getById;
|
|
@@ -187,7 +226,7 @@ export var RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
|
187
226
|
}
|
|
188
227
|
}, _callee5, this);
|
|
189
228
|
}));
|
|
190
|
-
function save(
|
|
229
|
+
function save(_x8, _x9) {
|
|
191
230
|
return _save.apply(this, arguments);
|
|
192
231
|
}
|
|
193
232
|
return save;
|
|
@@ -204,7 +243,7 @@ export var RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
|
204
243
|
}
|
|
205
244
|
}, _callee6, this);
|
|
206
245
|
}));
|
|
207
|
-
function create(
|
|
246
|
+
function create(_x10, _x11) {
|
|
208
247
|
return _create.apply(this, arguments);
|
|
209
248
|
}
|
|
210
249
|
return create;
|
|
@@ -221,7 +260,7 @@ export var RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
|
221
260
|
}
|
|
222
261
|
}, _callee7, this);
|
|
223
262
|
}));
|
|
224
|
-
function update(
|
|
263
|
+
function update(_x12, _x13, _x14) {
|
|
225
264
|
return _update.apply(this, arguments);
|
|
226
265
|
}
|
|
227
266
|
return update;
|
|
@@ -238,7 +277,7 @@ export var RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
|
238
277
|
}
|
|
239
278
|
}, _callee8, this);
|
|
240
279
|
}));
|
|
241
|
-
function serviceUpdate(
|
|
280
|
+
function serviceUpdate(_x15, _x16) {
|
|
242
281
|
return _serviceUpdate.apply(this, arguments);
|
|
243
282
|
}
|
|
244
283
|
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;
|
|
@@ -7,40 +7,85 @@ export function convertSaveData(data) {
|
|
|
7
7
|
if (!data) return data;
|
|
8
8
|
return JSON.parse(JSON.stringify(data, function (key, value) {
|
|
9
9
|
if (key == "parent") {
|
|
10
|
-
|
|
10
|
+
var id = value === null || value === void 0 ? void 0 : value.id;
|
|
11
|
+
return id ? {
|
|
12
|
+
id: id
|
|
13
|
+
} : undefined;
|
|
11
14
|
}
|
|
12
15
|
return value;
|
|
13
16
|
}));
|
|
14
17
|
}
|
|
15
18
|
function getDataKey(data) {
|
|
16
|
-
var
|
|
17
|
-
if (data
|
|
19
|
+
var _data$form, _data$form2;
|
|
20
|
+
if (!data) {
|
|
21
|
+
return "undefined";
|
|
22
|
+
}
|
|
23
|
+
var key = (_data$form = data.form) === null || _data$form === void 0 ? void 0 : _data$form.id;
|
|
24
|
+
if ((_data$form2 = data.form) !== null && _data$form2 !== void 0 && _data$form2.fieldId) {
|
|
18
25
|
key += "." + data.form.fieldId;
|
|
19
26
|
}
|
|
20
27
|
return key + "." + data.id;
|
|
21
28
|
}
|
|
29
|
+
export function handleEntityLabel(data) {
|
|
30
|
+
if (!Array.isArray(data)) {
|
|
31
|
+
data = [data];
|
|
32
|
+
}
|
|
33
|
+
for (var _iterator = _createForOfIteratorHelperLoose(data), _step; !(_step = _iterator()).done;) {
|
|
34
|
+
var _item$form;
|
|
35
|
+
var item = _step.value;
|
|
36
|
+
var labelField = (_item$form = item.form) === null || _item$form === void 0 ? void 0 : _item$form.labelField;
|
|
37
|
+
if (labelField) {
|
|
38
|
+
// @ts-ignore
|
|
39
|
+
var value = item[labelField];
|
|
40
|
+
item.label = dataToLabel(value);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
export function dataToLabel(value) {
|
|
45
|
+
if (value == null) {
|
|
46
|
+
return "";
|
|
47
|
+
}
|
|
48
|
+
if (Array.isArray(value)) {
|
|
49
|
+
return value.map(dataToLabel).filter(function (value) {
|
|
50
|
+
return !!value;
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
if (typeof value == "object") {
|
|
54
|
+
return (value === null || value === void 0 ? void 0 : value.label) || (value === null || value === void 0 ? void 0 : value.id) || value.label || "";
|
|
55
|
+
}
|
|
56
|
+
if (typeof value == "string") {
|
|
57
|
+
return value;
|
|
58
|
+
}
|
|
59
|
+
if (typeof value == "number") {
|
|
60
|
+
return value;
|
|
61
|
+
}
|
|
62
|
+
return (value === null || value === void 0 ? void 0 : value.id) || value.value || value;
|
|
63
|
+
}
|
|
22
64
|
export function assembleAssociationFieldV2(data, refs) {
|
|
23
65
|
if (!data || !refs) return;
|
|
24
66
|
var dataMap = new Map();
|
|
25
|
-
for (var
|
|
26
|
-
var ref =
|
|
27
|
-
for (var
|
|
28
|
-
var datum =
|
|
29
|
-
|
|
30
|
-
|
|
67
|
+
for (var _iterator2 = _createForOfIteratorHelperLoose(refs), _step2; !(_step2 = _iterator2()).done;) {
|
|
68
|
+
var ref = _step2.value;
|
|
69
|
+
for (var _iterator4 = _createForOfIteratorHelperLoose(ref.data), _step4; !(_step4 = _iterator4()).done;) {
|
|
70
|
+
var datum = _step4.value;
|
|
71
|
+
if (datum) {
|
|
72
|
+
var key = getDataKey(datum);
|
|
73
|
+
dataMap.set(key, datum);
|
|
74
|
+
}
|
|
31
75
|
}
|
|
32
76
|
}
|
|
33
77
|
|
|
34
78
|
//组装refs的关联属性
|
|
35
|
-
for (var
|
|
36
|
-
var item =
|
|
37
|
-
for (var _i2 = 0, _Object$
|
|
38
|
-
var _key = _Object$
|
|
79
|
+
for (var _iterator3 = _createForOfIteratorHelperLoose(dataMap.values()), _step3; !(_step3 = _iterator3()).done;) {
|
|
80
|
+
var item = _step3.value;
|
|
81
|
+
for (var _i2 = 0, _Object$keys2 = Object.keys(item); _i2 < _Object$keys2.length; _i2++) {
|
|
82
|
+
var _key = _Object$keys2[_i2];
|
|
39
83
|
// @ts-ignore
|
|
40
84
|
var value = item[_key];
|
|
41
85
|
assembleAssociationFieldDataV2(value, dataMap);
|
|
42
86
|
}
|
|
43
87
|
}
|
|
88
|
+
handleEntityLabel([].concat(dataMap.values()));
|
|
44
89
|
function loopAssembleAssociation(value) {
|
|
45
90
|
if (Array.isArray(value)) {
|
|
46
91
|
value.forEach(function (item) {
|
|
@@ -48,125 +93,49 @@ export function assembleAssociationFieldV2(data, refs) {
|
|
|
48
93
|
});
|
|
49
94
|
} else if (value !== null && value !== void 0 && value.id) {
|
|
50
95
|
assembleAssociationFieldDataV2(value, dataMap);
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
96
|
+
for (var _i = 0, _Object$keys = Object.keys(value); _i < _Object$keys.length; _i++) {
|
|
97
|
+
var key = _Object$keys[_i];
|
|
98
|
+
// @ts-ignore
|
|
99
|
+
var subValues = value[key];
|
|
54
100
|
if (typeof subValues == "object") {
|
|
101
|
+
if (key == "parent") {
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
55
104
|
loopAssembleAssociation(subValues);
|
|
56
105
|
}
|
|
57
106
|
}
|
|
58
107
|
}
|
|
59
108
|
}
|
|
60
109
|
loopAssembleAssociation(data);
|
|
110
|
+
handleEntityLabel(data);
|
|
61
111
|
}
|
|
62
112
|
export function assembleAssociationFieldDataV2(data, dataMap) {
|
|
63
113
|
if (data == null) {
|
|
64
114
|
return;
|
|
65
115
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
var key = getDataKey(data);
|
|
75
|
-
var value = dataMap.get(key);
|
|
76
|
-
if (value) {
|
|
77
|
-
Object.assign(data, value);
|
|
116
|
+
try {
|
|
117
|
+
if (Array.isArray(data)) {
|
|
118
|
+
data.forEach(function (item) {
|
|
119
|
+
return assembleAssociationFieldDataV2(item, dataMap);
|
|
120
|
+
});
|
|
121
|
+
} else {
|
|
122
|
+
var _data$form3;
|
|
123
|
+
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) {
|
|
78
124
|
delete data._load;
|
|
125
|
+
var key = getDataKey(data);
|
|
126
|
+
var value = dataMap.get(key);
|
|
127
|
+
if (value) {
|
|
128
|
+
Object.assign(data, value);
|
|
129
|
+
delete data._load;
|
|
130
|
+
}
|
|
79
131
|
}
|
|
80
132
|
}
|
|
133
|
+
} catch (e) {
|
|
134
|
+
console.log("装配对象失败", data, dataMap);
|
|
81
135
|
}
|
|
82
136
|
}
|
|
83
137
|
export function assembleAssociationField(data, refs) {
|
|
84
138
|
assembleAssociationFieldV2(data, refs);
|
|
85
|
-
return;
|
|
86
|
-
if (!data || !refs) return;
|
|
87
|
-
var fieldIdDataMap = new Map();
|
|
88
|
-
for (var _iterator4 = _createForOfIteratorHelperLoose(refs), _step4; !(_step4 = _iterator4()).done;) {
|
|
89
|
-
var ref = _step4.value;
|
|
90
|
-
var dataMap = new Map();
|
|
91
|
-
for (var _iterator7 = _createForOfIteratorHelperLoose(ref.data), _step7; !(_step7 = _iterator7()).done;) {
|
|
92
|
-
var datum = _step7.value;
|
|
93
|
-
dataMap.set(datum.id, datum);
|
|
94
|
-
}
|
|
95
|
-
for (var _iterator8 = _createForOfIteratorHelperLoose(ref.fieldIds), _step8; !(_step8 = _iterator8()).done;) {
|
|
96
|
-
var fieldId = _step8.value;
|
|
97
|
-
fieldIdDataMap.set(fieldId + "Id", dataMap);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
//组装refs的关联属性
|
|
101
|
-
for (var _iterator5 = _createForOfIteratorHelperLoose(refs), _step5; !(_step5 = _iterator5()).done;) {
|
|
102
|
-
var _ref = _step5.value;
|
|
103
|
-
var key = _ref.form.id;
|
|
104
|
-
if (_ref.form.fieldId) {
|
|
105
|
-
key += "." + _ref.form.fieldId;
|
|
106
|
-
}
|
|
107
|
-
assembleAssociationFieldValue(_ref.data, fieldIdDataMap, key);
|
|
108
|
-
}
|
|
109
|
-
function loopAssembleAssociation(values) {
|
|
110
|
-
if (!Array.isArray(values)) {
|
|
111
|
-
if (values !== null && values !== void 0 && values.id) {
|
|
112
|
-
loopAssembleAssociation([values]);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
if (Array.isArray(values)) {
|
|
116
|
-
var _values$;
|
|
117
|
-
if ((_values$ = values[0]) !== null && _values$ !== void 0 && _values$.id) {
|
|
118
|
-
assembleAssociationFieldValue(values, fieldIdDataMap);
|
|
119
|
-
//处理子表
|
|
120
|
-
for (var _iterator6 = _createForOfIteratorHelperLoose(values), _step6; !(_step6 = _iterator6()).done;) {
|
|
121
|
-
var value = _step6.value;
|
|
122
|
-
for (var _i3 = 0, _Object$values2 = Object.values(value); _i3 < _Object$values2.length; _i3++) {
|
|
123
|
-
var subValues = _Object$values2[_i3];
|
|
124
|
-
if (Array.isArray(subValues)) {
|
|
125
|
-
loopAssembleAssociation(subValues);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
loopAssembleAssociation(data);
|
|
133
|
-
}
|
|
134
|
-
function assembleAssociationFieldValue(data, fieldIdDataMap, prefixKey) {
|
|
135
|
-
var arrayData = [];
|
|
136
|
-
if (Array.isArray(data)) {
|
|
137
|
-
arrayData = data;
|
|
138
|
-
} else if (typeof data == "object") {
|
|
139
|
-
arrayData = [data];
|
|
140
|
-
}
|
|
141
|
-
for (var _iterator9 = _createForOfIteratorHelperLoose(arrayData), _step9; !(_step9 = _iterator9()).done;) {
|
|
142
|
-
var item = _step9.value;
|
|
143
|
-
var _loop = function _loop() {
|
|
144
|
-
var fieldIdName = _Object$keys2[_i4];
|
|
145
|
-
var fieldIdKey = fieldIdName;
|
|
146
|
-
if (prefixKey) {
|
|
147
|
-
fieldIdKey = prefixKey + "." + fieldIdName;
|
|
148
|
-
}
|
|
149
|
-
var dataMap = fieldIdDataMap.get(fieldIdKey);
|
|
150
|
-
if (dataMap) {
|
|
151
|
-
var fieldIdValue = item[fieldIdName];
|
|
152
|
-
var fieldValue = null;
|
|
153
|
-
if (Array.isArray(fieldIdValue)) {
|
|
154
|
-
// @ts-ignore
|
|
155
|
-
fieldValue = fieldIdValue.map(function (id) {
|
|
156
|
-
return dataMap.get(id);
|
|
157
|
-
}).filter(function (v) {
|
|
158
|
-
return !!v;
|
|
159
|
-
});
|
|
160
|
-
} else if (typeof fieldIdValue == "string") {
|
|
161
|
-
fieldValue = dataMap.get(fieldIdValue);
|
|
162
|
-
}
|
|
163
|
-
item[fieldIdName.slice(0, -2)] = fieldValue;
|
|
164
|
-
}
|
|
165
|
-
};
|
|
166
|
-
for (var _i4 = 0, _Object$keys2 = Object.keys(item); _i4 < _Object$keys2.length; _i4++) {
|
|
167
|
-
_loop();
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
139
|
}
|
|
171
140
|
export function handleFilterRules(filters, options) {
|
|
172
141
|
var filterNullValue = options.filterNullValue;
|
package/es/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/es/utils/api/index.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
-
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
3
1
|
import axios from "axios";
|
|
4
|
-
import { formApi, schema } from "../cache";
|
|
5
2
|
export { RestApi } from "./rest-api";
|
|
3
|
+
export { getFormApi, RestFormApi } from "./form-api";
|
|
4
|
+
export { getSchema } from "./schema-api";
|
|
6
5
|
export { loadUserInfo } from "./user-info";
|
|
7
|
-
|
|
6
|
+
import * as _files from "./file-api";
|
|
7
|
+
export { _files as files };
|
|
8
|
+
import * as _scrips from "./script-api";
|
|
9
|
+
export { _scrips as scrips };
|
|
8
10
|
export var apiRequest = axios.create({
|
|
9
11
|
baseURL: "/api",
|
|
10
12
|
// 基础URL
|
|
@@ -15,69 +17,7 @@ export var apiRequest = axios.create({
|
|
|
15
17
|
}
|
|
16
18
|
});
|
|
17
19
|
apiRequest.interceptors.response.use(onFulfilled, onRejected);
|
|
18
|
-
export
|
|
19
|
-
return _getSchema.apply(this, arguments);
|
|
20
|
-
}
|
|
21
|
-
function _getSchema() {
|
|
22
|
-
_getSchema = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(pageId, mock) {
|
|
23
|
-
var key;
|
|
24
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
25
|
-
while (1) switch (_context.prev = _context.next) {
|
|
26
|
-
case 0:
|
|
27
|
-
if (typeof mock != "boolean") {
|
|
28
|
-
if (typeof window.__mock == "boolean") {
|
|
29
|
-
mock = window.__mock;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
key = mock ? pageId + "_mock" : pageId;
|
|
33
|
-
_context.next = 4;
|
|
34
|
-
return schema.getInstance(key, {
|
|
35
|
-
mock: mock,
|
|
36
|
-
pageId: pageId
|
|
37
|
-
});
|
|
38
|
-
case 4:
|
|
39
|
-
return _context.abrupt("return", _context.sent);
|
|
40
|
-
case 5:
|
|
41
|
-
case "end":
|
|
42
|
-
return _context.stop();
|
|
43
|
-
}
|
|
44
|
-
}, _callee);
|
|
45
|
-
}));
|
|
46
|
-
return _getSchema.apply(this, arguments);
|
|
47
|
-
}
|
|
48
|
-
export function getFormApi(_x3, _x4, _x5) {
|
|
49
|
-
return _getFormApi.apply(this, arguments);
|
|
50
|
-
}
|
|
51
|
-
function _getFormApi() {
|
|
52
|
-
_getFormApi = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(formId, fieldId, mock) {
|
|
53
|
-
var key;
|
|
54
|
-
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
55
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
56
|
-
case 0:
|
|
57
|
-
if (typeof mock != "boolean") {
|
|
58
|
-
if (typeof window.__mock == "boolean") {
|
|
59
|
-
mock = window.__mock;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
key = [formId, fieldId, mock ? "mock" : ""].filter(function (key) {
|
|
63
|
-
return !!key;
|
|
64
|
-
}).join("_");
|
|
65
|
-
_context2.next = 4;
|
|
66
|
-
return formApi.getInstance(key, {
|
|
67
|
-
mock: mock,
|
|
68
|
-
fieldId: fieldId,
|
|
69
|
-
formId: formId
|
|
70
|
-
});
|
|
71
|
-
case 4:
|
|
72
|
-
return _context2.abrupt("return", _context2.sent);
|
|
73
|
-
case 5:
|
|
74
|
-
case "end":
|
|
75
|
-
return _context2.stop();
|
|
76
|
-
}
|
|
77
|
-
}, _callee2);
|
|
78
|
-
}));
|
|
79
|
-
return _getFormApi.apply(this, arguments);
|
|
80
|
-
}
|
|
20
|
+
export var request = apiRequest.request;
|
|
81
21
|
export function onFulfilled(res) {
|
|
82
22
|
return res.data;
|
|
83
23
|
}
|