@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.
- package/es/index.less +10 -0
- package/es/utils/api/file-api.d.ts +17 -5
- package/es/utils/api/file-api.js +10 -7
- package/es/utils/api/form-api.d.ts +1 -1
- package/es/utils/api/form-api.js +70 -66
- package/es/utils/api/form-api.utils.d.ts +5 -5
- package/es/utils/api/form-api.utils.js +55 -36
- package/es/utils/api/index.d.ts +4 -3
- package/es/utils/api/index.js +9 -2
- package/es/utils/api/rest-api.d.ts +6 -5
- package/es/utils/api/rest-api.js +1 -1
- package/es/utils/api/schema.util.d.ts +14 -0
- package/es/utils/api/schema.util.js +32 -0
- package/es/utils/api/script-api.js +1 -1
- package/es/utils/api/user-info.d.ts +16 -6
- package/es/utils/api/user-info.js +31 -20
- package/es/utils/cache/index.d.ts +6 -6
- package/es/utils/cache/index.js +56 -24
- package/es/utils/cache/schema.d.ts +0 -2
- package/es/utils/cache/schema.js +0 -388
- package/es/utils/formIds.d.ts +3 -0
- package/es/utils/formIds.js +3 -0
- package/es/utils/page/index.d.ts +2 -0
- package/es/utils/page/index.js +2 -0
- package/es/utils/page/page-form-data-manager-group.d.ts +2 -0
- package/es/utils/page/page-form-data-manager-group.js +3 -7
- package/es/utils/page/page-form-data-manager.d.ts +2 -1
- package/es/utils/page/page-form-data-manager.js +1 -0
- package/es/utils/page/page-form-group.d.ts +17 -0
- package/es/utils/page/page-form-group.js +97 -0
- package/es/utils/page/page-form.d.ts +2 -1
- package/es/utils/page/page-form.js +3 -3
- package/es/utils/page/page-show.d.ts +1 -0
- package/es/utils/page/print-form.d.ts +8 -0
- package/es/utils/page/print-form.js +147 -0
- package/lib/index.less +10 -0
- package/lib/utils/api/file-api.d.ts +17 -5
- package/lib/utils/api/file-api.js +10 -7
- package/lib/utils/api/form-api.d.ts +1 -1
- package/lib/utils/api/form-api.js +70 -66
- package/lib/utils/api/form-api.utils.d.ts +5 -5
- package/lib/utils/api/form-api.utils.js +55 -36
- package/lib/utils/api/index.d.ts +4 -3
- package/lib/utils/api/index.js +10 -3
- package/lib/utils/api/rest-api.d.ts +6 -5
- package/lib/utils/api/rest-api.js +1 -1
- package/lib/utils/api/schema.util.d.ts +14 -0
- package/lib/utils/api/schema.util.js +37 -0
- package/lib/utils/api/script-api.js +1 -1
- package/lib/utils/api/user-info.d.ts +16 -6
- package/lib/utils/api/user-info.js +32 -21
- package/lib/utils/cache/index.d.ts +6 -6
- package/lib/utils/cache/index.js +57 -24
- package/lib/utils/cache/schema.d.ts +0 -2
- package/lib/utils/cache/schema.js +0 -390
- package/lib/utils/formIds.d.ts +3 -0
- package/lib/utils/formIds.js +7 -0
- package/lib/utils/page/index.d.ts +2 -0
- package/lib/utils/page/index.js +7 -1
- package/lib/utils/page/page-form-data-manager-group.d.ts +2 -0
- package/lib/utils/page/page-form-data-manager-group.js +3 -7
- package/lib/utils/page/page-form-data-manager.d.ts +2 -1
- package/lib/utils/page/page-form-data-manager.js +1 -0
- package/lib/utils/page/page-form-group.d.ts +17 -0
- package/lib/utils/page/page-form-group.js +104 -0
- package/lib/utils/page/page-form.d.ts +2 -1
- package/lib/utils/page/page-form.js +3 -3
- package/lib/utils/page/page-show.d.ts +1 -0
- package/lib/utils/page/print-form.d.ts +8 -0
- package/lib/utils/page/print-form.js +153 -0
- package/package.json +1 -1
package/es/index.less
CHANGED
|
@@ -1,7 +1,19 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
1
2
|
import { AxiosProgressEvent } from "axios";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
interface File {
|
|
4
|
+
id?: string;
|
|
5
|
+
size?: number;
|
|
6
|
+
name?: string;
|
|
7
|
+
type?: string;
|
|
8
|
+
status?: "done" | "uploading" | "error";
|
|
9
|
+
url: string;
|
|
10
|
+
percent?: number;
|
|
11
|
+
buffer?: Buffer;
|
|
12
|
+
}
|
|
13
|
+
export declare function upload(file: File, options?: {
|
|
14
|
+
onProgress?: (evt: AxiosProgressEvent) => void;
|
|
15
|
+
onFinished?: () => void;
|
|
16
|
+
onError?: (e: any) => void;
|
|
17
|
+
}): Promise<File>;
|
|
7
18
|
export declare function update(file: any): Promise<void>;
|
|
19
|
+
export {};
|
package/es/utils/api/file-api.js
CHANGED
|
@@ -14,10 +14,11 @@ function _upload() {
|
|
|
14
14
|
_context.next = 2;
|
|
15
15
|
break;
|
|
16
16
|
}
|
|
17
|
-
return _context.abrupt("return");
|
|
17
|
+
return _context.abrupt("return", file);
|
|
18
18
|
case 2:
|
|
19
19
|
_context.next = 4;
|
|
20
20
|
return apiRequest.post("files/signature", {
|
|
21
|
+
id: file.id,
|
|
21
22
|
size: file.size,
|
|
22
23
|
name: file.name,
|
|
23
24
|
type: file.type
|
|
@@ -35,7 +36,7 @@ function _upload() {
|
|
|
35
36
|
file.status = "uploading";
|
|
36
37
|
_context.prev = 10;
|
|
37
38
|
_context.next = 13;
|
|
38
|
-
return apiRequest.put(ossFile.uploadUrl, file, {
|
|
39
|
+
return apiRequest.put(ossFile.uploadUrl, (file === null || file === void 0 ? void 0 : file.buffer) || file, {
|
|
39
40
|
headers: {
|
|
40
41
|
'Content-Type': file.type
|
|
41
42
|
},
|
|
@@ -48,18 +49,20 @@ function _upload() {
|
|
|
48
49
|
}
|
|
49
50
|
});
|
|
50
51
|
case 13:
|
|
52
|
+
file.status = "done";
|
|
51
53
|
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 =
|
|
54
|
+
_context.next = 21;
|
|
53
55
|
break;
|
|
54
|
-
case
|
|
55
|
-
_context.prev =
|
|
56
|
+
case 17:
|
|
57
|
+
_context.prev = 17;
|
|
56
58
|
_context.t0 = _context["catch"](10);
|
|
59
|
+
file.status = "error";
|
|
57
60
|
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
|
|
61
|
+
case 21:
|
|
59
62
|
case "end":
|
|
60
63
|
return _context.stop();
|
|
61
64
|
}
|
|
62
|
-
}, _callee, null, [[10,
|
|
65
|
+
}, _callee, null, [[10, 17]]);
|
|
63
66
|
}));
|
|
64
67
|
return _upload.apply(this, arguments);
|
|
65
68
|
}
|
|
@@ -1,6 +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): RestFormApi<any
|
|
3
|
+
export declare function getFormApi(formId: string, fieldId?: string, mock?: boolean): Promise<RestFormApi<any>>;
|
|
4
4
|
export declare class RestFormApi<DataType> extends RestApi<DataType> {
|
|
5
5
|
private readonly formId;
|
|
6
6
|
private readonly fieldId?;
|
package/es/utils/api/form-api.js
CHANGED
|
@@ -1,25 +1,40 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
3
2
|
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
|
|
3
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
4
4
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
5
5
|
import { RestApi } from "./rest-api";
|
|
6
|
-
import { getSchema } from "./index";
|
|
7
6
|
import { assembleAssociationField, convertSaveData, handleFilterRules } from "./form-api.utils";
|
|
8
7
|
import { formApi } from "../cache";
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
8
|
+
import { getSchemaFromCache } from "./schema-api";
|
|
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
|
+
return _context9.abrupt("return", formApi.getInstance(key, {
|
|
27
|
+
mock: mock,
|
|
28
|
+
fieldId: fieldId,
|
|
29
|
+
formId: formId
|
|
30
|
+
}));
|
|
31
|
+
case 3:
|
|
32
|
+
case "end":
|
|
33
|
+
return _context9.stop();
|
|
34
|
+
}
|
|
35
|
+
}, _callee9);
|
|
36
|
+
}));
|
|
37
|
+
return _getFormApi.apply(this, arguments);
|
|
23
38
|
}
|
|
24
39
|
export var RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
25
40
|
function RestFormApi(formId, fieldId, mock) {
|
|
@@ -40,56 +55,46 @@ export var RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
|
40
55
|
_proto.initialize = /*#__PURE__*/function () {
|
|
41
56
|
var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
42
57
|
var _this2 = this;
|
|
43
|
-
var _this$schema$children, _this$schema$children2
|
|
58
|
+
var res, _this$schema, _this$schema$children, _this$schema$children2;
|
|
44
59
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
45
60
|
while (1) switch (_context.prev = _context.next) {
|
|
46
61
|
case 0:
|
|
47
62
|
if (!this.initialized) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
if ((value === null || value === void 0 ? void 0 : (_value$props = value.props) === null || _value$props === void 0 ? void 0 : _value$props.fieldId) === _this2.fieldId) {
|
|
68
|
-
if (value.props.label) {
|
|
69
|
-
_this2.title += "." + value.props.label;
|
|
63
|
+
try {
|
|
64
|
+
res = getSchemaFromCache(this.formId, this.mock);
|
|
65
|
+
this.schema = res === null || res === void 0 ? void 0 : res.data;
|
|
66
|
+
this.initialized = !!this.schema;
|
|
67
|
+
if (this.initialized) {
|
|
68
|
+
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;
|
|
69
|
+
if (this.fieldId) {
|
|
70
|
+
JSON.stringify(this.schema, function (key, value) {
|
|
71
|
+
var _value$props;
|
|
72
|
+
if (key == "fdmSchema") {
|
|
73
|
+
return undefined;
|
|
74
|
+
}
|
|
75
|
+
if ((value === null || value === void 0 ? void 0 : (_value$props = value.props) === null || _value$props === void 0 ? void 0 : _value$props.fieldId) === _this2.fieldId) {
|
|
76
|
+
if (value.props.label) {
|
|
77
|
+
_this2.title += "." + value.props.label;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return value;
|
|
81
|
+
});
|
|
70
82
|
}
|
|
71
83
|
}
|
|
72
|
-
|
|
73
|
-
|
|
84
|
+
} catch (e) {
|
|
85
|
+
console.log("获取schema失败!", {
|
|
86
|
+
formId: this.formId,
|
|
87
|
+
field: this.fieldId,
|
|
88
|
+
mock: this.mock
|
|
89
|
+
}, e);
|
|
90
|
+
}
|
|
74
91
|
}
|
|
75
|
-
_context.next = 18;
|
|
76
|
-
break;
|
|
77
|
-
case 14:
|
|
78
|
-
_context.prev = 14;
|
|
79
|
-
_context.t0 = _context["catch"](4);
|
|
80
|
-
console.log("获取schema失败!", {
|
|
81
|
-
formId: this.formId,
|
|
82
|
-
field: this.fieldId,
|
|
83
|
-
mock: this.mock
|
|
84
|
-
}, _context.t0);
|
|
85
|
-
throw _context.t0;
|
|
86
|
-
case 18:
|
|
87
92
|
return _context.abrupt("return", this.initialized);
|
|
88
|
-
case
|
|
93
|
+
case 2:
|
|
89
94
|
case "end":
|
|
90
95
|
return _context.stop();
|
|
91
96
|
}
|
|
92
|
-
}, _callee, this
|
|
97
|
+
}, _callee, this);
|
|
93
98
|
}));
|
|
94
99
|
function initialize() {
|
|
95
100
|
return _initialize.apply(this, arguments);
|
|
@@ -121,7 +126,7 @@ export var RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
|
121
126
|
}
|
|
122
127
|
}, _callee2, this);
|
|
123
128
|
}));
|
|
124
|
-
function handleRequestConfig(
|
|
129
|
+
function handleRequestConfig(_x4) {
|
|
125
130
|
return _handleRequestConfig.apply(this, arguments);
|
|
126
131
|
}
|
|
127
132
|
return handleRequestConfig;
|
|
@@ -139,7 +144,7 @@ export var RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
|
139
144
|
fieldId: this.fieldId
|
|
140
145
|
};
|
|
141
146
|
if (__mock) {
|
|
142
|
-
params.description = "" +
|
|
147
|
+
params.description = (this.title || "表单") + ".\u67E5\u8BE2";
|
|
143
148
|
}
|
|
144
149
|
config = {
|
|
145
150
|
params: params
|
|
@@ -169,14 +174,14 @@ export var RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
|
169
174
|
}
|
|
170
175
|
}, _callee3, this);
|
|
171
176
|
}));
|
|
172
|
-
function search(
|
|
177
|
+
function search(_x5) {
|
|
173
178
|
return _search.apply(this, arguments);
|
|
174
179
|
}
|
|
175
180
|
return search;
|
|
176
181
|
}();
|
|
177
182
|
_proto.getById = /*#__PURE__*/function () {
|
|
178
183
|
var _getById = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(id, options) {
|
|
179
|
-
var res
|
|
184
|
+
var res;
|
|
180
185
|
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
181
186
|
while (1) switch (_context4.prev = _context4.next) {
|
|
182
187
|
case 0:
|
|
@@ -184,17 +189,16 @@ export var RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
|
184
189
|
return _RestApi.prototype.getById.call(this, id, options);
|
|
185
190
|
case 2:
|
|
186
191
|
res = _context4.sent;
|
|
187
|
-
start = Date.now();
|
|
188
192
|
assembleAssociationField(res.data, res.refs);
|
|
189
193
|
console.debug("formApi.getById", res);
|
|
190
194
|
return _context4.abrupt("return", res);
|
|
191
|
-
case
|
|
195
|
+
case 6:
|
|
192
196
|
case "end":
|
|
193
197
|
return _context4.stop();
|
|
194
198
|
}
|
|
195
199
|
}, _callee4, this);
|
|
196
200
|
}));
|
|
197
|
-
function getById(
|
|
201
|
+
function getById(_x6, _x7) {
|
|
198
202
|
return _getById.apply(this, arguments);
|
|
199
203
|
}
|
|
200
204
|
return getById;
|
|
@@ -211,7 +215,7 @@ export var RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
|
211
215
|
}
|
|
212
216
|
}, _callee5, this);
|
|
213
217
|
}));
|
|
214
|
-
function save(
|
|
218
|
+
function save(_x8, _x9) {
|
|
215
219
|
return _save.apply(this, arguments);
|
|
216
220
|
}
|
|
217
221
|
return save;
|
|
@@ -228,7 +232,7 @@ export var RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
|
228
232
|
}
|
|
229
233
|
}, _callee6, this);
|
|
230
234
|
}));
|
|
231
|
-
function create(
|
|
235
|
+
function create(_x10, _x11) {
|
|
232
236
|
return _create.apply(this, arguments);
|
|
233
237
|
}
|
|
234
238
|
return create;
|
|
@@ -245,7 +249,7 @@ export var RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
|
245
249
|
}
|
|
246
250
|
}, _callee7, this);
|
|
247
251
|
}));
|
|
248
|
-
function update(
|
|
252
|
+
function update(_x12, _x13, _x14) {
|
|
249
253
|
return _update.apply(this, arguments);
|
|
250
254
|
}
|
|
251
255
|
return update;
|
|
@@ -262,7 +266,7 @@ export var RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
|
262
266
|
}
|
|
263
267
|
}, _callee8, this);
|
|
264
268
|
}));
|
|
265
|
-
function serviceUpdate(
|
|
269
|
+
function serviceUpdate(_x15, _x16) {
|
|
266
270
|
return _serviceUpdate.apply(this, arguments);
|
|
267
271
|
}
|
|
268
272
|
return serviceUpdate;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import {
|
|
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:
|
|
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:
|
|
12
|
-
export declare function
|
|
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[];
|
|
@@ -23,21 +23,6 @@ function getDataKey(data) {
|
|
|
23
23
|
}
|
|
24
24
|
return key + "." + data.id;
|
|
25
25
|
}
|
|
26
|
-
export function handleEntityLabel(data) {
|
|
27
|
-
if (!Array.isArray(data)) {
|
|
28
|
-
data = [data];
|
|
29
|
-
}
|
|
30
|
-
for (var _iterator = _createForOfIteratorHelperLoose(data), _step; !(_step = _iterator()).done;) {
|
|
31
|
-
var _item$form;
|
|
32
|
-
var item = _step.value;
|
|
33
|
-
var labelField = (_item$form = item.form) === null || _item$form === void 0 ? void 0 : _item$form.labelField;
|
|
34
|
-
if (labelField) {
|
|
35
|
-
// @ts-ignore
|
|
36
|
-
var value = safeGet(item, labelField);
|
|
37
|
-
item.label = dataToLabel(value);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
26
|
export function dataToLabel(value) {
|
|
42
27
|
if (value == null) {
|
|
43
28
|
return "";
|
|
@@ -61,44 +46,44 @@ export function dataToLabel(value) {
|
|
|
61
46
|
export function assembleAssociationFieldV2(data, refs) {
|
|
62
47
|
if (!data || !refs) return;
|
|
63
48
|
var dataMap = new Map();
|
|
64
|
-
for (var
|
|
65
|
-
var ref =
|
|
66
|
-
|
|
67
|
-
|
|
49
|
+
for (var _iterator = _createForOfIteratorHelperLoose(refs), _step; !(_step = _iterator()).done;) {
|
|
50
|
+
var ref = _step.value;
|
|
51
|
+
ref.label = ref.form.label;
|
|
52
|
+
for (var _iterator3 = _createForOfIteratorHelperLoose(ref.data), _step3; !(_step3 = _iterator3()).done;) {
|
|
53
|
+
var datum = _step3.value;
|
|
68
54
|
var key = getDataKey(datum);
|
|
69
55
|
dataMap.set(key, datum);
|
|
70
56
|
}
|
|
71
57
|
}
|
|
72
|
-
|
|
73
58
|
//组装refs的关联属性
|
|
74
|
-
for (var
|
|
75
|
-
var item =
|
|
59
|
+
for (var _iterator2 = _createForOfIteratorHelperLoose(dataMap.values()), _step2; !(_step2 = _iterator2()).done;) {
|
|
60
|
+
var item = _step2.value;
|
|
76
61
|
for (var _i2 = 0, _Object$keys = Object.keys(item); _i2 < _Object$keys.length; _i2++) {
|
|
77
62
|
var _key = _Object$keys[_i2];
|
|
78
|
-
// @ts-ignore
|
|
79
63
|
var value = item[_key];
|
|
80
64
|
assembleAssociationFieldDataV2(value, dataMap);
|
|
81
65
|
}
|
|
82
66
|
}
|
|
83
|
-
handleEntityLabel([].concat(dataMap.values()));
|
|
84
67
|
function loopAssembleAssociation(value) {
|
|
68
|
+
var _value$form;
|
|
85
69
|
if (Array.isArray(value)) {
|
|
86
70
|
value.forEach(function (item) {
|
|
87
71
|
return loopAssembleAssociation(item);
|
|
88
72
|
});
|
|
89
|
-
} else if (value !== null && value !== void 0 && value.id) {
|
|
90
|
-
|
|
73
|
+
} else if (value !== null && value !== void 0 && value.id && (_value$form = value.form) !== null && _value$form !== void 0 && _value$form.id) {
|
|
74
|
+
if (value._load) return;
|
|
91
75
|
assembleAssociationFieldDataV2(value, dataMap);
|
|
92
|
-
//处理子表
|
|
93
76
|
for (var _i = 0, _Object$values = Object.values(value); _i < _Object$values.length; _i++) {
|
|
94
77
|
var subValues = _Object$values[_i];
|
|
95
|
-
if (typeof subValues == "object") {
|
|
78
|
+
if (subValues !== null && typeof subValues == "object") {
|
|
96
79
|
loopAssembleAssociation(subValues);
|
|
97
80
|
}
|
|
98
81
|
}
|
|
99
82
|
}
|
|
100
83
|
}
|
|
101
84
|
loopAssembleAssociation(data);
|
|
85
|
+
handleEntityLabel(data);
|
|
86
|
+
dataMap.clear();
|
|
102
87
|
}
|
|
103
88
|
|
|
104
89
|
/**
|
|
@@ -107,28 +92,62 @@ export function assembleAssociationFieldV2(data, refs) {
|
|
|
107
92
|
* @param dataMap
|
|
108
93
|
*/
|
|
109
94
|
export function assembleAssociationFieldDataV2(data, dataMap) {
|
|
110
|
-
if (data == null)
|
|
111
|
-
return;
|
|
112
|
-
}
|
|
95
|
+
if (data == null || typeof data != "object") return;
|
|
113
96
|
if (Array.isArray(data)) {
|
|
114
97
|
data.forEach(function (item) {
|
|
115
98
|
return assembleAssociationFieldDataV2(item, dataMap);
|
|
116
99
|
});
|
|
117
100
|
} else {
|
|
118
|
-
if (data._load
|
|
101
|
+
if (!data._load) {
|
|
119
102
|
var _data$form3;
|
|
120
|
-
if (data !== null && data !== void 0 &&
|
|
121
|
-
delete data._load;
|
|
103
|
+
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) {
|
|
122
104
|
var key = getDataKey(data);
|
|
123
105
|
var value = dataMap.get(key);
|
|
124
106
|
if (value) {
|
|
125
|
-
Object.assign(data, value);
|
|
126
|
-
delete data._load;
|
|
107
|
+
Object.assign(data, JSON.parse(JSON.stringify(value)));
|
|
127
108
|
}
|
|
109
|
+
data._load = true;
|
|
128
110
|
}
|
|
129
111
|
}
|
|
130
112
|
}
|
|
131
113
|
}
|
|
114
|
+
export function handleEntityLabel(data) {
|
|
115
|
+
if (Array.isArray(data)) {
|
|
116
|
+
data.forEach(function (item) {
|
|
117
|
+
return handleEntityLabel(item);
|
|
118
|
+
});
|
|
119
|
+
} else if (typeof data == "object") {
|
|
120
|
+
var form = data === null || data === void 0 ? void 0 : data.form;
|
|
121
|
+
if (form) {
|
|
122
|
+
var labelField = form === null || form === void 0 ? void 0 : form.labelField;
|
|
123
|
+
if (labelField) {
|
|
124
|
+
// @ts-ignore
|
|
125
|
+
var label = safeGet(data, labelField);
|
|
126
|
+
data.label = dataToLabel(label);
|
|
127
|
+
}
|
|
128
|
+
for (var _i3 = 0, _Object$keys2 = Object.keys(data); _i3 < _Object$keys2.length; _i3++) {
|
|
129
|
+
var key = _Object$keys2[_i3];
|
|
130
|
+
// @ts-ignore
|
|
131
|
+
handleEntityLabel(data[key]);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
function valueToFormDataArray(value) {
|
|
137
|
+
if (typeof value == null || typeof value !== "object") {
|
|
138
|
+
return [];
|
|
139
|
+
}
|
|
140
|
+
if (Array.isArray(value)) {
|
|
141
|
+
return value === null || value === void 0 ? void 0 : value.filter(function (item) {
|
|
142
|
+
var _item$form;
|
|
143
|
+
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);
|
|
144
|
+
});
|
|
145
|
+
} else if (typeof value == "object" && value !== null) {
|
|
146
|
+
return valueToFormDataArray([value]);
|
|
147
|
+
} else {
|
|
148
|
+
return [];
|
|
149
|
+
}
|
|
150
|
+
}
|
|
132
151
|
export function assembleAssociationField(data, refs) {
|
|
133
152
|
assembleAssociationFieldV2(data, refs);
|
|
134
153
|
}
|
package/es/utils/api/index.d.ts
CHANGED
|
@@ -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 {
|
|
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 =
|
|
9
|
-
export declare function onFulfilled(res:
|
|
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;
|
package/es/utils/api/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import axios from "axios";
|
|
|
2
2
|
export { RestApi } from "./rest-api";
|
|
3
3
|
export { getFormApi, RestFormApi } from "./form-api";
|
|
4
4
|
export { getSchema } from "./schema-api";
|
|
5
|
-
export {
|
|
5
|
+
export { getUserinfo } from "./user-info";
|
|
6
6
|
import * as _files from "./file-api";
|
|
7
7
|
export { _files as files };
|
|
8
8
|
import * as _scrips from "./script-api";
|
|
@@ -10,7 +10,7 @@ export { _scrips as scrips };
|
|
|
10
10
|
export var apiRequest = axios.create({
|
|
11
11
|
baseURL: "/api",
|
|
12
12
|
// 基础URL
|
|
13
|
-
timeout:
|
|
13
|
+
timeout: 600000,
|
|
14
14
|
// 请求超时时间(毫秒)
|
|
15
15
|
headers: {
|
|
16
16
|
'Content-Type': 'application/json;charset=UTF-8'
|
|
@@ -19,6 +19,13 @@ export var apiRequest = axios.create({
|
|
|
19
19
|
apiRequest.interceptors.response.use(onFulfilled, onRejected);
|
|
20
20
|
export var request = apiRequest.request;
|
|
21
21
|
export function onFulfilled(res) {
|
|
22
|
+
if (typeof res.data == "object") {
|
|
23
|
+
if ("success" in res.data) {
|
|
24
|
+
if (res.headers["Request-Id"]) {
|
|
25
|
+
res.data.requestId = res.headers["Request-Id"];
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
22
29
|
return res.data;
|
|
23
30
|
}
|
|
24
31
|
export 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
|
|
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
|
-
|
|
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 &
|
|
116
|
+
data: DataType & IBaseEntity;
|
|
116
117
|
}
|
|
117
118
|
export interface ManyResult<DataType> extends BaseResult<DataType> {
|
|
118
|
-
data: (DataType &
|
|
119
|
+
data: (DataType & IBaseEntity)[];
|
|
119
120
|
total: number;
|
|
120
121
|
}
|
|
121
122
|
export interface BaseRequestOptions<DataType> {
|
package/es/utils/api/rest-api.js
CHANGED
|
@@ -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,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 遍历schema
|
|
3
|
+
* @param schema
|
|
4
|
+
* @param callback 返回true 继续往下遍历
|
|
5
|
+
*/
|
|
6
|
+
export function forEachSchema(schema, callback) {
|
|
7
|
+
var _schema$children;
|
|
8
|
+
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) {
|
|
9
|
+
var ctn = callback(child, index, children);
|
|
10
|
+
if (ctn) {
|
|
11
|
+
forEachSchema(child, callback);
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
export function forEachFormSchema(schema, fdm, callback) {
|
|
16
|
+
forEachSchema(schema, function (child) {
|
|
17
|
+
if (["PageForm", "SubFormField"].includes(child.componentName)) {
|
|
18
|
+
callback(child);
|
|
19
|
+
if (fdm) {
|
|
20
|
+
if (child.fdmSchema) {
|
|
21
|
+
forEachSchema(child.fdmSchema, function (fdmChild) {
|
|
22
|
+
if (fdmChild.componentName == "PageFdm") {
|
|
23
|
+
callback(child);
|
|
24
|
+
}
|
|
25
|
+
return true;
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return true;
|
|
31
|
+
});
|
|
32
|
+
}
|