@zhubangyun/lowcode-core 6.1.90 → 6.3.20
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/react-render/index.js +11 -1
- package/es/index.js +12 -34
- package/es/index.less +11 -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 +1 -1
- package/es/utils/api/form-api/form-api.assemble-entity.d.ts +2 -0
- package/es/utils/api/form-api/form-api.assemble-entity.js +95 -0
- package/es/utils/api/form-api/form-api.entity-map.d.ts +12 -0
- package/es/utils/api/form-api/form-api.entity-map.js +50 -0
- package/es/utils/api/{form-api.utils.d.ts → form-api/form-api.utils.d.ts} +3 -2
- package/es/utils/api/{form-api.utils.js → form-api/form-api.utils.js} +41 -8
- package/es/utils/api/form-api.d.ts +1 -0
- package/es/utils/api/form-api.js +105 -30
- package/es/utils/api/index.js +3 -2
- package/es/utils/api/rest-api.d.ts +2 -1
- package/es/utils/api/schema-api.d.ts +2 -1
- package/es/utils/api/schema-api.js +1 -1
- package/es/utils/api/schema.util.d.ts +1 -0
- package/es/utils/api/schema.util.js +10 -0
- package/es/utils/cache/index.d.ts +0 -1
- package/es/utils/cache/index.js +58 -35
- package/es/utils/cache/index_db_cache.d.ts +9 -0
- package/es/utils/cache/index_db_cache.js +7 -0
- package/es/utils/common/SingletonInstanceMap.d.ts +2 -2
- package/es/utils/common/index.d.ts +1 -1
- package/es/utils/common/index.js +5 -1
- package/es/utils/data/index.d.ts +3 -1
- package/es/utils/data/index.js +10 -3
- package/es/utils/page/index.d.ts +1 -0
- package/es/utils/page/index.js +10 -6
- package/es/utils/page/page-create-element.d.ts +6 -0
- package/es/utils/page/page-create-element.js +23 -0
- package/es/utils/page/page-form-data-manager-group.js +8 -8
- package/es/utils/page/page-form-data-manager.js +8 -8
- package/es/utils/page/page-form.js +4 -6
- package/es/utils/page/page-layout.d.ts +2 -1
- package/es/utils/page/page-layout.js +23 -3
- package/es/utils/page/page-render.js +5 -6
- package/es/utils/page/page-schema-utils.js +2 -1
- package/es/utils/page/page-show.js +4 -4
- package/es/utils/page/print-form.d.ts +3 -2
- package/es/utils/page/print-form.js +193 -57
- package/es/utils/uni-bridge.d.ts +2 -0
- package/es/utils/uni-bridge.js +76 -36
- package/es/utils/util.common.d.ts +1 -1
- package/es/utils/util.common.js +1 -2
- package/lib/components/react-render/index.js +11 -1
- package/lib/index.js +12 -34
- package/lib/index.less +11 -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 +1 -1
- package/lib/utils/api/form-api/form-api.assemble-entity.d.ts +2 -0
- package/lib/utils/api/form-api/form-api.assemble-entity.js +99 -0
- package/lib/utils/api/form-api/form-api.entity-map.d.ts +12 -0
- package/lib/utils/api/form-api/form-api.entity-map.js +54 -0
- package/lib/utils/api/{form-api.utils.d.ts → form-api/form-api.utils.d.ts} +3 -2
- package/lib/utils/api/{form-api.utils.js → form-api/form-api.utils.js} +41 -7
- package/lib/utils/api/form-api.d.ts +1 -0
- package/lib/utils/api/form-api.js +104 -29
- package/lib/utils/api/index.js +3 -2
- package/lib/utils/api/rest-api.d.ts +2 -1
- package/lib/utils/api/schema-api.d.ts +2 -1
- package/lib/utils/api/schema-api.js +1 -1
- package/lib/utils/api/schema.util.d.ts +1 -0
- package/lib/utils/api/schema.util.js +11 -0
- package/lib/utils/cache/index.d.ts +0 -1
- package/lib/utils/cache/index.js +57 -34
- package/lib/utils/cache/index_db_cache.d.ts +9 -0
- package/lib/utils/cache/index_db_cache.js +11 -0
- package/lib/utils/common/SingletonInstanceMap.d.ts +2 -2
- package/lib/utils/common/index.d.ts +1 -1
- package/lib/utils/common/index.js +5 -1
- package/lib/utils/data/index.d.ts +3 -1
- package/lib/utils/data/index.js +10 -3
- package/lib/utils/page/index.d.ts +1 -0
- package/lib/utils/page/index.js +13 -7
- package/lib/utils/page/page-create-element.d.ts +6 -0
- package/lib/utils/page/page-create-element.js +29 -0
- package/lib/utils/page/page-form-data-manager-group.js +8 -8
- package/lib/utils/page/page-form-data-manager.js +8 -8
- package/lib/utils/page/page-form.js +4 -6
- package/lib/utils/page/page-layout.d.ts +2 -1
- package/lib/utils/page/page-layout.js +23 -3
- package/lib/utils/page/page-render.js +5 -6
- package/lib/utils/page/page-schema-utils.js +2 -1
- package/lib/utils/page/page-show.js +4 -4
- package/lib/utils/page/print-form.d.ts +3 -2
- package/lib/utils/page/print-form.js +193 -57
- package/lib/utils/uni-bridge.d.ts +2 -0
- package/lib/utils/uni-bridge.js +76 -36
- package/lib/utils/util.common.d.ts +1 -1
- package/lib/utils/util.common.js +2 -3
- package/package.json +5 -4
- package/es/utils/cache/schema.d.ts +0 -6
- package/es/utils/cache/schema.js +0 -14
- package/lib/utils/cache/schema.d.ts +0 -6
- package/lib/utils/cache/schema.js +0 -18
|
@@ -2,8 +2,8 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
|
|
3
3
|
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
|
|
4
4
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
5
|
-
var _excluded = ["layout", "items", "onSelectOk", "onClose"],
|
|
6
|
-
_excluded2 = ["
|
|
5
|
+
var _excluded = ["layout", "items", "onSelectOk", "container", "onClose"],
|
|
6
|
+
_excluded2 = ["onClose"];
|
|
7
7
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
8
8
|
import { PageLayout } from "./page-layout";
|
|
9
9
|
import React, { Component } from "react";
|
|
@@ -15,13 +15,13 @@ export function showFormDataManagerGroup(_x) {
|
|
|
15
15
|
}
|
|
16
16
|
function _showFormDataManagerGroup() {
|
|
17
17
|
_showFormDataManagerGroup = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(options) {
|
|
18
|
-
var
|
|
18
|
+
var onClose, props;
|
|
19
19
|
return _regeneratorRuntime.wrap(function (_context) {
|
|
20
20
|
while (1) switch (_context.prev = _context.next) {
|
|
21
21
|
case 0:
|
|
22
|
-
|
|
22
|
+
onClose = options.onClose, props = _objectWithoutPropertiesLoose(options, _excluded2);
|
|
23
23
|
return _context.abrupt("return", renderElement({
|
|
24
|
-
container: container,
|
|
24
|
+
container: props.container,
|
|
25
25
|
onClose: onClose,
|
|
26
26
|
element: {
|
|
27
27
|
component: FormDataManagerRender,
|
|
@@ -55,6 +55,7 @@ var FormDataManagerRender = /*#__PURE__*/function (_Component) {
|
|
|
55
55
|
layout = _this$props.layout,
|
|
56
56
|
items = _this$props.items,
|
|
57
57
|
onSelectOk = _this$props.onSelectOk,
|
|
58
|
+
container = _this$props.container,
|
|
58
59
|
onClose = _this$props.onClose,
|
|
59
60
|
restProps = _objectWithoutPropertiesLoose(_this$props, _excluded);
|
|
60
61
|
// @ts-ignore
|
|
@@ -72,13 +73,12 @@ var FormDataManagerRender = /*#__PURE__*/function (_Component) {
|
|
|
72
73
|
onSelectOk === null || onSelectOk === void 0 ? void 0 : onSelectOk(data);
|
|
73
74
|
};
|
|
74
75
|
return /*#__PURE__*/React.createElement(PageLayout, {
|
|
76
|
+
container: container,
|
|
75
77
|
ref: function ref(layout) {
|
|
76
78
|
return _this2.layoutRef = layout;
|
|
77
79
|
},
|
|
78
80
|
layout: layout,
|
|
79
|
-
onClose:
|
|
80
|
-
onSelectOk === null || onSelectOk === void 0 ? void 0 : onSelectOk(undefined);
|
|
81
|
-
}
|
|
81
|
+
onClose: onClose
|
|
82
82
|
}, /*#__PURE__*/React.createElement(ReactRender, _extends({}, restProps, {
|
|
83
83
|
components: window._components || window.components || window.__components,
|
|
84
84
|
schema: {
|
|
@@ -2,8 +2,8 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
|
|
3
3
|
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
|
|
4
4
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
5
|
-
var _excluded = ["layout", "form", "onSelectOk", "onClose"],
|
|
6
|
-
_excluded2 = ["
|
|
5
|
+
var _excluded = ["layout", "form", "onSelectOk", "onClose", "container"],
|
|
6
|
+
_excluded2 = ["onClose"];
|
|
7
7
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
8
8
|
import { PageLayout } from "./page-layout";
|
|
9
9
|
import React, { Component } from "react";
|
|
@@ -17,13 +17,13 @@ export function showFormDataManager(_x) {
|
|
|
17
17
|
}
|
|
18
18
|
function _showFormDataManager() {
|
|
19
19
|
_showFormDataManager = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(options) {
|
|
20
|
-
var
|
|
20
|
+
var onClose, props;
|
|
21
21
|
return _regeneratorRuntime.wrap(function (_context) {
|
|
22
22
|
while (1) switch (_context.prev = _context.next) {
|
|
23
23
|
case 0:
|
|
24
|
-
|
|
24
|
+
onClose = options.onClose, props = _objectWithoutPropertiesLoose(options, _excluded2);
|
|
25
25
|
return _context.abrupt("return", renderElement({
|
|
26
|
-
container: container,
|
|
26
|
+
container: props.container,
|
|
27
27
|
onClose: onClose,
|
|
28
28
|
element: {
|
|
29
29
|
component: FormDataManagerRender,
|
|
@@ -58,6 +58,7 @@ var FormDataManagerRender = /*#__PURE__*/function (_Component) {
|
|
|
58
58
|
form = _this$props.form,
|
|
59
59
|
onSelectOk = _this$props.onSelectOk,
|
|
60
60
|
onClose = _this$props.onClose,
|
|
61
|
+
container = _this$props.container,
|
|
61
62
|
restProps = _objectWithoutPropertiesLoose(_this$props, _excluded);
|
|
62
63
|
// @ts-ignore
|
|
63
64
|
restProps.layout = layout || "modal";
|
|
@@ -75,13 +76,12 @@ var FormDataManagerRender = /*#__PURE__*/function (_Component) {
|
|
|
75
76
|
};
|
|
76
77
|
var dataView = cloneDataView(this.props.dataView, this.props.extraProps);
|
|
77
78
|
return /*#__PURE__*/React.createElement(PageLayout, {
|
|
79
|
+
container: container,
|
|
78
80
|
ref: function ref(layout) {
|
|
79
81
|
return _this2.layoutRef = layout;
|
|
80
82
|
},
|
|
81
83
|
layout: layout,
|
|
82
|
-
onClose:
|
|
83
|
-
onSelectOk === null || onSelectOk === void 0 ? void 0 : onSelectOk(undefined);
|
|
84
|
-
}
|
|
84
|
+
onClose: onClose
|
|
85
85
|
}, /*#__PURE__*/React.createElement(PageLoadSchema, {
|
|
86
86
|
pageId: form === null || form === void 0 ? void 0 : form.id
|
|
87
87
|
}, function (schema) {
|
|
@@ -16,7 +16,7 @@ export function showForm(_x) {
|
|
|
16
16
|
}
|
|
17
17
|
function _showForm() {
|
|
18
18
|
_showForm = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(options) {
|
|
19
|
-
var container, onClose, props, _options$form, paths, mode, dataId, params, _options$form2, url
|
|
19
|
+
var container, onClose, props, _options$form, paths, mode, dataId, params, _options$form2, url;
|
|
20
20
|
return _regeneratorRuntime.wrap(function (_context) {
|
|
21
21
|
while (1) switch (_context.prev = _context.next) {
|
|
22
22
|
case 0:
|
|
@@ -37,16 +37,14 @@ function _showForm() {
|
|
|
37
37
|
if (dataId) {
|
|
38
38
|
params.set("dataId", dataId);
|
|
39
39
|
}
|
|
40
|
-
url = "/
|
|
41
|
-
if (paths[1] == "
|
|
42
|
-
url = "/pages?" + params.toString();
|
|
40
|
+
url = "/pages?" + params.toString();
|
|
41
|
+
if (paths[1] == "admin") {
|
|
42
|
+
url = "/admin/pages?" + params.toString();
|
|
43
43
|
}
|
|
44
44
|
//const url = `/${paths[1]}/${paths[2]}/${options.form?.id}/${mode}?${params.toString()}`;
|
|
45
45
|
_context.next = 1;
|
|
46
46
|
return openPage(url, url);
|
|
47
47
|
case 1:
|
|
48
|
-
page = _context.sent;
|
|
49
|
-
console.debug("openPage", page);
|
|
50
48
|
return _context.abrupt("return");
|
|
51
49
|
case 2:
|
|
52
50
|
return _context.abrupt("return", renderElement({
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Component } from "react";
|
|
2
2
|
export type PageLayoutType = "page" | "modal" | "drawer";
|
|
3
3
|
interface PageLayoutProps {
|
|
4
|
+
container?: any;
|
|
4
5
|
layout?: PageLayoutType;
|
|
5
|
-
onClose?: (
|
|
6
|
+
onClose?: () => void;
|
|
6
7
|
keyboard?: boolean;
|
|
7
8
|
children: any;
|
|
8
9
|
}
|
|
@@ -41,6 +41,7 @@ export var PageLayout = /*#__PURE__*/function (_Component) {
|
|
|
41
41
|
window.removeEventListener("resize", this.handleResize);
|
|
42
42
|
};
|
|
43
43
|
_proto.render = function render() {
|
|
44
|
+
var _this2 = this;
|
|
44
45
|
var _this$props = this.props,
|
|
45
46
|
children = _this$props.children,
|
|
46
47
|
extraProps = _objectWithoutPropertiesLoose(_this$props, _excluded);
|
|
@@ -65,19 +66,38 @@ export var PageLayout = /*#__PURE__*/function (_Component) {
|
|
|
65
66
|
padding: 0
|
|
66
67
|
}
|
|
67
68
|
},
|
|
68
|
-
maskClosable:
|
|
69
|
+
maskClosable: isMobile
|
|
69
70
|
});
|
|
70
71
|
var loadChildren = /*#__PURE__*/React.createElement(LoadMaterialChildren, null, children);
|
|
71
72
|
if (layout == "modal") {
|
|
72
73
|
restProps.style.top = 64;
|
|
73
74
|
restProps.styles.body.height = "calc(100vh - 120px)";
|
|
74
|
-
return /*#__PURE__*/React.createElement(_Modal, restProps,
|
|
75
|
+
return /*#__PURE__*/React.createElement(_Modal, _extends({}, restProps, {
|
|
76
|
+
getContainer: function getContainer() {
|
|
77
|
+
return _this2.props.container || window.document.body;
|
|
78
|
+
},
|
|
79
|
+
afterOpenChange: function afterOpenChange(open) {
|
|
80
|
+
if (!open) {
|
|
81
|
+
var _this2$props$onClose, _this2$props;
|
|
82
|
+
(_this2$props$onClose = (_this2$props = _this2.props).onClose) === null || _this2$props$onClose === void 0 ? void 0 : _this2$props$onClose.call(_this2$props);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}), loadChildren);
|
|
75
86
|
} else if (layout == "drawer") {
|
|
76
87
|
if (window.isMobile) {
|
|
77
88
|
restProps.placement = "bottom";
|
|
78
89
|
}
|
|
79
90
|
return /*#__PURE__*/React.createElement(_Drawer, _extends({}, restProps, {
|
|
80
|
-
|
|
91
|
+
getContainer: function getContainer() {
|
|
92
|
+
return _this2.props.container || window.document.body;
|
|
93
|
+
},
|
|
94
|
+
height: "75vh",
|
|
95
|
+
afterVisibleChange: function afterVisibleChange(open) {
|
|
96
|
+
if (!open) {
|
|
97
|
+
var _this2$props$onClose2, _this2$props2;
|
|
98
|
+
(_this2$props$onClose2 = (_this2$props2 = _this2.props).onClose) === null || _this2$props$onClose2 === void 0 ? void 0 : _this2$props$onClose2.call(_this2$props2);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
81
101
|
}), loadChildren);
|
|
82
102
|
}
|
|
83
103
|
return loadChildren;
|
|
@@ -6,13 +6,13 @@ import { createRoot } from "react-dom/client";
|
|
|
6
6
|
export function renderElement(options) {
|
|
7
7
|
return new Promise(/*#__PURE__*/function () {
|
|
8
8
|
var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(resolve, reject) {
|
|
9
|
-
var container, _onClose, _options$element, component, props,
|
|
9
|
+
var container, _onClose, _options$element, component, props, needUnmount, root, element;
|
|
10
10
|
return _regeneratorRuntime.wrap(function (_context) {
|
|
11
11
|
while (1) switch (_context.prev = _context.next) {
|
|
12
12
|
case 0:
|
|
13
13
|
container = options.container, _onClose = options.onClose;
|
|
14
14
|
_options$element = options.element, component = _options$element.component, props = _options$element.props;
|
|
15
|
-
|
|
15
|
+
needUnmount = !container;
|
|
16
16
|
if (!container) {
|
|
17
17
|
container = document.createElement("div");
|
|
18
18
|
document.body.append(container);
|
|
@@ -23,16 +23,15 @@ export function renderElement(options) {
|
|
|
23
23
|
resolve(data || null);
|
|
24
24
|
},
|
|
25
25
|
onClose: function onClose() {
|
|
26
|
-
resolve(
|
|
26
|
+
resolve(null);
|
|
27
27
|
//等待动画结束
|
|
28
28
|
setTimeout(function () {
|
|
29
29
|
root.unmount();
|
|
30
|
-
if (
|
|
30
|
+
if (needUnmount) {
|
|
31
31
|
var _container;
|
|
32
|
-
//移除
|
|
33
32
|
(_container = container) === null || _container === void 0 ? void 0 : _container.remove();
|
|
34
33
|
}
|
|
35
|
-
},
|
|
34
|
+
}, 150);
|
|
36
35
|
_onClose === null || _onClose === void 0 ? void 0 : _onClose();
|
|
37
36
|
}
|
|
38
37
|
}));
|
|
@@ -60,10 +60,11 @@ function compileFilterRules(rules) {
|
|
|
60
60
|
if (value === "") {
|
|
61
61
|
value = "undefined";
|
|
62
62
|
}
|
|
63
|
-
} else if (rule.valueType == "value" || !rule.valueType || typeof value === "object") {
|
|
63
|
+
} else if (rule.valueType == "value" || rule.valueType == "column" || !rule.valueType || typeof value === "object") {
|
|
64
64
|
value = JSON.stringify(value);
|
|
65
65
|
}
|
|
66
66
|
scripts.push("\"key\":\"" + rule.key + "\",");
|
|
67
|
+
scripts.push("\"valueType\":\"" + rule.valueType + "\",");
|
|
67
68
|
scripts.push("\"operator\":\"" + rule.operator + "\",");
|
|
68
69
|
scripts.push("\"value\":" + value + ",");
|
|
69
70
|
}
|
|
@@ -3,7 +3,7 @@ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutP
|
|
|
3
3
|
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
|
|
4
4
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
5
5
|
var _excluded = ["layout", "pageId", "onClose"],
|
|
6
|
-
_excluded2 = ["
|
|
6
|
+
_excluded2 = ["onClose"];
|
|
7
7
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
8
8
|
import { renderElement } from "./page-render";
|
|
9
9
|
import React, { Component } from "react";
|
|
@@ -15,13 +15,13 @@ export function show(_x) {
|
|
|
15
15
|
}
|
|
16
16
|
function _show() {
|
|
17
17
|
_show = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(options) {
|
|
18
|
-
var
|
|
18
|
+
var onClose, props;
|
|
19
19
|
return _regeneratorRuntime.wrap(function (_context) {
|
|
20
20
|
while (1) switch (_context.prev = _context.next) {
|
|
21
21
|
case 0:
|
|
22
|
-
|
|
22
|
+
onClose = options.onClose, props = _objectWithoutPropertiesLoose(options, _excluded2);
|
|
23
23
|
return _context.abrupt("return", renderElement({
|
|
24
|
-
container: container,
|
|
24
|
+
container: props.container,
|
|
25
25
|
onClose: onClose,
|
|
26
26
|
element: {
|
|
27
27
|
component: PageRender,
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
interface PrintOptions {
|
|
2
|
+
showLoading?: boolean;
|
|
2
3
|
templateId: string;
|
|
3
|
-
mode?: "print" | "export";
|
|
4
|
+
mode?: "print" | "export" | "cloud_print";
|
|
4
5
|
data: any;
|
|
5
6
|
}
|
|
6
|
-
export declare function getFormPrintTemplates(formId: string): Promise<any
|
|
7
|
+
export declare function getFormPrintTemplates(formId: string, disableCache?: boolean): Promise<any>;
|
|
7
8
|
export declare function print(options: PrintOptions): Promise<void>;
|
|
8
9
|
export {};
|
|
@@ -4,16 +4,27 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
|
4
4
|
import { apiRequest } from "../api";
|
|
5
5
|
import { FormIds } from "../formIds";
|
|
6
6
|
import { hideLoading, showLoading } from "./index";
|
|
7
|
-
|
|
7
|
+
var cache = new Map();
|
|
8
|
+
export function getFormPrintTemplates(_x, _x2) {
|
|
8
9
|
return _getFormPrintTemplates.apply(this, arguments);
|
|
9
10
|
}
|
|
10
11
|
function _getFormPrintTemplates() {
|
|
11
|
-
_getFormPrintTemplates = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function
|
|
12
|
+
_getFormPrintTemplates = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(formId, disableCache) {
|
|
12
13
|
var res;
|
|
13
|
-
return _regeneratorRuntime.wrap(function (
|
|
14
|
-
while (1) switch (
|
|
14
|
+
return _regeneratorRuntime.wrap(function (_context2) {
|
|
15
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
15
16
|
case 0:
|
|
16
|
-
|
|
17
|
+
if (disableCache) {
|
|
18
|
+
_context2.next = 1;
|
|
19
|
+
break;
|
|
20
|
+
}
|
|
21
|
+
if (!cache.has(formId)) {
|
|
22
|
+
_context2.next = 1;
|
|
23
|
+
break;
|
|
24
|
+
}
|
|
25
|
+
return _context2.abrupt("return", cache.get(formId));
|
|
26
|
+
case 1:
|
|
27
|
+
_context2.next = 2;
|
|
17
28
|
return apiRequest.get("forms/search", {
|
|
18
29
|
params: {
|
|
19
30
|
formId: FormIds.printTemplate,
|
|
@@ -25,99 +36,108 @@ function _getFormPrintTemplates() {
|
|
|
25
36
|
pageSize: 1000
|
|
26
37
|
}
|
|
27
38
|
});
|
|
28
|
-
case
|
|
29
|
-
res =
|
|
39
|
+
case 2:
|
|
40
|
+
res = _context2.sent;
|
|
41
|
+
cache.set(formId, res.data || []);
|
|
30
42
|
if (!res.success) {
|
|
31
|
-
|
|
43
|
+
_context2.next = 3;
|
|
32
44
|
break;
|
|
33
45
|
}
|
|
34
|
-
return
|
|
35
|
-
case 2:
|
|
36
|
-
return _context.abrupt("return", []);
|
|
46
|
+
return _context2.abrupt("return", res.data);
|
|
37
47
|
case 3:
|
|
48
|
+
return _context2.abrupt("return", []);
|
|
49
|
+
case 4:
|
|
38
50
|
case "end":
|
|
39
|
-
return
|
|
51
|
+
return _context2.stop();
|
|
40
52
|
}
|
|
41
|
-
},
|
|
53
|
+
}, _callee2);
|
|
42
54
|
}));
|
|
43
55
|
return _getFormPrintTemplates.apply(this, arguments);
|
|
44
56
|
}
|
|
45
|
-
export function print(
|
|
57
|
+
export function print(_x3) {
|
|
46
58
|
return _print.apply(this, arguments);
|
|
47
59
|
}
|
|
48
60
|
function _print() {
|
|
49
|
-
_print = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function
|
|
61
|
+
_print = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(options) {
|
|
50
62
|
var templateId, iw, _t;
|
|
51
|
-
return _regeneratorRuntime.wrap(function (
|
|
52
|
-
while (1) switch (
|
|
63
|
+
return _regeneratorRuntime.wrap(function (_context3) {
|
|
64
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
53
65
|
case 0:
|
|
54
|
-
|
|
55
|
-
|
|
66
|
+
_context3.prev = 0;
|
|
67
|
+
if (!(options.showLoading != false)) {
|
|
68
|
+
_context3.next = 1;
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
_context3.next = 1;
|
|
56
72
|
return showLoading();
|
|
57
73
|
case 1:
|
|
58
74
|
templateId = options === null || options === void 0 ? void 0 : options.templateId;
|
|
59
75
|
if (templateId) {
|
|
60
|
-
|
|
76
|
+
_context3.next = 2;
|
|
61
77
|
break;
|
|
62
78
|
}
|
|
63
79
|
_message.error("\u6253\u5370\u5931\u8D25!\u6A21\u677Fid\u4E0D\u53EF\u4E3A\u7A7A!");
|
|
64
|
-
return
|
|
80
|
+
return _context3.abrupt("return");
|
|
65
81
|
case 2:
|
|
66
|
-
|
|
82
|
+
_context3.next = 3;
|
|
67
83
|
return openPrint(templateId, options);
|
|
68
84
|
case 3:
|
|
69
|
-
iw =
|
|
85
|
+
iw = _context3.sent;
|
|
70
86
|
if (iw) {
|
|
71
|
-
|
|
87
|
+
_context3.next = 4;
|
|
72
88
|
break;
|
|
73
89
|
}
|
|
74
90
|
_message.error("\u6253\u5370\u5931\u8D25!\u6253\u5370\u7A97\u53E3\u4E0D\u53EF\u4E3A\u7A7A!");
|
|
75
|
-
return
|
|
91
|
+
return _context3.abrupt("return");
|
|
76
92
|
case 4:
|
|
77
|
-
|
|
93
|
+
_context3.next = 6;
|
|
78
94
|
break;
|
|
79
95
|
case 5:
|
|
80
|
-
|
|
81
|
-
_t =
|
|
96
|
+
_context3.prev = 5;
|
|
97
|
+
_t = _context3["catch"](0);
|
|
82
98
|
console.log("打印失败", _t);
|
|
83
99
|
case 6:
|
|
84
|
-
|
|
85
|
-
return
|
|
100
|
+
_context3.prev = 6;
|
|
101
|
+
return _context3.finish(6);
|
|
86
102
|
case 7:
|
|
87
103
|
case "end":
|
|
88
|
-
return
|
|
104
|
+
return _context3.stop();
|
|
89
105
|
}
|
|
90
|
-
},
|
|
106
|
+
}, _callee3, null, [[0, 5, 6, 7]]);
|
|
91
107
|
}));
|
|
92
108
|
return _print.apply(this, arguments);
|
|
93
109
|
}
|
|
94
|
-
function openPrint(
|
|
110
|
+
function openPrint(_x4, _x5) {
|
|
95
111
|
return _openPrint.apply(this, arguments);
|
|
96
112
|
}
|
|
97
113
|
function _openPrint() {
|
|
98
|
-
_openPrint = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function
|
|
114
|
+
_openPrint = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee6(templateId, options) {
|
|
99
115
|
var url;
|
|
100
|
-
return _regeneratorRuntime.wrap(function (
|
|
101
|
-
while (1) switch (
|
|
116
|
+
return _regeneratorRuntime.wrap(function (_context6) {
|
|
117
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
102
118
|
case 0:
|
|
103
119
|
url = "/print/" + templateId;
|
|
104
|
-
return
|
|
105
|
-
var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function
|
|
120
|
+
return _context6.abrupt("return", new Promise(/*#__PURE__*/function () {
|
|
121
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee5(resolve, reject) {
|
|
106
122
|
var printWindow, iframe;
|
|
107
|
-
return _regeneratorRuntime.wrap(function (
|
|
108
|
-
while (1) switch (
|
|
123
|
+
return _regeneratorRuntime.wrap(function (_context5) {
|
|
124
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
109
125
|
case 0:
|
|
110
126
|
iframe = document.createElement("iframe");
|
|
111
127
|
iframe.src = url;
|
|
112
128
|
iframe.className = "print-iframe";
|
|
129
|
+
iframe.onload = function () {
|
|
130
|
+
// @ts-ignore
|
|
131
|
+
iframe.contentWindow.printOptions = options;
|
|
132
|
+
};
|
|
113
133
|
document.body.appendChild(iframe);
|
|
114
134
|
printWindow = iframe.contentWindow;
|
|
115
135
|
if (printWindow) {
|
|
116
|
-
|
|
136
|
+
_context5.next = 1;
|
|
117
137
|
break;
|
|
118
138
|
}
|
|
119
139
|
reject("创建Iframe失败!");
|
|
120
|
-
return
|
|
140
|
+
return _context5.abrupt("return");
|
|
121
141
|
case 1:
|
|
122
142
|
// @ts-ignore
|
|
123
143
|
window.printWindow = printWindow;
|
|
@@ -126,31 +146,147 @@ function _openPrint() {
|
|
|
126
146
|
printWindow.printOptions = options;
|
|
127
147
|
};
|
|
128
148
|
printWindow.addEventListener("beforeprint", function () {});
|
|
129
|
-
printWindow.addEventListener("afterprint", function () {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
149
|
+
printWindow.addEventListener("afterprint", /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
|
|
150
|
+
var _printWindow, printer, _printWindow2, doc, html;
|
|
151
|
+
return _regeneratorRuntime.wrap(function (_context4) {
|
|
152
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
153
|
+
case 0:
|
|
154
|
+
if (window.__debug) {
|
|
155
|
+
console.debug((_printWindow = printWindow) === null || _printWindow === void 0 ? void 0 : _printWindow.document.documentElement.outerHTML);
|
|
156
|
+
}
|
|
157
|
+
_context4.next = 1;
|
|
158
|
+
return hideLoading();
|
|
159
|
+
case 1:
|
|
160
|
+
if (!(options.mode == "cloud_print")) {
|
|
161
|
+
_context4.next = 5;
|
|
162
|
+
break;
|
|
163
|
+
}
|
|
164
|
+
_context4.next = 2;
|
|
165
|
+
return getCloudPrinter();
|
|
166
|
+
case 2:
|
|
167
|
+
printer = _context4.sent;
|
|
168
|
+
if (!printer) {
|
|
169
|
+
_context4.next = 4;
|
|
170
|
+
break;
|
|
171
|
+
}
|
|
172
|
+
doc = (_printWindow2 = printWindow) === null || _printWindow2 === void 0 ? void 0 : _printWindow2.document;
|
|
173
|
+
if (!doc) {
|
|
174
|
+
_context4.next = 3;
|
|
175
|
+
break;
|
|
176
|
+
}
|
|
177
|
+
doc.querySelectorAll("script").forEach(function (item) {
|
|
178
|
+
return item.remove();
|
|
179
|
+
});
|
|
180
|
+
html = doc.documentElement.outerHTML;
|
|
181
|
+
_context4.next = 3;
|
|
182
|
+
return printer.post("<!doctype html>" + html);
|
|
183
|
+
case 3:
|
|
184
|
+
_context4.next = 5;
|
|
185
|
+
break;
|
|
186
|
+
case 4:
|
|
187
|
+
_message.error("\u6253\u5370\u5931\u8D25\uFF01\u8BF7\u5148\u7ED1\u5B9A\u4E91\u6253\u5370\u673A");
|
|
188
|
+
case 5:
|
|
189
|
+
resolve(printWindow);
|
|
190
|
+
setTimeout(function () {
|
|
191
|
+
return iframe.remove();
|
|
192
|
+
}, 100);
|
|
193
|
+
case 6:
|
|
194
|
+
case "end":
|
|
195
|
+
return _context4.stop();
|
|
135
196
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
});
|
|
197
|
+
}, _callee4);
|
|
198
|
+
})));
|
|
139
199
|
case 2:
|
|
140
200
|
case "end":
|
|
141
|
-
return
|
|
201
|
+
return _context5.stop();
|
|
142
202
|
}
|
|
143
|
-
},
|
|
203
|
+
}, _callee5);
|
|
144
204
|
}));
|
|
145
|
-
return function (
|
|
205
|
+
return function (_x7, _x8) {
|
|
146
206
|
return _ref.apply(this, arguments);
|
|
147
207
|
};
|
|
148
208
|
}()));
|
|
149
209
|
case 1:
|
|
150
210
|
case "end":
|
|
151
|
-
return
|
|
211
|
+
return _context6.stop();
|
|
152
212
|
}
|
|
153
|
-
},
|
|
213
|
+
}, _callee6);
|
|
154
214
|
}));
|
|
155
215
|
return _openPrint.apply(this, arguments);
|
|
156
|
-
}
|
|
216
|
+
}
|
|
217
|
+
function getCloudPrinter() {
|
|
218
|
+
return _getCloudPrinter.apply(this, arguments);
|
|
219
|
+
}
|
|
220
|
+
function _getCloudPrinter() {
|
|
221
|
+
_getCloudPrinter = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee7() {
|
|
222
|
+
var itemValue;
|
|
223
|
+
return _regeneratorRuntime.wrap(function (_context7) {
|
|
224
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
225
|
+
case 0:
|
|
226
|
+
itemValue = localStorage.getItem("default:cloud-printer");
|
|
227
|
+
if (!(itemValue == null)) {
|
|
228
|
+
_context7.next = 1;
|
|
229
|
+
break;
|
|
230
|
+
}
|
|
231
|
+
return _context7.abrupt("return", null);
|
|
232
|
+
case 1:
|
|
233
|
+
return _context7.abrupt("return", new CloudPrinter(JSON.parse(itemValue)));
|
|
234
|
+
case 2:
|
|
235
|
+
case "end":
|
|
236
|
+
return _context7.stop();
|
|
237
|
+
}
|
|
238
|
+
}, _callee7);
|
|
239
|
+
}));
|
|
240
|
+
return _getCloudPrinter.apply(this, arguments);
|
|
241
|
+
}
|
|
242
|
+
var CloudPrinter = /*#__PURE__*/function () {
|
|
243
|
+
function CloudPrinter(options) {
|
|
244
|
+
this.deviceName = void 0;
|
|
245
|
+
this.serverIp = void 0;
|
|
246
|
+
this.port = void 0;
|
|
247
|
+
Object.assign(this, options);
|
|
248
|
+
}
|
|
249
|
+
var _proto = CloudPrinter.prototype;
|
|
250
|
+
_proto.post = /*#__PURE__*/function () {
|
|
251
|
+
var _post = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(html) {
|
|
252
|
+
var baseUrl, baseRes, res;
|
|
253
|
+
return _regeneratorRuntime.wrap(function (_context) {
|
|
254
|
+
while (1) switch (_context.prev = _context.next) {
|
|
255
|
+
case 0:
|
|
256
|
+
baseUrl = "http://" + this.serverIp + ":" + this.port;
|
|
257
|
+
_context.next = 1;
|
|
258
|
+
return apiRequest.get(baseUrl);
|
|
259
|
+
case 1:
|
|
260
|
+
baseRes = _context.sent;
|
|
261
|
+
if (baseRes !== null && baseRes !== void 0 && baseRes.success) {
|
|
262
|
+
_context.next = 2;
|
|
263
|
+
break;
|
|
264
|
+
}
|
|
265
|
+
_message.error("云打印服务不可用");
|
|
266
|
+
return _context.abrupt("return");
|
|
267
|
+
case 2:
|
|
268
|
+
_context.next = 3;
|
|
269
|
+
return apiRequest.post(baseUrl + "/print", {
|
|
270
|
+
deviceName: this.deviceName,
|
|
271
|
+
data: html
|
|
272
|
+
});
|
|
273
|
+
case 3:
|
|
274
|
+
res = _context.sent;
|
|
275
|
+
if (res.success) {
|
|
276
|
+
_message.success(res.message);
|
|
277
|
+
} else {
|
|
278
|
+
_message.error(res.message);
|
|
279
|
+
}
|
|
280
|
+
case 4:
|
|
281
|
+
case "end":
|
|
282
|
+
return _context.stop();
|
|
283
|
+
}
|
|
284
|
+
}, _callee, this);
|
|
285
|
+
}));
|
|
286
|
+
function post(_x6) {
|
|
287
|
+
return _post.apply(this, arguments);
|
|
288
|
+
}
|
|
289
|
+
return post;
|
|
290
|
+
}();
|
|
291
|
+
return CloudPrinter;
|
|
292
|
+
}();
|
package/es/utils/uni-bridge.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
interface ScanCodeOptions {
|
|
2
2
|
onlyFromCamera?: boolean;
|
|
3
3
|
openUrl?: boolean;
|
|
4
|
+
scanType?: string[];
|
|
4
5
|
}
|
|
5
6
|
interface ScanCodeResult {
|
|
6
7
|
result: string;
|
|
@@ -10,6 +11,7 @@ declare class UniBridge {
|
|
|
10
11
|
navigateTo(src: string): void;
|
|
11
12
|
scanCode(options: ScanCodeOptions): Promise<ScanCodeResult>;
|
|
12
13
|
getBarHeight(): Promise<unknown>;
|
|
14
|
+
scanCodeResult(): Promise<string>;
|
|
13
15
|
getLocation(options: {}): Promise<unknown>;
|
|
14
16
|
private doAction;
|
|
15
17
|
private receiveMessage;
|