@zhubangyun/lowcode-core 5.4.116 → 5.4.150
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.js +1 -1
- package/es/utils/api/form-api.d.ts +1 -1
- package/es/utils/api/form-api.js +8 -3
- package/es/utils/api/index.d.ts +2 -0
- package/es/utils/api/index.js +15 -1
- package/es/utils/api/rest-api.js +1 -1
- package/es/utils/page/index.d.ts +2 -2
- package/es/utils/page/index.js +69 -1
- package/es/utils/page/page-form.d.ts +1 -1
- package/es/utils/page/page-form.js +71 -39
- package/es/utils/page/page-layout.d.ts +5 -0
- package/es/utils/page/page-layout.js +20 -7
- package/lib/index.js +1 -1
- package/lib/utils/api/form-api.d.ts +1 -1
- package/lib/utils/api/form-api.js +8 -3
- package/lib/utils/api/index.d.ts +2 -0
- package/lib/utils/api/index.js +18 -2
- package/lib/utils/api/rest-api.js +2 -2
- package/lib/utils/page/index.d.ts +2 -2
- package/lib/utils/page/index.js +72 -1
- package/lib/utils/page/page-form.d.ts +1 -1
- package/lib/utils/page/page-form.js +76 -42
- package/lib/utils/page/page-layout.d.ts +5 -0
- package/lib/utils/page/page-layout.js +20 -7
- package/package.json +1 -1
- /package/es/utils/api/{request.d.ts → Request.d.ts} +0 -0
- /package/es/utils/api/{request.js → Request.js} +0 -0
- /package/lib/utils/api/{request.d.ts → Request.d.ts} +0 -0
- /package/lib/utils/api/{request.js → Request.js} +0 -0
package/es/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { RestApi } from "./rest-api";
|
|
|
2
2
|
import { AxiosRequestConfig } from "axios";
|
|
3
3
|
export declare class RestFormApi<DataType> extends RestApi<DataType> {
|
|
4
4
|
private readonly formId;
|
|
5
|
-
private readonly fieldId
|
|
5
|
+
private readonly fieldId?;
|
|
6
6
|
private readonly mock;
|
|
7
7
|
private initialized;
|
|
8
8
|
private schema;
|
package/es/utils/api/form-api.js
CHANGED
|
@@ -6,6 +6,7 @@ import { getSchema } from "./index";
|
|
|
6
6
|
export var RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
7
7
|
function RestFormApi(formId, fieldId, mock) {
|
|
8
8
|
var _this;
|
|
9
|
+
console.log(formId, fieldId);
|
|
9
10
|
_this = _RestApi.call(this, "forms", {}) || this;
|
|
10
11
|
_this.formId = void 0;
|
|
11
12
|
_this.fieldId = void 0;
|
|
@@ -13,7 +14,7 @@ export var RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
|
13
14
|
_this.initialized = false;
|
|
14
15
|
_this.schema = void 0;
|
|
15
16
|
_this.formId = formId;
|
|
16
|
-
_this.fieldId =
|
|
17
|
+
_this.fieldId = fieldId;
|
|
17
18
|
_this.mock = !!mock;
|
|
18
19
|
return _this;
|
|
19
20
|
}
|
|
@@ -72,8 +73,12 @@ export var RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
|
72
73
|
case 2:
|
|
73
74
|
config.params = config.params || {};
|
|
74
75
|
config.params.formId = this.formId;
|
|
75
|
-
|
|
76
|
-
|
|
76
|
+
if (this.fieldId) {
|
|
77
|
+
config.params.fieldId = this.fieldId;
|
|
78
|
+
}
|
|
79
|
+
if (this.mock) {
|
|
80
|
+
config.params.mock = this.mock;
|
|
81
|
+
}
|
|
77
82
|
case 6:
|
|
78
83
|
case "end":
|
|
79
84
|
return _context2.stop();
|
package/es/utils/api/index.d.ts
CHANGED
|
@@ -6,3 +6,5 @@ export { RestFormApi } from "./form-api";
|
|
|
6
6
|
export declare const apiRequest: import("axios").AxiosInstance;
|
|
7
7
|
export declare function getSchema(pageId: string, mock?: boolean): Promise<OneResult<any>>;
|
|
8
8
|
export declare function getFormApi(formId: string, fieldId?: string, mock?: boolean): Promise<RestFormApi<any>>;
|
|
9
|
+
export declare function onFulfilled(res: any): any;
|
|
10
|
+
export declare function onRejected(error: any): any;
|
package/es/utils/api/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
2
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
3
3
|
import axios from "axios";
|
|
4
|
-
import { onFulfilled, onRejected } from "./request";
|
|
5
4
|
import { formApi, schema } from "../cache";
|
|
6
5
|
export { RestApi } from "./rest-api";
|
|
7
6
|
export { loadUserInfo } from "./user-info";
|
|
@@ -76,4 +75,19 @@ function _getFormApi() {
|
|
|
76
75
|
}, _callee2);
|
|
77
76
|
}));
|
|
78
77
|
return _getFormApi.apply(this, arguments);
|
|
78
|
+
}
|
|
79
|
+
export function onFulfilled(res) {
|
|
80
|
+
return res.data;
|
|
81
|
+
}
|
|
82
|
+
export function onRejected(error) {
|
|
83
|
+
var _error$response = error.response,
|
|
84
|
+
status = _error$response.status,
|
|
85
|
+
statusText = _error$response.statusText;
|
|
86
|
+
if (status == 400) {
|
|
87
|
+
return error.response.data || {};
|
|
88
|
+
}
|
|
89
|
+
return {
|
|
90
|
+
success: false,
|
|
91
|
+
message: statusText
|
|
92
|
+
};
|
|
79
93
|
}
|
package/es/utils/api/rest-api.js
CHANGED
|
@@ -2,7 +2,7 @@ import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
|
|
|
2
2
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
3
3
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
4
4
|
import axios from "axios";
|
|
5
|
-
import { onFulfilled, onRejected } from "./
|
|
5
|
+
import { onFulfilled, onRejected } from "./index";
|
|
6
6
|
export var BaseRestApi = /*#__PURE__*/function () {
|
|
7
7
|
function BaseRestApi(uri, options) {
|
|
8
8
|
this.uri = void 0;
|
package/es/utils/page/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { showForm } from "./page-form";
|
|
2
|
-
export
|
|
3
|
-
|
|
2
|
+
export declare function openPage(url: string, target?: string): Promise<any>;
|
|
3
|
+
export declare function closePage(url: string, target?: string): Promise<void>;
|
package/es/utils/page/index.js
CHANGED
|
@@ -1 +1,69 @@
|
|
|
1
|
-
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
3
|
+
export { showForm } from "./page-form";
|
|
4
|
+
export function openPage(_x, _x2) {
|
|
5
|
+
return _openPage.apply(this, arguments);
|
|
6
|
+
}
|
|
7
|
+
function _openPage() {
|
|
8
|
+
_openPage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(url, target) {
|
|
9
|
+
var _window$parent;
|
|
10
|
+
var page, func;
|
|
11
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
12
|
+
while (1) switch (_context.prev = _context.next) {
|
|
13
|
+
case 0:
|
|
14
|
+
// @ts-ignore
|
|
15
|
+
func = (_window$parent = window.parent) === null || _window$parent === void 0 ? void 0 : _window$parent.openWorkPlatformTab;
|
|
16
|
+
if (!func) {
|
|
17
|
+
_context.next = 7;
|
|
18
|
+
break;
|
|
19
|
+
}
|
|
20
|
+
_context.next = 4;
|
|
21
|
+
return func({
|
|
22
|
+
value: target,
|
|
23
|
+
url: url
|
|
24
|
+
});
|
|
25
|
+
case 4:
|
|
26
|
+
page = _context.sent;
|
|
27
|
+
_context.next = 8;
|
|
28
|
+
break;
|
|
29
|
+
case 7:
|
|
30
|
+
page = window.open(url, target);
|
|
31
|
+
case 8:
|
|
32
|
+
console.log("openPage", page);
|
|
33
|
+
return _context.abrupt("return", page);
|
|
34
|
+
case 10:
|
|
35
|
+
case "end":
|
|
36
|
+
return _context.stop();
|
|
37
|
+
}
|
|
38
|
+
}, _callee);
|
|
39
|
+
}));
|
|
40
|
+
return _openPage.apply(this, arguments);
|
|
41
|
+
}
|
|
42
|
+
export function closePage(_x3, _x4) {
|
|
43
|
+
return _closePage.apply(this, arguments);
|
|
44
|
+
}
|
|
45
|
+
function _closePage() {
|
|
46
|
+
_closePage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(url, target) {
|
|
47
|
+
var _window$parent2;
|
|
48
|
+
var func;
|
|
49
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
50
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
51
|
+
case 0:
|
|
52
|
+
// @ts-ignore
|
|
53
|
+
func = (_window$parent2 = window.parent) === null || _window$parent2 === void 0 ? void 0 : _window$parent2.closeWorkPlatformTab;
|
|
54
|
+
if (func) {
|
|
55
|
+
func({
|
|
56
|
+
value: target,
|
|
57
|
+
url: url
|
|
58
|
+
});
|
|
59
|
+
} else {
|
|
60
|
+
window.close();
|
|
61
|
+
}
|
|
62
|
+
case 2:
|
|
63
|
+
case "end":
|
|
64
|
+
return _context2.stop();
|
|
65
|
+
}
|
|
66
|
+
}, _callee2);
|
|
67
|
+
}));
|
|
68
|
+
return _closePage.apply(this, arguments);
|
|
69
|
+
}
|
|
@@ -1,48 +1,80 @@
|
|
|
1
|
-
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
|
|
2
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
3
|
-
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
4
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
|
|
4
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
5
|
+
var _excluded = ["layout", "form", "onClose"],
|
|
6
|
+
_excluded2 = ["container", "onClose"];
|
|
7
7
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
8
8
|
import { PageLayout } from "./page-layout";
|
|
9
9
|
import ReactDOM from "react-dom";
|
|
10
|
-
import { Component } from "react";
|
|
10
|
+
import React, { Component } from "react";
|
|
11
11
|
import { PageLoadSchema } from "./page-load-schema";
|
|
12
12
|
import { ReactRender } from "../../components/react-render";
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
13
|
+
import { openPage } from "./index";
|
|
14
|
+
export function showForm(_x) {
|
|
15
|
+
return _showForm.apply(this, arguments);
|
|
16
|
+
}
|
|
17
|
+
function _showForm() {
|
|
18
|
+
_showForm = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(options) {
|
|
19
|
+
var container, onClose, restProps, unmount, _options$form, paths, mode, dataId, params, url, page;
|
|
20
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
21
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
22
|
+
case 0:
|
|
23
|
+
container = options.container, onClose = options.onClose, restProps = _objectWithoutPropertiesLoose(options, _excluded2); //容器不存在需要手动取消挂载
|
|
24
|
+
unmount = !container;
|
|
25
|
+
if (container) {
|
|
26
|
+
_context2.next = 16;
|
|
27
|
+
break;
|
|
28
|
+
}
|
|
29
|
+
if (!(options.layout == "page")) {
|
|
30
|
+
_context2.next = 14;
|
|
31
|
+
break;
|
|
32
|
+
}
|
|
33
|
+
paths = window.location.pathname.split("/");
|
|
34
|
+
mode = options.mode, dataId = options.dataId;
|
|
35
|
+
params = new URLSearchParams();
|
|
36
|
+
params.set("dataId", dataId || "");
|
|
37
|
+
url = "/" + paths[1] + "/" + paths[2] + "/" + ((_options$form = options.form) === null || _options$form === void 0 ? void 0 : _options$form.id) + "/" + mode + "?" + params.toString();
|
|
38
|
+
_context2.next = 11;
|
|
39
|
+
return openPage(url, url);
|
|
40
|
+
case 11:
|
|
41
|
+
page = _context2.sent;
|
|
42
|
+
console.debug("openPage", page);
|
|
43
|
+
return _context2.abrupt("return");
|
|
44
|
+
case 14:
|
|
45
|
+
container = document.createElement("div");
|
|
46
|
+
document.body.append(container);
|
|
47
|
+
case 16:
|
|
48
|
+
ReactDOM.render( /*#__PURE__*/React.createElement(FormRender, _extends({}, restProps, {
|
|
49
|
+
onClose: /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
50
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
51
|
+
while (1) switch (_context.prev = _context.next) {
|
|
52
|
+
case 0:
|
|
53
|
+
if (unmount) {
|
|
54
|
+
//等待动画结束
|
|
55
|
+
setTimeout(function () {
|
|
56
|
+
var _container;
|
|
57
|
+
//取消挂载
|
|
58
|
+
ReactDOM.unmountComponentAtNode(container);
|
|
59
|
+
//移除
|
|
60
|
+
(_container = container) === null || _container === void 0 ? void 0 : _container.remove();
|
|
61
|
+
}, 1000);
|
|
62
|
+
}
|
|
63
|
+
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
64
|
+
case 2:
|
|
65
|
+
case "end":
|
|
66
|
+
return _context.stop();
|
|
67
|
+
}
|
|
68
|
+
}, _callee);
|
|
69
|
+
}))
|
|
70
|
+
})), container);
|
|
71
|
+
case 17:
|
|
72
|
+
case "end":
|
|
73
|
+
return _context2.stop();
|
|
74
|
+
}
|
|
75
|
+
}, _callee2);
|
|
76
|
+
}));
|
|
77
|
+
return _showForm.apply(this, arguments);
|
|
46
78
|
}
|
|
47
79
|
var FormRender = /*#__PURE__*/function (_Component) {
|
|
48
80
|
function FormRender() {
|
|
@@ -63,7 +95,7 @@ var FormRender = /*#__PURE__*/function (_Component) {
|
|
|
63
95
|
layout = _this$props.layout,
|
|
64
96
|
form = _this$props.form,
|
|
65
97
|
onClose = _this$props.onClose,
|
|
66
|
-
restProps = _objectWithoutPropertiesLoose(_this$props,
|
|
98
|
+
restProps = _objectWithoutPropertiesLoose(_this$props, _excluded);
|
|
67
99
|
// @ts-ignore
|
|
68
100
|
restProps.layout = layout || "drawer";
|
|
69
101
|
// @ts-ignore
|
|
@@ -6,10 +6,15 @@ interface PageLayoutProps {
|
|
|
6
6
|
}
|
|
7
7
|
interface PageLayoutState {
|
|
8
8
|
open: boolean;
|
|
9
|
+
width?: number;
|
|
9
10
|
}
|
|
10
11
|
export declare class PageLayout extends Component<PageLayoutProps, PageLayoutState> {
|
|
11
12
|
state: PageLayoutState;
|
|
12
13
|
close: () => void;
|
|
14
|
+
constructor(props: any);
|
|
15
|
+
componentDidMount(): void;
|
|
16
|
+
componentWillUnmount(): void;
|
|
17
|
+
handleResize: () => void;
|
|
13
18
|
render(): any;
|
|
14
19
|
}
|
|
15
20
|
export {};
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import _Drawer from "antd/es/drawer";
|
|
2
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
3
|
import _Modal from "antd/es/modal";
|
|
3
4
|
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
|
|
4
5
|
import React, { Component } from "react";
|
|
5
6
|
export var PageLayout = /*#__PURE__*/function (_Component) {
|
|
6
|
-
function PageLayout() {
|
|
7
|
+
function PageLayout(props) {
|
|
7
8
|
var _this;
|
|
8
|
-
|
|
9
|
-
args[_key] = arguments[_key];
|
|
10
|
-
}
|
|
11
|
-
_this = _Component.call.apply(_Component, [this].concat(args)) || this;
|
|
9
|
+
_this = _Component.call(this, props) || this;
|
|
12
10
|
_this.state = {
|
|
13
11
|
open: true
|
|
14
12
|
};
|
|
@@ -17,10 +15,22 @@ export var PageLayout = /*#__PURE__*/function (_Component) {
|
|
|
17
15
|
open: false
|
|
18
16
|
});
|
|
19
17
|
};
|
|
18
|
+
_this.handleResize = function () {
|
|
19
|
+
_this.setState({
|
|
20
|
+
width: Math.min(window.innerWidth, 1200)
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
_this.state.width = Math.min(window.innerWidth, 1200);
|
|
20
24
|
return _this;
|
|
21
25
|
}
|
|
22
26
|
_inheritsLoose(PageLayout, _Component);
|
|
23
27
|
var _proto = PageLayout.prototype;
|
|
28
|
+
_proto.componentDidMount = function componentDidMount() {
|
|
29
|
+
window.addEventListener("resize", this.handleResize);
|
|
30
|
+
};
|
|
31
|
+
_proto.componentWillUnmount = function componentWillUnmount() {
|
|
32
|
+
window.removeEventListener("resize", this.handleResize);
|
|
33
|
+
};
|
|
24
34
|
_proto.render = function render() {
|
|
25
35
|
var _this$props = this.props,
|
|
26
36
|
layout = _this$props.layout,
|
|
@@ -28,6 +38,8 @@ export var PageLayout = /*#__PURE__*/function (_Component) {
|
|
|
28
38
|
var state = this.state;
|
|
29
39
|
var restProps = {
|
|
30
40
|
open: state.open,
|
|
41
|
+
width: state.width,
|
|
42
|
+
onClose: this.close,
|
|
31
43
|
footer: false,
|
|
32
44
|
closable: false,
|
|
33
45
|
styles: {
|
|
@@ -41,14 +53,15 @@ export var PageLayout = /*#__PURE__*/function (_Component) {
|
|
|
41
53
|
padding: 0
|
|
42
54
|
}
|
|
43
55
|
},
|
|
44
|
-
onClose: this.close,
|
|
45
56
|
keyboard: false,
|
|
46
57
|
maskClosable: false
|
|
47
58
|
};
|
|
48
59
|
if (layout == "modal") {
|
|
49
60
|
return /*#__PURE__*/React.createElement(_Modal, restProps, children);
|
|
50
61
|
} else if (layout == "drawer") {
|
|
51
|
-
return /*#__PURE__*/React.createElement(_Drawer, restProps,
|
|
62
|
+
return /*#__PURE__*/React.createElement(_Drawer, _extends({}, restProps, {
|
|
63
|
+
width: Math.max(1200, window.innerWidth)
|
|
64
|
+
}), children);
|
|
52
65
|
}
|
|
53
66
|
return children;
|
|
54
67
|
};
|
package/lib/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { RestApi } from "./rest-api";
|
|
|
2
2
|
import { AxiosRequestConfig } from "axios";
|
|
3
3
|
export declare class RestFormApi<DataType> extends RestApi<DataType> {
|
|
4
4
|
private readonly formId;
|
|
5
|
-
private readonly fieldId
|
|
5
|
+
private readonly fieldId?;
|
|
6
6
|
private readonly mock;
|
|
7
7
|
private initialized;
|
|
8
8
|
private schema;
|
|
@@ -11,6 +11,7 @@ var _index = require("./index");
|
|
|
11
11
|
var RestFormApi = exports.RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
12
12
|
function RestFormApi(formId, fieldId, mock) {
|
|
13
13
|
var _this;
|
|
14
|
+
console.log(formId, fieldId);
|
|
14
15
|
_this = _RestApi.call(this, "forms", {}) || this;
|
|
15
16
|
_this.formId = void 0;
|
|
16
17
|
_this.fieldId = void 0;
|
|
@@ -18,7 +19,7 @@ var RestFormApi = exports.RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
|
18
19
|
_this.initialized = false;
|
|
19
20
|
_this.schema = void 0;
|
|
20
21
|
_this.formId = formId;
|
|
21
|
-
_this.fieldId =
|
|
22
|
+
_this.fieldId = fieldId;
|
|
22
23
|
_this.mock = !!mock;
|
|
23
24
|
return _this;
|
|
24
25
|
}
|
|
@@ -77,8 +78,12 @@ var RestFormApi = exports.RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
|
77
78
|
case 2:
|
|
78
79
|
config.params = config.params || {};
|
|
79
80
|
config.params.formId = this.formId;
|
|
80
|
-
|
|
81
|
-
|
|
81
|
+
if (this.fieldId) {
|
|
82
|
+
config.params.fieldId = this.fieldId;
|
|
83
|
+
}
|
|
84
|
+
if (this.mock) {
|
|
85
|
+
config.params.mock = this.mock;
|
|
86
|
+
}
|
|
82
87
|
case 6:
|
|
83
88
|
case "end":
|
|
84
89
|
return _context2.stop();
|
package/lib/utils/api/index.d.ts
CHANGED
|
@@ -6,3 +6,5 @@ export { RestFormApi } from "./form-api";
|
|
|
6
6
|
export declare const apiRequest: import("axios").AxiosInstance;
|
|
7
7
|
export declare function getSchema(pageId: string, mock?: boolean): Promise<OneResult<any>>;
|
|
8
8
|
export declare function getFormApi(formId: string, fieldId?: string, mock?: boolean): Promise<RestFormApi<any>>;
|
|
9
|
+
export declare function onFulfilled(res: any): any;
|
|
10
|
+
export declare function onRejected(error: any): any;
|
package/lib/utils/api/index.js
CHANGED
|
@@ -6,10 +6,11 @@ exports.apiRequest = exports.RestFormApi = exports.RestApi = void 0;
|
|
|
6
6
|
exports.getFormApi = getFormApi;
|
|
7
7
|
exports.getSchema = getSchema;
|
|
8
8
|
exports.loadUserInfo = void 0;
|
|
9
|
+
exports.onFulfilled = onFulfilled;
|
|
10
|
+
exports.onRejected = onRejected;
|
|
9
11
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
10
12
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
11
13
|
var _axios = _interopRequireDefault(require("axios"));
|
|
12
|
-
var _request = require("./request");
|
|
13
14
|
var _cache = require("../cache");
|
|
14
15
|
var _restApi = require("./rest-api");
|
|
15
16
|
exports.RestApi = _restApi.RestApi;
|
|
@@ -26,7 +27,7 @@ var apiRequest = exports.apiRequest = _axios["default"].create({
|
|
|
26
27
|
'Content-Type': 'application/json;charset=UTF-8'
|
|
27
28
|
}
|
|
28
29
|
});
|
|
29
|
-
apiRequest.interceptors.response.use(
|
|
30
|
+
apiRequest.interceptors.response.use(onFulfilled, onRejected);
|
|
30
31
|
function getSchema(_x, _x2) {
|
|
31
32
|
return _getSchema.apply(this, arguments);
|
|
32
33
|
}
|
|
@@ -87,4 +88,19 @@ function _getFormApi() {
|
|
|
87
88
|
}, _callee2);
|
|
88
89
|
}));
|
|
89
90
|
return _getFormApi.apply(this, arguments);
|
|
91
|
+
}
|
|
92
|
+
function onFulfilled(res) {
|
|
93
|
+
return res.data;
|
|
94
|
+
}
|
|
95
|
+
function onRejected(error) {
|
|
96
|
+
var _error$response = error.response,
|
|
97
|
+
status = _error$response.status,
|
|
98
|
+
statusText = _error$response.statusText;
|
|
99
|
+
if (status == 400) {
|
|
100
|
+
return error.response.data || {};
|
|
101
|
+
}
|
|
102
|
+
return {
|
|
103
|
+
success: false,
|
|
104
|
+
message: statusText
|
|
105
|
+
};
|
|
90
106
|
}
|
|
@@ -7,7 +7,7 @@ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"))
|
|
|
7
7
|
var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));
|
|
8
8
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
9
9
|
var _axios = _interopRequireDefault(require("axios"));
|
|
10
|
-
var
|
|
10
|
+
var _index = require("./index");
|
|
11
11
|
var BaseRestApi = exports.BaseRestApi = /*#__PURE__*/function () {
|
|
12
12
|
function BaseRestApi(uri, options) {
|
|
13
13
|
this.uri = void 0;
|
|
@@ -24,7 +24,7 @@ var BaseRestApi = exports.BaseRestApi = /*#__PURE__*/function () {
|
|
|
24
24
|
'Content-Type': 'application/json;charset=UTF-8'
|
|
25
25
|
}
|
|
26
26
|
});
|
|
27
|
-
this.request.interceptors.response.use(
|
|
27
|
+
this.request.interceptors.response.use(_index.onFulfilled, _index.onRejected);
|
|
28
28
|
}
|
|
29
29
|
var _proto = BaseRestApi.prototype;
|
|
30
30
|
_proto.search = /*#__PURE__*/function () {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { showForm } from "./page-form";
|
|
2
|
-
export
|
|
3
|
-
|
|
2
|
+
export declare function openPage(url: string, target?: string): Promise<any>;
|
|
3
|
+
export declare function closePage(url: string, target?: string): Promise<void>;
|
package/lib/utils/page/index.js
CHANGED
|
@@ -1,6 +1,77 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
4
|
exports.__esModule = true;
|
|
5
|
+
exports.closePage = closePage;
|
|
6
|
+
exports.openPage = openPage;
|
|
4
7
|
exports.showForm = void 0;
|
|
8
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
5
10
|
var _pageForm = require("./page-form");
|
|
6
|
-
exports.showForm = _pageForm.showForm;
|
|
11
|
+
exports.showForm = _pageForm.showForm;
|
|
12
|
+
function openPage(_x, _x2) {
|
|
13
|
+
return _openPage.apply(this, arguments);
|
|
14
|
+
}
|
|
15
|
+
function _openPage() {
|
|
16
|
+
_openPage = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(url, target) {
|
|
17
|
+
var _window$parent;
|
|
18
|
+
var page, func;
|
|
19
|
+
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
20
|
+
while (1) switch (_context.prev = _context.next) {
|
|
21
|
+
case 0:
|
|
22
|
+
// @ts-ignore
|
|
23
|
+
func = (_window$parent = window.parent) === null || _window$parent === void 0 ? void 0 : _window$parent.openWorkPlatformTab;
|
|
24
|
+
if (!func) {
|
|
25
|
+
_context.next = 7;
|
|
26
|
+
break;
|
|
27
|
+
}
|
|
28
|
+
_context.next = 4;
|
|
29
|
+
return func({
|
|
30
|
+
value: target,
|
|
31
|
+
url: url
|
|
32
|
+
});
|
|
33
|
+
case 4:
|
|
34
|
+
page = _context.sent;
|
|
35
|
+
_context.next = 8;
|
|
36
|
+
break;
|
|
37
|
+
case 7:
|
|
38
|
+
page = window.open(url, target);
|
|
39
|
+
case 8:
|
|
40
|
+
console.log("openPage", page);
|
|
41
|
+
return _context.abrupt("return", page);
|
|
42
|
+
case 10:
|
|
43
|
+
case "end":
|
|
44
|
+
return _context.stop();
|
|
45
|
+
}
|
|
46
|
+
}, _callee);
|
|
47
|
+
}));
|
|
48
|
+
return _openPage.apply(this, arguments);
|
|
49
|
+
}
|
|
50
|
+
function closePage(_x3, _x4) {
|
|
51
|
+
return _closePage.apply(this, arguments);
|
|
52
|
+
}
|
|
53
|
+
function _closePage() {
|
|
54
|
+
_closePage = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(url, target) {
|
|
55
|
+
var _window$parent2;
|
|
56
|
+
var func;
|
|
57
|
+
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
58
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
59
|
+
case 0:
|
|
60
|
+
// @ts-ignore
|
|
61
|
+
func = (_window$parent2 = window.parent) === null || _window$parent2 === void 0 ? void 0 : _window$parent2.closeWorkPlatformTab;
|
|
62
|
+
if (func) {
|
|
63
|
+
func({
|
|
64
|
+
value: target,
|
|
65
|
+
url: url
|
|
66
|
+
});
|
|
67
|
+
} else {
|
|
68
|
+
window.close();
|
|
69
|
+
}
|
|
70
|
+
case 2:
|
|
71
|
+
case "end":
|
|
72
|
+
return _context2.stop();
|
|
73
|
+
}
|
|
74
|
+
}, _callee2);
|
|
75
|
+
}));
|
|
76
|
+
return _closePage.apply(this, arguments);
|
|
77
|
+
}
|
|
@@ -4,50 +4,84 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
exports.__esModule = true;
|
|
5
5
|
exports.showForm = showForm;
|
|
6
6
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
7
|
-
var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));
|
|
8
7
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
8
|
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
9
|
+
var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));
|
|
10
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
11
11
|
var _pageLayout = require("./page-layout");
|
|
12
12
|
var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
13
|
-
var _react = require("react");
|
|
13
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
14
14
|
var _pageLoadSchema = require("./page-load-schema");
|
|
15
15
|
var _reactRender = require("../../components/react-render");
|
|
16
|
-
var
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
16
|
+
var _index = require("./index");
|
|
17
|
+
var _excluded = ["layout", "form", "onClose"],
|
|
18
|
+
_excluded2 = ["container", "onClose"];
|
|
19
|
+
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); }
|
|
20
|
+
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; }
|
|
21
|
+
function showForm(_x) {
|
|
22
|
+
return _showForm.apply(this, arguments);
|
|
23
|
+
}
|
|
24
|
+
function _showForm() {
|
|
25
|
+
_showForm = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(options) {
|
|
26
|
+
var container, onClose, restProps, unmount, _options$form, paths, mode, dataId, params, url, page;
|
|
27
|
+
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
28
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
29
|
+
case 0:
|
|
30
|
+
container = options.container, onClose = options.onClose, restProps = (0, _objectWithoutPropertiesLoose2["default"])(options, _excluded2); //容器不存在需要手动取消挂载
|
|
31
|
+
unmount = !container;
|
|
32
|
+
if (container) {
|
|
33
|
+
_context2.next = 16;
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
36
|
+
if (!(options.layout == "page")) {
|
|
37
|
+
_context2.next = 14;
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
40
|
+
paths = window.location.pathname.split("/");
|
|
41
|
+
mode = options.mode, dataId = options.dataId;
|
|
42
|
+
params = new URLSearchParams();
|
|
43
|
+
params.set("dataId", dataId || "");
|
|
44
|
+
url = "/" + paths[1] + "/" + paths[2] + "/" + ((_options$form = options.form) === null || _options$form === void 0 ? void 0 : _options$form.id) + "/" + mode + "?" + params.toString();
|
|
45
|
+
_context2.next = 11;
|
|
46
|
+
return (0, _index.openPage)(url, url);
|
|
47
|
+
case 11:
|
|
48
|
+
page = _context2.sent;
|
|
49
|
+
console.debug("openPage", page);
|
|
50
|
+
return _context2.abrupt("return");
|
|
51
|
+
case 14:
|
|
52
|
+
container = document.createElement("div");
|
|
53
|
+
document.body.append(container);
|
|
54
|
+
case 16:
|
|
55
|
+
_reactDom["default"].render( /*#__PURE__*/_react["default"].createElement(FormRender, (0, _extends2["default"])({}, restProps, {
|
|
56
|
+
onClose: /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
|
|
57
|
+
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
58
|
+
while (1) switch (_context.prev = _context.next) {
|
|
59
|
+
case 0:
|
|
60
|
+
if (unmount) {
|
|
61
|
+
//等待动画结束
|
|
62
|
+
setTimeout(function () {
|
|
63
|
+
var _container;
|
|
64
|
+
//取消挂载
|
|
65
|
+
_reactDom["default"].unmountComponentAtNode(container);
|
|
66
|
+
//移除
|
|
67
|
+
(_container = container) === null || _container === void 0 ? void 0 : _container.remove();
|
|
68
|
+
}, 1000);
|
|
69
|
+
}
|
|
70
|
+
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
71
|
+
case 2:
|
|
72
|
+
case "end":
|
|
73
|
+
return _context.stop();
|
|
74
|
+
}
|
|
75
|
+
}, _callee);
|
|
76
|
+
}))
|
|
77
|
+
})), container);
|
|
78
|
+
case 17:
|
|
79
|
+
case "end":
|
|
80
|
+
return _context2.stop();
|
|
81
|
+
}
|
|
82
|
+
}, _callee2);
|
|
83
|
+
}));
|
|
84
|
+
return _showForm.apply(this, arguments);
|
|
51
85
|
}
|
|
52
86
|
var FormRender = /*#__PURE__*/function (_Component) {
|
|
53
87
|
function FormRender() {
|
|
@@ -68,7 +102,7 @@ var FormRender = /*#__PURE__*/function (_Component) {
|
|
|
68
102
|
layout = _this$props.layout,
|
|
69
103
|
form = _this$props.form,
|
|
70
104
|
onClose = _this$props.onClose,
|
|
71
|
-
restProps = (0, _objectWithoutPropertiesLoose2["default"])(_this$props,
|
|
105
|
+
restProps = (0, _objectWithoutPropertiesLoose2["default"])(_this$props, _excluded);
|
|
72
106
|
// @ts-ignore
|
|
73
107
|
restProps.layout = layout || "drawer";
|
|
74
108
|
// @ts-ignore
|
|
@@ -77,15 +111,15 @@ var FormRender = /*#__PURE__*/function (_Component) {
|
|
|
77
111
|
(_self$layoutRef = self.layoutRef) === null || _self$layoutRef === void 0 ? void 0 : _self$layoutRef.close();
|
|
78
112
|
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
79
113
|
};
|
|
80
|
-
return /*#__PURE__*/
|
|
114
|
+
return /*#__PURE__*/_react["default"].createElement(_pageLayout.PageLayout, {
|
|
81
115
|
layout: layout,
|
|
82
116
|
ref: function ref(layout) {
|
|
83
117
|
return _this2.layoutRef = layout;
|
|
84
118
|
}
|
|
85
|
-
}, /*#__PURE__*/
|
|
119
|
+
}, /*#__PURE__*/_react["default"].createElement(_pageLoadSchema.PageLoadSchema, {
|
|
86
120
|
pageId: form === null || form === void 0 ? void 0 : form.id
|
|
87
121
|
}, function (schema) {
|
|
88
|
-
return /*#__PURE__*/
|
|
122
|
+
return /*#__PURE__*/_react["default"].createElement(_reactRender.ReactRender, (0, _extends2["default"])({
|
|
89
123
|
schema: schema,
|
|
90
124
|
components: window.__components
|
|
91
125
|
}, restProps));
|
|
@@ -6,10 +6,15 @@ interface PageLayoutProps {
|
|
|
6
6
|
}
|
|
7
7
|
interface PageLayoutState {
|
|
8
8
|
open: boolean;
|
|
9
|
+
width?: number;
|
|
9
10
|
}
|
|
10
11
|
export declare class PageLayout extends Component<PageLayoutProps, PageLayoutState> {
|
|
11
12
|
state: PageLayoutState;
|
|
12
13
|
close: () => void;
|
|
14
|
+
constructor(props: any);
|
|
15
|
+
componentDidMount(): void;
|
|
16
|
+
componentWillUnmount(): void;
|
|
17
|
+
handleResize: () => void;
|
|
13
18
|
render(): any;
|
|
14
19
|
}
|
|
15
20
|
export {};
|
|
@@ -4,18 +4,16 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
exports.__esModule = true;
|
|
5
5
|
exports.PageLayout = void 0;
|
|
6
6
|
var _drawer = _interopRequireDefault(require("antd/lib/drawer"));
|
|
7
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
7
8
|
var _modal = _interopRequireDefault(require("antd/lib/modal"));
|
|
8
9
|
var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));
|
|
9
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
10
11
|
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); }
|
|
11
12
|
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; }
|
|
12
13
|
var PageLayout = exports.PageLayout = /*#__PURE__*/function (_Component) {
|
|
13
|
-
function PageLayout() {
|
|
14
|
+
function PageLayout(props) {
|
|
14
15
|
var _this;
|
|
15
|
-
|
|
16
|
-
args[_key] = arguments[_key];
|
|
17
|
-
}
|
|
18
|
-
_this = _Component.call.apply(_Component, [this].concat(args)) || this;
|
|
16
|
+
_this = _Component.call(this, props) || this;
|
|
19
17
|
_this.state = {
|
|
20
18
|
open: true
|
|
21
19
|
};
|
|
@@ -24,10 +22,22 @@ var PageLayout = exports.PageLayout = /*#__PURE__*/function (_Component) {
|
|
|
24
22
|
open: false
|
|
25
23
|
});
|
|
26
24
|
};
|
|
25
|
+
_this.handleResize = function () {
|
|
26
|
+
_this.setState({
|
|
27
|
+
width: Math.min(window.innerWidth, 1200)
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
_this.state.width = Math.min(window.innerWidth, 1200);
|
|
27
31
|
return _this;
|
|
28
32
|
}
|
|
29
33
|
(0, _inheritsLoose2["default"])(PageLayout, _Component);
|
|
30
34
|
var _proto = PageLayout.prototype;
|
|
35
|
+
_proto.componentDidMount = function componentDidMount() {
|
|
36
|
+
window.addEventListener("resize", this.handleResize);
|
|
37
|
+
};
|
|
38
|
+
_proto.componentWillUnmount = function componentWillUnmount() {
|
|
39
|
+
window.removeEventListener("resize", this.handleResize);
|
|
40
|
+
};
|
|
31
41
|
_proto.render = function render() {
|
|
32
42
|
var _this$props = this.props,
|
|
33
43
|
layout = _this$props.layout,
|
|
@@ -35,6 +45,8 @@ var PageLayout = exports.PageLayout = /*#__PURE__*/function (_Component) {
|
|
|
35
45
|
var state = this.state;
|
|
36
46
|
var restProps = {
|
|
37
47
|
open: state.open,
|
|
48
|
+
width: state.width,
|
|
49
|
+
onClose: this.close,
|
|
38
50
|
footer: false,
|
|
39
51
|
closable: false,
|
|
40
52
|
styles: {
|
|
@@ -48,14 +60,15 @@ var PageLayout = exports.PageLayout = /*#__PURE__*/function (_Component) {
|
|
|
48
60
|
padding: 0
|
|
49
61
|
}
|
|
50
62
|
},
|
|
51
|
-
onClose: this.close,
|
|
52
63
|
keyboard: false,
|
|
53
64
|
maskClosable: false
|
|
54
65
|
};
|
|
55
66
|
if (layout == "modal") {
|
|
56
67
|
return /*#__PURE__*/_react["default"].createElement(_modal["default"], restProps, children);
|
|
57
68
|
} else if (layout == "drawer") {
|
|
58
|
-
return /*#__PURE__*/_react["default"].createElement(_drawer["default"], restProps,
|
|
69
|
+
return /*#__PURE__*/_react["default"].createElement(_drawer["default"], (0, _extends2["default"])({}, restProps, {
|
|
70
|
+
width: Math.max(1200, window.innerWidth)
|
|
71
|
+
}), children);
|
|
59
72
|
}
|
|
60
73
|
return children;
|
|
61
74
|
};
|
package/package.json
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|