@zhubangyun/lowcode-core 5.10.221 → 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.js +33 -44
- 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.js +21 -11
- 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-render.js +1 -2
- 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.js +33 -44
- 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.js +20 -9
- 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-render.js +1 -2
- 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
|
}
|
package/es/utils/api/form-api.js
CHANGED
|
@@ -3,9 +3,9 @@ import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
|
|
|
3
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";
|
|
8
|
+
import { getSchemaFromCache } from "./schema-api";
|
|
9
9
|
export function getFormApi(_x, _x2, _x3) {
|
|
10
10
|
return _getFormApi.apply(this, arguments);
|
|
11
11
|
}
|
|
@@ -55,56 +55,46 @@ export var RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
|
55
55
|
_proto.initialize = /*#__PURE__*/function () {
|
|
56
56
|
var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
57
57
|
var _this2 = this;
|
|
58
|
-
var _this$schema$children, _this$schema$children2
|
|
58
|
+
var res, _this$schema, _this$schema$children, _this$schema$children2;
|
|
59
59
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
60
60
|
while (1) switch (_context.prev = _context.next) {
|
|
61
61
|
case 0:
|
|
62
62
|
if (!this.initialized) {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
if ((value === null || value === void 0 ? void 0 : (_value$props = value.props) === null || _value$props === void 0 ? void 0 : _value$props.fieldId) === _this2.fieldId) {
|
|
83
|
-
if (value.props.label) {
|
|
84
|
-
_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
|
+
});
|
|
85
82
|
}
|
|
86
83
|
}
|
|
87
|
-
|
|
88
|
-
|
|
84
|
+
} catch (e) {
|
|
85
|
+
console.log("获取schema失败!", {
|
|
86
|
+
formId: this.formId,
|
|
87
|
+
field: this.fieldId,
|
|
88
|
+
mock: this.mock
|
|
89
|
+
}, e);
|
|
90
|
+
}
|
|
89
91
|
}
|
|
90
|
-
_context.next = 18;
|
|
91
|
-
break;
|
|
92
|
-
case 14:
|
|
93
|
-
_context.prev = 14;
|
|
94
|
-
_context.t0 = _context["catch"](4);
|
|
95
|
-
console.log("获取schema失败!", {
|
|
96
|
-
formId: this.formId,
|
|
97
|
-
field: this.fieldId,
|
|
98
|
-
mock: this.mock
|
|
99
|
-
}, _context.t0);
|
|
100
|
-
throw _context.t0;
|
|
101
|
-
case 18:
|
|
102
92
|
return _context.abrupt("return", this.initialized);
|
|
103
|
-
case
|
|
93
|
+
case 2:
|
|
104
94
|
case "end":
|
|
105
95
|
return _context.stop();
|
|
106
96
|
}
|
|
107
|
-
}, _callee, this
|
|
97
|
+
}, _callee, this);
|
|
108
98
|
}));
|
|
109
99
|
function initialize() {
|
|
110
100
|
return _initialize.apply(this, arguments);
|
|
@@ -154,7 +144,7 @@ export var RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
|
154
144
|
fieldId: this.fieldId
|
|
155
145
|
};
|
|
156
146
|
if (__mock) {
|
|
157
|
-
params.description = "" +
|
|
147
|
+
params.description = (this.title || "表单") + ".\u67E5\u8BE2";
|
|
158
148
|
}
|
|
159
149
|
config = {
|
|
160
150
|
params: params
|
|
@@ -191,7 +181,7 @@ export var RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
|
191
181
|
}();
|
|
192
182
|
_proto.getById = /*#__PURE__*/function () {
|
|
193
183
|
var _getById = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(id, options) {
|
|
194
|
-
var res
|
|
184
|
+
var res;
|
|
195
185
|
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
196
186
|
while (1) switch (_context4.prev = _context4.next) {
|
|
197
187
|
case 0:
|
|
@@ -199,11 +189,10 @@ export var RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
|
199
189
|
return _RestApi.prototype.getById.call(this, id, options);
|
|
200
190
|
case 2:
|
|
201
191
|
res = _context4.sent;
|
|
202
|
-
start = Date.now();
|
|
203
192
|
assembleAssociationField(res.data, res.refs);
|
|
204
193
|
console.debug("formApi.getById", res);
|
|
205
194
|
return _context4.abrupt("return", res);
|
|
206
|
-
case
|
|
195
|
+
case 6:
|
|
207
196
|
case "end":
|
|
208
197
|
return _context4.stop();
|
|
209
198
|
}
|
|
@@ -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
|
+
}
|
|
@@ -1,9 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
|
-
|
|
7
|
-
|
|
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
|
|
19
|
+
export declare function getUserinfo(): Promise<Userinfo | null>;
|
|
@@ -1,39 +1,50 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
2
1
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
3
2
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
4
3
|
import { apiRequest } from "./index";
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
var userinfoKey = "userinfo";
|
|
5
|
+
export function getUserinfo() {
|
|
6
|
+
return _getUserinfo.apply(this, arguments);
|
|
7
7
|
}
|
|
8
|
-
function
|
|
9
|
-
|
|
10
|
-
var res;
|
|
8
|
+
function _getUserinfo() {
|
|
9
|
+
_getUserinfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
10
|
+
var userinfo, cache, res;
|
|
11
11
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
12
12
|
while (1) switch (_context.prev = _context.next) {
|
|
13
13
|
case 0:
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
userinfo = null;
|
|
15
|
+
cache = sessionStorage.getItem(userinfoKey);
|
|
16
|
+
if (cache) {
|
|
17
|
+
try {
|
|
18
|
+
userinfo = JSON.parse(cache);
|
|
19
|
+
} catch (e) {}
|
|
20
|
+
}
|
|
21
|
+
if (userinfo) {
|
|
22
|
+
_context.next = 8;
|
|
16
23
|
break;
|
|
17
24
|
}
|
|
18
|
-
return _context.abrupt("return", _extends({}, window.userInfo));
|
|
19
|
-
case 4:
|
|
20
25
|
_context.next = 6;
|
|
21
|
-
return apiRequest.get("
|
|
26
|
+
return apiRequest.get("auths/userinfo");
|
|
22
27
|
case 6:
|
|
23
28
|
res = _context.sent;
|
|
24
|
-
if (
|
|
25
|
-
|
|
26
|
-
|
|
29
|
+
if (res.success) {
|
|
30
|
+
sessionStorage.setItem(userinfoKey, JSON.stringify(res.data));
|
|
31
|
+
userinfo = res.data;
|
|
32
|
+
}
|
|
33
|
+
case 8:
|
|
34
|
+
if (userinfo) {
|
|
35
|
+
Object.defineProperty(window, "userinfo", {
|
|
36
|
+
value: userinfo
|
|
37
|
+
});
|
|
38
|
+
Object.defineProperty(window, "corp", {
|
|
39
|
+
value: userinfo.corp
|
|
40
|
+
});
|
|
27
41
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
case 12:
|
|
31
|
-
return _context.abrupt("return", false);
|
|
32
|
-
case 13:
|
|
42
|
+
return _context.abrupt("return", userinfo);
|
|
43
|
+
case 10:
|
|
33
44
|
case "end":
|
|
34
45
|
return _context.stop();
|
|
35
46
|
}
|
|
36
47
|
}, _callee);
|
|
37
48
|
}));
|
|
38
|
-
return
|
|
49
|
+
return _getUserinfo.apply(this, arguments);
|
|
39
50
|
}
|