@zhubangyun/lowcode-core 5.12.161 → 6.2.30
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 +38 -22
- package/es/components/page-loading/index.js +4 -1
- package/es/index.d.ts +1 -1
- package/es/index.js +19 -2
- package/es/index.less +21 -0
- package/es/init/init.bar-height.d.ts +1 -0
- package/es/init/init.bar-height.js +37 -0
- package/es/init/init.mobile-class.d.ts +1 -0
- package/es/init/init.mobile-class.js +10 -0
- package/es/init/init.scroll-size.d.ts +5 -0
- package/es/init/init.scroll-size.js +26 -0
- package/es/style.js +3 -3
- package/es/utils/api/form-api.d.ts +2 -0
- package/es/utils/api/form-api.js +155 -34
- package/es/utils/api/index.d.ts +1 -1
- package/es/utils/api/index.js +4 -2
- package/es/utils/api/rest-api.d.ts +3 -1
- package/es/utils/api/rest-api.js +105 -23
- package/es/utils/api/schema.util.d.ts +3 -3
- package/es/utils/api/schema.util.js +17 -12
- package/es/utils/cache/index.js +57 -17
- package/es/utils/common/index.d.ts +3 -0
- package/es/utils/common/index.js +17 -3
- package/es/utils/page/index.js +10 -6
- package/es/utils/page/page-form-data-manager-group.js +10 -10
- package/es/utils/page/page-form-data-manager.d.ts +1 -0
- package/es/utils/page/page-form-data-manager.js +10 -10
- package/es/utils/page/page-form-group.d.ts +1 -0
- package/es/utils/page/page-form-group.js +2 -2
- package/es/utils/page/page-form.d.ts +1 -0
- package/es/utils/page/page-form.js +12 -4
- package/es/utils/page/page-layout.d.ts +3 -1
- package/es/utils/page/page-layout.js +44 -7
- package/es/utils/page/page-load-schema.js +20 -28
- package/es/utils/page/page-render.js +4 -5
- package/es/utils/page/page-show.d.ts +2 -0
- package/es/utils/page/page-show.js +9 -4
- package/es/utils/page/print-form.d.ts +3 -2
- package/es/utils/page/print-form.js +200 -61
- package/es/utils/uni-bridge.d.ts +20 -0
- package/es/utils/uni-bridge.js +172 -0
- package/es/utils/util.common.d.ts +1 -0
- package/es/utils/util.common.js +4 -0
- package/es/utils/utils.scrollbar-size.js +0 -0
- package/lib/components/load-materials/index.js +38 -22
- package/lib/components/page-loading/index.js +4 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +22 -4
- package/lib/index.less +21 -0
- package/lib/init/init.bar-height.d.ts +1 -0
- package/lib/init/init.bar-height.js +42 -0
- package/lib/init/init.mobile-class.d.ts +1 -0
- package/lib/init/init.mobile-class.js +14 -0
- package/lib/init/init.scroll-size.d.ts +5 -0
- package/lib/init/init.scroll-size.js +31 -0
- package/lib/style.js +3 -3
- package/lib/utils/api/form-api.d.ts +2 -0
- package/lib/utils/api/form-api.js +155 -34
- package/lib/utils/api/index.d.ts +1 -1
- package/lib/utils/api/index.js +4 -2
- package/lib/utils/api/rest-api.d.ts +3 -1
- package/lib/utils/api/rest-api.js +105 -23
- package/lib/utils/api/schema.util.d.ts +3 -3
- package/lib/utils/api/schema.util.js +19 -13
- package/lib/utils/cache/index.js +56 -16
- package/lib/utils/common/index.d.ts +3 -0
- package/lib/utils/common/index.js +19 -2
- package/lib/utils/page/index.js +10 -6
- package/lib/utils/page/page-form-data-manager-group.js +10 -10
- package/lib/utils/page/page-form-data-manager.d.ts +1 -0
- package/lib/utils/page/page-form-data-manager.js +10 -10
- package/lib/utils/page/page-form-group.d.ts +1 -0
- package/lib/utils/page/page-form-group.js +2 -2
- package/lib/utils/page/page-form.d.ts +1 -0
- package/lib/utils/page/page-form.js +12 -4
- package/lib/utils/page/page-layout.d.ts +3 -1
- package/lib/utils/page/page-layout.js +44 -7
- package/lib/utils/page/page-load-schema.js +19 -27
- package/lib/utils/page/page-render.js +4 -5
- package/lib/utils/page/page-show.d.ts +2 -0
- package/lib/utils/page/page-show.js +9 -4
- package/lib/utils/page/print-form.d.ts +3 -2
- package/lib/utils/page/print-form.js +200 -61
- package/lib/utils/uni-bridge.d.ts +20 -0
- package/lib/utils/uni-bridge.js +177 -0
- package/lib/utils/util.common.d.ts +1 -0
- package/lib/utils/util.common.js +8 -0
- package/lib/utils/utils.scrollbar-size.js +1 -0
- package/package.json +2 -2
|
@@ -3,16 +3,23 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
|
3
3
|
import React, { useEffect, useState } from "react";
|
|
4
4
|
import { PageLoading } from "../page-loading";
|
|
5
5
|
import { loadPlugins } from "../../utils/common";
|
|
6
|
+
function getInit() {
|
|
7
|
+
if (window._components) {
|
|
8
|
+
return true;
|
|
9
|
+
}
|
|
10
|
+
if (window.AntdProMaterial) {
|
|
11
|
+
setComponents();
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
6
16
|
export function LoadMaterials(props) {
|
|
7
|
-
var _useState = useState(
|
|
17
|
+
var _useState = useState(getInit()),
|
|
8
18
|
init = _useState[0],
|
|
9
19
|
setInit = _useState[1];
|
|
10
20
|
useEffect(function () {
|
|
11
21
|
initialize().then();
|
|
12
22
|
}, []);
|
|
13
|
-
if (window._components) {
|
|
14
|
-
return props.children;
|
|
15
|
-
}
|
|
16
23
|
function initialize() {
|
|
17
24
|
return _initialize.apply(this, arguments);
|
|
18
25
|
}
|
|
@@ -21,11 +28,17 @@ export function LoadMaterials(props) {
|
|
|
21
28
|
return _regeneratorRuntime.wrap(function (_context) {
|
|
22
29
|
while (1) switch (_context.prev = _context.next) {
|
|
23
30
|
case 0:
|
|
24
|
-
|
|
25
|
-
|
|
31
|
+
if (!init) {
|
|
32
|
+
_context.next = 1;
|
|
33
|
+
break;
|
|
34
|
+
}
|
|
35
|
+
return _context.abrupt("return");
|
|
26
36
|
case 1:
|
|
27
|
-
|
|
37
|
+
_context.next = 2;
|
|
38
|
+
return loadMaterials();
|
|
28
39
|
case 2:
|
|
40
|
+
setInit(true);
|
|
41
|
+
case 3:
|
|
29
42
|
case "end":
|
|
30
43
|
return _context.stop();
|
|
31
44
|
}
|
|
@@ -46,35 +59,23 @@ function loadMaterials() {
|
|
|
46
59
|
}
|
|
47
60
|
function _loadMaterials() {
|
|
48
61
|
_loadMaterials = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
49
|
-
var
|
|
62
|
+
var urls;
|
|
50
63
|
return _regeneratorRuntime.wrap(function (_context2) {
|
|
51
64
|
while (1) switch (_context2.prev = _context2.next) {
|
|
52
65
|
case 0:
|
|
53
|
-
components = {};
|
|
54
66
|
if (!window._components) {
|
|
55
67
|
_context2.next = 1;
|
|
56
68
|
break;
|
|
57
69
|
}
|
|
58
70
|
return _context2.abrupt("return");
|
|
59
71
|
case 1:
|
|
60
|
-
urls = ["prop-types/15.8.1/prop-types.min.js", "lodash/4.17.15/lodash.min.js", "dayjs/dayjs.min.js", "
|
|
72
|
+
urls = ["prop-types/15.8.1/prop-types.min.js", "lodash/4.17.15/lodash.min.js", "dayjs/dayjs.min.js", "antdIcon/1.0.0/antdIcon.min.js", "lowcode/core/index.js", "lowcode/core/index.css", "lowcode/materials/root/view.js", "lowcode/materials/root/view.css", "lowcode/materials/antd/view.js", "lowcode/materials/antd/view.css", "lowcode/materials/antd-pro/view.js", "lowcode/materials/antd-pro/view.css", "lowcode/icon-font/app/iconfont.js"];
|
|
61
73
|
_context2.next = 2;
|
|
62
74
|
return loadPlugins(urls.map(function (url) {
|
|
63
75
|
return "https://cdn.zhiyunhe.com/plugin/" + url;
|
|
64
76
|
}));
|
|
65
77
|
case 2:
|
|
66
|
-
|
|
67
|
-
var data = window[lib];
|
|
68
|
-
if (data) {
|
|
69
|
-
Object.entries(data).forEach(function (_ref) {
|
|
70
|
-
var key = _ref[0],
|
|
71
|
-
value = _ref[1];
|
|
72
|
-
// @ts-ignore
|
|
73
|
-
components[key] = value;
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
window._components = components;
|
|
78
|
+
setComponents();
|
|
78
79
|
case 3:
|
|
79
80
|
case "end":
|
|
80
81
|
return _context2.stop();
|
|
@@ -82,4 +83,19 @@ function _loadMaterials() {
|
|
|
82
83
|
}, _callee2);
|
|
83
84
|
}));
|
|
84
85
|
return _loadMaterials.apply(this, arguments);
|
|
86
|
+
}
|
|
87
|
+
function setComponents() {
|
|
88
|
+
var components = {};
|
|
89
|
+
["RootMaterial", "AntdMaterial", "AntdProMaterial"].forEach(function (lib) {
|
|
90
|
+
var data = window[lib];
|
|
91
|
+
if (data) {
|
|
92
|
+
Object.entries(data).forEach(function (_ref) {
|
|
93
|
+
var key = _ref[0],
|
|
94
|
+
value = _ref[1];
|
|
95
|
+
// @ts-ignore
|
|
96
|
+
components[key] = value;
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
window._components = components;
|
|
85
101
|
}
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import "./index.less";
|
|
2
|
+
import { useEffect } from "react";
|
|
2
3
|
export function PageLoading(props) {
|
|
3
4
|
var loading = props.loading,
|
|
4
5
|
_props$background = props.background,
|
|
5
6
|
background = _props$background === void 0 ? "#f1f1f1" : _props$background,
|
|
6
7
|
children = props.children;
|
|
8
|
+
useEffect(function () {}, [loading]);
|
|
7
9
|
return /*#__PURE__*/React.createElement("div", {
|
|
8
10
|
className: "page-loading-wrapper",
|
|
9
11
|
style: {
|
|
10
12
|
width: "100%",
|
|
11
|
-
height: "100%"
|
|
13
|
+
height: "100%",
|
|
14
|
+
background: "rgba(0,0,0,0)"
|
|
12
15
|
}
|
|
13
16
|
}, children, loading && /*#__PURE__*/React.createElement("div", {
|
|
14
17
|
className: "page-loading",
|
package/es/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import "./index.less";
|
|
2
|
-
import utils from "./utils";
|
|
3
2
|
import * as lodash from "lodash";
|
|
4
3
|
export { LoadMaterials } from "./components/load-materials";
|
|
5
4
|
export { PageLoading } from "./components/page-loading";
|
|
6
5
|
export { RestApi, RestFormApi, apiRequest } from "./utils/api";
|
|
7
6
|
export { Layout } from "./components/layout";
|
|
8
7
|
export { ReactRender } from "./components/react-render";
|
|
8
|
+
import utils from "./utils/index";
|
|
9
9
|
export { utils, lodash };
|
package/es/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import _message from "antd/es/message";
|
|
1
2
|
import "./index.less";
|
|
2
|
-
import utils from "./utils";
|
|
3
3
|
import { ReactRender } from "./components/react-render";
|
|
4
4
|
import * as lodash from "lodash";
|
|
5
5
|
export { LoadMaterials } from "./components/load-materials";
|
|
@@ -7,7 +7,11 @@ export { PageLoading } from "./components/page-loading";
|
|
|
7
7
|
export { RestApi, RestFormApi, apiRequest } from "./utils/api";
|
|
8
8
|
export { Layout } from "./components/layout";
|
|
9
9
|
export { ReactRender } from "./components/react-render";
|
|
10
|
-
|
|
10
|
+
import utils from "./utils/index";
|
|
11
|
+
import { uniBridge } from "./utils/uni-bridge";
|
|
12
|
+
import { initBarHeight } from "./init/init.bar-height";
|
|
13
|
+
import { initScrollSize } from "./init/init.scroll-size";
|
|
14
|
+
import { initMobileClass } from "./init/init.mobile-class";
|
|
11
15
|
// @ts-ignore
|
|
12
16
|
window.__ReactRender = ReactRender;
|
|
13
17
|
// @ts-ignore
|
|
@@ -20,4 +24,17 @@ if (!window.utils) {
|
|
|
20
24
|
// @ts-ignore
|
|
21
25
|
window.utils = utils;
|
|
22
26
|
}
|
|
27
|
+
initMobileClass();
|
|
28
|
+
|
|
29
|
+
// @ts-ignore
|
|
30
|
+
utils.uniBridge = uniBridge;
|
|
31
|
+
// @ts-ignore
|
|
32
|
+
window.uniBridge = uniBridge;
|
|
33
|
+
_message.config({
|
|
34
|
+
top: 150,
|
|
35
|
+
duration: 5,
|
|
36
|
+
maxCount: 3
|
|
37
|
+
});
|
|
38
|
+
initBarHeight();
|
|
39
|
+
initScrollSize();
|
|
23
40
|
export { utils, lodash };
|
package/es/index.less
CHANGED
|
@@ -1,7 +1,18 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
--scroll-bar-width: 15px;
|
|
3
|
+
--scroll-bar-height: 15px;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.ant-table-cell-scrollbar {
|
|
7
|
+
padding: 0 !important;
|
|
8
|
+
width: var(--scroll-bar-width);
|
|
9
|
+
}
|
|
10
|
+
|
|
1
11
|
[componentname="Page"] {
|
|
2
12
|
height: 100%;
|
|
3
13
|
}
|
|
4
14
|
|
|
15
|
+
|
|
5
16
|
ul {
|
|
6
17
|
margin-bottom: 0;
|
|
7
18
|
padding-left: 0;
|
|
@@ -11,3 +22,13 @@ ul {
|
|
|
11
22
|
.page-content {
|
|
12
23
|
overflow: hidden;
|
|
13
24
|
}
|
|
25
|
+
|
|
26
|
+
.print-iframe {
|
|
27
|
+
position: fixed;
|
|
28
|
+
z-index: -1;
|
|
29
|
+
top: 0;
|
|
30
|
+
left: 0;
|
|
31
|
+
width: 100vw;
|
|
32
|
+
height: 100vh;
|
|
33
|
+
background: white;
|
|
34
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function initBarHeight(): void;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
3
|
+
import { uniBridge } from "../utils/uni-bridge";
|
|
4
|
+
var bar_height_key = "bar_height";
|
|
5
|
+
export function initBarHeight() {
|
|
6
|
+
updateBarHeight();
|
|
7
|
+
window.onload = function () {
|
|
8
|
+
setTimeout(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
9
|
+
var height;
|
|
10
|
+
return _regeneratorRuntime.wrap(function (_context) {
|
|
11
|
+
while (1) switch (_context.prev = _context.next) {
|
|
12
|
+
case 0:
|
|
13
|
+
if (!window.uni) {
|
|
14
|
+
_context.next = 2;
|
|
15
|
+
break;
|
|
16
|
+
}
|
|
17
|
+
_context.next = 1;
|
|
18
|
+
return uniBridge.getBarHeight();
|
|
19
|
+
case 1:
|
|
20
|
+
height = _context.sent;
|
|
21
|
+
localStorage.setItem(bar_height_key, height);
|
|
22
|
+
updateBarHeight();
|
|
23
|
+
case 2:
|
|
24
|
+
case "end":
|
|
25
|
+
return _context.stop();
|
|
26
|
+
}
|
|
27
|
+
}, _callee);
|
|
28
|
+
})), 100);
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
function updateBarHeight() {
|
|
32
|
+
var style = document.documentElement.style;
|
|
33
|
+
var barHeight = localStorage.getItem(bar_height_key);
|
|
34
|
+
if (barHeight) {
|
|
35
|
+
style.setProperty('--bar-height', barHeight);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function initMobileClass(): void;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { isMobile } from "../utils/common";
|
|
2
|
+
export function initMobileClass() {
|
|
3
|
+
window.isMobile = isMobile();
|
|
4
|
+
if (window.isMobile) {
|
|
5
|
+
var classList = window.document.body.classList;
|
|
6
|
+
if (!classList.contains("mobile")) {
|
|
7
|
+
classList.add("mobile");
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
var scrollbarSize = {};
|
|
2
|
+
|
|
3
|
+
// @ts-ignore
|
|
4
|
+
window.scrollbarSize = scrollbarSize;
|
|
5
|
+
export function initScrollSize() {
|
|
6
|
+
var size = getScrollbarSize();
|
|
7
|
+
var style = document.documentElement.style;
|
|
8
|
+
style.setProperty('--scroll-bar-height', size.height + "px");
|
|
9
|
+
style.setProperty('--scroll-bar-width', size.width + "px");
|
|
10
|
+
}
|
|
11
|
+
export function getScrollbarSize() {
|
|
12
|
+
if (typeof scrollbarSize.height == "number" && typeof scrollbarSize.width == "number") {
|
|
13
|
+
return scrollbarSize;
|
|
14
|
+
}
|
|
15
|
+
var outer = document.createElement('div');
|
|
16
|
+
outer.style.cssText = "\n visibility: hidden;\n overflow: scroll;\n position: absolute;\n top: -9999px;\n width: 50px;\n height: 50px;\n ";
|
|
17
|
+
document.body.appendChild(outer);
|
|
18
|
+
var inner = document.createElement('div');
|
|
19
|
+
inner.style.width = '100%';
|
|
20
|
+
inner.style.height = '100%';
|
|
21
|
+
outer.appendChild(inner);
|
|
22
|
+
scrollbarSize.width = outer.offsetWidth - inner.offsetWidth;
|
|
23
|
+
scrollbarSize.height = outer.offsetHeight - inner.offsetHeight;
|
|
24
|
+
document.body.removeChild(outer);
|
|
25
|
+
return scrollbarSize;
|
|
26
|
+
}
|
package/es/style.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import 'antd/es/message/style';
|
|
2
|
+
import 'antd/es/config-provider/style';
|
|
3
|
+
|
|
1
4
|
import 'antd/es/notification/style';
|
|
2
5
|
import 'antd/es/modal/style';
|
|
3
|
-
import 'antd/es/message/style';
|
|
4
6
|
import 'antd/es/typography/style';
|
|
5
7
|
import 'antd/es/drawer/style';
|
|
6
8
|
import 'antd/es/result/style';
|
|
7
|
-
import 'antd/es/config-provider/style';
|
|
8
|
-
|
|
9
9
|
import './index.less';
|
|
@@ -12,8 +12,10 @@ export declare class RestFormApi<DataType> extends RestApi<DataType> {
|
|
|
12
12
|
handleRequestConfig(config: AxiosRequestConfig): Promise<void>;
|
|
13
13
|
search(searchParams?: RestSearchParams): Promise<ManyResult<DataType>>;
|
|
14
14
|
getById(id: string, options?: BaseRequestOptions<DataType>): Promise<OneResult<DataType>>;
|
|
15
|
+
labelToValue(data: any[], options?: any): Promise<ManyResult<DataType>>;
|
|
15
16
|
save(data: DataType, options?: BaseRequestOptions<DataType>): Promise<OneResult<DataType>>;
|
|
16
17
|
create(data: DataType, options?: BaseRequestOptions<DataType>): Promise<OneResult<DataType>>;
|
|
17
18
|
update(id: string, data: DataType, options?: BaseRequestOptions<DataType>): Promise<OneResult<DataType>>;
|
|
19
|
+
fieldFilters(searchParams?: RestSearchParams): Promise<ManyResult<DataType>>;
|
|
18
20
|
serviceUpdate(data: DataType, options?: BaseRequestOptions<DataType>): Promise<import("axios").AxiosResponse<any, any, {}>>;
|
|
19
21
|
}
|
package/es/utils/api/form-api.js
CHANGED
|
@@ -6,14 +6,15 @@ import { RestApi } from "./rest-api";
|
|
|
6
6
|
import { assembleAssociationField, convertSaveData, handleFilterRules } from "./form-api.utils";
|
|
7
7
|
import { formApi } from "../cache";
|
|
8
8
|
import { getSchemaFromCache } from "./schema-api";
|
|
9
|
+
import { uuid, uuidVersion } from "../common";
|
|
9
10
|
export function getFormApi(_x, _x2, _x3) {
|
|
10
11
|
return _getFormApi.apply(this, arguments);
|
|
11
12
|
}
|
|
12
13
|
function _getFormApi() {
|
|
13
|
-
_getFormApi = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function
|
|
14
|
+
_getFormApi = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee1(formId, fieldId, mock) {
|
|
14
15
|
var key;
|
|
15
|
-
return _regeneratorRuntime.wrap(function (
|
|
16
|
-
while (1) switch (
|
|
16
|
+
return _regeneratorRuntime.wrap(function (_context1) {
|
|
17
|
+
while (1) switch (_context1.prev = _context1.next) {
|
|
17
18
|
case 0:
|
|
18
19
|
if (typeof mock != "boolean") {
|
|
19
20
|
if (typeof window.__mock == "boolean") {
|
|
@@ -23,16 +24,16 @@ function _getFormApi() {
|
|
|
23
24
|
key = [formId, fieldId, mock ? "mock" : ""].filter(function (key) {
|
|
24
25
|
return !!key;
|
|
25
26
|
}).join("_");
|
|
26
|
-
return
|
|
27
|
+
return _context1.abrupt("return", formApi.getInstance(key, {
|
|
27
28
|
mock: mock,
|
|
28
29
|
fieldId: fieldId,
|
|
29
30
|
formId: formId
|
|
30
31
|
}));
|
|
31
32
|
case 1:
|
|
32
33
|
case "end":
|
|
33
|
-
return
|
|
34
|
+
return _context1.stop();
|
|
34
35
|
}
|
|
35
|
-
},
|
|
36
|
+
}, _callee1);
|
|
36
37
|
}));
|
|
37
38
|
return _getFormApi.apply(this, arguments);
|
|
38
39
|
}
|
|
@@ -183,84 +184,204 @@ export var RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
|
183
184
|
}();
|
|
184
185
|
_proto.getById = /*#__PURE__*/function () {
|
|
185
186
|
var _getById = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4(id, options) {
|
|
186
|
-
var res;
|
|
187
|
+
var searchId, url, res, _t;
|
|
187
188
|
return _regeneratorRuntime.wrap(function (_context4) {
|
|
188
189
|
while (1) switch (_context4.prev = _context4.next) {
|
|
189
190
|
case 0:
|
|
190
|
-
|
|
191
|
-
|
|
191
|
+
if (id) {
|
|
192
|
+
_context4.next = 1;
|
|
193
|
+
break;
|
|
194
|
+
}
|
|
195
|
+
return _context4.abrupt("return", {
|
|
196
|
+
success: false,
|
|
197
|
+
message: "数据Id不可为空!"
|
|
198
|
+
});
|
|
192
199
|
case 1:
|
|
200
|
+
searchId = id;
|
|
201
|
+
if (!id.startsWith("http")) {
|
|
202
|
+
_context4.next = 2;
|
|
203
|
+
break;
|
|
204
|
+
}
|
|
205
|
+
url = new URL(searchId);
|
|
206
|
+
searchId = url.searchParams.get("dataId");
|
|
207
|
+
if (searchId) {
|
|
208
|
+
_context4.next = 2;
|
|
209
|
+
break;
|
|
210
|
+
}
|
|
211
|
+
return _context4.abrupt("return", {
|
|
212
|
+
success: false,
|
|
213
|
+
message: "数据Id不可为空!"
|
|
214
|
+
});
|
|
215
|
+
case 2:
|
|
216
|
+
_context4.prev = 2;
|
|
217
|
+
uuidVersion(searchId);
|
|
218
|
+
_context4.next = 4;
|
|
219
|
+
break;
|
|
220
|
+
case 3:
|
|
221
|
+
_context4.prev = 3;
|
|
222
|
+
_t = _context4["catch"](2);
|
|
223
|
+
return _context4.abrupt("return", {
|
|
224
|
+
success: false,
|
|
225
|
+
message: "\u975E\u6CD5\u7684\u6570\u636EID:" + searchId
|
|
226
|
+
});
|
|
227
|
+
case 4:
|
|
228
|
+
_context4.next = 5;
|
|
229
|
+
return _RestApi.prototype.getById.call(this, searchId, options);
|
|
230
|
+
case 5:
|
|
193
231
|
res = _context4.sent;
|
|
194
232
|
assembleAssociationField(res.data, res.refs);
|
|
195
233
|
console.debug("formApi.getById", res);
|
|
196
234
|
return _context4.abrupt("return", res);
|
|
197
|
-
case
|
|
235
|
+
case 6:
|
|
198
236
|
case "end":
|
|
199
237
|
return _context4.stop();
|
|
200
238
|
}
|
|
201
|
-
}, _callee4, this);
|
|
239
|
+
}, _callee4, this, [[2, 3]]);
|
|
202
240
|
}));
|
|
203
241
|
function getById(_x6, _x7) {
|
|
204
242
|
return _getById.apply(this, arguments);
|
|
205
243
|
}
|
|
206
244
|
return getById;
|
|
207
245
|
}();
|
|
208
|
-
_proto.
|
|
209
|
-
var
|
|
246
|
+
_proto.labelToValue = /*#__PURE__*/function () {
|
|
247
|
+
var _labelToValue = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee5(data, options) {
|
|
248
|
+
var _this3 = this;
|
|
249
|
+
var config, res;
|
|
210
250
|
return _regeneratorRuntime.wrap(function (_context5) {
|
|
211
251
|
while (1) switch (_context5.prev = _context5.next) {
|
|
212
252
|
case 0:
|
|
213
|
-
|
|
253
|
+
config = {};
|
|
254
|
+
_context5.next = 1;
|
|
255
|
+
return this.handleRequestConfig(config);
|
|
214
256
|
case 1:
|
|
257
|
+
_context5.next = 2;
|
|
258
|
+
return this.request.post("labelToValue", data, config);
|
|
259
|
+
case 2:
|
|
260
|
+
res = _context5.sent;
|
|
261
|
+
if (Array.isArray(res.data)) {
|
|
262
|
+
res.data.forEach(function (item) {
|
|
263
|
+
item.id = uuid();
|
|
264
|
+
item.form = {
|
|
265
|
+
id: _this3.formId,
|
|
266
|
+
fieldId: _this3.fieldId
|
|
267
|
+
};
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
assembleAssociationField(res.data, res.refs);
|
|
271
|
+
console.debug("formApi.labelToValue", res);
|
|
272
|
+
return _context5.abrupt("return", res);
|
|
273
|
+
case 3:
|
|
215
274
|
case "end":
|
|
216
275
|
return _context5.stop();
|
|
217
276
|
}
|
|
218
277
|
}, _callee5, this);
|
|
219
278
|
}));
|
|
220
|
-
function
|
|
221
|
-
return
|
|
279
|
+
function labelToValue(_x8, _x9) {
|
|
280
|
+
return _labelToValue.apply(this, arguments);
|
|
222
281
|
}
|
|
223
|
-
return
|
|
282
|
+
return labelToValue;
|
|
224
283
|
}();
|
|
225
|
-
_proto.
|
|
226
|
-
var
|
|
284
|
+
_proto.save = /*#__PURE__*/function () {
|
|
285
|
+
var _save = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee6(data, options) {
|
|
227
286
|
return _regeneratorRuntime.wrap(function (_context6) {
|
|
228
287
|
while (1) switch (_context6.prev = _context6.next) {
|
|
229
288
|
case 0:
|
|
230
|
-
return _context6.abrupt("return", _RestApi.prototype.
|
|
289
|
+
return _context6.abrupt("return", _RestApi.prototype.save.call(this, convertSaveData(data), options));
|
|
231
290
|
case 1:
|
|
232
291
|
case "end":
|
|
233
292
|
return _context6.stop();
|
|
234
293
|
}
|
|
235
294
|
}, _callee6, this);
|
|
236
295
|
}));
|
|
237
|
-
function
|
|
238
|
-
return
|
|
296
|
+
function save(_x0, _x1) {
|
|
297
|
+
return _save.apply(this, arguments);
|
|
239
298
|
}
|
|
240
|
-
return
|
|
299
|
+
return save;
|
|
241
300
|
}();
|
|
242
|
-
_proto.
|
|
243
|
-
var
|
|
301
|
+
_proto.create = /*#__PURE__*/function () {
|
|
302
|
+
var _create = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee7(data, options) {
|
|
244
303
|
return _regeneratorRuntime.wrap(function (_context7) {
|
|
245
304
|
while (1) switch (_context7.prev = _context7.next) {
|
|
246
305
|
case 0:
|
|
247
|
-
return _context7.abrupt("return", _RestApi.prototype.
|
|
306
|
+
return _context7.abrupt("return", _RestApi.prototype.create.call(this, convertSaveData(data), options));
|
|
248
307
|
case 1:
|
|
249
308
|
case "end":
|
|
250
309
|
return _context7.stop();
|
|
251
310
|
}
|
|
252
311
|
}, _callee7, this);
|
|
253
312
|
}));
|
|
254
|
-
function
|
|
313
|
+
function create(_x10, _x11) {
|
|
314
|
+
return _create.apply(this, arguments);
|
|
315
|
+
}
|
|
316
|
+
return create;
|
|
317
|
+
}();
|
|
318
|
+
_proto.update = /*#__PURE__*/function () {
|
|
319
|
+
var _update = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee8(id, data, options) {
|
|
320
|
+
return _regeneratorRuntime.wrap(function (_context8) {
|
|
321
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
322
|
+
case 0:
|
|
323
|
+
return _context8.abrupt("return", _RestApi.prototype.update.call(this, id, convertSaveData(data), options));
|
|
324
|
+
case 1:
|
|
325
|
+
case "end":
|
|
326
|
+
return _context8.stop();
|
|
327
|
+
}
|
|
328
|
+
}, _callee8, this);
|
|
329
|
+
}));
|
|
330
|
+
function update(_x12, _x13, _x14) {
|
|
255
331
|
return _update.apply(this, arguments);
|
|
256
332
|
}
|
|
257
333
|
return update;
|
|
258
334
|
}();
|
|
335
|
+
_proto.fieldFilters = /*#__PURE__*/function () {
|
|
336
|
+
var _fieldFilters = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee9(searchParams) {
|
|
337
|
+
var _searchParams3, _searchParams4;
|
|
338
|
+
var params, config, res;
|
|
339
|
+
return _regeneratorRuntime.wrap(function (_context9) {
|
|
340
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
341
|
+
case 0:
|
|
342
|
+
searchParams = searchParams || {};
|
|
343
|
+
params = {
|
|
344
|
+
formId: this.formId,
|
|
345
|
+
fieldId: this.fieldId
|
|
346
|
+
};
|
|
347
|
+
if (__mock) {
|
|
348
|
+
params.description = (this.title || "表单") + ".\u67E5\u8BE2";
|
|
349
|
+
}
|
|
350
|
+
config = {
|
|
351
|
+
params: params
|
|
352
|
+
};
|
|
353
|
+
_context9.next = 1;
|
|
354
|
+
return this.handleRequestConfig(config);
|
|
355
|
+
case 1:
|
|
356
|
+
searchParams.filterRules = handleFilterRules(((_searchParams3 = searchParams) === null || _searchParams3 === void 0 ? void 0 : _searchParams3.filterRules) || [], {
|
|
357
|
+
filterNullValue: false
|
|
358
|
+
});
|
|
359
|
+
searchParams.searchFields = handleFilterRules(((_searchParams4 = searchParams) === null || _searchParams4 === void 0 ? void 0 : _searchParams4.searchFields) || [], {
|
|
360
|
+
filterNullValue: true
|
|
361
|
+
});
|
|
362
|
+
config.params = _extends({}, params, searchParams);
|
|
363
|
+
_context9.next = 2;
|
|
364
|
+
return this.request.get("fieldFilters", config);
|
|
365
|
+
case 2:
|
|
366
|
+
res = _context9.sent;
|
|
367
|
+
console.debug("form.fieldFilters:", res);
|
|
368
|
+
return _context9.abrupt("return", res);
|
|
369
|
+
case 3:
|
|
370
|
+
case "end":
|
|
371
|
+
return _context9.stop();
|
|
372
|
+
}
|
|
373
|
+
}, _callee9, this);
|
|
374
|
+
}));
|
|
375
|
+
function fieldFilters(_x15) {
|
|
376
|
+
return _fieldFilters.apply(this, arguments);
|
|
377
|
+
}
|
|
378
|
+
return fieldFilters;
|
|
379
|
+
}();
|
|
259
380
|
_proto.serviceUpdate = /*#__PURE__*/function () {
|
|
260
|
-
var _serviceUpdate = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function
|
|
381
|
+
var _serviceUpdate = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee0(data, options) {
|
|
261
382
|
var params;
|
|
262
|
-
return _regeneratorRuntime.wrap(function (
|
|
263
|
-
while (1) switch (
|
|
383
|
+
return _regeneratorRuntime.wrap(function (_context0) {
|
|
384
|
+
while (1) switch (_context0.prev = _context0.next) {
|
|
264
385
|
case 0:
|
|
265
386
|
params = {
|
|
266
387
|
formId: this.formId,
|
|
@@ -270,16 +391,16 @@ export var RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
|
270
391
|
params.mock = true;
|
|
271
392
|
params.description = (this.title || "表单") + ".\u67E5\u8BE2";
|
|
272
393
|
}
|
|
273
|
-
return
|
|
394
|
+
return _context0.abrupt("return", this.request.post("serviceUpdate", data, {
|
|
274
395
|
params: params
|
|
275
396
|
}));
|
|
276
397
|
case 1:
|
|
277
398
|
case "end":
|
|
278
|
-
return
|
|
399
|
+
return _context0.stop();
|
|
279
400
|
}
|
|
280
|
-
},
|
|
401
|
+
}, _callee0, this);
|
|
281
402
|
}));
|
|
282
|
-
function serviceUpdate(
|
|
403
|
+
function serviceUpdate(_x16, _x17) {
|
|
283
404
|
return _serviceUpdate.apply(this, arguments);
|
|
284
405
|
}
|
|
285
406
|
return serviceUpdate;
|
package/es/utils/api/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { AxiosResponse } from "axios";
|
|
1
2
|
export { RestApi } from "./rest-api";
|
|
2
3
|
export { getFormApi, RestFormApi } from "./form-api";
|
|
3
|
-
import { AxiosResponse } from "axios/index";
|
|
4
4
|
export { getSchema } from "./schema-api";
|
|
5
5
|
export { getUserinfo } from "./user-info";
|
|
6
6
|
export * as files from "./file-api";
|
package/es/utils/api/index.js
CHANGED
|
@@ -31,12 +31,14 @@ export function onFulfilled(res) {
|
|
|
31
31
|
export function onRejected(error) {
|
|
32
32
|
var _error$response = error.response,
|
|
33
33
|
status = _error$response.status,
|
|
34
|
-
statusText = _error$response.statusText
|
|
34
|
+
statusText = _error$response.statusText,
|
|
35
|
+
data = _error$response.data;
|
|
36
|
+
console.error("请求失败!", error);
|
|
35
37
|
if (status == 400) {
|
|
36
38
|
return error.response.data || {};
|
|
37
39
|
}
|
|
38
40
|
return {
|
|
39
41
|
success: false,
|
|
40
|
-
message: statusText
|
|
42
|
+
message: (data === null || data === void 0 ? void 0 : data.message) || statusText
|
|
41
43
|
};
|
|
42
44
|
}
|
|
@@ -36,7 +36,7 @@ export declare abstract class BaseRestApi<DataType> {
|
|
|
36
36
|
title: string;
|
|
37
37
|
request: AxiosInstance;
|
|
38
38
|
protected constructor(uri: string, options?: RestApiOptions);
|
|
39
|
-
abstract handleRequestConfig(config: AxiosRequestConfig): void
|
|
39
|
+
abstract handleRequestConfig(config: AxiosRequestConfig): Promise<void>;
|
|
40
40
|
search(params?: RestSearchParams): Promise<ManyResult<DataType>>;
|
|
41
41
|
/**
|
|
42
42
|
* 通过id获取
|
|
@@ -58,6 +58,8 @@ export declare abstract class BaseRestApi<DataType> {
|
|
|
58
58
|
*/
|
|
59
59
|
deleteById(id: string, options?: BaseRequestOptions<DataType>): Promise<OneResult<DataType>>;
|
|
60
60
|
delete(data: any | any[], options?: BaseRequestOptions<DataType>): Promise<OneResult<DataType>>;
|
|
61
|
+
export(data: any, options?: BaseRequestOptions<DataType>): Promise<OneResult<DataType>>;
|
|
62
|
+
import(data: any, options?: BaseRequestOptions<DataType>): Promise<OneResult<DataType>>;
|
|
61
63
|
showError(type: string, res: BaseResult<any>): Promise<void>;
|
|
62
64
|
}
|
|
63
65
|
export declare class RestApi<DataType> extends BaseRestApi<DataType> {
|