@zhubangyun/lowcode-core 5.8.110 → 5.8.291
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/components/load-materials/index.js +1 -1
- package/es/style.js +1 -0
- package/es/utils/api/form-api.d.ts +1 -1
- package/es/utils/api/form-api.js +16 -13
- package/es/utils/api/form-api.utils.d.ts +3 -2
- package/es/utils/api/form-api.utils.js +88 -17
- package/es/utils/api/rest-api.d.ts +6 -0
- package/es/utils/api/rest-api.js +12 -7
- package/es/utils/cache/schema.d.ts +1 -0
- package/es/utils/cache/schema.js +268 -170
- package/lib/components/load-materials/index.js +1 -1
- package/lib/style.js +1 -0
- package/lib/utils/api/form-api.d.ts +1 -1
- package/lib/utils/api/form-api.js +16 -13
- package/lib/utils/api/form-api.utils.d.ts +3 -2
- package/lib/utils/api/form-api.utils.js +89 -17
- package/lib/utils/api/rest-api.d.ts +6 -0
- package/lib/utils/api/rest-api.js +12 -7
- package/lib/utils/cache/schema.d.ts +1 -0
- package/lib/utils/cache/schema.js +270 -170
- package/package.json +1 -1
|
@@ -54,7 +54,7 @@ function _loadMaterials() {
|
|
|
54
54
|
}
|
|
55
55
|
return _context2.abrupt("return");
|
|
56
56
|
case 3:
|
|
57
|
-
urls = ["prop-types/15.8.1/prop-types.min.js", "lodash/4.
|
|
57
|
+
urls = ["prop-types/15.8.1/prop-types.min.js", "lodash/4.17.15/lodash.min.js", "dayjs/dayjs.min.js", "antd/latest/reset.css", "antd/latest/antd.min.js", "antdIcon/1.0.0/antdIcon.min.js", "lowcode/core/index.js", "lowcode/core/index.css", "lowcode/materials/root/view.js", "lowcode/materials/root/view.css", "lowcode/materials/antd/view.js", "lowcode/materials/antd/view.css", "lowcode/materials/antd-pro/view.js", "lowcode/materials/antd-pro/view.css", "lowcode/icon-font/app/iconfont.js"];
|
|
58
58
|
_context2.next = 6;
|
|
59
59
|
return loadPlugins(urls.map(function (url) {
|
|
60
60
|
return "https://cdn.zhiyunhe.com/plugin/" + url;
|
package/es/style.js
CHANGED
|
@@ -9,7 +9,7 @@ export declare class RestFormApi<DataType> extends RestApi<DataType> {
|
|
|
9
9
|
constructor(formId: string, fieldId?: string, mock?: boolean);
|
|
10
10
|
initialize(): Promise<boolean>;
|
|
11
11
|
handleRequestConfig(config: AxiosRequestConfig): Promise<void>;
|
|
12
|
-
search(
|
|
12
|
+
search(searchParams?: RestSearchParams): Promise<ManyResult<DataType>>;
|
|
13
13
|
getById(id: string, options?: BaseRequestOptions<DataType>): Promise<OneResult<DataType>>;
|
|
14
14
|
save(data: DataType, options?: BaseRequestOptions<DataType>): Promise<OneResult<DataType>>;
|
|
15
15
|
create(data: DataType, options?: BaseRequestOptions<DataType>): Promise<OneResult<DataType>>;
|
package/es/utils/api/form-api.js
CHANGED
|
@@ -23,7 +23,7 @@ export var RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
|
23
23
|
_proto.initialize = /*#__PURE__*/function () {
|
|
24
24
|
var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
25
25
|
var _this2 = this;
|
|
26
|
-
var _this$schema$
|
|
26
|
+
var _this$schema$children, _this$schema$children2, res;
|
|
27
27
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
28
28
|
while (1) switch (_context.prev = _context.next) {
|
|
29
29
|
case 0:
|
|
@@ -40,7 +40,7 @@ export var RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
|
40
40
|
res = _context.sent;
|
|
41
41
|
this.schema = res.data;
|
|
42
42
|
this.initialized = !!this.schema;
|
|
43
|
-
this.title = (_this$schema$
|
|
43
|
+
this.title = (_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;
|
|
44
44
|
if (this.fieldId) {
|
|
45
45
|
JSON.stringify(this.schema, function (key, value) {
|
|
46
46
|
var _value$props;
|
|
@@ -108,13 +108,13 @@ export var RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
|
108
108
|
return handleRequestConfig;
|
|
109
109
|
}();
|
|
110
110
|
_proto.search = /*#__PURE__*/function () {
|
|
111
|
-
var _search = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(
|
|
112
|
-
var
|
|
113
|
-
var config, res;
|
|
111
|
+
var _search = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(searchParams) {
|
|
112
|
+
var _searchParams, _searchParams2;
|
|
113
|
+
var config, res, start;
|
|
114
114
|
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
115
115
|
while (1) switch (_context3.prev = _context3.next) {
|
|
116
116
|
case 0:
|
|
117
|
-
|
|
117
|
+
searchParams = searchParams || {};
|
|
118
118
|
config = {
|
|
119
119
|
params: {
|
|
120
120
|
description: this.title + "\u67E5\u8BE2",
|
|
@@ -125,19 +125,21 @@ export var RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
|
125
125
|
_context3.next = 4;
|
|
126
126
|
return this.handleRequestConfig(config);
|
|
127
127
|
case 4:
|
|
128
|
-
|
|
128
|
+
searchParams.filterRules = handleFilterRules(((_searchParams = searchParams) === null || _searchParams === void 0 ? void 0 : _searchParams.filterRules) || [], {
|
|
129
129
|
filterNullValue: false
|
|
130
130
|
});
|
|
131
|
-
|
|
131
|
+
searchParams.searchFields = handleFilterRules(((_searchParams2 = searchParams) === null || _searchParams2 === void 0 ? void 0 : _searchParams2.searchFields) || [], {
|
|
132
132
|
filterNullValue: true
|
|
133
133
|
});
|
|
134
134
|
_context3.next = 8;
|
|
135
|
-
return this.request.post("search",
|
|
135
|
+
return this.request.post("search", searchParams, config);
|
|
136
136
|
case 8:
|
|
137
137
|
res = _context3.sent;
|
|
138
|
+
start = Date.now();
|
|
138
139
|
assembleAssociationField(res.data, res.refs);
|
|
140
|
+
console.debug("form.search:" + (Date.now() - start), res);
|
|
139
141
|
return _context3.abrupt("return", res);
|
|
140
|
-
case
|
|
142
|
+
case 13:
|
|
141
143
|
case "end":
|
|
142
144
|
return _context3.stop();
|
|
143
145
|
}
|
|
@@ -150,7 +152,7 @@ export var RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
|
150
152
|
}();
|
|
151
153
|
_proto.getById = /*#__PURE__*/function () {
|
|
152
154
|
var _getById = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(id, options) {
|
|
153
|
-
var res;
|
|
155
|
+
var res, start;
|
|
154
156
|
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
155
157
|
while (1) switch (_context4.prev = _context4.next) {
|
|
156
158
|
case 0:
|
|
@@ -158,10 +160,11 @@ export var RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
|
158
160
|
return _RestApi.prototype.getById.call(this, id, options);
|
|
159
161
|
case 2:
|
|
160
162
|
res = _context4.sent;
|
|
163
|
+
start = Date.now();
|
|
161
164
|
assembleAssociationField(res.data, res.refs);
|
|
162
|
-
console.debug("formApi.getById", res);
|
|
165
|
+
console.debug("formApi.getById" + (Date.now() - start), res);
|
|
163
166
|
return _context4.abrupt("return", res);
|
|
164
|
-
case
|
|
167
|
+
case 7:
|
|
165
168
|
case "end":
|
|
166
169
|
return _context4.stop();
|
|
167
170
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { BaseType, FilterRule, Refs } from "./rest-api";
|
|
2
2
|
export declare function convertSaveData(data: any): any;
|
|
3
|
+
export declare function assembleAssociationFieldV2(data: BaseType | BaseType[], refs?: Refs): void;
|
|
4
|
+
export declare function assembleAssociationFieldDataV2(data: BaseType | BaseType[], dataMap: Map<string, BaseType>): void;
|
|
3
5
|
export declare function assembleAssociationField(data: BaseType | BaseType[], refs?: Refs): void;
|
|
4
|
-
export declare function assembleAssociationFieldValue(data: BaseType | BaseType[], fieldIdDataMap: Map<string, Map<string, BaseType>>, prefixKey?: string): void;
|
|
5
6
|
export declare function handleFilterRules(filters: FilterRule[], options: {
|
|
6
7
|
filterNullValue: boolean;
|
|
7
|
-
}):
|
|
8
|
+
}): FilterRule[];
|
|
@@ -12,24 +12,94 @@ export function convertSaveData(data) {
|
|
|
12
12
|
return value;
|
|
13
13
|
}));
|
|
14
14
|
}
|
|
15
|
-
|
|
15
|
+
function getDataKey(data) {
|
|
16
|
+
var key = data.form.id;
|
|
17
|
+
if (data.form.fieldId) {
|
|
18
|
+
key += "." + data.form.fieldId;
|
|
19
|
+
}
|
|
20
|
+
return key + "." + data.id;
|
|
21
|
+
}
|
|
22
|
+
export function assembleAssociationFieldV2(data, refs) {
|
|
16
23
|
if (!data || !refs) return;
|
|
17
|
-
var
|
|
24
|
+
var dataMap = new Map();
|
|
18
25
|
for (var _iterator = _createForOfIteratorHelperLoose(refs), _step; !(_step = _iterator()).done;) {
|
|
19
26
|
var ref = _step.value;
|
|
27
|
+
for (var _iterator3 = _createForOfIteratorHelperLoose(ref.data), _step3; !(_step3 = _iterator3()).done;) {
|
|
28
|
+
var datum = _step3.value;
|
|
29
|
+
var key = getDataKey(datum);
|
|
30
|
+
dataMap.set(key, datum);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
//组装refs的关联属性
|
|
35
|
+
for (var _iterator2 = _createForOfIteratorHelperLoose(dataMap.values()), _step2; !(_step2 = _iterator2()).done;) {
|
|
36
|
+
var item = _step2.value;
|
|
37
|
+
for (var _i2 = 0, _Object$keys = Object.keys(item); _i2 < _Object$keys.length; _i2++) {
|
|
38
|
+
var _key = _Object$keys[_i2];
|
|
39
|
+
// @ts-ignore
|
|
40
|
+
var value = item[_key];
|
|
41
|
+
assembleAssociationFieldDataV2(value, dataMap);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function loopAssembleAssociation(value) {
|
|
45
|
+
if (Array.isArray(value)) {
|
|
46
|
+
value.forEach(function (item) {
|
|
47
|
+
return loopAssembleAssociation(item);
|
|
48
|
+
});
|
|
49
|
+
} else if (value !== null && value !== void 0 && value.id) {
|
|
50
|
+
assembleAssociationFieldDataV2(value, dataMap);
|
|
51
|
+
//处理子表
|
|
52
|
+
for (var _i = 0, _Object$values = Object.values(value); _i < _Object$values.length; _i++) {
|
|
53
|
+
var subValues = _Object$values[_i];
|
|
54
|
+
if (typeof subValues == "object") {
|
|
55
|
+
loopAssembleAssociation(subValues);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
loopAssembleAssociation(data);
|
|
61
|
+
}
|
|
62
|
+
export function assembleAssociationFieldDataV2(data, dataMap) {
|
|
63
|
+
if (data == null) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
if (Array.isArray(data)) {
|
|
67
|
+
data.forEach(function (item) {
|
|
68
|
+
return assembleAssociationFieldDataV2(item, dataMap);
|
|
69
|
+
});
|
|
70
|
+
} else {
|
|
71
|
+
var _data$form;
|
|
72
|
+
if (data !== null && data !== void 0 && (_data$form = data.form) !== null && _data$form !== void 0 && _data$form.id && data !== null && data !== void 0 && data.id) {
|
|
73
|
+
delete data._load;
|
|
74
|
+
var key = getDataKey(data);
|
|
75
|
+
var value = dataMap.get(key);
|
|
76
|
+
if (value) {
|
|
77
|
+
Object.assign(data, value);
|
|
78
|
+
delete data._load;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
export function assembleAssociationField(data, refs) {
|
|
84
|
+
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;
|
|
20
90
|
var dataMap = new Map();
|
|
21
|
-
for (var
|
|
22
|
-
var datum =
|
|
91
|
+
for (var _iterator7 = _createForOfIteratorHelperLoose(ref.data), _step7; !(_step7 = _iterator7()).done;) {
|
|
92
|
+
var datum = _step7.value;
|
|
23
93
|
dataMap.set(datum.id, datum);
|
|
24
94
|
}
|
|
25
|
-
for (var
|
|
26
|
-
var fieldId =
|
|
95
|
+
for (var _iterator8 = _createForOfIteratorHelperLoose(ref.fieldIds), _step8; !(_step8 = _iterator8()).done;) {
|
|
96
|
+
var fieldId = _step8.value;
|
|
27
97
|
fieldIdDataMap.set(fieldId + "Id", dataMap);
|
|
28
98
|
}
|
|
29
99
|
}
|
|
30
100
|
//组装refs的关联属性
|
|
31
|
-
for (var
|
|
32
|
-
var _ref =
|
|
101
|
+
for (var _iterator5 = _createForOfIteratorHelperLoose(refs), _step5; !(_step5 = _iterator5()).done;) {
|
|
102
|
+
var _ref = _step5.value;
|
|
33
103
|
var key = _ref.form.id;
|
|
34
104
|
if (_ref.form.fieldId) {
|
|
35
105
|
key += "." + _ref.form.fieldId;
|
|
@@ -47,10 +117,10 @@ export function assembleAssociationField(data, refs) {
|
|
|
47
117
|
if ((_values$ = values[0]) !== null && _values$ !== void 0 && _values$.id) {
|
|
48
118
|
assembleAssociationFieldValue(values, fieldIdDataMap);
|
|
49
119
|
//处理子表
|
|
50
|
-
for (var
|
|
51
|
-
var value =
|
|
52
|
-
for (var
|
|
53
|
-
var subValues = _Object$
|
|
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];
|
|
54
124
|
if (Array.isArray(subValues)) {
|
|
55
125
|
loopAssembleAssociation(subValues);
|
|
56
126
|
}
|
|
@@ -61,17 +131,17 @@ export function assembleAssociationField(data, refs) {
|
|
|
61
131
|
}
|
|
62
132
|
loopAssembleAssociation(data);
|
|
63
133
|
}
|
|
64
|
-
|
|
134
|
+
function assembleAssociationFieldValue(data, fieldIdDataMap, prefixKey) {
|
|
65
135
|
var arrayData = [];
|
|
66
136
|
if (Array.isArray(data)) {
|
|
67
137
|
arrayData = data;
|
|
68
138
|
} else if (typeof data == "object") {
|
|
69
139
|
arrayData = [data];
|
|
70
140
|
}
|
|
71
|
-
for (var
|
|
72
|
-
var item =
|
|
141
|
+
for (var _iterator9 = _createForOfIteratorHelperLoose(arrayData), _step9; !(_step9 = _iterator9()).done;) {
|
|
142
|
+
var item = _step9.value;
|
|
73
143
|
var _loop = function _loop() {
|
|
74
|
-
var fieldIdName = _Object$
|
|
144
|
+
var fieldIdName = _Object$keys2[_i4];
|
|
75
145
|
var fieldIdKey = fieldIdName;
|
|
76
146
|
if (prefixKey) {
|
|
77
147
|
fieldIdKey = prefixKey + "." + fieldIdName;
|
|
@@ -93,7 +163,7 @@ export function assembleAssociationFieldValue(data, fieldIdDataMap, prefixKey) {
|
|
|
93
163
|
item[fieldIdName.slice(0, -2)] = fieldValue;
|
|
94
164
|
}
|
|
95
165
|
};
|
|
96
|
-
for (var
|
|
166
|
+
for (var _i4 = 0, _Object$keys2 = Object.keys(item); _i4 < _Object$keys2.length; _i4++) {
|
|
97
167
|
_loop();
|
|
98
168
|
}
|
|
99
169
|
}
|
|
@@ -122,6 +192,7 @@ export function handleFilterRules(filters, options) {
|
|
|
122
192
|
if (cloneRules.length == 0) {
|
|
123
193
|
return undefined;
|
|
124
194
|
}
|
|
195
|
+
return cloneRules;
|
|
125
196
|
} else {
|
|
126
197
|
return undefined;
|
|
127
198
|
}
|
package/es/utils/api/rest-api.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
|
|
2
|
+
import _Typography from "antd/es/typography";
|
|
2
3
|
import _notification from "antd/es/notification";
|
|
3
4
|
import _Modal from "antd/es/modal";
|
|
4
5
|
import _message from "antd/es/message";
|
|
@@ -357,7 +358,7 @@ export var BaseRestApi = /*#__PURE__*/function () {
|
|
|
357
358
|
}
|
|
358
359
|
props = JSON.parse(msg);
|
|
359
360
|
props.content = props.message;
|
|
360
|
-
if (props.title) {
|
|
361
|
+
if (!props.title) {
|
|
361
362
|
props.title = "" + this.title + type;
|
|
362
363
|
}
|
|
363
364
|
if (!(props.type == "message")) {
|
|
@@ -381,16 +382,20 @@ export var BaseRestApi = /*#__PURE__*/function () {
|
|
|
381
382
|
_notification.error(props);
|
|
382
383
|
return _context8.abrupt("return");
|
|
383
384
|
case 18:
|
|
384
|
-
_context8.next =
|
|
385
|
+
_context8.next = 24;
|
|
385
386
|
break;
|
|
386
387
|
case 20:
|
|
387
388
|
_context8.prev = 20;
|
|
388
389
|
_context8.t0 = _context8["catch"](0);
|
|
389
|
-
console.
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
390
|
+
console.error("" + this.title + type + (msg || ""));
|
|
391
|
+
_Modal.error({
|
|
392
|
+
title: "" + this.title + type,
|
|
393
|
+
centered: true,
|
|
394
|
+
content: /*#__PURE__*/React.createElement(_Typography.Text, {
|
|
395
|
+
type: "danger"
|
|
396
|
+
}, msg || "")
|
|
397
|
+
});
|
|
398
|
+
case 24:
|
|
394
399
|
case "end":
|
|
395
400
|
return _context8.stop();
|
|
396
401
|
}
|
|
@@ -5,3 +5,4 @@ export declare function handleFormSchema(schema: any): Promise<void>;
|
|
|
5
5
|
* @param callback 返回true 继续往下遍历
|
|
6
6
|
*/
|
|
7
7
|
export declare function forEachFormSchema(schema: any, callback: (child: any, index: number, children: any[]) => boolean): void;
|
|
8
|
+
export declare function getAdminFormSchema(id: string): Promise<any>;
|