@zhubangyun/lowcode-core 5.6.214 → 5.8.110
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/page-loading/index.less +14 -12
- package/es/index.d.ts +2 -1
- package/es/index.js +13 -3
- package/es/style.js +2 -1
- package/es/utils/api/form-api.d.ts +1 -0
- package/es/utils/api/form-api.js +49 -66
- package/es/utils/api/form-api.utils.d.ts +7 -0
- package/es/utils/api/form-api.utils.js +128 -0
- package/es/utils/api/rest-api.d.ts +3 -0
- package/es/utils/api/rest-api.js +120 -13
- package/es/utils/cache/schema.js +15 -3
- package/es/utils/data/index.d.ts +1 -0
- package/es/utils/data/index.js +20 -0
- package/es/utils/page/page-form-data-manager.d.ts +7 -1
- package/es/utils/page/page-form-data-manager.js +10 -8
- package/es/utils/page/page-layout.js +9 -4
- package/es/utils/page/page-load-schema.js +2 -1
- package/lib/components/page-loading/index.less +14 -12
- package/lib/index.d.ts +2 -1
- package/lib/index.js +15 -3
- package/lib/style.js +2 -1
- package/lib/utils/api/form-api.d.ts +1 -0
- package/lib/utils/api/form-api.js +52 -69
- package/lib/utils/api/form-api.utils.d.ts +7 -0
- package/lib/utils/api/form-api.utils.js +136 -0
- package/lib/utils/api/rest-api.d.ts +3 -0
- package/lib/utils/api/rest-api.js +120 -13
- package/lib/utils/cache/schema.js +15 -3
- package/lib/utils/data/index.d.ts +1 -0
- package/lib/utils/data/index.js +24 -0
- package/lib/utils/page/page-form-data-manager.d.ts +7 -1
- package/lib/utils/page/page-form-data-manager.js +10 -8
- package/lib/utils/page/page-layout.js +9 -4
- package/lib/utils/page/page-load-schema.js +2 -1
- package/package.json +1 -1
|
@@ -5,10 +5,13 @@ exports.__esModule = true;
|
|
|
5
5
|
exports.RestApi = exports.BaseRestApi = void 0;
|
|
6
6
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
7
7
|
var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));
|
|
8
|
+
var _notification2 = _interopRequireDefault(require("antd/lib/notification"));
|
|
9
|
+
var _modal = _interopRequireDefault(require("antd/lib/modal"));
|
|
8
10
|
var _message2 = _interopRequireDefault(require("antd/lib/message"));
|
|
9
11
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
12
|
var _axios = _interopRequireDefault(require("axios"));
|
|
11
13
|
var _index = require("./index");
|
|
14
|
+
var _data = require("../data");
|
|
12
15
|
var BaseRestApi = exports.BaseRestApi = /*#__PURE__*/function () {
|
|
13
16
|
function BaseRestApi(uri, options) {
|
|
14
17
|
this.uri = void 0;
|
|
@@ -119,7 +122,7 @@ var BaseRestApi = exports.BaseRestApi = /*#__PURE__*/function () {
|
|
|
119
122
|
return (_this$handleRequestCo3 = this.handleRequestConfig) === null || _this$handleRequestCo3 === void 0 ? void 0 : _this$handleRequestCo3.call(this, config);
|
|
120
123
|
case 3:
|
|
121
124
|
_context3.next = 5;
|
|
122
|
-
return this.request.post("", data, config);
|
|
125
|
+
return this.request.post("save", data, config);
|
|
123
126
|
case 5:
|
|
124
127
|
res = _context3.sent;
|
|
125
128
|
if (res.success) {
|
|
@@ -289,26 +292,130 @@ var BaseRestApi = exports.BaseRestApi = /*#__PURE__*/function () {
|
|
|
289
292
|
}
|
|
290
293
|
return deleteById;
|
|
291
294
|
}();
|
|
292
|
-
_proto
|
|
293
|
-
var
|
|
295
|
+
_proto["delete"] = /*#__PURE__*/function () {
|
|
296
|
+
var _delete2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee7(data, options) {
|
|
297
|
+
var _this$handleRequestCo7;
|
|
298
|
+
var config, arrayData, idValue, res, _options$onError6, _options$onSuccess6;
|
|
294
299
|
return _regenerator["default"].wrap(function _callee7$(_context7) {
|
|
295
300
|
while (1) switch (_context7.prev = _context7.next) {
|
|
296
301
|
case 0:
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
302
|
+
config = {};
|
|
303
|
+
_context7.next = 3;
|
|
304
|
+
return (_this$handleRequestCo7 = this.handleRequestConfig) === null || _this$handleRequestCo7 === void 0 ? void 0 : _this$handleRequestCo7.call(this, config);
|
|
305
|
+
case 3:
|
|
306
|
+
arrayData = [];
|
|
307
|
+
idValue = (0, _data.transformerId)(data);
|
|
308
|
+
if (!Array.isArray(idValue)) {
|
|
309
|
+
arrayData.push(idValue);
|
|
310
|
+
} else {
|
|
311
|
+
arrayData = idValue;
|
|
312
|
+
}
|
|
313
|
+
arrayData = arrayData.filter(function (item) {
|
|
314
|
+
return !!item;
|
|
315
|
+
});
|
|
316
|
+
if (!(arrayData.length == 0)) {
|
|
317
|
+
_context7.next = 9;
|
|
318
|
+
break;
|
|
319
|
+
}
|
|
320
|
+
throw new Error("删除对象不可为空!");
|
|
321
|
+
case 9:
|
|
322
|
+
_context7.next = 11;
|
|
323
|
+
return this.request.post("remove", arrayData, config);
|
|
324
|
+
case 11:
|
|
325
|
+
res = _context7.sent;
|
|
326
|
+
if (res.success) {
|
|
327
|
+
_context7.next = 18;
|
|
328
|
+
break;
|
|
329
|
+
}
|
|
330
|
+
this.showError("\u5220\u9664\u5931\u8D25!", res.message).then();
|
|
331
|
+
_context7.next = 16;
|
|
332
|
+
return options === null || options === void 0 ? void 0 : (_options$onError6 = options.onError) === null || _options$onError6 === void 0 ? void 0 : _options$onError6.call(options, res);
|
|
333
|
+
case 16:
|
|
334
|
+
_context7.next = 20;
|
|
335
|
+
break;
|
|
336
|
+
case 18:
|
|
337
|
+
_context7.next = 20;
|
|
338
|
+
return options === null || options === void 0 ? void 0 : (_options$onSuccess6 = options.onSuccess) === null || _options$onSuccess6 === void 0 ? void 0 : _options$onSuccess6.call(options, res);
|
|
339
|
+
case 20:
|
|
340
|
+
return _context7.abrupt("return", res);
|
|
341
|
+
case 21:
|
|
300
342
|
case "end":
|
|
301
343
|
return _context7.stop();
|
|
302
344
|
}
|
|
303
345
|
}, _callee7, this);
|
|
304
346
|
}));
|
|
305
|
-
function
|
|
347
|
+
function _delete(_x13, _x14) {
|
|
348
|
+
return _delete2.apply(this, arguments);
|
|
349
|
+
}
|
|
350
|
+
return _delete;
|
|
351
|
+
}();
|
|
352
|
+
_proto.showError = /*#__PURE__*/function () {
|
|
353
|
+
var _showError = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee8(type, msg) {
|
|
354
|
+
var props;
|
|
355
|
+
return _regenerator["default"].wrap(function _callee8$(_context8) {
|
|
356
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
357
|
+
case 0:
|
|
358
|
+
_context8.prev = 0;
|
|
359
|
+
if (!msg) {
|
|
360
|
+
_context8.next = 18;
|
|
361
|
+
break;
|
|
362
|
+
}
|
|
363
|
+
props = JSON.parse(msg);
|
|
364
|
+
props.content = props.message;
|
|
365
|
+
if (props.title) {
|
|
366
|
+
props.title = "" + this.title + type;
|
|
367
|
+
}
|
|
368
|
+
if (!(props.type == "message")) {
|
|
369
|
+
_context8.next = 10;
|
|
370
|
+
break;
|
|
371
|
+
}
|
|
372
|
+
_message2["default"].error(props);
|
|
373
|
+
return _context8.abrupt("return");
|
|
374
|
+
case 10:
|
|
375
|
+
if (!(props.type == "modal")) {
|
|
376
|
+
_context8.next = 15;
|
|
377
|
+
break;
|
|
378
|
+
}
|
|
379
|
+
_modal["default"].error(props);
|
|
380
|
+
return _context8.abrupt("return");
|
|
381
|
+
case 15:
|
|
382
|
+
if (!(props.type == "notification")) {
|
|
383
|
+
_context8.next = 18;
|
|
384
|
+
break;
|
|
385
|
+
}
|
|
386
|
+
_notification2["default"].error(props);
|
|
387
|
+
return _context8.abrupt("return");
|
|
388
|
+
case 18:
|
|
389
|
+
_context8.next = 23;
|
|
390
|
+
break;
|
|
391
|
+
case 20:
|
|
392
|
+
_context8.prev = 20;
|
|
393
|
+
_context8.t0 = _context8["catch"](0);
|
|
394
|
+
console.log("`showError`解析异常:", _context8.t0);
|
|
395
|
+
case 23:
|
|
396
|
+
console.error("{" + this.title + "}" + type + (msg || ""));
|
|
397
|
+
_message2["default"] === null || _message2["default"] === void 0 ? void 0 : _message2["default"].error("{" + this.title + "}" + type + (msg || "")).then();
|
|
398
|
+
case 25:
|
|
399
|
+
case "end":
|
|
400
|
+
return _context8.stop();
|
|
401
|
+
}
|
|
402
|
+
}, _callee8, this, [[0, 20]]);
|
|
403
|
+
}));
|
|
404
|
+
function showError(_x15, _x16) {
|
|
306
405
|
return _showError.apply(this, arguments);
|
|
307
406
|
}
|
|
308
407
|
return showError;
|
|
309
408
|
}();
|
|
310
409
|
return BaseRestApi;
|
|
311
410
|
}();
|
|
411
|
+
function getStringId(item) {
|
|
412
|
+
if (typeof (item === null || item === void 0 ? void 0 : item.id) === "string") {
|
|
413
|
+
return item.id;
|
|
414
|
+
} else if (typeof item === "string") {
|
|
415
|
+
return item;
|
|
416
|
+
}
|
|
417
|
+
return null;
|
|
418
|
+
}
|
|
312
419
|
var RestApi = exports.RestApi = /*#__PURE__*/function (_BaseRestApi2) {
|
|
313
420
|
function RestApi(uri, options) {
|
|
314
421
|
return _BaseRestApi2.call(this, uri, options) || this;
|
|
@@ -316,16 +423,16 @@ var RestApi = exports.RestApi = /*#__PURE__*/function (_BaseRestApi2) {
|
|
|
316
423
|
(0, _inheritsLoose2["default"])(RestApi, _BaseRestApi2);
|
|
317
424
|
var _proto2 = RestApi.prototype;
|
|
318
425
|
_proto2.handleRequestConfig = /*#__PURE__*/function () {
|
|
319
|
-
var _handleRequestConfig = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function
|
|
320
|
-
return _regenerator["default"].wrap(function
|
|
321
|
-
while (1) switch (
|
|
426
|
+
var _handleRequestConfig = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee9(config) {
|
|
427
|
+
return _regenerator["default"].wrap(function _callee9$(_context9) {
|
|
428
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
322
429
|
case 0:
|
|
323
430
|
case "end":
|
|
324
|
-
return
|
|
431
|
+
return _context9.stop();
|
|
325
432
|
}
|
|
326
|
-
},
|
|
433
|
+
}, _callee9);
|
|
327
434
|
}));
|
|
328
|
-
function handleRequestConfig(
|
|
435
|
+
function handleRequestConfig(_x17) {
|
|
329
436
|
return _handleRequestConfig.apply(this, arguments);
|
|
330
437
|
}
|
|
331
438
|
return handleRequestConfig;
|
|
@@ -20,13 +20,25 @@ function _handleFormSchema() {
|
|
|
20
20
|
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
21
21
|
while (1) switch (_context.prev = _context.next) {
|
|
22
22
|
case 0:
|
|
23
|
+
if (!(schema.type !== "form")) {
|
|
24
|
+
_context.next = 2;
|
|
25
|
+
break;
|
|
26
|
+
}
|
|
27
|
+
return _context.abrupt("return");
|
|
28
|
+
case 2:
|
|
29
|
+
if (schema !== null && schema !== void 0 && schema.componentName) {
|
|
30
|
+
_context.next = 4;
|
|
31
|
+
break;
|
|
32
|
+
}
|
|
33
|
+
return _context.abrupt("return");
|
|
34
|
+
case 4:
|
|
23
35
|
fdmItems = [];
|
|
24
36
|
fieldIdMap = new Map();
|
|
25
37
|
schema.state = schema.state || {};
|
|
26
38
|
schema.methods = schema.methods || {};
|
|
27
|
-
_context.next =
|
|
39
|
+
_context.next = 10;
|
|
28
40
|
return handleAssociationForm(schema);
|
|
29
|
-
case
|
|
41
|
+
case 10:
|
|
30
42
|
//初次处理
|
|
31
43
|
forEachFormSchema(schema, function (field) {
|
|
32
44
|
if (field.fdmSchema) {
|
|
@@ -73,7 +85,7 @@ function _handleFormSchema() {
|
|
|
73
85
|
return true;
|
|
74
86
|
});
|
|
75
87
|
});
|
|
76
|
-
case
|
|
88
|
+
case 12:
|
|
77
89
|
case "end":
|
|
78
90
|
return _context.stop();
|
|
79
91
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function transformerId(value: any): any;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.transformerId = transformerId;
|
|
5
|
+
function transformerId(value) {
|
|
6
|
+
if (value == null) {
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
9
|
+
if (Array.isArray(value)) {
|
|
10
|
+
return value.map(transformerId).filter(function (value) {
|
|
11
|
+
return !!value;
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
if (typeof value == "object") {
|
|
15
|
+
return (value === null || value === void 0 ? void 0 : value.id) || (value === null || value === void 0 ? void 0 : value.value) || value;
|
|
16
|
+
}
|
|
17
|
+
if (typeof value == "string") {
|
|
18
|
+
return value;
|
|
19
|
+
}
|
|
20
|
+
if (typeof value == "number") {
|
|
21
|
+
return value;
|
|
22
|
+
}
|
|
23
|
+
return (value === null || value === void 0 ? void 0 : value.id) || value.value || value;
|
|
24
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PageLayoutType } from "./page-layout";
|
|
2
|
-
export declare type PageFormDataManagerModeType = "dataManager" | "selectOne" | "selectMore";
|
|
2
|
+
export declare type PageFormDataManagerModeType = "associationField" | "dataManager" | "selectOne" | "selectMore";
|
|
3
3
|
export interface ShowPageFormDataManagerProps {
|
|
4
4
|
container?: HTMLDivElement;
|
|
5
5
|
layout?: PageLayoutType;
|
|
@@ -8,6 +8,12 @@ export interface ShowPageFormDataManagerProps {
|
|
|
8
8
|
fieldId?: string;
|
|
9
9
|
};
|
|
10
10
|
mode?: PageFormDataManagerModeType;
|
|
11
|
+
extraProps?: any;
|
|
11
12
|
onClose?: () => void | Promise<void>;
|
|
13
|
+
onSearch?: (params: any[]) => void | Promise<void>;
|
|
14
|
+
onLoadData?: (response: {
|
|
15
|
+
data: any[];
|
|
16
|
+
total: number;
|
|
17
|
+
}) => void | Promise<void>;
|
|
12
18
|
}
|
|
13
19
|
export declare function showFormDataManager(options: ShowPageFormDataManagerProps): Promise<any | any[]>;
|
|
@@ -29,7 +29,7 @@ function _showFormDataManager() {
|
|
|
29
29
|
case 0:
|
|
30
30
|
return _context3.abrupt("return", new Promise( /*#__PURE__*/function () {
|
|
31
31
|
var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(resolve, reject) {
|
|
32
|
-
var container, onClose, restProps, unmount, _options$form, paths, mode,
|
|
32
|
+
var container, onClose, restProps, unmount, _options$form, paths, mode, _params, url, page;
|
|
33
33
|
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
34
34
|
while (1) switch (_context2.prev = _context2.next) {
|
|
35
35
|
case 0:
|
|
@@ -45,8 +45,8 @@ function _showFormDataManager() {
|
|
|
45
45
|
}
|
|
46
46
|
paths = window.location.pathname.split("/");
|
|
47
47
|
mode = options.mode;
|
|
48
|
-
|
|
49
|
-
url = "/" + paths[1] + "/" + paths[2] + "/" + ((_options$form = options.form) === null || _options$form === void 0 ? void 0 : _options$form.id) + "/" + mode + "?" +
|
|
48
|
+
_params = new URLSearchParams();
|
|
49
|
+
url = "/" + paths[1] + "/" + paths[2] + "/" + ((_options$form = options.form) === null || _options$form === void 0 ? void 0 : _options$form.id) + "/" + mode + "?" + _params.toString();
|
|
50
50
|
_context2.next = 10;
|
|
51
51
|
return (0, _index.openPage)(url, url);
|
|
52
52
|
case 10:
|
|
@@ -66,18 +66,19 @@ function _showFormDataManager() {
|
|
|
66
66
|
while (1) switch (_context.prev = _context.next) {
|
|
67
67
|
case 0:
|
|
68
68
|
resolve(null);
|
|
69
|
+
setTimeout(function () {
|
|
70
|
+
_reactDom["default"].unmountComponentAtNode(container);
|
|
71
|
+
}, 10);
|
|
69
72
|
if (unmount) {
|
|
70
73
|
//等待动画结束
|
|
71
74
|
setTimeout(function () {
|
|
72
75
|
var _container;
|
|
73
|
-
//取消挂载
|
|
74
|
-
_reactDom["default"].unmountComponentAtNode(container);
|
|
75
76
|
//移除
|
|
76
77
|
(_container = container) === null || _container === void 0 ? void 0 : _container.remove();
|
|
77
|
-
},
|
|
78
|
+
}, 100);
|
|
78
79
|
}
|
|
79
80
|
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
80
|
-
case
|
|
81
|
+
case 4:
|
|
81
82
|
case "end":
|
|
82
83
|
return _context.stop();
|
|
83
84
|
}
|
|
@@ -123,8 +124,9 @@ var FormDataManagerRender = /*#__PURE__*/function (_Component) {
|
|
|
123
124
|
onSelectOk = _this$props.onSelectOk,
|
|
124
125
|
onClose = _this$props.onClose,
|
|
125
126
|
restProps = (0, _objectWithoutPropertiesLoose2["default"])(_this$props, _excluded);
|
|
127
|
+
|
|
126
128
|
// @ts-ignore
|
|
127
|
-
restProps.layout = layout || "
|
|
129
|
+
restProps.layout = layout || "modal";
|
|
128
130
|
// @ts-ignore
|
|
129
131
|
restProps.onClose = function () {
|
|
130
132
|
var _self$layoutRef;
|
|
@@ -22,12 +22,14 @@ var PageLayout = exports.PageLayout = /*#__PURE__*/function (_Component) {
|
|
|
22
22
|
});
|
|
23
23
|
};
|
|
24
24
|
_this.getWith = function () {
|
|
25
|
-
return Math.min(window.innerWidth,
|
|
25
|
+
return Math.min(window.innerWidth, 1600);
|
|
26
26
|
};
|
|
27
27
|
_this.handleResize = function () {
|
|
28
|
-
_this.
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
if (_this.props.layout == "drawer") {
|
|
29
|
+
_this.setState({
|
|
30
|
+
width: _this.getWith()
|
|
31
|
+
});
|
|
32
|
+
}
|
|
31
33
|
};
|
|
32
34
|
_this.state.width = _this.getWith();
|
|
33
35
|
return _this;
|
|
@@ -51,6 +53,7 @@ var PageLayout = exports.PageLayout = /*#__PURE__*/function (_Component) {
|
|
|
51
53
|
onClose: this.close,
|
|
52
54
|
footer: false,
|
|
53
55
|
closable: false,
|
|
56
|
+
style: {},
|
|
54
57
|
styles: {
|
|
55
58
|
header: {
|
|
56
59
|
display: "none"
|
|
@@ -65,6 +68,8 @@ var PageLayout = exports.PageLayout = /*#__PURE__*/function (_Component) {
|
|
|
65
68
|
maskClosable: false
|
|
66
69
|
};
|
|
67
70
|
if (layout == "modal") {
|
|
71
|
+
restProps.style.top = 64;
|
|
72
|
+
restProps.styles.body.maxHeight = "calc(100vh - 180px)";
|
|
68
73
|
return /*#__PURE__*/_react["default"].createElement(_modal["default"], restProps, children);
|
|
69
74
|
} else if (layout == "drawer") {
|
|
70
75
|
return /*#__PURE__*/_react["default"].createElement(_drawer["default"], restProps, children);
|