@zhubangyun/lowcode-core 5.8.290 → 5.10.81
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 -0
- package/es/utils/api/file-api.d.ts +7 -0
- package/es/utils/api/file-api.js +86 -0
- package/es/utils/api/form-api.d.ts +1 -0
- package/es/utils/api/form-api.js +66 -27
- package/es/utils/api/form-api.utils.d.ts +2 -0
- package/es/utils/api/form-api.utils.js +82 -113
- package/es/utils/api/index.d.ts +5 -5
- package/es/utils/api/index.js +7 -67
- package/es/utils/api/rest-api.d.ts +6 -2
- package/es/utils/api/rest-api.js +64 -34
- package/es/utils/api/schema-api.d.ts +2 -0
- package/es/utils/api/schema-api.js +33 -0
- package/es/utils/api/script-api.d.ts +1 -0
- package/es/utils/api/script-api.js +41 -0
- package/es/utils/cache/schema.js +15 -9
- package/es/utils/common/LoadPlugins.js +9 -16
- package/es/utils/common/index.d.ts +1 -0
- package/es/utils/common/index.js +12 -0
- package/es/utils/page/index.d.ts +1 -0
- package/es/utils/page/index.js +1 -0
- package/es/utils/page/page-form-data-manager-group.d.ts +17 -0
- package/es/utils/page/page-form-data-manager-group.js +104 -0
- package/es/utils/page/page-form-data-manager.d.ts +6 -0
- package/es/utils/page/page-form-data-manager.js +24 -79
- package/es/utils/page/page-form.d.ts +1 -1
- package/es/utils/page/page-form.js +24 -47
- package/es/utils/page/page-layout.js +1 -1
- package/es/utils/page/page-render.d.ts +10 -0
- package/es/utils/page/page-render.js +51 -0
- package/es/utils/page/page-schema-utils.d.ts +1 -0
- package/es/utils/page/page-schema-utils.js +74 -0
- package/lib/index.js +2 -0
- package/lib/utils/api/file-api.d.ts +7 -0
- package/lib/utils/api/file-api.js +92 -0
- package/lib/utils/api/form-api.d.ts +1 -0
- package/lib/utils/api/form-api.js +67 -27
- package/lib/utils/api/form-api.utils.d.ts +2 -0
- package/lib/utils/api/form-api.utils.js +84 -113
- package/lib/utils/api/index.d.ts +5 -5
- package/lib/utils/api/index.js +14 -72
- package/lib/utils/api/rest-api.d.ts +6 -2
- package/lib/utils/api/rest-api.js +64 -34
- package/lib/utils/api/schema-api.d.ts +2 -0
- package/lib/utils/api/schema-api.js +38 -0
- package/lib/utils/api/script-api.d.ts +1 -0
- package/lib/utils/api/script-api.js +46 -0
- package/lib/utils/cache/schema.js +15 -9
- package/lib/utils/common/LoadPlugins.js +9 -16
- package/lib/utils/common/index.d.ts +1 -0
- package/lib/utils/common/index.js +13 -0
- package/lib/utils/page/index.d.ts +1 -0
- package/lib/utils/page/index.js +3 -1
- package/lib/utils/page/page-form-data-manager-group.d.ts +17 -0
- package/lib/utils/page/page-form-data-manager-group.js +111 -0
- package/lib/utils/page/page-form-data-manager.d.ts +6 -0
- package/lib/utils/page/page-form-data-manager.js +24 -79
- package/lib/utils/page/page-form.d.ts +1 -1
- package/lib/utils/page/page-form.js +24 -47
- package/lib/utils/page/page-layout.js +1 -1
- package/lib/utils/page/page-render.d.ts +10 -0
- package/lib/utils/page/page-render.js +56 -0
- package/lib/utils/page/page-schema-utils.d.ts +1 -0
- package/lib/utils/page/page-schema-utils.js +79 -0
- package/package.json +1 -1
- package/es/utils/common/FormDataHandler.d.ts +0 -45
- package/es/utils/common/FormDataHandler.js +0 -410
- package/lib/utils/common/FormDataHandler.d.ts +0 -45
- package/lib/utils/common/FormDataHandler.js +0 -416
|
@@ -6,93 +6,35 @@ var _excluded = ["layout", "form", "onSelectOk", "onClose"],
|
|
|
6
6
|
_excluded2 = ["container", "onClose"];
|
|
7
7
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
8
8
|
import { PageLayout } from "./page-layout";
|
|
9
|
-
import ReactDOM from "react-dom";
|
|
10
9
|
import React, { Component } from "react";
|
|
11
10
|
import { PageLoadSchema } from "./page-load-schema";
|
|
12
11
|
import { ReactRender } from "../../components/react-render";
|
|
13
|
-
import { openPage } from "./index";
|
|
14
12
|
import { forEachFormSchema } from "../cache/schema";
|
|
13
|
+
import { cloneDataView } from "./page-schema-utils";
|
|
14
|
+
import { renderElement } from "./page-render";
|
|
15
15
|
export function showFormDataManager(_x) {
|
|
16
16
|
return _showFormDataManager.apply(this, arguments);
|
|
17
17
|
}
|
|
18
18
|
function _showFormDataManager() {
|
|
19
|
-
_showFormDataManager = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
_showFormDataManager = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(options) {
|
|
20
|
+
var container, onClose, props;
|
|
21
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
22
|
+
while (1) switch (_context.prev = _context.next) {
|
|
22
23
|
case 0:
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
break;
|
|
34
|
-
}
|
|
35
|
-
if (!(options.layout == "page")) {
|
|
36
|
-
_context2.next = 13;
|
|
37
|
-
break;
|
|
38
|
-
}
|
|
39
|
-
paths = window.location.pathname.split("/");
|
|
40
|
-
mode = options.mode;
|
|
41
|
-
_params = new URLSearchParams();
|
|
42
|
-
url = "/" + paths[1] + "/" + paths[2] + "/" + ((_options$form = options.form) === null || _options$form === void 0 ? void 0 : _options$form.id) + "/" + mode + "?" + _params.toString();
|
|
43
|
-
_context2.next = 10;
|
|
44
|
-
return openPage(url, url);
|
|
45
|
-
case 10:
|
|
46
|
-
page = _context2.sent;
|
|
47
|
-
console.debug("openPage", page);
|
|
48
|
-
return _context2.abrupt("return");
|
|
49
|
-
case 13:
|
|
50
|
-
container = document.createElement("div");
|
|
51
|
-
document.body.append(container);
|
|
52
|
-
case 15:
|
|
53
|
-
ReactDOM.render( /*#__PURE__*/React.createElement(FormDataManagerRender, _extends({}, restProps, {
|
|
54
|
-
onSelectOk: function onSelectOk(data) {
|
|
55
|
-
resolve(data || null);
|
|
56
|
-
},
|
|
57
|
-
onClose: /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
58
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
59
|
-
while (1) switch (_context.prev = _context.next) {
|
|
60
|
-
case 0:
|
|
61
|
-
resolve(null);
|
|
62
|
-
setTimeout(function () {
|
|
63
|
-
ReactDOM.unmountComponentAtNode(container);
|
|
64
|
-
}, 10);
|
|
65
|
-
if (unmount) {
|
|
66
|
-
//等待动画结束
|
|
67
|
-
setTimeout(function () {
|
|
68
|
-
var _container;
|
|
69
|
-
//移除
|
|
70
|
-
(_container = container) === null || _container === void 0 ? void 0 : _container.remove();
|
|
71
|
-
}, 100);
|
|
72
|
-
}
|
|
73
|
-
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
74
|
-
case 4:
|
|
75
|
-
case "end":
|
|
76
|
-
return _context.stop();
|
|
77
|
-
}
|
|
78
|
-
}, _callee);
|
|
79
|
-
}))
|
|
80
|
-
})), container);
|
|
81
|
-
case 16:
|
|
82
|
-
case "end":
|
|
83
|
-
return _context2.stop();
|
|
84
|
-
}
|
|
85
|
-
}, _callee2);
|
|
86
|
-
}));
|
|
87
|
-
return function (_x2, _x3) {
|
|
88
|
-
return _ref.apply(this, arguments);
|
|
89
|
-
};
|
|
90
|
-
}()));
|
|
91
|
-
case 1:
|
|
24
|
+
container = options.container, onClose = options.onClose, props = _objectWithoutPropertiesLoose(options, _excluded2);
|
|
25
|
+
return _context.abrupt("return", renderElement({
|
|
26
|
+
container: container,
|
|
27
|
+
onClose: onClose,
|
|
28
|
+
element: {
|
|
29
|
+
component: FormDataManagerRender,
|
|
30
|
+
props: props
|
|
31
|
+
}
|
|
32
|
+
}));
|
|
33
|
+
case 2:
|
|
92
34
|
case "end":
|
|
93
|
-
return
|
|
35
|
+
return _context.stop();
|
|
94
36
|
}
|
|
95
|
-
},
|
|
37
|
+
}, _callee);
|
|
96
38
|
}));
|
|
97
39
|
return _showFormDataManager.apply(this, arguments);
|
|
98
40
|
}
|
|
@@ -117,7 +59,6 @@ var FormDataManagerRender = /*#__PURE__*/function (_Component) {
|
|
|
117
59
|
onSelectOk = _this$props.onSelectOk,
|
|
118
60
|
onClose = _this$props.onClose,
|
|
119
61
|
restProps = _objectWithoutPropertiesLoose(_this$props, _excluded);
|
|
120
|
-
|
|
121
62
|
// @ts-ignore
|
|
122
63
|
restProps.layout = layout || "modal";
|
|
123
64
|
// @ts-ignore
|
|
@@ -132,6 +73,7 @@ var FormDataManagerRender = /*#__PURE__*/function (_Component) {
|
|
|
132
73
|
(_self$layoutRef2 = self.layoutRef) === null || _self$layoutRef2 === void 0 ? void 0 : _self$layoutRef2.close();
|
|
133
74
|
onSelectOk === null || onSelectOk === void 0 ? void 0 : onSelectOk(data);
|
|
134
75
|
};
|
|
76
|
+
var dataView = cloneDataView(this.props.dataView, this.props.extraProps);
|
|
135
77
|
return /*#__PURE__*/React.createElement(PageLayout, {
|
|
136
78
|
layout: layout,
|
|
137
79
|
ref: function ref(layout) {
|
|
@@ -150,10 +92,13 @@ var FormDataManagerRender = /*#__PURE__*/function (_Component) {
|
|
|
150
92
|
return true;
|
|
151
93
|
});
|
|
152
94
|
}
|
|
153
|
-
return /*#__PURE__*/React.createElement(ReactRender, _extends({
|
|
95
|
+
return /*#__PURE__*/React.createElement(ReactRender, _extends({}, restProps, {
|
|
154
96
|
schema: fdmSchema,
|
|
155
97
|
components: window._components || window.components || window.__components
|
|
156
|
-
|
|
98
|
+
// @ts-ignore
|
|
99
|
+
,
|
|
100
|
+
dataView: dataView
|
|
101
|
+
}));
|
|
157
102
|
}));
|
|
158
103
|
};
|
|
159
104
|
return FormDataManagerRender;
|
|
@@ -6,28 +6,23 @@ var _excluded = ["layout", "form", "onClose"],
|
|
|
6
6
|
_excluded2 = ["container", "onClose"];
|
|
7
7
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
8
8
|
import { PageLayout } from "./page-layout";
|
|
9
|
-
import ReactDOM from "react-dom";
|
|
10
9
|
import React, { Component } from "react";
|
|
11
10
|
import { PageLoadSchema } from "./page-load-schema";
|
|
12
11
|
import { ReactRender } from "../../components/react-render";
|
|
13
12
|
import { openPage } from "./index";
|
|
13
|
+
import { renderElement } from "./page-render";
|
|
14
14
|
export function showForm(_x) {
|
|
15
15
|
return _showForm.apply(this, arguments);
|
|
16
16
|
}
|
|
17
17
|
function _showForm() {
|
|
18
|
-
_showForm = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
19
|
-
var container, onClose,
|
|
20
|
-
return _regeneratorRuntime.wrap(function
|
|
21
|
-
while (1) switch (
|
|
18
|
+
_showForm = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(options) {
|
|
19
|
+
var container, onClose, props, _options$form, paths, mode, dataId, params, url, page;
|
|
20
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
21
|
+
while (1) switch (_context.prev = _context.next) {
|
|
22
22
|
case 0:
|
|
23
|
-
container = options.container, onClose = options.onClose,
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
_context2.next = 16;
|
|
27
|
-
break;
|
|
28
|
-
}
|
|
29
|
-
if (!(options.layout == "page")) {
|
|
30
|
-
_context2.next = 14;
|
|
23
|
+
container = options.container, onClose = options.onClose, props = _objectWithoutPropertiesLoose(options, _excluded2); //容器不存在需要手动取消挂载
|
|
24
|
+
if (!(options.layout == "page" && !container)) {
|
|
25
|
+
_context.next = 12;
|
|
31
26
|
break;
|
|
32
27
|
}
|
|
33
28
|
paths = window.location.pathname.split("/");
|
|
@@ -37,44 +32,26 @@ function _showForm() {
|
|
|
37
32
|
params.set("dataId", dataId);
|
|
38
33
|
}
|
|
39
34
|
url = "/" + paths[1] + "/" + paths[2] + "/" + ((_options$form = options.form) === null || _options$form === void 0 ? void 0 : _options$form.id) + "/" + mode + "?" + params.toString();
|
|
40
|
-
|
|
35
|
+
_context.next = 9;
|
|
41
36
|
return openPage(url, url);
|
|
42
|
-
case
|
|
43
|
-
page =
|
|
37
|
+
case 9:
|
|
38
|
+
page = _context.sent;
|
|
44
39
|
console.debug("openPage", page);
|
|
45
|
-
return
|
|
46
|
-
case
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
//等待动画结束
|
|
57
|
-
setTimeout(function () {
|
|
58
|
-
var _container;
|
|
59
|
-
//取消挂载
|
|
60
|
-
ReactDOM.unmountComponentAtNode(container);
|
|
61
|
-
//移除
|
|
62
|
-
(_container = container) === null || _container === void 0 ? void 0 : _container.remove();
|
|
63
|
-
}, 1000);
|
|
64
|
-
}
|
|
65
|
-
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
66
|
-
case 2:
|
|
67
|
-
case "end":
|
|
68
|
-
return _context.stop();
|
|
69
|
-
}
|
|
70
|
-
}, _callee);
|
|
71
|
-
}))
|
|
72
|
-
})), container);
|
|
73
|
-
case 17:
|
|
40
|
+
return _context.abrupt("return");
|
|
41
|
+
case 12:
|
|
42
|
+
return _context.abrupt("return", renderElement({
|
|
43
|
+
container: container,
|
|
44
|
+
onClose: onClose,
|
|
45
|
+
element: {
|
|
46
|
+
component: FormRender,
|
|
47
|
+
props: props
|
|
48
|
+
}
|
|
49
|
+
}));
|
|
50
|
+
case 13:
|
|
74
51
|
case "end":
|
|
75
|
-
return
|
|
52
|
+
return _context.stop();
|
|
76
53
|
}
|
|
77
|
-
},
|
|
54
|
+
}, _callee);
|
|
78
55
|
}));
|
|
79
56
|
return _showForm.apply(this, arguments);
|
|
80
57
|
}
|
|
@@ -62,7 +62,7 @@ export var PageLayout = /*#__PURE__*/function (_Component) {
|
|
|
62
62
|
};
|
|
63
63
|
if (layout == "modal") {
|
|
64
64
|
restProps.style.top = 64;
|
|
65
|
-
restProps.styles.body.
|
|
65
|
+
restProps.styles.body.height = "calc(100vh - 120px)";
|
|
66
66
|
return /*#__PURE__*/React.createElement(_Modal, restProps, children);
|
|
67
67
|
} else if (layout == "drawer") {
|
|
68
68
|
return /*#__PURE__*/React.createElement(_Drawer, restProps, children);
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
3
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
4
|
+
import ReactDOM from "react-dom";
|
|
5
|
+
import { createElement } from "react";
|
|
6
|
+
export function renderElement(options) {
|
|
7
|
+
return new Promise( /*#__PURE__*/function () {
|
|
8
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(resolve, reject) {
|
|
9
|
+
var container, _onClose, _options$element, component, props, unmount, element;
|
|
10
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
11
|
+
while (1) switch (_context.prev = _context.next) {
|
|
12
|
+
case 0:
|
|
13
|
+
container = options.container, _onClose = options.onClose;
|
|
14
|
+
_options$element = options.element, component = _options$element.component, props = _options$element.props;
|
|
15
|
+
unmount = !container;
|
|
16
|
+
if (!container) {
|
|
17
|
+
container = document.createElement("div");
|
|
18
|
+
document.body.append(container);
|
|
19
|
+
}
|
|
20
|
+
element = /*#__PURE__*/createElement(component, _extends({}, props, {
|
|
21
|
+
onSelectOk: function onSelectOk(data) {
|
|
22
|
+
resolve(data || null);
|
|
23
|
+
},
|
|
24
|
+
onClose: function onClose() {
|
|
25
|
+
resolve(false);
|
|
26
|
+
setTimeout(function () {
|
|
27
|
+
ReactDOM.unmountComponentAtNode(container);
|
|
28
|
+
}, 100);
|
|
29
|
+
if (unmount) {
|
|
30
|
+
//等待动画结束
|
|
31
|
+
setTimeout(function () {
|
|
32
|
+
var _container;
|
|
33
|
+
//移除
|
|
34
|
+
(_container = container) === null || _container === void 0 ? void 0 : _container.remove();
|
|
35
|
+
}, 1000);
|
|
36
|
+
}
|
|
37
|
+
_onClose === null || _onClose === void 0 ? void 0 : _onClose();
|
|
38
|
+
}
|
|
39
|
+
}));
|
|
40
|
+
ReactDOM.render(element, container);
|
|
41
|
+
case 6:
|
|
42
|
+
case "end":
|
|
43
|
+
return _context.stop();
|
|
44
|
+
}
|
|
45
|
+
}, _callee);
|
|
46
|
+
}));
|
|
47
|
+
return function (_x, _x2) {
|
|
48
|
+
return _ref.apply(this, arguments);
|
|
49
|
+
};
|
|
50
|
+
}());
|
|
51
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function cloneDataView(dataView: any, extraProps: any): any;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
export function cloneDataView(dataView, extraProps) {
|
|
3
|
+
if (!dataView) {
|
|
4
|
+
return {};
|
|
5
|
+
}
|
|
6
|
+
if (typeof extraProps !== "object") {
|
|
7
|
+
extraProps = {};
|
|
8
|
+
}
|
|
9
|
+
var cloneDataView = _extends({}, dataView);
|
|
10
|
+
var filterRules = dataView.filterRules,
|
|
11
|
+
searchFields = dataView.searchFields;
|
|
12
|
+
function createFilterRules(rules) {
|
|
13
|
+
if (!Array.isArray(rules)) {
|
|
14
|
+
return [];
|
|
15
|
+
}
|
|
16
|
+
var scripts = [];
|
|
17
|
+
for (var _i = 0, _Object$keys = Object.keys(extraProps); _i < _Object$keys.length; _i++) {
|
|
18
|
+
var key = _Object$keys[_i];
|
|
19
|
+
scripts.push("const " + key + " = extraProps[\"" + key + "\"];");
|
|
20
|
+
}
|
|
21
|
+
scripts.push(compileFilterRules(rules));
|
|
22
|
+
var compile = scripts.join("\n");
|
|
23
|
+
try {
|
|
24
|
+
return eval(compile);
|
|
25
|
+
} catch (e) {
|
|
26
|
+
console.log("\u89E3\u6790dataView.rules\u5F02\u5E38", e);
|
|
27
|
+
console.log({
|
|
28
|
+
rules: rules,
|
|
29
|
+
compile: compile,
|
|
30
|
+
extraProps: extraProps
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
return [];
|
|
34
|
+
}
|
|
35
|
+
cloneDataView.filterRules = createFilterRules(filterRules);
|
|
36
|
+
cloneDataView.searchFields = createFilterRules(searchFields);
|
|
37
|
+
return cloneDataView;
|
|
38
|
+
}
|
|
39
|
+
function compileFilterRules(rules) {
|
|
40
|
+
var _rules, _rules$forEach;
|
|
41
|
+
if (rules === void 0) {
|
|
42
|
+
rules = [];
|
|
43
|
+
}
|
|
44
|
+
var scripts = ["["];
|
|
45
|
+
(_rules = rules) === null || _rules === void 0 ? void 0 : (_rules$forEach = _rules.forEach) === null || _rules$forEach === void 0 ? void 0 : _rules$forEach.call(_rules, function (rule, index, array) {
|
|
46
|
+
var _rule$rules;
|
|
47
|
+
var isFirst = index == 0;
|
|
48
|
+
var isLast = index + 1 == array.length;
|
|
49
|
+
scripts.push("{");
|
|
50
|
+
if (!isFirst) {
|
|
51
|
+
var connector = rule.connector == "or" ? "or" : "and";
|
|
52
|
+
scripts.push("\"connector\":\"" + connector + "\",");
|
|
53
|
+
}
|
|
54
|
+
if (rule !== null && rule !== void 0 && (_rule$rules = rule.rules) !== null && _rule$rules !== void 0 && _rule$rules.length) {
|
|
55
|
+
//分组
|
|
56
|
+
scripts.push("\"rules\":" + compileFilterRules(rule.rules) + ",");
|
|
57
|
+
} else {
|
|
58
|
+
var value = rule.value;
|
|
59
|
+
if (rule.valueType == "express") {
|
|
60
|
+
if (value === "") {
|
|
61
|
+
value = "undefined";
|
|
62
|
+
}
|
|
63
|
+
} else if (rule.valueType == "value" || !rule.valueType || typeof value === "object") {
|
|
64
|
+
value = JSON.stringify(value);
|
|
65
|
+
}
|
|
66
|
+
scripts.push("\"key\":\"" + rule.key + "\",");
|
|
67
|
+
scripts.push("\"operator\":\"" + rule.operator + "\",");
|
|
68
|
+
scripts.push("\"value\":" + value + ",");
|
|
69
|
+
}
|
|
70
|
+
scripts.push("}" + (isLast ? "" : ","));
|
|
71
|
+
});
|
|
72
|
+
scripts.push("]");
|
|
73
|
+
return scripts.join("");
|
|
74
|
+
}
|
package/lib/index.js
CHANGED
|
@@ -22,6 +22,8 @@ var _layout = require("./components/layout");
|
|
|
22
22
|
exports.Layout = _layout.Layout;
|
|
23
23
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
24
24
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
|
25
|
+
// @ts-ignore
|
|
26
|
+
|
|
25
27
|
// @ts-ignore
|
|
26
28
|
window.__ReactRender = _reactRender.ReactRender;
|
|
27
29
|
// @ts-ignore
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AxiosProgressEvent } from "axios";
|
|
2
|
+
export declare function upload(file: any, options?: {
|
|
3
|
+
onProgress: (evt: AxiosProgressEvent) => void;
|
|
4
|
+
onFinished: () => void;
|
|
5
|
+
onError: (e: any) => void;
|
|
6
|
+
}): Promise<void>;
|
|
7
|
+
export declare function update(file: any): Promise<void>;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
exports.__esModule = true;
|
|
5
|
+
exports.update = update;
|
|
6
|
+
exports.upload = upload;
|
|
7
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
8
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
9
|
+
var _index = require("./index");
|
|
10
|
+
function upload(_x, _x2) {
|
|
11
|
+
return _upload.apply(this, arguments);
|
|
12
|
+
}
|
|
13
|
+
function _upload() {
|
|
14
|
+
_upload = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(file, options) {
|
|
15
|
+
var res, ossFile, _options$onFinished, _options$onError;
|
|
16
|
+
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
17
|
+
while (1) switch (_context.prev = _context.next) {
|
|
18
|
+
case 0:
|
|
19
|
+
if (file) {
|
|
20
|
+
_context.next = 2;
|
|
21
|
+
break;
|
|
22
|
+
}
|
|
23
|
+
return _context.abrupt("return");
|
|
24
|
+
case 2:
|
|
25
|
+
_context.next = 4;
|
|
26
|
+
return _index.apiRequest.post("files/signature", {
|
|
27
|
+
size: file.size,
|
|
28
|
+
name: file.name,
|
|
29
|
+
type: file.type
|
|
30
|
+
}, {
|
|
31
|
+
params: {
|
|
32
|
+
type: "oss"
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
case 4:
|
|
36
|
+
res = _context.sent;
|
|
37
|
+
ossFile = res.data;
|
|
38
|
+
file.id = ossFile.id;
|
|
39
|
+
file.url = ossFile.url;
|
|
40
|
+
file.percent = 0;
|
|
41
|
+
file.status = "uploading";
|
|
42
|
+
_context.prev = 10;
|
|
43
|
+
_context.next = 13;
|
|
44
|
+
return _index.apiRequest.put(ossFile.uploadUrl, file, {
|
|
45
|
+
headers: {
|
|
46
|
+
'Content-Type': file.type
|
|
47
|
+
},
|
|
48
|
+
onUploadProgress: function onUploadProgress(evt) {
|
|
49
|
+
var _options$onProgress;
|
|
50
|
+
if (evt.total) {
|
|
51
|
+
file.percent = Math.round(evt.loaded * 100 / evt.total);
|
|
52
|
+
}
|
|
53
|
+
options === null || options === void 0 ? void 0 : (_options$onProgress = options.onProgress) === null || _options$onProgress === void 0 ? void 0 : _options$onProgress.call(options, evt);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
case 13:
|
|
57
|
+
options === null || options === void 0 ? void 0 : (_options$onFinished = options.onFinished) === null || _options$onFinished === void 0 ? void 0 : _options$onFinished.call(options);
|
|
58
|
+
_context.next = 19;
|
|
59
|
+
break;
|
|
60
|
+
case 16:
|
|
61
|
+
_context.prev = 16;
|
|
62
|
+
_context.t0 = _context["catch"](10);
|
|
63
|
+
options === null || options === void 0 ? void 0 : (_options$onError = options.onError) === null || _options$onError === void 0 ? void 0 : _options$onError.call(options, _context.t0);
|
|
64
|
+
case 19:
|
|
65
|
+
case "end":
|
|
66
|
+
return _context.stop();
|
|
67
|
+
}
|
|
68
|
+
}, _callee, null, [[10, 16]]);
|
|
69
|
+
}));
|
|
70
|
+
return _upload.apply(this, arguments);
|
|
71
|
+
}
|
|
72
|
+
function update(_x3) {
|
|
73
|
+
return _update.apply(this, arguments);
|
|
74
|
+
}
|
|
75
|
+
function _update() {
|
|
76
|
+
_update = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(file) {
|
|
77
|
+
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
78
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
79
|
+
case 0:
|
|
80
|
+
_context2.next = 2;
|
|
81
|
+
return _index.apiRequest.post("files/update", {
|
|
82
|
+
id: file.id,
|
|
83
|
+
fileName: file.fileName
|
|
84
|
+
});
|
|
85
|
+
case 2:
|
|
86
|
+
case "end":
|
|
87
|
+
return _context2.stop();
|
|
88
|
+
}
|
|
89
|
+
}, _callee2);
|
|
90
|
+
}));
|
|
91
|
+
return _update.apply(this, arguments);
|
|
92
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { BaseRequestOptions, ManyResult, OneResult, RestApi, RestSearchParams } from "./rest-api";
|
|
2
2
|
import { AxiosRequestConfig } from "axios";
|
|
3
|
+
export declare function getFormApi(formId: string, fieldId?: string, mock?: boolean): Promise<RestFormApi<any>>;
|
|
3
4
|
export declare class RestFormApi<DataType> extends RestApi<DataType> {
|
|
4
5
|
private readonly formId;
|
|
5
6
|
private readonly fieldId?;
|