@zhubangyun/lowcode-core 5.10.221 → 5.12.90
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 +47 -47
- 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 +10 -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 +10 -1
- package/es/utils/page/page-form-data-manager-group.js +3 -7
- package/es/utils/page/page-form-data-manager.d.ts +49 -7
- 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 +47 -47
- 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 +10 -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 +10 -1
- package/lib/utils/page/page-form-data-manager-group.js +3 -7
- package/lib/utils/page/page-form-data-manager.d.ts +49 -7
- 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
|
@@ -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[];
|
|
@@ -34,21 +34,6 @@ function getDataKey(data) {
|
|
|
34
34
|
}
|
|
35
35
|
return key + "." + data.id;
|
|
36
36
|
}
|
|
37
|
-
function handleEntityLabel(data) {
|
|
38
|
-
if (!Array.isArray(data)) {
|
|
39
|
-
data = [data];
|
|
40
|
-
}
|
|
41
|
-
for (var _iterator = _createForOfIteratorHelperLoose(data), _step; !(_step = _iterator()).done;) {
|
|
42
|
-
var _item$form;
|
|
43
|
-
var item = _step.value;
|
|
44
|
-
var labelField = (_item$form = item.form) === null || _item$form === void 0 ? void 0 : _item$form.labelField;
|
|
45
|
-
if (labelField) {
|
|
46
|
-
// @ts-ignore
|
|
47
|
-
var value = safeGet(item, labelField);
|
|
48
|
-
item.label = dataToLabel(value);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
37
|
function dataToLabel(value) {
|
|
53
38
|
if (value == null) {
|
|
54
39
|
return "";
|
|
@@ -72,44 +57,44 @@ function dataToLabel(value) {
|
|
|
72
57
|
function assembleAssociationFieldV2(data, refs) {
|
|
73
58
|
if (!data || !refs) return;
|
|
74
59
|
var dataMap = new Map();
|
|
75
|
-
for (var
|
|
76
|
-
var ref =
|
|
77
|
-
|
|
78
|
-
|
|
60
|
+
for (var _iterator = _createForOfIteratorHelperLoose(refs), _step; !(_step = _iterator()).done;) {
|
|
61
|
+
var ref = _step.value;
|
|
62
|
+
ref.label = ref.form.label;
|
|
63
|
+
for (var _iterator3 = _createForOfIteratorHelperLoose(ref.data), _step3; !(_step3 = _iterator3()).done;) {
|
|
64
|
+
var datum = _step3.value;
|
|
79
65
|
var key = getDataKey(datum);
|
|
80
66
|
dataMap.set(key, datum);
|
|
81
67
|
}
|
|
82
68
|
}
|
|
83
|
-
|
|
84
69
|
//组装refs的关联属性
|
|
85
|
-
for (var
|
|
86
|
-
var item =
|
|
70
|
+
for (var _iterator2 = _createForOfIteratorHelperLoose(dataMap.values()), _step2; !(_step2 = _iterator2()).done;) {
|
|
71
|
+
var item = _step2.value;
|
|
87
72
|
for (var _i2 = 0, _Object$keys = Object.keys(item); _i2 < _Object$keys.length; _i2++) {
|
|
88
73
|
var _key = _Object$keys[_i2];
|
|
89
|
-
// @ts-ignore
|
|
90
74
|
var value = item[_key];
|
|
91
75
|
assembleAssociationFieldDataV2(value, dataMap);
|
|
92
76
|
}
|
|
93
77
|
}
|
|
94
|
-
handleEntityLabel([].concat(dataMap.values()));
|
|
95
78
|
function loopAssembleAssociation(value) {
|
|
79
|
+
var _value$form;
|
|
96
80
|
if (Array.isArray(value)) {
|
|
97
81
|
value.forEach(function (item) {
|
|
98
82
|
return loopAssembleAssociation(item);
|
|
99
83
|
});
|
|
100
|
-
} else if (value !== null && value !== void 0 && value.id) {
|
|
101
|
-
|
|
84
|
+
} else if (value !== null && value !== void 0 && value.id && (_value$form = value.form) !== null && _value$form !== void 0 && _value$form.id) {
|
|
85
|
+
if (value._load) return;
|
|
102
86
|
assembleAssociationFieldDataV2(value, dataMap);
|
|
103
|
-
//处理子表
|
|
104
87
|
for (var _i = 0, _Object$values = Object.values(value); _i < _Object$values.length; _i++) {
|
|
105
88
|
var subValues = _Object$values[_i];
|
|
106
|
-
if (typeof subValues == "object") {
|
|
89
|
+
if (subValues !== null && typeof subValues == "object") {
|
|
107
90
|
loopAssembleAssociation(subValues);
|
|
108
91
|
}
|
|
109
92
|
}
|
|
110
93
|
}
|
|
111
94
|
}
|
|
112
95
|
loopAssembleAssociation(data);
|
|
96
|
+
handleEntityLabel(data);
|
|
97
|
+
dataMap.clear();
|
|
113
98
|
}
|
|
114
99
|
|
|
115
100
|
/**
|
|
@@ -118,28 +103,62 @@ function assembleAssociationFieldV2(data, refs) {
|
|
|
118
103
|
* @param dataMap
|
|
119
104
|
*/
|
|
120
105
|
function assembleAssociationFieldDataV2(data, dataMap) {
|
|
121
|
-
if (data == null)
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
106
|
+
if (data == null || typeof data != "object") return;
|
|
124
107
|
if (Array.isArray(data)) {
|
|
125
108
|
data.forEach(function (item) {
|
|
126
109
|
return assembleAssociationFieldDataV2(item, dataMap);
|
|
127
110
|
});
|
|
128
111
|
} else {
|
|
129
|
-
if (data._load
|
|
112
|
+
if (!data._load) {
|
|
130
113
|
var _data$form3;
|
|
131
|
-
if (data !== null && data !== void 0 &&
|
|
132
|
-
delete data._load;
|
|
114
|
+
if (data !== null && data !== void 0 && data.id && data !== null && data !== void 0 && (_data$form3 = data.form) !== null && _data$form3 !== void 0 && _data$form3.id) {
|
|
133
115
|
var key = getDataKey(data);
|
|
134
116
|
var value = dataMap.get(key);
|
|
135
117
|
if (value) {
|
|
136
|
-
Object.assign(data, value);
|
|
137
|
-
delete data._load;
|
|
118
|
+
Object.assign(data, JSON.parse(JSON.stringify(value)));
|
|
138
119
|
}
|
|
120
|
+
data._load = true;
|
|
139
121
|
}
|
|
140
122
|
}
|
|
141
123
|
}
|
|
142
124
|
}
|
|
125
|
+
function handleEntityLabel(data) {
|
|
126
|
+
if (Array.isArray(data)) {
|
|
127
|
+
data.forEach(function (item) {
|
|
128
|
+
return handleEntityLabel(item);
|
|
129
|
+
});
|
|
130
|
+
} else if (typeof data == "object") {
|
|
131
|
+
var form = data === null || data === void 0 ? void 0 : data.form;
|
|
132
|
+
if (form) {
|
|
133
|
+
var labelField = form === null || form === void 0 ? void 0 : form.labelField;
|
|
134
|
+
if (labelField) {
|
|
135
|
+
// @ts-ignore
|
|
136
|
+
var label = safeGet(data, labelField);
|
|
137
|
+
data.label = dataToLabel(label);
|
|
138
|
+
}
|
|
139
|
+
for (var _i3 = 0, _Object$keys2 = Object.keys(data); _i3 < _Object$keys2.length; _i3++) {
|
|
140
|
+
var key = _Object$keys2[_i3];
|
|
141
|
+
// @ts-ignore
|
|
142
|
+
handleEntityLabel(data[key]);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
function valueToFormDataArray(value) {
|
|
148
|
+
if (typeof value == null || typeof value !== "object") {
|
|
149
|
+
return [];
|
|
150
|
+
}
|
|
151
|
+
if (Array.isArray(value)) {
|
|
152
|
+
return value === null || value === void 0 ? void 0 : value.filter(function (item) {
|
|
153
|
+
var _item$form;
|
|
154
|
+
return (item === null || item === void 0 ? void 0 : item.id) && (item === null || item === void 0 ? void 0 : (_item$form = item.form) === null || _item$form === void 0 ? void 0 : _item$form.id);
|
|
155
|
+
});
|
|
156
|
+
} else if (typeof value == "object" && value !== null) {
|
|
157
|
+
return valueToFormDataArray([value]);
|
|
158
|
+
} else {
|
|
159
|
+
return [];
|
|
160
|
+
}
|
|
161
|
+
}
|
|
143
162
|
function assembleAssociationField(data, refs) {
|
|
144
163
|
assembleAssociationFieldV2(data, refs);
|
|
145
164
|
}
|
package/lib/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/lib/utils/api/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
exports.__esModule = true;
|
|
5
|
-
exports.
|
|
5
|
+
exports.getUserinfo = exports.getSchema = exports.getFormApi = exports.files = exports.apiRequest = exports.RestFormApi = exports.RestApi = void 0;
|
|
6
6
|
exports.onFulfilled = onFulfilled;
|
|
7
7
|
exports.onRejected = onRejected;
|
|
8
8
|
exports.scrips = exports.request = void 0;
|
|
@@ -15,7 +15,7 @@ exports.RestFormApi = _formApi.RestFormApi;
|
|
|
15
15
|
var _schemaApi = require("./schema-api");
|
|
16
16
|
exports.getSchema = _schemaApi.getSchema;
|
|
17
17
|
var _userInfo = require("./user-info");
|
|
18
|
-
exports.
|
|
18
|
+
exports.getUserinfo = _userInfo.getUserinfo;
|
|
19
19
|
var _files = _interopRequireWildcard(require("./file-api"));
|
|
20
20
|
exports.files = _files;
|
|
21
21
|
var _scrips = _interopRequireWildcard(require("./script-api"));
|
|
@@ -25,7 +25,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
25
25
|
var apiRequest = exports.apiRequest = _axios["default"].create({
|
|
26
26
|
baseURL: "/api",
|
|
27
27
|
// 基础URL
|
|
28
|
-
timeout:
|
|
28
|
+
timeout: 600000,
|
|
29
29
|
// 请求超时时间(毫秒)
|
|
30
30
|
headers: {
|
|
31
31
|
'Content-Type': 'application/json;charset=UTF-8'
|
|
@@ -34,6 +34,13 @@ var apiRequest = exports.apiRequest = _axios["default"].create({
|
|
|
34
34
|
apiRequest.interceptors.response.use(onFulfilled, onRejected);
|
|
35
35
|
var request = exports.request = apiRequest.request;
|
|
36
36
|
function onFulfilled(res) {
|
|
37
|
+
if (typeof res.data == "object") {
|
|
38
|
+
if ("success" in res.data) {
|
|
39
|
+
if (res.headers["Request-Id"]) {
|
|
40
|
+
res.data.requestId = res.headers["Request-Id"];
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
37
44
|
return res.data;
|
|
38
45
|
}
|
|
39
46
|
function onRejected(error) {
|
|
@@ -19,6 +19,10 @@ export interface FilterRule {
|
|
|
19
19
|
value?: any;
|
|
20
20
|
rules?: FilterRule[];
|
|
21
21
|
}
|
|
22
|
+
export interface OrderRule {
|
|
23
|
+
key: string;
|
|
24
|
+
direction: "asc" | "desc";
|
|
25
|
+
}
|
|
22
26
|
export type OperatorType = "eq" | "ne" | "gt" | "goe" | "lt" | "loe" | "like" | "notLike" | "in" | "notIn" | "isNull" | "isNotNull" | "between" | "notBetween";
|
|
23
27
|
export interface RestSearchParams {
|
|
24
28
|
page?: number;
|
|
@@ -60,7 +64,7 @@ export declare class RestApi<DataType> extends BaseRestApi<DataType> {
|
|
|
60
64
|
constructor(uri: string, options?: RestApiOptions);
|
|
61
65
|
handleRequestConfig(config: AxiosRequestConfig): Promise<void>;
|
|
62
66
|
}
|
|
63
|
-
export interface
|
|
67
|
+
export interface IBaseEntity {
|
|
64
68
|
/**
|
|
65
69
|
* 对象id
|
|
66
70
|
*/
|
|
@@ -103,19 +107,20 @@ export interface BaseResult<DataType> {
|
|
|
103
107
|
refs?: Refs;
|
|
104
108
|
}
|
|
105
109
|
export interface Ref {
|
|
110
|
+
label: string;
|
|
106
111
|
form: {
|
|
107
112
|
id: string;
|
|
108
113
|
fieldId?: string;
|
|
114
|
+
label: string;
|
|
109
115
|
};
|
|
110
|
-
|
|
111
|
-
data: BaseType[];
|
|
116
|
+
data: IBaseEntity[];
|
|
112
117
|
}
|
|
113
118
|
export type Refs = Ref[];
|
|
114
119
|
export interface OneResult<DataType> extends BaseResult<DataType> {
|
|
115
|
-
data: DataType &
|
|
120
|
+
data: DataType & IBaseEntity;
|
|
116
121
|
}
|
|
117
122
|
export interface ManyResult<DataType> extends BaseResult<DataType> {
|
|
118
|
-
data: (DataType &
|
|
123
|
+
data: (DataType & IBaseEntity)[];
|
|
119
124
|
total: number;
|
|
120
125
|
}
|
|
121
126
|
export interface BaseRequestOptions<DataType> {
|
|
@@ -23,7 +23,7 @@ var BaseRestApi = exports.BaseRestApi = /*#__PURE__*/function () {
|
|
|
23
23
|
this.request = _axios["default"].create({
|
|
24
24
|
baseURL: "/api/" + uri,
|
|
25
25
|
// 基础URL
|
|
26
|
-
timeout:
|
|
26
|
+
timeout: 60000,
|
|
27
27
|
// 请求超时时间(毫秒)
|
|
28
28
|
headers: {
|
|
29
29
|
'Content-Type': 'application/json;charset=UTF-8'
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 遍历schema
|
|
3
|
+
* @param schema
|
|
4
|
+
* @param callback 返回true 继续往下遍历
|
|
5
|
+
*/
|
|
6
|
+
export declare function forEachSchema(schema: Schema, callback: (child: Schema, index: number, children: any[]) => boolean): void;
|
|
7
|
+
export declare function forEachFormSchema(schema: Schema, fdm: boolean, callback: (child: Schema) => void): void;
|
|
8
|
+
interface Schema {
|
|
9
|
+
componentName: string;
|
|
10
|
+
props: any;
|
|
11
|
+
children?: Schema[];
|
|
12
|
+
fdmSchema?: Schema;
|
|
13
|
+
}
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.forEachFormSchema = forEachFormSchema;
|
|
5
|
+
exports.forEachSchema = forEachSchema;
|
|
6
|
+
/**
|
|
7
|
+
* 遍历schema
|
|
8
|
+
* @param schema
|
|
9
|
+
* @param callback 返回true 继续往下遍历
|
|
10
|
+
*/
|
|
11
|
+
function forEachSchema(schema, callback) {
|
|
12
|
+
var _schema$children;
|
|
13
|
+
schema === null || schema === void 0 ? void 0 : (_schema$children = schema.children) === null || _schema$children === void 0 ? void 0 : _schema$children.forEach(function (child, index, children) {
|
|
14
|
+
var ctn = callback(child, index, children);
|
|
15
|
+
if (ctn) {
|
|
16
|
+
forEachSchema(child, callback);
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
function forEachFormSchema(schema, fdm, callback) {
|
|
21
|
+
forEachSchema(schema, function (child) {
|
|
22
|
+
if (["PageForm", "SubFormField"].includes(child.componentName)) {
|
|
23
|
+
callback(child);
|
|
24
|
+
if (fdm) {
|
|
25
|
+
if (child.fdmSchema) {
|
|
26
|
+
forEachSchema(child.fdmSchema, function (fdmChild) {
|
|
27
|
+
if (fdmChild.componentName == "PageFdm") {
|
|
28
|
+
callback(child);
|
|
29
|
+
}
|
|
30
|
+
return true;
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return true;
|
|
36
|
+
});
|
|
37
|
+
}
|
|
@@ -17,7 +17,7 @@ function _loadDts() {
|
|
|
17
17
|
case 0:
|
|
18
18
|
_context.prev = 0;
|
|
19
19
|
_context.next = 3;
|
|
20
|
-
return (0, _index.getFormApi)("
|
|
20
|
+
return (0, _index.getFormApi)("c40772eb-864b-42bb-ae31-9921d8ede97f");
|
|
21
21
|
case 3:
|
|
22
22
|
api = _context.sent;
|
|
23
23
|
_context.next = 6;
|
|
@@ -1,9 +1,19 @@
|
|
|
1
|
-
|
|
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>;
|
|
@@ -2,43 +2,54 @@
|
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
exports.__esModule = true;
|
|
5
|
-
exports.
|
|
5
|
+
exports.getUserinfo = getUserinfo;
|
|
6
6
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
7
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
8
7
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
9
8
|
var _index = require("./index");
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
var userinfoKey = "userinfo";
|
|
10
|
+
function getUserinfo() {
|
|
11
|
+
return _getUserinfo.apply(this, arguments);
|
|
12
12
|
}
|
|
13
|
-
function
|
|
14
|
-
|
|
15
|
-
var res;
|
|
13
|
+
function _getUserinfo() {
|
|
14
|
+
_getUserinfo = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
|
|
15
|
+
var userinfo, cache, res;
|
|
16
16
|
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
17
17
|
while (1) switch (_context.prev = _context.next) {
|
|
18
18
|
case 0:
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
userinfo = null;
|
|
20
|
+
cache = sessionStorage.getItem(userinfoKey);
|
|
21
|
+
if (cache) {
|
|
22
|
+
try {
|
|
23
|
+
userinfo = JSON.parse(cache);
|
|
24
|
+
} catch (e) {}
|
|
25
|
+
}
|
|
26
|
+
if (userinfo) {
|
|
27
|
+
_context.next = 8;
|
|
21
28
|
break;
|
|
22
29
|
}
|
|
23
|
-
return _context.abrupt("return", (0, _extends2["default"])({}, window.userInfo));
|
|
24
|
-
case 4:
|
|
25
30
|
_context.next = 6;
|
|
26
|
-
return _index.apiRequest.get("
|
|
31
|
+
return _index.apiRequest.get("auths/userinfo");
|
|
27
32
|
case 6:
|
|
28
33
|
res = _context.sent;
|
|
29
|
-
if (
|
|
30
|
-
|
|
31
|
-
|
|
34
|
+
if (res.success) {
|
|
35
|
+
sessionStorage.setItem(userinfoKey, JSON.stringify(res.data));
|
|
36
|
+
userinfo = res.data;
|
|
37
|
+
}
|
|
38
|
+
case 8:
|
|
39
|
+
if (userinfo) {
|
|
40
|
+
Object.defineProperty(window, "userinfo", {
|
|
41
|
+
value: userinfo
|
|
42
|
+
});
|
|
43
|
+
Object.defineProperty(window, "corp", {
|
|
44
|
+
value: userinfo.corp
|
|
45
|
+
});
|
|
32
46
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
case 12:
|
|
36
|
-
return _context.abrupt("return", false);
|
|
37
|
-
case 13:
|
|
47
|
+
return _context.abrupt("return", userinfo);
|
|
48
|
+
case 10:
|
|
38
49
|
case "end":
|
|
39
50
|
return _context.stop();
|
|
40
51
|
}
|
|
41
52
|
}, _callee);
|
|
42
53
|
}));
|
|
43
|
-
return
|
|
54
|
+
return _getUserinfo.apply(this, arguments);
|
|
44
55
|
}
|
package/lib/utils/cache/index.js
CHANGED
|
@@ -8,7 +8,7 @@ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/
|
|
|
8
8
|
var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));
|
|
9
9
|
var _SingletonInstanceMap3 = require("../common/SingletonInstanceMap");
|
|
10
10
|
var _api = require("../api");
|
|
11
|
-
var _schema = require("
|
|
11
|
+
var _schema = require("../api/schema.util");
|
|
12
12
|
var SchemaCache = exports.SchemaCache = /*#__PURE__*/function (_SingletonInstanceMap) {
|
|
13
13
|
function SchemaCache() {
|
|
14
14
|
return _SingletonInstanceMap.apply(this, arguments) || this;
|
|
@@ -17,7 +17,7 @@ var SchemaCache = exports.SchemaCache = /*#__PURE__*/function (_SingletonInstanc
|
|
|
17
17
|
var _proto = SchemaCache.prototype;
|
|
18
18
|
_proto.createInstance = /*#__PURE__*/function () {
|
|
19
19
|
var _createInstance = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(key, options) {
|
|
20
|
-
var mock, pageId,
|
|
20
|
+
var mock, pageId, schemaRes, schema, permissionRes, permission;
|
|
21
21
|
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
22
22
|
while (1) switch (_context.prev = _context.next) {
|
|
23
23
|
case 0:
|
|
@@ -29,16 +29,27 @@ var SchemaCache = exports.SchemaCache = /*#__PURE__*/function (_SingletonInstanc
|
|
|
29
29
|
}
|
|
30
30
|
});
|
|
31
31
|
case 3:
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
schemaRes = _context.sent;
|
|
33
|
+
schema = schemaRes.data;
|
|
34
|
+
if (!(typeof schema == "object")) {
|
|
35
|
+
_context.next = 11;
|
|
35
36
|
break;
|
|
36
37
|
}
|
|
37
|
-
_context.next =
|
|
38
|
-
return (
|
|
39
|
-
case 7:
|
|
40
|
-
return _context.abrupt("return", res);
|
|
38
|
+
_context.next = 8;
|
|
39
|
+
return _api.apiRequest.get("pages/" + pageId + "/permission");
|
|
41
40
|
case 8:
|
|
41
|
+
permissionRes = _context.sent;
|
|
42
|
+
permission = permissionRes.data;
|
|
43
|
+
if (typeof permission == "object") {
|
|
44
|
+
(0, _schema.forEachFormSchema)(schema, true, function (child) {
|
|
45
|
+
child.props = child.props || {};
|
|
46
|
+
child.props.permission = permission;
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
case 11:
|
|
50
|
+
console.log("schemaRes", schemaRes);
|
|
51
|
+
return _context.abrupt("return", schemaRes);
|
|
52
|
+
case 13:
|
|
42
53
|
case "end":
|
|
43
54
|
return _context.stop();
|
|
44
55
|
}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
export declare function handleFormSchema(schema: any): Promise<void>;
|
|
2
1
|
/**
|
|
3
2
|
* 遍历schema
|
|
4
3
|
* @param schema
|
|
5
4
|
* @param callback 返回true 继续往下遍历
|
|
6
5
|
*/
|
|
7
6
|
export declare function forEachFormSchema(schema: any, callback: (child: any, index: number, children: any[]) => boolean): void;
|
|
8
|
-
export declare function getAdminFormSchema(id: string): Promise<any>;
|