@zhubangyun/lowcode-core 5.10.82 → 5.10.91
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 +3 -4
- package/es/components/log-error-content.d.ts +5 -0
- package/es/components/log-error-content.js +32 -0
- package/es/components/typing.d.ts +1 -1
- package/es/index.js +0 -1
- package/es/style.js +1 -1
- package/es/utils/api/form-api.js +8 -5
- package/es/utils/api/form-api.utils.js +19 -32
- package/es/utils/api/rest-api.d.ts +6 -6
- package/es/utils/api/rest-api.js +24 -52
- package/es/utils/api/schema-api.d.ts +1 -0
- package/es/utils/api/schema-api.js +10 -8
- package/es/utils/common/LoadPlugins.js +16 -9
- package/es/utils/common/SingletonInstanceMap.d.ts +1 -0
- package/es/utils/common/SingletonInstanceMap.js +3 -0
- package/es/utils/designer/assets/assets.typing.d.ts +3 -3
- package/es/utils/designer/assets/index.d.ts +1 -1
- package/es/utils/page/page-form-data-manager-group.d.ts +1 -1
- package/es/utils/page/page-form-data-manager.d.ts +1 -1
- package/es/utils/page/page-form.d.ts +2 -1
- package/es/utils/page/page-layout.d.ts +2 -2
- package/es/utils/page/page-layout.js +7 -4
- package/es/utils/page/page-load-schema.js +8 -0
- package/es/utils/page/page-render.js +10 -11
- package/es/utils/page/page-show.d.ts +1 -4
- package/es/utils/page/page-show.js +3 -3
- package/lib/components/load-materials/index.js +3 -4
- package/lib/components/log-error-content.d.ts +5 -0
- package/lib/components/log-error-content.js +37 -0
- package/lib/components/typing.d.ts +1 -1
- package/lib/index.js +0 -2
- package/lib/style.js +1 -1
- package/lib/utils/api/form-api.js +8 -5
- package/lib/utils/api/form-api.utils.js +19 -32
- package/lib/utils/api/rest-api.d.ts +6 -6
- package/lib/utils/api/rest-api.js +24 -52
- package/lib/utils/api/schema-api.d.ts +1 -0
- package/lib/utils/api/schema-api.js +11 -8
- package/lib/utils/common/LoadPlugins.js +16 -9
- package/lib/utils/common/SingletonInstanceMap.d.ts +1 -0
- package/lib/utils/common/SingletonInstanceMap.js +3 -0
- package/lib/utils/designer/assets/assets.typing.d.ts +3 -3
- package/lib/utils/designer/assets/index.d.ts +1 -1
- package/lib/utils/page/page-form-data-manager-group.d.ts +1 -1
- package/lib/utils/page/page-form-data-manager.d.ts +1 -1
- package/lib/utils/page/page-form.d.ts +2 -1
- package/lib/utils/page/page-layout.d.ts +2 -2
- package/lib/utils/page/page-layout.js +7 -4
- package/lib/utils/page/page-load-schema.js +8 -0
- package/lib/utils/page/page-render.js +10 -11
- package/lib/utils/page/page-show.d.ts +1 -4
- package/lib/utils/page/page-show.js +3 -3
- package/package.json +7 -7
- package/es/utils/common/LoadMaterials.d.ts +0 -1
- package/es/utils/common/LoadMaterials.js +0 -37
- package/es/utils/common/ProcessHandler.d.ts +0 -30
- package/es/utils/common/ProcessHandler.js +0 -303
- package/lib/utils/common/LoadMaterials.d.ts +0 -1
- package/lib/utils/common/LoadMaterials.js +0 -42
- package/lib/utils/common/ProcessHandler.d.ts +0 -30
- package/lib/utils/common/ProcessHandler.js +0 -308
|
@@ -3,9 +3,11 @@ import _message from "antd/es/message";
|
|
|
3
3
|
import { useEffect, useState } from "react";
|
|
4
4
|
import { getSchema } from "../api";
|
|
5
5
|
import { PageLoading } from "../../components/page-loading";
|
|
6
|
+
import { getSchemaFromCache } from "../api/schema-api";
|
|
6
7
|
export function PageLoadSchema(props) {
|
|
7
8
|
var pageId = props.pageId,
|
|
8
9
|
children = props.children;
|
|
10
|
+
var cache = getSchemaFromCache(pageId);
|
|
9
11
|
var _useState = useState(true),
|
|
10
12
|
loading = _useState[0],
|
|
11
13
|
setLoading = _useState[1];
|
|
@@ -16,6 +18,9 @@ export function PageLoadSchema(props) {
|
|
|
16
18
|
errorMsg = _useState3[0],
|
|
17
19
|
setErrorMsg = _useState3[1];
|
|
18
20
|
useEffect(function () {
|
|
21
|
+
if (cache) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
19
24
|
if (pageId) {
|
|
20
25
|
getSchema(pageId).then(function (res) {
|
|
21
26
|
if (res.success) {
|
|
@@ -32,6 +37,9 @@ export function PageLoadSchema(props) {
|
|
|
32
37
|
_message.error("页面id不可为空!").then();
|
|
33
38
|
}
|
|
34
39
|
}, []);
|
|
40
|
+
if (cache) {
|
|
41
|
+
return children(schema);
|
|
42
|
+
}
|
|
35
43
|
if (loading) {
|
|
36
44
|
return /*#__PURE__*/React.createElement(PageLoading, {
|
|
37
45
|
loading: true,
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
3
3
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
4
|
-
import ReactDOM from "react-dom";
|
|
5
4
|
import { createElement } from "react";
|
|
5
|
+
import { createRoot } from "react-dom/client";
|
|
6
6
|
export function renderElement(options) {
|
|
7
7
|
return new Promise( /*#__PURE__*/function () {
|
|
8
8
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(resolve, reject) {
|
|
9
|
-
var container, _onClose, _options$element, component, props, unmount, element;
|
|
9
|
+
var container, _onClose, _options$element, component, props, unmount, root, element;
|
|
10
10
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
11
11
|
while (1) switch (_context.prev = _context.next) {
|
|
12
12
|
case 0:
|
|
@@ -17,28 +17,27 @@ export function renderElement(options) {
|
|
|
17
17
|
container = document.createElement("div");
|
|
18
18
|
document.body.append(container);
|
|
19
19
|
}
|
|
20
|
+
root = createRoot(container);
|
|
20
21
|
element = /*#__PURE__*/createElement(component, _extends({}, props, {
|
|
21
22
|
onSelectOk: function onSelectOk(data) {
|
|
22
23
|
resolve(data || null);
|
|
23
24
|
},
|
|
24
25
|
onClose: function onClose() {
|
|
25
26
|
resolve(false);
|
|
27
|
+
//等待动画结束
|
|
26
28
|
setTimeout(function () {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
if (unmount) {
|
|
30
|
-
//等待动画结束
|
|
31
|
-
setTimeout(function () {
|
|
29
|
+
root.unmount();
|
|
30
|
+
if (unmount) {
|
|
32
31
|
var _container;
|
|
33
32
|
//移除
|
|
34
33
|
(_container = container) === null || _container === void 0 ? void 0 : _container.remove();
|
|
35
|
-
}
|
|
36
|
-
}
|
|
34
|
+
}
|
|
35
|
+
}, 200);
|
|
37
36
|
_onClose === null || _onClose === void 0 ? void 0 : _onClose();
|
|
38
37
|
}
|
|
39
38
|
}));
|
|
40
|
-
|
|
41
|
-
case
|
|
39
|
+
root.render(element);
|
|
40
|
+
case 7:
|
|
42
41
|
case "end":
|
|
43
42
|
return _context.stop();
|
|
44
43
|
}
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import { PageLayoutType } from "./page-layout";
|
|
2
2
|
export interface ShowPageProps {
|
|
3
3
|
container?: HTMLDivElement;
|
|
4
|
+
pageId: string;
|
|
4
5
|
layout?: PageLayoutType;
|
|
5
|
-
form?: {
|
|
6
|
-
id: string;
|
|
7
|
-
fieldId?: string;
|
|
8
|
-
};
|
|
9
6
|
onClose?: () => void | Promise<void>;
|
|
10
7
|
}
|
|
11
8
|
export declare function show(options: ShowPageProps): Promise<any | any[]>;
|
|
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
|
|
3
3
|
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
|
|
4
4
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
5
|
-
var _excluded = ["layout", "
|
|
5
|
+
var _excluded = ["layout", "pageId", "onClose"],
|
|
6
6
|
_excluded2 = ["container", "onClose"];
|
|
7
7
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
8
8
|
import { renderElement } from "./page-render";
|
|
@@ -53,7 +53,7 @@ var PageRender = /*#__PURE__*/function (_Component) {
|
|
|
53
53
|
var self = this;
|
|
54
54
|
var _this$props = this.props,
|
|
55
55
|
layout = _this$props.layout,
|
|
56
|
-
|
|
56
|
+
pageId = _this$props.pageId,
|
|
57
57
|
onClose = _this$props.onClose,
|
|
58
58
|
restProps = _objectWithoutPropertiesLoose(_this$props, _excluded);
|
|
59
59
|
// @ts-ignore
|
|
@@ -70,7 +70,7 @@ var PageRender = /*#__PURE__*/function (_Component) {
|
|
|
70
70
|
return _this2.layoutRef = layout;
|
|
71
71
|
}
|
|
72
72
|
}, /*#__PURE__*/React.createElement(PageLoadSchema, {
|
|
73
|
-
pageId:
|
|
73
|
+
pageId: pageId
|
|
74
74
|
}, function (schema) {
|
|
75
75
|
return /*#__PURE__*/React.createElement(ReactRender, _extends({
|
|
76
76
|
schema: schema,
|
|
@@ -17,6 +17,9 @@ function LoadMaterials(props) {
|
|
|
17
17
|
(0, _react.useEffect)(function () {
|
|
18
18
|
initialize().then();
|
|
19
19
|
}, []);
|
|
20
|
+
if (window._components) {
|
|
21
|
+
return props.children;
|
|
22
|
+
}
|
|
20
23
|
function initialize() {
|
|
21
24
|
return _initialize.apply(this, arguments);
|
|
22
25
|
}
|
|
@@ -79,10 +82,6 @@ function _loadMaterials() {
|
|
|
79
82
|
}
|
|
80
83
|
});
|
|
81
84
|
window._components = components;
|
|
82
|
-
/* Object.defineProperty(window, "_components", {
|
|
83
|
-
writable: false,
|
|
84
|
-
value: components
|
|
85
|
-
})*/
|
|
86
85
|
case 8:
|
|
87
86
|
case "end":
|
|
88
87
|
return _context2.stop();
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
exports.__esModule = true;
|
|
5
|
+
exports.LogErrorContent = LogErrorContent;
|
|
6
|
+
var _notification2 = _interopRequireDefault(require("antd/lib/notification"));
|
|
7
|
+
var _message2 = _interopRequireDefault(require("antd/lib/message"));
|
|
8
|
+
var _modal = _interopRequireDefault(require("antd/lib/modal"));
|
|
9
|
+
var _typography = _interopRequireDefault(require("antd/lib/typography"));
|
|
10
|
+
function LogErrorContent(props) {
|
|
11
|
+
var content = /*#__PURE__*/React.createElement(_typography["default"].Text, {
|
|
12
|
+
type: "danger",
|
|
13
|
+
style: {
|
|
14
|
+
whiteSpace: "pre-wrap"
|
|
15
|
+
}
|
|
16
|
+
}, props.message || "");
|
|
17
|
+
if (props.requestId) {
|
|
18
|
+
return /*#__PURE__*/React.createElement("div", null, content, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("a", {
|
|
19
|
+
onClick: function onClick() {
|
|
20
|
+
var _window$utils;
|
|
21
|
+
_modal["default"].destroyAll();
|
|
22
|
+
_message2["default"].destroy();
|
|
23
|
+
_notification2["default"].destroy();
|
|
24
|
+
(_window$utils = window.utils) === null || _window$utils === void 0 ? void 0 : _window$utils.showForm({
|
|
25
|
+
layout: "modal",
|
|
26
|
+
form: {
|
|
27
|
+
id: "form_e3dbb9076a544f86a3bb6ec113e22494"
|
|
28
|
+
},
|
|
29
|
+
mode: "detail",
|
|
30
|
+
dataId: props.requestId
|
|
31
|
+
}).then();
|
|
32
|
+
}
|
|
33
|
+
}, "\u67E5\u770B\u65E5\u5FD7")));
|
|
34
|
+
} else {
|
|
35
|
+
return content;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type PageSize = "small" | "middle" | "larger" | "full";
|
|
2
2
|
export declare const PageSizeEnum: Record<PageSize, string | number>;
|
|
3
3
|
export declare function getPageSize(size?: PageSize): string | number;
|
package/lib/index.js
CHANGED
|
@@ -22,8 +22,6 @@ var _layout = require("./components/layout");
|
|
|
22
22
|
exports.Layout = _layout.Layout;
|
|
23
23
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
24
24
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
|
25
|
-
// @ts-ignore
|
|
26
|
-
|
|
27
25
|
// @ts-ignore
|
|
28
26
|
window.__ReactRender = _reactRender.ReactRender;
|
|
29
27
|
// @ts-ignore
|
package/lib/style.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
require('antd/lib/typography/style');
|
|
2
1
|
require('antd/lib/notification/style');
|
|
3
2
|
require('antd/lib/modal/style');
|
|
4
3
|
require('antd/lib/message/style');
|
|
4
|
+
require('antd/lib/typography/style');
|
|
5
5
|
require('antd/lib/drawer/style');
|
|
6
6
|
require('antd/lib/result/style');
|
|
7
7
|
require('antd/lib/config-provider/style');
|
|
@@ -153,7 +153,7 @@ var RestFormApi = exports.RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
|
153
153
|
_proto.search = /*#__PURE__*/function () {
|
|
154
154
|
var _search = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(searchParams) {
|
|
155
155
|
var _searchParams, _searchParams2;
|
|
156
|
-
var params, config, res;
|
|
156
|
+
var params, config, res, start;
|
|
157
157
|
return _regenerator["default"].wrap(function _callee3$(_context3) {
|
|
158
158
|
while (1) switch (_context3.prev = _context3.next) {
|
|
159
159
|
case 0:
|
|
@@ -182,10 +182,12 @@ var RestFormApi = exports.RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
|
182
182
|
return this.request.get("search", config);
|
|
183
183
|
case 11:
|
|
184
184
|
res = _context3.sent;
|
|
185
|
+
//const res = await this.request.post<any, ManyResult<DataType>>("search", searchParams, config);
|
|
186
|
+
start = Date.now();
|
|
185
187
|
(0, _formApi.assembleAssociationField)(res.data, res.refs);
|
|
186
188
|
console.debug("form.search:", res);
|
|
187
189
|
return _context3.abrupt("return", res);
|
|
188
|
-
case
|
|
190
|
+
case 16:
|
|
189
191
|
case "end":
|
|
190
192
|
return _context3.stop();
|
|
191
193
|
}
|
|
@@ -198,7 +200,7 @@ var RestFormApi = exports.RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
|
198
200
|
}();
|
|
199
201
|
_proto.getById = /*#__PURE__*/function () {
|
|
200
202
|
var _getById = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(id, options) {
|
|
201
|
-
var res;
|
|
203
|
+
var res, start;
|
|
202
204
|
return _regenerator["default"].wrap(function _callee4$(_context4) {
|
|
203
205
|
while (1) switch (_context4.prev = _context4.next) {
|
|
204
206
|
case 0:
|
|
@@ -206,10 +208,11 @@ var RestFormApi = exports.RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
|
206
208
|
return _RestApi.prototype.getById.call(this, id, options);
|
|
207
209
|
case 2:
|
|
208
210
|
res = _context4.sent;
|
|
211
|
+
start = Date.now();
|
|
209
212
|
(0, _formApi.assembleAssociationField)(res.data, res.refs);
|
|
210
|
-
console.debug("
|
|
213
|
+
console.debug("formApi.getById", res);
|
|
211
214
|
return _context4.abrupt("return", res);
|
|
212
|
-
case
|
|
215
|
+
case 7:
|
|
213
216
|
case "end":
|
|
214
217
|
return _context4.stop();
|
|
215
218
|
}
|
|
@@ -28,9 +28,6 @@ function convertSaveData(data) {
|
|
|
28
28
|
}
|
|
29
29
|
function getDataKey(data) {
|
|
30
30
|
var _data$form, _data$form2;
|
|
31
|
-
if (!data) {
|
|
32
|
-
return "undefined";
|
|
33
|
-
}
|
|
34
31
|
var key = (_data$form = data.form) === null || _data$form === void 0 ? void 0 : _data$form.id;
|
|
35
32
|
if ((_data$form2 = data.form) !== null && _data$form2 !== void 0 && _data$form2.fieldId) {
|
|
36
33
|
key += "." + data.form.fieldId;
|
|
@@ -79,18 +76,16 @@ function assembleAssociationFieldV2(data, refs) {
|
|
|
79
76
|
var ref = _step2.value;
|
|
80
77
|
for (var _iterator4 = _createForOfIteratorHelperLoose(ref.data), _step4; !(_step4 = _iterator4()).done;) {
|
|
81
78
|
var datum = _step4.value;
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
dataMap.set(key, datum);
|
|
85
|
-
}
|
|
79
|
+
var key = getDataKey(datum);
|
|
80
|
+
dataMap.set(key, datum);
|
|
86
81
|
}
|
|
87
82
|
}
|
|
88
83
|
|
|
89
84
|
//组装refs的关联属性
|
|
90
85
|
for (var _iterator3 = _createForOfIteratorHelperLoose(dataMap.values()), _step3; !(_step3 = _iterator3()).done;) {
|
|
91
86
|
var item = _step3.value;
|
|
92
|
-
for (var _i2 = 0, _Object$
|
|
93
|
-
var _key = _Object$
|
|
87
|
+
for (var _i2 = 0, _Object$keys = Object.keys(item); _i2 < _Object$keys.length; _i2++) {
|
|
88
|
+
var _key = _Object$keys[_i2];
|
|
94
89
|
// @ts-ignore
|
|
95
90
|
var value = item[_key];
|
|
96
91
|
assembleAssociationFieldDataV2(value, dataMap);
|
|
@@ -104,14 +99,10 @@ function assembleAssociationFieldV2(data, refs) {
|
|
|
104
99
|
});
|
|
105
100
|
} else if (value !== null && value !== void 0 && value.id) {
|
|
106
101
|
assembleAssociationFieldDataV2(value, dataMap);
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
var subValues = value[key];
|
|
102
|
+
//处理子表
|
|
103
|
+
for (var _i = 0, _Object$values = Object.values(value); _i < _Object$values.length; _i++) {
|
|
104
|
+
var subValues = _Object$values[_i];
|
|
111
105
|
if (typeof subValues == "object") {
|
|
112
|
-
if (key == "parent") {
|
|
113
|
-
continue;
|
|
114
|
-
}
|
|
115
106
|
loopAssembleAssociation(subValues);
|
|
116
107
|
}
|
|
117
108
|
}
|
|
@@ -124,25 +115,21 @@ function assembleAssociationFieldDataV2(data, dataMap) {
|
|
|
124
115
|
if (data == null) {
|
|
125
116
|
return;
|
|
126
117
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
118
|
+
if (Array.isArray(data)) {
|
|
119
|
+
data.forEach(function (item) {
|
|
120
|
+
return assembleAssociationFieldDataV2(item, dataMap);
|
|
121
|
+
});
|
|
122
|
+
} else {
|
|
123
|
+
var _data$form3;
|
|
124
|
+
if (data !== null && data !== void 0 && (_data$form3 = data.form) !== null && _data$form3 !== void 0 && _data$form3.id && data !== null && data !== void 0 && data.id) {
|
|
125
|
+
delete data._load;
|
|
126
|
+
var key = getDataKey(data);
|
|
127
|
+
var value = dataMap.get(key);
|
|
128
|
+
if (value) {
|
|
129
|
+
Object.assign(data, value);
|
|
135
130
|
delete data._load;
|
|
136
|
-
var key = getDataKey(data);
|
|
137
|
-
var value = dataMap.get(key);
|
|
138
|
-
if (value) {
|
|
139
|
-
Object.assign(data, value);
|
|
140
|
-
delete data._load;
|
|
141
|
-
}
|
|
142
131
|
}
|
|
143
132
|
}
|
|
144
|
-
} catch (e) {
|
|
145
|
-
console.log("装配对象失败", data, dataMap);
|
|
146
133
|
}
|
|
147
134
|
}
|
|
148
135
|
function assembleAssociationField(data, refs) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AxiosInstance, AxiosRequestConfig } from "axios";
|
|
2
|
-
export
|
|
2
|
+
export type ValueType = "value" | "field" | "express";
|
|
3
3
|
export interface RestApiOptions {
|
|
4
4
|
/**
|
|
5
5
|
* 超时时间
|
|
@@ -13,13 +13,13 @@ export interface RestApiOptions {
|
|
|
13
13
|
}
|
|
14
14
|
export interface FilterRule {
|
|
15
15
|
connector?: "and" | "or";
|
|
16
|
-
key
|
|
16
|
+
key: string;
|
|
17
17
|
operator?: OperatorType;
|
|
18
18
|
valueType?: ValueType;
|
|
19
19
|
value?: any;
|
|
20
20
|
rules?: FilterRule[];
|
|
21
21
|
}
|
|
22
|
-
export
|
|
22
|
+
export type OperatorType = "eq" | "ne" | "gt" | "goe" | "lt" | "loe" | "like" | "notLike" | "in" | "notIn" | "isNull" | "isNotNull" | "between" | "notBetween";
|
|
23
23
|
export interface RestSearchParams {
|
|
24
24
|
page?: number;
|
|
25
25
|
pageSize?: number;
|
|
@@ -54,7 +54,7 @@ export declare abstract class BaseRestApi<DataType> {
|
|
|
54
54
|
*/
|
|
55
55
|
deleteById(id: string, options?: BaseRequestOptions<DataType>): Promise<OneResult<DataType>>;
|
|
56
56
|
delete(data: any | any[], options?: BaseRequestOptions<DataType>): Promise<OneResult<DataType>>;
|
|
57
|
-
|
|
57
|
+
showError(type: string, res: BaseResult<any>): Promise<void>;
|
|
58
58
|
}
|
|
59
59
|
export declare class RestApi<DataType> extends BaseRestApi<DataType> {
|
|
60
60
|
constructor(uri: string, options?: RestApiOptions);
|
|
@@ -98,8 +98,8 @@ export interface BaseType {
|
|
|
98
98
|
*/
|
|
99
99
|
export interface BaseResult<DataType> {
|
|
100
100
|
success: boolean;
|
|
101
|
-
requestId?: string;
|
|
102
101
|
message?: string;
|
|
102
|
+
requestId: string;
|
|
103
103
|
refs?: Refs;
|
|
104
104
|
}
|
|
105
105
|
export interface Ref {
|
|
@@ -110,7 +110,7 @@ export interface Ref {
|
|
|
110
110
|
fieldIds: string[];
|
|
111
111
|
data: BaseType[];
|
|
112
112
|
}
|
|
113
|
-
export
|
|
113
|
+
export type Refs = Ref[];
|
|
114
114
|
export interface OneResult<DataType> extends BaseResult<DataType> {
|
|
115
115
|
data: DataType & BaseType;
|
|
116
116
|
}
|
|
@@ -5,7 +5,6 @@ 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 _typography = _interopRequireDefault(require("antd/lib/typography"));
|
|
9
8
|
var _notification2 = _interopRequireDefault(require("antd/lib/notification"));
|
|
10
9
|
var _modal = _interopRequireDefault(require("antd/lib/modal"));
|
|
11
10
|
var _message2 = _interopRequireDefault(require("antd/lib/message"));
|
|
@@ -13,7 +12,7 @@ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/
|
|
|
13
12
|
var _axios = _interopRequireDefault(require("axios"));
|
|
14
13
|
var _index = require("./index");
|
|
15
14
|
var _data = require("../data");
|
|
16
|
-
var
|
|
15
|
+
var _logErrorContent = require("../../components/log-error-content");
|
|
17
16
|
var BaseRestApi = exports.BaseRestApi = /*#__PURE__*/function () {
|
|
18
17
|
function BaseRestApi(uri, options) {
|
|
19
18
|
this.uri = void 0;
|
|
@@ -350,72 +349,64 @@ var BaseRestApi = exports.BaseRestApi = /*#__PURE__*/function () {
|
|
|
350
349
|
return _delete2.apply(this, arguments);
|
|
351
350
|
}
|
|
352
351
|
return _delete;
|
|
353
|
-
}()
|
|
354
|
-
|
|
355
|
-
_proto.showError =
|
|
356
|
-
/*#__PURE__*/
|
|
357
|
-
function () {
|
|
352
|
+
}();
|
|
353
|
+
_proto.showError = /*#__PURE__*/function () {
|
|
358
354
|
var _showError = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee8(type, res) {
|
|
359
|
-
var msg, props
|
|
355
|
+
var msg, props;
|
|
360
356
|
return _regenerator["default"].wrap(function _callee8$(_context8) {
|
|
361
357
|
while (1) switch (_context8.prev = _context8.next) {
|
|
362
358
|
case 0:
|
|
363
359
|
msg = res.message;
|
|
364
360
|
_context8.prev = 1;
|
|
365
361
|
if (!msg) {
|
|
366
|
-
_context8.next =
|
|
362
|
+
_context8.next = 19;
|
|
367
363
|
break;
|
|
368
364
|
}
|
|
369
365
|
props = JSON.parse(msg);
|
|
370
|
-
content =
|
|
371
|
-
requestId: res.requestId,
|
|
372
|
-
message: props.message
|
|
373
|
-
});
|
|
374
|
-
props.content = content;
|
|
375
|
-
props.message = content;
|
|
366
|
+
props.content = props.message;
|
|
376
367
|
if (!props.title) {
|
|
377
368
|
props.title = "" + this.title + type;
|
|
378
369
|
}
|
|
379
370
|
if (!(props.type == "message")) {
|
|
380
|
-
_context8.next =
|
|
371
|
+
_context8.next = 11;
|
|
381
372
|
break;
|
|
382
373
|
}
|
|
383
374
|
_message2["default"].error(props);
|
|
384
375
|
return _context8.abrupt("return");
|
|
385
|
-
case
|
|
376
|
+
case 11:
|
|
386
377
|
if (!(props.type == "modal")) {
|
|
387
|
-
_context8.next =
|
|
378
|
+
_context8.next = 16;
|
|
388
379
|
break;
|
|
389
380
|
}
|
|
390
381
|
_modal["default"].error(props);
|
|
391
382
|
return _context8.abrupt("return");
|
|
392
|
-
case
|
|
383
|
+
case 16:
|
|
393
384
|
if (!(props.type == "notification")) {
|
|
394
|
-
_context8.next =
|
|
385
|
+
_context8.next = 19;
|
|
395
386
|
break;
|
|
396
387
|
}
|
|
397
388
|
_notification2["default"].error(props);
|
|
398
389
|
return _context8.abrupt("return");
|
|
399
|
-
case
|
|
400
|
-
_context8.next =
|
|
390
|
+
case 19:
|
|
391
|
+
_context8.next = 25;
|
|
401
392
|
break;
|
|
402
|
-
case
|
|
403
|
-
_context8.prev =
|
|
393
|
+
case 21:
|
|
394
|
+
_context8.prev = 21;
|
|
404
395
|
_context8.t0 = _context8["catch"](1);
|
|
405
396
|
console.error("" + this.title + type + (msg || ""));
|
|
406
397
|
_modal["default"].error({
|
|
407
398
|
title: "" + this.title + type,
|
|
408
399
|
centered: true,
|
|
409
|
-
content: /*#__PURE__*/React.createElement(
|
|
400
|
+
content: /*#__PURE__*/React.createElement(_logErrorContent.LogErrorContent, {
|
|
410
401
|
requestId: res.requestId,
|
|
411
402
|
message: res.message
|
|
412
403
|
})
|
|
413
404
|
});
|
|
414
|
-
case
|
|
405
|
+
case 25:
|
|
415
406
|
case "end":
|
|
416
407
|
return _context8.stop();
|
|
417
408
|
}
|
|
418
|
-
}, _callee8, this, [[1,
|
|
409
|
+
}, _callee8, this, [[1, 21]]);
|
|
419
410
|
}));
|
|
420
411
|
function showError(_x15, _x16) {
|
|
421
412
|
return _showError.apply(this, arguments);
|
|
@@ -424,32 +415,13 @@ var BaseRestApi = exports.BaseRestApi = /*#__PURE__*/function () {
|
|
|
424
415
|
}();
|
|
425
416
|
return BaseRestApi;
|
|
426
417
|
}();
|
|
427
|
-
function
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
}
|
|
433
|
-
}, props.message || "");
|
|
434
|
-
if (props.requestId) {
|
|
435
|
-
return /*#__PURE__*/React.createElement("div", null, content, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("a", {
|
|
436
|
-
onClick: function onClick() {
|
|
437
|
-
_modal["default"].destroyAll();
|
|
438
|
-
_message2["default"].destroy();
|
|
439
|
-
_notification2["default"].destroy();
|
|
440
|
-
(0, _page.showForm)({
|
|
441
|
-
layout: "modal",
|
|
442
|
-
form: {
|
|
443
|
-
id: "form_e3dbb9076a544f86a3bb6ec113e22494"
|
|
444
|
-
},
|
|
445
|
-
mode: "detail",
|
|
446
|
-
dataId: props.requestId
|
|
447
|
-
}).then();
|
|
448
|
-
}
|
|
449
|
-
}, "\u67E5\u770B\u65E5\u5FD7")));
|
|
450
|
-
} else {
|
|
451
|
-
return content;
|
|
418
|
+
function getStringId(item) {
|
|
419
|
+
if (typeof (item === null || item === void 0 ? void 0 : item.id) === "string") {
|
|
420
|
+
return item.id;
|
|
421
|
+
} else if (typeof item === "string") {
|
|
422
|
+
return item;
|
|
452
423
|
}
|
|
424
|
+
return null;
|
|
453
425
|
}
|
|
454
426
|
var RestApi = exports.RestApi = /*#__PURE__*/function (_BaseRestApi2) {
|
|
455
427
|
function RestApi(uri, options) {
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
exports.__esModule = true;
|
|
5
5
|
exports.getSchema = getSchema;
|
|
6
|
+
exports.getSchemaFromCache = getSchemaFromCache;
|
|
6
7
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
7
8
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
8
9
|
var _cache = require("../cache");
|
|
@@ -15,24 +16,26 @@ function _getSchema() {
|
|
|
15
16
|
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
16
17
|
while (1) switch (_context.prev = _context.next) {
|
|
17
18
|
case 0:
|
|
18
|
-
if (typeof mock != "boolean") {
|
|
19
|
-
if (typeof window.__mock == "boolean") {
|
|
20
|
-
mock = window.__mock;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
19
|
key = mock ? pageId + "_mock" : pageId;
|
|
24
|
-
_context.next =
|
|
20
|
+
_context.next = 3;
|
|
25
21
|
return _cache.schema.getInstance(key, {
|
|
26
22
|
mock: mock,
|
|
27
23
|
pageId: pageId
|
|
28
24
|
});
|
|
29
|
-
case
|
|
25
|
+
case 3:
|
|
30
26
|
return _context.abrupt("return", _context.sent);
|
|
31
|
-
case
|
|
27
|
+
case 4:
|
|
32
28
|
case "end":
|
|
33
29
|
return _context.stop();
|
|
34
30
|
}
|
|
35
31
|
}, _callee);
|
|
36
32
|
}));
|
|
37
33
|
return _getSchema.apply(this, arguments);
|
|
34
|
+
}
|
|
35
|
+
function getSchemaFromCache(pageId, mock) {
|
|
36
|
+
if (!pageId) {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
var key = mock ? pageId + "_mock" : pageId;
|
|
40
|
+
return _cache.schema.get(key);
|
|
38
41
|
}
|
|
@@ -67,10 +67,15 @@ function _loadStyle() {
|
|
|
67
67
|
case 2:
|
|
68
68
|
return _context3.abrupt("return", new Promise( /*#__PURE__*/function () {
|
|
69
69
|
var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(resolve) {
|
|
70
|
-
var target;
|
|
70
|
+
var callback, target;
|
|
71
71
|
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
72
72
|
while (1) switch (_context2.prev = _context2.next) {
|
|
73
73
|
case 0:
|
|
74
|
+
callback = function _callback(status) {
|
|
75
|
+
setTimeout(function () {
|
|
76
|
+
resolve(status);
|
|
77
|
+
}, 10);
|
|
78
|
+
};
|
|
74
79
|
//加载式样
|
|
75
80
|
target = doc.querySelector("link[href='" + src + "']");
|
|
76
81
|
if (!target) {
|
|
@@ -78,16 +83,16 @@ function _loadStyle() {
|
|
|
78
83
|
target.href = src;
|
|
79
84
|
target.rel = "stylesheet";
|
|
80
85
|
target.onload = function () {
|
|
81
|
-
|
|
86
|
+
return callback(true);
|
|
82
87
|
};
|
|
83
88
|
target.onerror = function () {
|
|
84
|
-
|
|
89
|
+
return callback(false);
|
|
85
90
|
};
|
|
86
91
|
doc.head.appendChild(target);
|
|
87
92
|
} else {
|
|
88
|
-
|
|
93
|
+
callback(true);
|
|
89
94
|
}
|
|
90
|
-
case
|
|
95
|
+
case 3:
|
|
91
96
|
case "end":
|
|
92
97
|
return _context2.stop();
|
|
93
98
|
}
|
|
@@ -125,8 +130,10 @@ function _loadScript() {
|
|
|
125
130
|
return _regenerator["default"].wrap(function _callee4$(_context4) {
|
|
126
131
|
while (1) switch (_context4.prev = _context4.next) {
|
|
127
132
|
case 0:
|
|
128
|
-
callback = function
|
|
129
|
-
|
|
133
|
+
callback = function _callback2(status) {
|
|
134
|
+
setTimeout(function () {
|
|
135
|
+
resolve(status);
|
|
136
|
+
}, 10);
|
|
130
137
|
};
|
|
131
138
|
//加载脚本
|
|
132
139
|
target = doc.querySelector("script[src='" + src + "']");
|
|
@@ -137,10 +144,10 @@ function _loadScript() {
|
|
|
137
144
|
}
|
|
138
145
|
target.src = src;
|
|
139
146
|
target.onload = function () {
|
|
140
|
-
callback(true);
|
|
147
|
+
return callback(true);
|
|
141
148
|
};
|
|
142
149
|
target.onerror = function () {
|
|
143
|
-
callback(false);
|
|
150
|
+
return callback(false);
|
|
144
151
|
};
|
|
145
152
|
doc.body.appendChild(target);
|
|
146
153
|
} else {
|