@zhubangyun/lowcode-core 5.12.92 → 6.1.90
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 +44 -28
- package/es/components/page-loading/index.js +4 -1
- package/es/demo/index.js +8 -8
- package/es/index.d.ts +1 -1
- package/es/index.js +41 -2
- package/es/index.less +10 -0
- package/es/style.js +2 -2
- package/es/utils/api/file-api.js +21 -21
- package/es/utils/api/form-api.d.ts +2 -1
- package/es/utils/api/form-api.js +90 -51
- package/es/utils/api/form-api.utils.js +5 -4
- package/es/utils/api/index.d.ts +2 -2
- package/es/utils/api/index.js +1 -0
- package/es/utils/api/rest-api.d.ts +3 -1
- package/es/utils/api/rest-api.js +207 -125
- package/es/utils/api/schema-api.js +5 -5
- package/es/utils/api/schema.util.d.ts +3 -3
- package/es/utils/api/schema.util.js +17 -12
- package/es/utils/api/script-api.js +12 -12
- package/es/utils/api/user-info.js +7 -7
- package/es/utils/cache/index.js +66 -26
- package/es/utils/common/LoadPlugins.js +33 -33
- package/es/utils/common/SingletonInstanceMap.js +21 -21
- package/es/utils/common/index.d.ts +3 -0
- package/es/utils/common/index.js +13 -3
- package/es/utils/designer/assets/assets.parse.js +15 -15
- package/es/utils/designer/assets/assets.typing.js +6 -0
- package/es/utils/designer/engine/index.js +23 -23
- package/es/utils/designer/index.js +7 -7
- package/es/utils/page/index.js +18 -18
- package/es/utils/page/page-form-data-manager-group.js +9 -6
- package/es/utils/page/page-form-data-manager.d.ts +1 -0
- package/es/utils/page/page-form-data-manager.js +9 -6
- package/es/utils/page/page-form-group.d.ts +1 -0
- package/es/utils/page/page-form-group.js +8 -7
- package/es/utils/page/page-form.d.ts +1 -0
- package/es/utils/page/page-form.js +23 -12
- package/es/utils/page/page-layout.d.ts +3 -0
- package/es/utils/page/page-layout.js +33 -9
- package/es/utils/page/page-load-schema.js +20 -28
- package/es/utils/page/page-render.js +4 -4
- package/es/utils/page/page-show.d.ts +2 -0
- package/es/utils/page/page-show.js +8 -3
- package/es/utils/page/print-form.js +60 -51
- package/es/utils/uni-bridge.d.ts +18 -0
- package/es/utils/uni-bridge.js +130 -0
- package/es/utils/util.common.d.ts +1 -0
- package/es/utils/util.common.js +4 -0
- package/lib/components/load-materials/index.js +45 -30
- package/lib/components/page-loading/index.js +4 -1
- package/lib/demo/index.js +9 -10
- package/lib/index.d.ts +1 -1
- package/lib/index.js +45 -6
- package/lib/index.less +10 -0
- package/lib/style.js +2 -2
- package/lib/utils/api/file-api.js +21 -21
- package/lib/utils/api/form-api.d.ts +2 -1
- package/lib/utils/api/form-api.js +90 -51
- package/lib/utils/api/form-api.utils.js +5 -4
- package/lib/utils/api/index.d.ts +2 -2
- package/lib/utils/api/index.js +2 -2
- package/lib/utils/api/rest-api.d.ts +3 -1
- package/lib/utils/api/rest-api.js +207 -125
- package/lib/utils/api/schema-api.js +5 -5
- package/lib/utils/api/schema.util.d.ts +3 -3
- package/lib/utils/api/schema.util.js +19 -13
- package/lib/utils/api/script-api.js +12 -12
- package/lib/utils/api/user-info.js +7 -7
- package/lib/utils/cache/index.js +65 -25
- package/lib/utils/common/LoadPlugins.js +33 -33
- package/lib/utils/common/SingletonInstanceMap.js +21 -21
- package/lib/utils/common/index.d.ts +3 -0
- package/lib/utils/common/index.js +15 -2
- package/lib/utils/designer/assets/assets.parse.js +16 -17
- package/lib/utils/designer/assets/assets.typing.js +6 -0
- package/lib/utils/designer/engine/index.js +23 -23
- package/lib/utils/designer/index.js +7 -7
- package/lib/utils/index.js +1 -2
- package/lib/utils/page/index.js +18 -18
- package/lib/utils/page/page-form-data-manager-group.js +10 -8
- package/lib/utils/page/page-form-data-manager.d.ts +1 -0
- package/lib/utils/page/page-form-data-manager.js +10 -8
- package/lib/utils/page/page-form-group.d.ts +1 -0
- package/lib/utils/page/page-form-group.js +9 -9
- package/lib/utils/page/page-form.d.ts +1 -0
- package/lib/utils/page/page-form.js +24 -14
- package/lib/utils/page/page-layout.d.ts +3 -0
- package/lib/utils/page/page-layout.js +34 -11
- package/lib/utils/page/page-load-schema.js +19 -27
- package/lib/utils/page/page-render.js +4 -4
- package/lib/utils/page/page-show.d.ts +2 -0
- package/lib/utils/page/page-show.js +9 -5
- package/lib/utils/page/print-form.js +60 -51
- package/lib/utils/uni-bridge.d.ts +18 -0
- package/lib/utils/uni-bridge.js +135 -0
- package/lib/utils/util.common.d.ts +1 -0
- package/lib/utils/util.common.js +8 -0
- package/package.json +2 -2
|
@@ -3,24 +3,37 @@ 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
|
}
|
|
19
26
|
function _initialize() {
|
|
20
|
-
_initialize = _asyncToGenerator(
|
|
21
|
-
return _regeneratorRuntime.wrap(function
|
|
27
|
+
_initialize = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
28
|
+
return _regeneratorRuntime.wrap(function (_context) {
|
|
22
29
|
while (1) switch (_context.prev = _context.next) {
|
|
23
30
|
case 0:
|
|
31
|
+
if (!init) {
|
|
32
|
+
_context.next = 1;
|
|
33
|
+
break;
|
|
34
|
+
}
|
|
35
|
+
return _context.abrupt("return");
|
|
36
|
+
case 1:
|
|
24
37
|
_context.next = 2;
|
|
25
38
|
return loadMaterials();
|
|
26
39
|
case 2:
|
|
@@ -45,41 +58,44 @@ function loadMaterials() {
|
|
|
45
58
|
return _loadMaterials.apply(this, arguments);
|
|
46
59
|
}
|
|
47
60
|
function _loadMaterials() {
|
|
48
|
-
_loadMaterials = _asyncToGenerator(
|
|
49
|
-
var
|
|
50
|
-
return _regeneratorRuntime.wrap(function
|
|
61
|
+
_loadMaterials = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
62
|
+
var urls;
|
|
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
|
-
_context2.next =
|
|
67
|
+
_context2.next = 1;
|
|
56
68
|
break;
|
|
57
69
|
}
|
|
58
70
|
return _context2.abrupt("return");
|
|
59
|
-
case
|
|
60
|
-
urls = ["prop-types/15.8.1/prop-types.min.js", "lodash/4.17.15/lodash.min.js", "dayjs/dayjs.min.js", "
|
|
61
|
-
_context2.next =
|
|
71
|
+
case 1:
|
|
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"];
|
|
73
|
+
_context2.next = 2;
|
|
62
74
|
return loadPlugins(urls.map(function (url) {
|
|
63
75
|
return "https://cdn.zhiyunhe.com/plugin/" + url;
|
|
64
76
|
}));
|
|
65
|
-
case
|
|
66
|
-
|
|
67
|
-
|
|
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
|
-
case 8:
|
|
77
|
+
case 2:
|
|
78
|
+
setComponents();
|
|
79
|
+
case 3:
|
|
79
80
|
case "end":
|
|
80
81
|
return _context2.stop();
|
|
81
82
|
}
|
|
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/demo/index.js
CHANGED
|
@@ -8,17 +8,17 @@ console.log(utils);
|
|
|
8
8
|
function App() {
|
|
9
9
|
var ref = useRef();
|
|
10
10
|
useEffect(function () {
|
|
11
|
-
utils.designer.initEngine().then(
|
|
12
|
-
var _ref = _asyncToGenerator(
|
|
13
|
-
return _regeneratorRuntime.wrap(function
|
|
11
|
+
utils.designer.initEngine().then(/*#__PURE__*/function () {
|
|
12
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(engine) {
|
|
13
|
+
return _regeneratorRuntime.wrap(function (_context) {
|
|
14
14
|
while (1) switch (_context.prev = _context.next) {
|
|
15
15
|
case 0:
|
|
16
|
-
_context.next =
|
|
16
|
+
_context.next = 1;
|
|
17
17
|
return engine.injectAssets([]);
|
|
18
|
-
case
|
|
19
|
-
_context.next =
|
|
18
|
+
case 1:
|
|
19
|
+
_context.next = 2;
|
|
20
20
|
return engine.init(ref.current, Schema);
|
|
21
|
-
case
|
|
21
|
+
case 2:
|
|
22
22
|
case "end":
|
|
23
23
|
return _context.stop();
|
|
24
24
|
}
|
|
@@ -37,4 +37,4 @@ function App() {
|
|
|
37
37
|
}
|
|
38
38
|
}));
|
|
39
39
|
}
|
|
40
|
-
ReactDOM.render(
|
|
40
|
+
ReactDOM.render(/*#__PURE__*/React.createElement(App, null), document.getElementById('root'));
|
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,6 @@
|
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
1
3
|
import "./index.less";
|
|
2
|
-
import utils from "./utils";
|
|
3
4
|
import { ReactRender } from "./components/react-render";
|
|
4
5
|
import * as lodash from "lodash";
|
|
5
6
|
export { LoadMaterials } from "./components/load-materials";
|
|
@@ -7,7 +8,8 @@ export { PageLoading } from "./components/page-loading";
|
|
|
7
8
|
export { RestApi, RestFormApi, apiRequest } from "./utils/api";
|
|
8
9
|
export { Layout } from "./components/layout";
|
|
9
10
|
export { ReactRender } from "./components/react-render";
|
|
10
|
-
|
|
11
|
+
import utils from "./utils/index";
|
|
12
|
+
import { uniBridge } from "./utils/uni-bridge";
|
|
11
13
|
// @ts-ignore
|
|
12
14
|
window.__ReactRender = ReactRender;
|
|
13
15
|
// @ts-ignore
|
|
@@ -20,4 +22,41 @@ if (!window.utils) {
|
|
|
20
22
|
// @ts-ignore
|
|
21
23
|
window.utils = utils;
|
|
22
24
|
}
|
|
25
|
+
window.isMobile = utils.common.isMobile();
|
|
26
|
+
if (window.isMobile) {
|
|
27
|
+
var classList = window.document.body.classList;
|
|
28
|
+
if (!classList.contains("mobile")) {
|
|
29
|
+
classList.add("mobile");
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
var bar_height_key = "bar_height";
|
|
33
|
+
// @ts-ignore
|
|
34
|
+
utils.uniBridge = uniBridge;
|
|
35
|
+
// @ts-ignore
|
|
36
|
+
window.uniBridge = uniBridge;
|
|
37
|
+
window.addEventListener("load", function () {
|
|
38
|
+
setTimeout(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
39
|
+
var height;
|
|
40
|
+
return _regeneratorRuntime.wrap(function (_context) {
|
|
41
|
+
while (1) switch (_context.prev = _context.next) {
|
|
42
|
+
case 0:
|
|
43
|
+
_context.next = 1;
|
|
44
|
+
return uniBridge.getBarHeight();
|
|
45
|
+
case 1:
|
|
46
|
+
height = _context.sent;
|
|
47
|
+
localStorage.setItem(bar_height_key, height);
|
|
48
|
+
updateBarHeight();
|
|
49
|
+
case 2:
|
|
50
|
+
case "end":
|
|
51
|
+
return _context.stop();
|
|
52
|
+
}
|
|
53
|
+
}, _callee);
|
|
54
|
+
})), 100);
|
|
55
|
+
});
|
|
56
|
+
function updateBarHeight() {
|
|
57
|
+
if (localStorage.getItem(bar_height_key)) {
|
|
58
|
+
document.documentElement.style.setProperty('--bar-height', localStorage.getItem(bar_height_key));
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
updateBarHeight();
|
|
23
62
|
export { utils, lodash };
|
package/es/index.less
CHANGED
package/es/style.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import 'antd/es/config-provider/style';
|
|
2
|
+
|
|
1
3
|
import 'antd/es/notification/style';
|
|
2
4
|
import 'antd/es/modal/style';
|
|
3
5
|
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';
|
package/es/utils/api/file-api.js
CHANGED
|
@@ -5,18 +5,18 @@ export function upload(_x, _x2) {
|
|
|
5
5
|
return _upload.apply(this, arguments);
|
|
6
6
|
}
|
|
7
7
|
function _upload() {
|
|
8
|
-
_upload = _asyncToGenerator(
|
|
9
|
-
var res, ossFile, _options$onFinished, _options$onError;
|
|
10
|
-
return _regeneratorRuntime.wrap(function
|
|
8
|
+
_upload = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(file, options) {
|
|
9
|
+
var res, ossFile, _options$onFinished, _options$onError, _t;
|
|
10
|
+
return _regeneratorRuntime.wrap(function (_context) {
|
|
11
11
|
while (1) switch (_context.prev = _context.next) {
|
|
12
12
|
case 0:
|
|
13
13
|
if (file) {
|
|
14
|
-
_context.next =
|
|
14
|
+
_context.next = 1;
|
|
15
15
|
break;
|
|
16
16
|
}
|
|
17
17
|
return _context.abrupt("return", file);
|
|
18
|
-
case
|
|
19
|
-
_context.next =
|
|
18
|
+
case 1:
|
|
19
|
+
_context.next = 2;
|
|
20
20
|
return apiRequest.post("files/signature", {
|
|
21
21
|
id: file.id,
|
|
22
22
|
size: file.size,
|
|
@@ -27,15 +27,15 @@ function _upload() {
|
|
|
27
27
|
type: "oss"
|
|
28
28
|
}
|
|
29
29
|
});
|
|
30
|
-
case
|
|
30
|
+
case 2:
|
|
31
31
|
res = _context.sent;
|
|
32
32
|
ossFile = res.data;
|
|
33
33
|
file.id = ossFile.id;
|
|
34
34
|
file.url = ossFile.url;
|
|
35
35
|
file.percent = 0;
|
|
36
36
|
file.status = "uploading";
|
|
37
|
-
_context.prev =
|
|
38
|
-
_context.next =
|
|
37
|
+
_context.prev = 3;
|
|
38
|
+
_context.next = 4;
|
|
39
39
|
return apiRequest.put(ossFile.uploadUrl, (file === null || file === void 0 ? void 0 : file.buffer) || file, {
|
|
40
40
|
headers: {
|
|
41
41
|
'Content-Type': file.type
|
|
@@ -48,21 +48,21 @@ function _upload() {
|
|
|
48
48
|
options === null || options === void 0 ? void 0 : (_options$onProgress = options.onProgress) === null || _options$onProgress === void 0 ? void 0 : _options$onProgress.call(options, evt);
|
|
49
49
|
}
|
|
50
50
|
});
|
|
51
|
-
case
|
|
51
|
+
case 4:
|
|
52
52
|
file.status = "done";
|
|
53
53
|
options === null || options === void 0 ? void 0 : (_options$onFinished = options.onFinished) === null || _options$onFinished === void 0 ? void 0 : _options$onFinished.call(options);
|
|
54
|
-
_context.next =
|
|
54
|
+
_context.next = 6;
|
|
55
55
|
break;
|
|
56
|
-
case
|
|
57
|
-
_context.prev =
|
|
58
|
-
|
|
56
|
+
case 5:
|
|
57
|
+
_context.prev = 5;
|
|
58
|
+
_t = _context["catch"](3);
|
|
59
59
|
file.status = "error";
|
|
60
|
-
options === null || options === void 0 ? void 0 : (_options$onError = options.onError) === null || _options$onError === void 0 ? void 0 : _options$onError.call(options,
|
|
61
|
-
case
|
|
60
|
+
options === null || options === void 0 ? void 0 : (_options$onError = options.onError) === null || _options$onError === void 0 ? void 0 : _options$onError.call(options, _t);
|
|
61
|
+
case 6:
|
|
62
62
|
case "end":
|
|
63
63
|
return _context.stop();
|
|
64
64
|
}
|
|
65
|
-
}, _callee, null, [[
|
|
65
|
+
}, _callee, null, [[3, 5]]);
|
|
66
66
|
}));
|
|
67
67
|
return _upload.apply(this, arguments);
|
|
68
68
|
}
|
|
@@ -70,16 +70,16 @@ export function update(_x3) {
|
|
|
70
70
|
return _update.apply(this, arguments);
|
|
71
71
|
}
|
|
72
72
|
function _update() {
|
|
73
|
-
_update = _asyncToGenerator(
|
|
74
|
-
return _regeneratorRuntime.wrap(function
|
|
73
|
+
_update = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(file) {
|
|
74
|
+
return _regeneratorRuntime.wrap(function (_context2) {
|
|
75
75
|
while (1) switch (_context2.prev = _context2.next) {
|
|
76
76
|
case 0:
|
|
77
|
-
_context2.next =
|
|
77
|
+
_context2.next = 1;
|
|
78
78
|
return apiRequest.post("files/update", {
|
|
79
79
|
id: file.id,
|
|
80
80
|
fileName: file.fileName
|
|
81
81
|
});
|
|
82
|
-
case
|
|
82
|
+
case 1:
|
|
83
83
|
case "end":
|
|
84
84
|
return _context2.stop();
|
|
85
85
|
}
|
|
@@ -12,8 +12,9 @@ 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>>;
|
|
18
|
-
serviceUpdate(data: DataType, options?: BaseRequestOptions<DataType>): Promise<import("axios").AxiosResponse<any, any>>;
|
|
19
|
+
serviceUpdate(data: DataType, options?: BaseRequestOptions<DataType>): Promise<import("axios").AxiosResponse<any, any, {}>>;
|
|
19
20
|
}
|
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 } 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(
|
|
14
|
+
_getFormApi = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee0(formId, fieldId, mock) {
|
|
14
15
|
var key;
|
|
15
|
-
return _regeneratorRuntime.wrap(function
|
|
16
|
-
while (1) switch (
|
|
16
|
+
return _regeneratorRuntime.wrap(function (_context0) {
|
|
17
|
+
while (1) switch (_context0.prev = _context0.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 _context0.abrupt("return", formApi.getInstance(key, {
|
|
27
28
|
mock: mock,
|
|
28
29
|
fieldId: fieldId,
|
|
29
30
|
formId: formId
|
|
30
31
|
}));
|
|
31
|
-
case
|
|
32
|
+
case 1:
|
|
32
33
|
case "end":
|
|
33
|
-
return
|
|
34
|
+
return _context0.stop();
|
|
34
35
|
}
|
|
35
|
-
},
|
|
36
|
+
}, _callee0);
|
|
36
37
|
}));
|
|
37
38
|
return _getFormApi.apply(this, arguments);
|
|
38
39
|
}
|
|
@@ -55,10 +56,10 @@ export var RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
|
55
56
|
_inheritsLoose(RestFormApi, _RestApi);
|
|
56
57
|
var _proto = RestFormApi.prototype;
|
|
57
58
|
_proto.initialize = /*#__PURE__*/function () {
|
|
58
|
-
var _initialize = _asyncToGenerator(
|
|
59
|
+
var _initialize = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
59
60
|
var _this2 = this;
|
|
60
61
|
var res, _this$schema, _this$schema$children, _this$schema$children2;
|
|
61
|
-
return _regeneratorRuntime.wrap(function
|
|
62
|
+
return _regeneratorRuntime.wrap(function (_context) {
|
|
62
63
|
while (1) switch (_context.prev = _context.next) {
|
|
63
64
|
case 0:
|
|
64
65
|
if (!this.initialized) {
|
|
@@ -92,7 +93,7 @@ export var RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
|
92
93
|
}
|
|
93
94
|
}
|
|
94
95
|
return _context.abrupt("return", this.initialized);
|
|
95
|
-
case
|
|
96
|
+
case 1:
|
|
96
97
|
case "end":
|
|
97
98
|
return _context.stop();
|
|
98
99
|
}
|
|
@@ -104,13 +105,13 @@ export var RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
|
104
105
|
return initialize;
|
|
105
106
|
}();
|
|
106
107
|
_proto.handleRequestConfig = /*#__PURE__*/function () {
|
|
107
|
-
var _handleRequestConfig = _asyncToGenerator(
|
|
108
|
-
return _regeneratorRuntime.wrap(function
|
|
108
|
+
var _handleRequestConfig = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(config) {
|
|
109
|
+
return _regeneratorRuntime.wrap(function (_context2) {
|
|
109
110
|
while (1) switch (_context2.prev = _context2.next) {
|
|
110
111
|
case 0:
|
|
111
|
-
_context2.next =
|
|
112
|
+
_context2.next = 1;
|
|
112
113
|
return this.initialize();
|
|
113
|
-
case
|
|
114
|
+
case 1:
|
|
114
115
|
config.params = config.params || {};
|
|
115
116
|
if (__mock) {
|
|
116
117
|
config.params.description = "" + this.title;
|
|
@@ -122,7 +123,7 @@ export var RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
|
122
123
|
if (this.mock) {
|
|
123
124
|
config.params.mock = this.mock;
|
|
124
125
|
}
|
|
125
|
-
case
|
|
126
|
+
case 2:
|
|
126
127
|
case "end":
|
|
127
128
|
return _context2.stop();
|
|
128
129
|
}
|
|
@@ -134,10 +135,10 @@ export var RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
|
134
135
|
return handleRequestConfig;
|
|
135
136
|
}();
|
|
136
137
|
_proto.search = /*#__PURE__*/function () {
|
|
137
|
-
var _search = _asyncToGenerator(
|
|
138
|
+
var _search = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(searchParams) {
|
|
138
139
|
var _searchParams, _searchParams2;
|
|
139
140
|
var params, config, res, start;
|
|
140
|
-
return _regeneratorRuntime.wrap(function
|
|
141
|
+
return _regeneratorRuntime.wrap(function (_context3) {
|
|
141
142
|
while (1) switch (_context3.prev = _context3.next) {
|
|
142
143
|
case 0:
|
|
143
144
|
searchParams = searchParams || {};
|
|
@@ -151,9 +152,9 @@ export var RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
|
151
152
|
config = {
|
|
152
153
|
params: params
|
|
153
154
|
};
|
|
154
|
-
_context3.next =
|
|
155
|
+
_context3.next = 1;
|
|
155
156
|
return this.handleRequestConfig(config);
|
|
156
|
-
case
|
|
157
|
+
case 1:
|
|
157
158
|
searchParams.filterRules = handleFilterRules(((_searchParams = searchParams) === null || _searchParams === void 0 ? void 0 : _searchParams.filterRules) || [], {
|
|
158
159
|
filterNullValue: false
|
|
159
160
|
});
|
|
@@ -161,16 +162,16 @@ export var RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
|
161
162
|
filterNullValue: true
|
|
162
163
|
});
|
|
163
164
|
config.params = _extends({}, params, searchParams);
|
|
164
|
-
_context3.next =
|
|
165
|
+
_context3.next = 2;
|
|
165
166
|
return this.request.get("search", config);
|
|
166
|
-
case
|
|
167
|
+
case 2:
|
|
167
168
|
res = _context3.sent;
|
|
168
169
|
//const res = await this.request.post<any, ManyResult<DataType>>("search", searchParams, config);
|
|
169
170
|
start = Date.now();
|
|
170
171
|
assembleAssociationField(res.data, res.refs);
|
|
171
172
|
console.debug("form.search:", res);
|
|
172
173
|
return _context3.abrupt("return", res);
|
|
173
|
-
case
|
|
174
|
+
case 3:
|
|
174
175
|
case "end":
|
|
175
176
|
return _context3.stop();
|
|
176
177
|
}
|
|
@@ -182,19 +183,19 @@ export var RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
|
182
183
|
return search;
|
|
183
184
|
}();
|
|
184
185
|
_proto.getById = /*#__PURE__*/function () {
|
|
185
|
-
var _getById = _asyncToGenerator(
|
|
186
|
+
var _getById = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4(id, options) {
|
|
186
187
|
var res;
|
|
187
|
-
return _regeneratorRuntime.wrap(function
|
|
188
|
+
return _regeneratorRuntime.wrap(function (_context4) {
|
|
188
189
|
while (1) switch (_context4.prev = _context4.next) {
|
|
189
190
|
case 0:
|
|
190
|
-
_context4.next =
|
|
191
|
+
_context4.next = 1;
|
|
191
192
|
return _RestApi.prototype.getById.call(this, id, options);
|
|
192
|
-
case
|
|
193
|
+
case 1:
|
|
193
194
|
res = _context4.sent;
|
|
194
195
|
assembleAssociationField(res.data, res.refs);
|
|
195
196
|
console.debug("formApi.getById", res);
|
|
196
197
|
return _context4.abrupt("return", res);
|
|
197
|
-
case
|
|
198
|
+
case 2:
|
|
198
199
|
case "end":
|
|
199
200
|
return _context4.stop();
|
|
200
201
|
}
|
|
@@ -205,51 +206,89 @@ export var RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
|
205
206
|
}
|
|
206
207
|
return getById;
|
|
207
208
|
}();
|
|
208
|
-
_proto.
|
|
209
|
-
var
|
|
210
|
-
|
|
209
|
+
_proto.labelToValue = /*#__PURE__*/function () {
|
|
210
|
+
var _labelToValue = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee5(data, options) {
|
|
211
|
+
var _this3 = this;
|
|
212
|
+
var config, res;
|
|
213
|
+
return _regeneratorRuntime.wrap(function (_context5) {
|
|
211
214
|
while (1) switch (_context5.prev = _context5.next) {
|
|
212
215
|
case 0:
|
|
213
|
-
|
|
216
|
+
config = {};
|
|
217
|
+
_context5.next = 1;
|
|
218
|
+
return this.handleRequestConfig(config);
|
|
214
219
|
case 1:
|
|
220
|
+
_context5.next = 2;
|
|
221
|
+
return this.request.post("labelToValue", data, config);
|
|
222
|
+
case 2:
|
|
223
|
+
res = _context5.sent;
|
|
224
|
+
if (Array.isArray(res.data)) {
|
|
225
|
+
res.data.forEach(function (item) {
|
|
226
|
+
item.id = uuid();
|
|
227
|
+
item.form = {
|
|
228
|
+
id: _this3.formId,
|
|
229
|
+
fieldId: _this3.fieldId
|
|
230
|
+
};
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
assembleAssociationField(res.data, res.refs);
|
|
234
|
+
console.debug("formApi.labelToValue", res);
|
|
235
|
+
return _context5.abrupt("return", res);
|
|
236
|
+
case 3:
|
|
215
237
|
case "end":
|
|
216
238
|
return _context5.stop();
|
|
217
239
|
}
|
|
218
240
|
}, _callee5, this);
|
|
219
241
|
}));
|
|
220
|
-
function
|
|
221
|
-
return
|
|
242
|
+
function labelToValue(_x8, _x9) {
|
|
243
|
+
return _labelToValue.apply(this, arguments);
|
|
222
244
|
}
|
|
223
|
-
return
|
|
245
|
+
return labelToValue;
|
|
224
246
|
}();
|
|
225
|
-
_proto.
|
|
226
|
-
var
|
|
227
|
-
return _regeneratorRuntime.wrap(function
|
|
247
|
+
_proto.save = /*#__PURE__*/function () {
|
|
248
|
+
var _save = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee6(data, options) {
|
|
249
|
+
return _regeneratorRuntime.wrap(function (_context6) {
|
|
228
250
|
while (1) switch (_context6.prev = _context6.next) {
|
|
229
251
|
case 0:
|
|
230
|
-
return _context6.abrupt("return", _RestApi.prototype.
|
|
252
|
+
return _context6.abrupt("return", _RestApi.prototype.save.call(this, convertSaveData(data), options));
|
|
231
253
|
case 1:
|
|
232
254
|
case "end":
|
|
233
255
|
return _context6.stop();
|
|
234
256
|
}
|
|
235
257
|
}, _callee6, this);
|
|
236
258
|
}));
|
|
259
|
+
function save(_x0, _x1) {
|
|
260
|
+
return _save.apply(this, arguments);
|
|
261
|
+
}
|
|
262
|
+
return save;
|
|
263
|
+
}();
|
|
264
|
+
_proto.create = /*#__PURE__*/function () {
|
|
265
|
+
var _create = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee7(data, options) {
|
|
266
|
+
return _regeneratorRuntime.wrap(function (_context7) {
|
|
267
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
268
|
+
case 0:
|
|
269
|
+
return _context7.abrupt("return", _RestApi.prototype.create.call(this, convertSaveData(data), options));
|
|
270
|
+
case 1:
|
|
271
|
+
case "end":
|
|
272
|
+
return _context7.stop();
|
|
273
|
+
}
|
|
274
|
+
}, _callee7, this);
|
|
275
|
+
}));
|
|
237
276
|
function create(_x10, _x11) {
|
|
238
277
|
return _create.apply(this, arguments);
|
|
239
278
|
}
|
|
240
279
|
return create;
|
|
241
280
|
}();
|
|
242
281
|
_proto.update = /*#__PURE__*/function () {
|
|
243
|
-
var _update = _asyncToGenerator(
|
|
244
|
-
return _regeneratorRuntime.wrap(function
|
|
245
|
-
while (1) switch (
|
|
282
|
+
var _update = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee8(id, data, options) {
|
|
283
|
+
return _regeneratorRuntime.wrap(function (_context8) {
|
|
284
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
246
285
|
case 0:
|
|
247
|
-
return
|
|
286
|
+
return _context8.abrupt("return", _RestApi.prototype.update.call(this, id, convertSaveData(data), options));
|
|
248
287
|
case 1:
|
|
249
288
|
case "end":
|
|
250
|
-
return
|
|
289
|
+
return _context8.stop();
|
|
251
290
|
}
|
|
252
|
-
},
|
|
291
|
+
}, _callee8, this);
|
|
253
292
|
}));
|
|
254
293
|
function update(_x12, _x13, _x14) {
|
|
255
294
|
return _update.apply(this, arguments);
|
|
@@ -257,10 +296,10 @@ export var RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
|
257
296
|
return update;
|
|
258
297
|
}();
|
|
259
298
|
_proto.serviceUpdate = /*#__PURE__*/function () {
|
|
260
|
-
var _serviceUpdate = _asyncToGenerator(
|
|
299
|
+
var _serviceUpdate = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee9(data, options) {
|
|
261
300
|
var params;
|
|
262
|
-
return _regeneratorRuntime.wrap(function
|
|
263
|
-
while (1) switch (
|
|
301
|
+
return _regeneratorRuntime.wrap(function (_context9) {
|
|
302
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
264
303
|
case 0:
|
|
265
304
|
params = {
|
|
266
305
|
formId: this.formId,
|
|
@@ -270,14 +309,14 @@ export var RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
|
270
309
|
params.mock = true;
|
|
271
310
|
params.description = (this.title || "表单") + ".\u67E5\u8BE2";
|
|
272
311
|
}
|
|
273
|
-
return
|
|
312
|
+
return _context9.abrupt("return", this.request.post("serviceUpdate", data, {
|
|
274
313
|
params: params
|
|
275
314
|
}));
|
|
276
|
-
case
|
|
315
|
+
case 1:
|
|
277
316
|
case "end":
|
|
278
|
-
return
|
|
317
|
+
return _context9.stop();
|
|
279
318
|
}
|
|
280
|
-
},
|
|
319
|
+
}, _callee9, this);
|
|
281
320
|
}));
|
|
282
321
|
function serviceUpdate(_x15, _x16) {
|
|
283
322
|
return _serviceUpdate.apply(this, arguments);
|