@zhubangyun/lowcode-core 5.10.83 → 5.10.211
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/react-render/index.d.ts +1 -1
- package/es/components/react-render/index.js +4 -2
- 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.d.ts +5 -0
- package/es/utils/api/form-api.utils.js +43 -26
- 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 +16 -6
- 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 +10 -2
- package/es/utils/page/page-render.js +11 -11
- 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/react-render/index.d.ts +1 -1
- package/lib/components/react-render/index.js +5 -3
- 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.d.ts +5 -0
- package/lib/utils/api/form-api.utils.js +43 -26
- 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 +17 -6
- 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 +10 -2
- package/lib/utils/page/page-render.js +11 -11
- 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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PageLayoutType } from "./page-layout";
|
|
2
2
|
import { FilterRule } from "../api/rest-api";
|
|
3
|
-
export
|
|
3
|
+
export type PageFormDataManagerModeType = "associationField" | "dataManager" | "selectOne" | "selectMore";
|
|
4
4
|
export interface ShowPageFormDataManagerProps {
|
|
5
5
|
container?: HTMLDivElement;
|
|
6
6
|
layout?: PageLayoutType;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PageLayoutType } from "./page-layout";
|
|
2
|
-
export
|
|
2
|
+
export type PageFormModeType = "add" | "edit" | "detail";
|
|
3
3
|
export interface ShowFormProps {
|
|
4
4
|
container?: HTMLDivElement;
|
|
5
5
|
layout?: PageLayoutType;
|
|
@@ -8,6 +8,7 @@ export interface ShowFormProps {
|
|
|
8
8
|
fieldId?: string;
|
|
9
9
|
};
|
|
10
10
|
mode?: PageFormModeType;
|
|
11
|
+
lockMode?: boolean;
|
|
11
12
|
dataId?: string;
|
|
12
13
|
onSubmitOk?: () => void;
|
|
13
14
|
onRemoveOk?: () => void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Component } from "react";
|
|
2
|
-
export
|
|
2
|
+
export type PageLayoutType = "page" | "modal" | "drawer";
|
|
3
3
|
interface PageLayoutProps {
|
|
4
4
|
layout?: PageLayoutType;
|
|
5
5
|
children: any;
|
|
@@ -16,6 +16,6 @@ export declare class PageLayout extends Component<PageLayoutProps, PageLayoutSta
|
|
|
16
16
|
componentWillUnmount(): void;
|
|
17
17
|
getWith: () => number;
|
|
18
18
|
handleResize: () => void;
|
|
19
|
-
render():
|
|
19
|
+
render(): JSX.Element;
|
|
20
20
|
}
|
|
21
21
|
export {};
|
|
@@ -2,6 +2,7 @@ import _Drawer from "antd/es/drawer";
|
|
|
2
2
|
import _Modal from "antd/es/modal";
|
|
3
3
|
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
|
|
4
4
|
import React, { Component } from "react";
|
|
5
|
+
import { LoadMaterials } from "../../components/load-materials";
|
|
5
6
|
export var PageLayout = /*#__PURE__*/function (_Component) {
|
|
6
7
|
function PageLayout(props) {
|
|
7
8
|
var _this;
|
|
@@ -36,10 +37,9 @@ export var PageLayout = /*#__PURE__*/function (_Component) {
|
|
|
36
37
|
window.removeEventListener("resize", this.handleResize);
|
|
37
38
|
};
|
|
38
39
|
_proto.render = function render() {
|
|
39
|
-
var
|
|
40
|
-
layout = _this$props.layout,
|
|
41
|
-
children = _this$props.children;
|
|
40
|
+
var layout = this.props.layout;
|
|
42
41
|
var state = this.state;
|
|
42
|
+
var children = /*#__PURE__*/React.createElement(LoadMaterialChildren, null, this.props.children);
|
|
43
43
|
var restProps = {
|
|
44
44
|
open: state.open,
|
|
45
45
|
width: state.width,
|
|
@@ -70,4 +70,7 @@ export var PageLayout = /*#__PURE__*/function (_Component) {
|
|
|
70
70
|
return children;
|
|
71
71
|
};
|
|
72
72
|
return PageLayout;
|
|
73
|
-
}(Component);
|
|
73
|
+
}(Component);
|
|
74
|
+
function LoadMaterialChildren(props) {
|
|
75
|
+
return /*#__PURE__*/React.createElement(LoadMaterials, null, props.children);
|
|
76
|
+
}
|
|
@@ -3,19 +3,24 @@ 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;
|
|
9
|
-
var
|
|
10
|
+
var cache = getSchemaFromCache(pageId);
|
|
11
|
+
var _useState = useState(!cache),
|
|
10
12
|
loading = _useState[0],
|
|
11
13
|
setLoading = _useState[1];
|
|
12
|
-
var _useState2 = useState(),
|
|
14
|
+
var _useState2 = useState(cache === null || cache === void 0 ? void 0 : cache.data),
|
|
13
15
|
schema = _useState2[0],
|
|
14
16
|
setSchema = _useState2[1];
|
|
15
17
|
var _useState3 = useState(),
|
|
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(cache.data);
|
|
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,28 @@ 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
|
-
|
|
39
|
+
console.log("渲染", container, root, element);
|
|
40
|
+
root.render(element);
|
|
41
|
+
case 8:
|
|
42
42
|
case "end":
|
|
43
43
|
return _context.stop();
|
|
44
44
|
}
|
|
@@ -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.page.showForm({
|
|
25
|
+
layout: "modal",
|
|
26
|
+
form: {
|
|
27
|
+
id: "40120d0c-2b35-4ae7-8711-acae048f1a0"
|
|
28
|
+
},
|
|
29
|
+
mode: "detail",
|
|
30
|
+
dataId: props.requestId
|
|
31
|
+
}).then();
|
|
32
|
+
}
|
|
33
|
+
}, "\u67E5\u770B\u65E5\u5FD7")));
|
|
34
|
+
} else {
|
|
35
|
+
return content;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -3,5 +3,5 @@ import { IRendererProps } from "@zhubangyun/lowcode-render-core/lib/types";
|
|
|
3
3
|
export declare class ReactRender extends PureComponent<IRendererProps & {}> {
|
|
4
4
|
key: string;
|
|
5
5
|
node: any;
|
|
6
|
-
render(): import("react").JSX.Element;
|
|
6
|
+
render(utils?: any): import("react").JSX.Element;
|
|
7
7
|
}
|
|
@@ -8,7 +8,6 @@ var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inh
|
|
|
8
8
|
var _react = require("react");
|
|
9
9
|
var _lowcodeDatasourceFetchHandler = require("@alilc/lowcode-datasource-fetch-handler");
|
|
10
10
|
var _reactRenderFactory = _interopRequireDefault(require("./react-render-factory"));
|
|
11
|
-
var _utils = _interopRequireDefault(require("../../utils"));
|
|
12
11
|
var ReactRender = exports.ReactRender = /*#__PURE__*/function (_PureComponent) {
|
|
13
12
|
function ReactRender() {
|
|
14
13
|
var _this;
|
|
@@ -22,8 +21,11 @@ var ReactRender = exports.ReactRender = /*#__PURE__*/function (_PureComponent) {
|
|
|
22
21
|
}
|
|
23
22
|
(0, _inheritsLoose2["default"])(ReactRender, _PureComponent);
|
|
24
23
|
var _proto = ReactRender.prototype;
|
|
25
|
-
_proto.render = function render() {
|
|
24
|
+
_proto.render = function render(utils) {
|
|
26
25
|
var _this2 = this;
|
|
26
|
+
if (utils === void 0) {
|
|
27
|
+
utils = window.utils;
|
|
28
|
+
}
|
|
27
29
|
var components = this.props.components || window._components;
|
|
28
30
|
return /*#__PURE__*/React.createElement(_reactRenderFactory["default"], (0, _extends2["default"])({
|
|
29
31
|
key: this.key
|
|
@@ -34,7 +36,7 @@ var ReactRender = exports.ReactRender = /*#__PURE__*/function (_PureComponent) {
|
|
|
34
36
|
thisRequiredInJSE: true,
|
|
35
37
|
components: components,
|
|
36
38
|
appHelper: {
|
|
37
|
-
utils:
|
|
39
|
+
utils: utils,
|
|
38
40
|
requestHandlersMap: {
|
|
39
41
|
fetch: (0, _lowcodeDatasourceFetchHandler.createFetchHandler)()
|
|
40
42
|
}
|
|
@@ -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
|
}
|
|
@@ -3,6 +3,11 @@ export declare function convertSaveData(data: any): any;
|
|
|
3
3
|
export declare function handleEntityLabel(data: BaseType | BaseType[]): void;
|
|
4
4
|
export declare function dataToLabel(value: any): any;
|
|
5
5
|
export declare function assembleAssociationFieldV2(data: BaseType | BaseType[], refs?: Refs): void;
|
|
6
|
+
/**
|
|
7
|
+
* 加载字段
|
|
8
|
+
* @param data
|
|
9
|
+
* @param dataMap
|
|
10
|
+
*/
|
|
6
11
|
export declare function assembleAssociationFieldDataV2(data: BaseType | BaseType[], dataMap: Map<string, BaseType>): void;
|
|
7
12
|
export declare function assembleAssociationField(data: BaseType | BaseType[], refs?: Refs): void;
|
|
8
13
|
export declare function handleFilterRules(filters: FilterRule[], options: {
|
|
@@ -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;
|
|
@@ -47,7 +44,7 @@ function handleEntityLabel(data) {
|
|
|
47
44
|
var labelField = (_item$form = item.form) === null || _item$form === void 0 ? void 0 : _item$form.labelField;
|
|
48
45
|
if (labelField) {
|
|
49
46
|
// @ts-ignore
|
|
50
|
-
var value = item
|
|
47
|
+
var value = safeGet(item, labelField);
|
|
51
48
|
item.label = dataToLabel(value);
|
|
52
49
|
}
|
|
53
50
|
}
|
|
@@ -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);
|
|
@@ -103,33 +98,35 @@ function assembleAssociationFieldV2(data, refs) {
|
|
|
103
98
|
return loopAssembleAssociation(item);
|
|
104
99
|
});
|
|
105
100
|
} else if (value !== null && value !== void 0 && value.id) {
|
|
101
|
+
handleEntityLabel(value);
|
|
106
102
|
assembleAssociationFieldDataV2(value, dataMap);
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
var subValues = value[key];
|
|
103
|
+
//处理子表
|
|
104
|
+
for (var _i = 0, _Object$values = Object.values(value); _i < _Object$values.length; _i++) {
|
|
105
|
+
var subValues = _Object$values[_i];
|
|
111
106
|
if (typeof subValues == "object") {
|
|
112
|
-
if (key == "parent") {
|
|
113
|
-
continue;
|
|
114
|
-
}
|
|
115
107
|
loopAssembleAssociation(subValues);
|
|
116
108
|
}
|
|
117
109
|
}
|
|
118
110
|
}
|
|
119
111
|
}
|
|
120
112
|
loopAssembleAssociation(data);
|
|
121
|
-
handleEntityLabel(data);
|
|
122
113
|
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* 加载字段
|
|
117
|
+
* @param data
|
|
118
|
+
* @param dataMap
|
|
119
|
+
*/
|
|
123
120
|
function assembleAssociationFieldDataV2(data, dataMap) {
|
|
124
121
|
if (data == null) {
|
|
125
122
|
return;
|
|
126
123
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
124
|
+
if (Array.isArray(data)) {
|
|
125
|
+
data.forEach(function (item) {
|
|
126
|
+
return assembleAssociationFieldDataV2(item, dataMap);
|
|
127
|
+
});
|
|
128
|
+
} else {
|
|
129
|
+
if (data._load == false) {
|
|
133
130
|
var _data$form3;
|
|
134
131
|
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) {
|
|
135
132
|
delete data._load;
|
|
@@ -141,8 +138,6 @@ function assembleAssociationFieldDataV2(data, dataMap) {
|
|
|
141
138
|
}
|
|
142
139
|
}
|
|
143
140
|
}
|
|
144
|
-
} catch (e) {
|
|
145
|
-
console.log("装配对象失败", data, dataMap);
|
|
146
141
|
}
|
|
147
142
|
}
|
|
148
143
|
function assembleAssociationField(data, refs) {
|
|
@@ -176,4 +171,26 @@ function handleFilterRules(filters, options) {
|
|
|
176
171
|
} else {
|
|
177
172
|
return undefined;
|
|
178
173
|
}
|
|
174
|
+
}
|
|
175
|
+
function safeGet(value, key) {
|
|
176
|
+
if (typeof value !== "object") {
|
|
177
|
+
return null;
|
|
178
|
+
}
|
|
179
|
+
if (typeof key !== "string") {
|
|
180
|
+
return null;
|
|
181
|
+
}
|
|
182
|
+
if (!value || !key) return undefined;
|
|
183
|
+
var paths = key.split(".");
|
|
184
|
+
function safeGetValue(v) {
|
|
185
|
+
if (typeof v !== "object") {
|
|
186
|
+
return v;
|
|
187
|
+
}
|
|
188
|
+
if (paths.length) {
|
|
189
|
+
var k = paths.shift();
|
|
190
|
+
return safeGetValue(v === null || v === void 0 ? void 0 : v[k]);
|
|
191
|
+
} else {
|
|
192
|
+
return v;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
return safeGetValue(value);
|
|
179
196
|
}
|
|
@@ -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
|
}
|