@zhubangyun/lowcode-core 5.12.161 → 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 +38 -22
- package/es/components/page-loading/index.js +4 -1
- 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/form-api.d.ts +1 -0
- package/es/utils/api/form-api.js +68 -29
- package/es/utils/api/index.d.ts +1 -1
- 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 +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 +13 -3
- package/es/utils/page/page-form-data-manager-group.js +2 -2
- package/es/utils/page/page-form-data-manager.d.ts +1 -0
- package/es/utils/page/page-form-data-manager.js +2 -2
- 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 -2
- package/es/utils/page/page-layout.d.ts +1 -0
- package/es/utils/page/page-layout.js +22 -5
- package/es/utils/page/page-load-schema.js +20 -28
- package/es/utils/page/page-show.d.ts +2 -0
- package/es/utils/page/page-show.js +5 -0
- package/es/utils/page/print-form.js +25 -16
- 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 +38 -22
- package/lib/components/page-loading/index.js +4 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +44 -4
- package/lib/index.less +10 -0
- package/lib/style.js +2 -2
- package/lib/utils/api/form-api.d.ts +1 -0
- package/lib/utils/api/form-api.js +68 -29
- package/lib/utils/api/index.d.ts +1 -1
- package/lib/utils/api/index.js +1 -0
- 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 +15 -2
- package/lib/utils/page/page-form-data-manager-group.js +2 -2
- package/lib/utils/page/page-form-data-manager.d.ts +1 -0
- package/lib/utils/page/page-form-data-manager.js +2 -2
- 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 -2
- package/lib/utils/page/page-layout.d.ts +1 -0
- package/lib/utils/page/page-layout.js +22 -5
- package/lib/utils/page/page-load-schema.js +19 -27
- package/lib/utils/page/page-show.d.ts +2 -0
- package/lib/utils/page/page-show.js +5 -0
- package/lib/utils/page/print-form.js +25 -16
- 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
|
@@ -12,21 +12,26 @@ export function forEachSchema(schema, callback) {
|
|
|
12
12
|
}
|
|
13
13
|
});
|
|
14
14
|
}
|
|
15
|
-
export function
|
|
15
|
+
export function findFormSchemas(schema) {
|
|
16
|
+
var schemas = [];
|
|
16
17
|
forEachSchema(schema, function (child) {
|
|
17
18
|
if (["PageForm", "SubFormField"].includes(child.componentName)) {
|
|
18
|
-
|
|
19
|
-
if (fdm) {
|
|
20
|
-
if (child.fdmSchema) {
|
|
21
|
-
forEachSchema(child.fdmSchema, function (fdmChild) {
|
|
22
|
-
if (fdmChild.componentName == "PageFdm") {
|
|
23
|
-
callback(child);
|
|
24
|
-
}
|
|
25
|
-
return true;
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
}
|
|
19
|
+
schemas.push(child);
|
|
29
20
|
}
|
|
30
21
|
return true;
|
|
31
22
|
});
|
|
23
|
+
return schemas;
|
|
24
|
+
}
|
|
25
|
+
export function findFdmSchemas(schema) {
|
|
26
|
+
var schemas = [];
|
|
27
|
+
if (!schema) {
|
|
28
|
+
return schemas;
|
|
29
|
+
}
|
|
30
|
+
forEachSchema(schema, function (child) {
|
|
31
|
+
if (["PageFdm"].includes(child.componentName)) {
|
|
32
|
+
schemas.push(child);
|
|
33
|
+
}
|
|
34
|
+
return true;
|
|
35
|
+
});
|
|
36
|
+
return schemas;
|
|
32
37
|
}
|
package/es/utils/cache/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
|
|
|
3
3
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
4
4
|
import { SingletonInstanceMap } from "../common/SingletonInstanceMap";
|
|
5
5
|
import { apiRequest, RestFormApi } from "../api";
|
|
6
|
-
import {
|
|
6
|
+
import { findFdmSchemas, findFormSchemas } from "../api/schema.util";
|
|
7
7
|
export var SchemaCache = /*#__PURE__*/function (_SingletonInstanceMap) {
|
|
8
8
|
function SchemaCache() {
|
|
9
9
|
return _SingletonInstanceMap.apply(this, arguments) || this;
|
|
@@ -12,7 +12,7 @@ export var SchemaCache = /*#__PURE__*/function (_SingletonInstanceMap) {
|
|
|
12
12
|
var _proto = SchemaCache.prototype;
|
|
13
13
|
_proto.createInstance = /*#__PURE__*/function () {
|
|
14
14
|
var _createInstance = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(key, options) {
|
|
15
|
-
var mock, pageId, schemaRes, schema,
|
|
15
|
+
var mock, pageId, schemaRes, schema, handleCommonSchema, permission, printTemplates, workflow, cloneSchema, _t;
|
|
16
16
|
return _regeneratorRuntime.wrap(function (_context) {
|
|
17
17
|
while (1) switch (_context.prev = _context.next) {
|
|
18
18
|
case 0:
|
|
@@ -25,30 +25,70 @@ export var SchemaCache = /*#__PURE__*/function (_SingletonInstanceMap) {
|
|
|
25
25
|
});
|
|
26
26
|
case 1:
|
|
27
27
|
schemaRes = _context.sent;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
_context.next = 3;
|
|
28
|
+
if (schemaRes.succss) {
|
|
29
|
+
_context.next = 2;
|
|
31
30
|
break;
|
|
32
31
|
}
|
|
33
|
-
_context.
|
|
34
|
-
return apiRequest.get("pages/" + pageId + "/permission");
|
|
32
|
+
return _context.abrupt("return", schemaRes);
|
|
35
33
|
case 2:
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
34
|
+
schema = schemaRes.data;
|
|
35
|
+
if (!(schema != null && typeof schema == "object")) {
|
|
36
|
+
_context.next = 8;
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
handleCommonSchema = function handleCommonSchema(schema) {
|
|
40
|
+
schema.props = schema.props || {};
|
|
41
|
+
schema.props.permission = permission;
|
|
42
|
+
schema.props.printTemplates = printTemplates;
|
|
43
|
+
schema.props.workflow = workflow;
|
|
44
|
+
};
|
|
45
|
+
//处理权限
|
|
46
|
+
permission = null; //处理打印
|
|
47
|
+
workflow = null;
|
|
48
|
+
if (location.pathname.startsWith("/print")) {
|
|
49
|
+
_context.next = 7;
|
|
50
|
+
break;
|
|
43
51
|
}
|
|
52
|
+
_context.next = 3;
|
|
53
|
+
return apiRequest.get("pages/" + pageId + "/permission");
|
|
44
54
|
case 3:
|
|
45
|
-
|
|
55
|
+
permission = _context.sent.data;
|
|
56
|
+
if (!((schema === null || schema === void 0 ? void 0 : schema.type) == "form")) {
|
|
57
|
+
_context.next = 7;
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
_context.prev = 4;
|
|
61
|
+
_context.next = 5;
|
|
62
|
+
return apiRequest.get("pages/" + pageId + "/printTemplates");
|
|
63
|
+
case 5:
|
|
64
|
+
printTemplates = _context.sent.data;
|
|
65
|
+
_context.next = 7;
|
|
66
|
+
break;
|
|
67
|
+
case 6:
|
|
68
|
+
_context.prev = 6;
|
|
69
|
+
_t = _context["catch"](4);
|
|
70
|
+
console.log(_t);
|
|
71
|
+
case 7:
|
|
72
|
+
findFormSchemas(schema).forEach(function (formSchema) {
|
|
73
|
+
handleCommonSchema(formSchema);
|
|
74
|
+
findFdmSchemas(formSchema.fdmSchema).forEach(function (fdmSchema) {
|
|
75
|
+
handleCommonSchema(fdmSchema);
|
|
76
|
+
fdmSchema.props.form.label = formSchema.props.label;
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
cloneSchema = JSON.parse(JSON.stringify(schema));
|
|
80
|
+
findFormSchemas(schema).forEach(function (formSchema) {
|
|
81
|
+
findFdmSchemas(formSchema.fdmSchema).forEach(function (fdmSchema) {
|
|
82
|
+
fdmSchema.props.formElement = cloneSchema;
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
case 8:
|
|
46
86
|
return _context.abrupt("return", schemaRes);
|
|
47
|
-
case
|
|
87
|
+
case 9:
|
|
48
88
|
case "end":
|
|
49
89
|
return _context.stop();
|
|
50
90
|
}
|
|
51
|
-
}, _callee);
|
|
91
|
+
}, _callee, null, [[4, 6]]);
|
|
52
92
|
}));
|
|
53
93
|
function createInstance(_x, _x2) {
|
|
54
94
|
return _createInstance.apply(this, arguments);
|
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
export { loadPlugins } from "./LoadPlugins";
|
|
2
2
|
export declare function uuid(prefix?: string, separator?: string): string;
|
|
3
|
+
export declare function uuidVersion(id: string): number;
|
|
3
4
|
export declare function toArray(data: any): any[];
|
|
5
|
+
export declare function isLocalhost(): boolean;
|
|
6
|
+
export declare function isMobile(): boolean;
|
package/es/utils/common/index.js
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { v7, version } from "uuid";
|
|
2
2
|
export { loadPlugins } from "./LoadPlugins";
|
|
3
3
|
export function uuid(prefix, separator) {
|
|
4
4
|
if (!prefix && !separator) {
|
|
5
|
-
return
|
|
5
|
+
return v7();
|
|
6
6
|
}
|
|
7
|
-
return [prefix, separator,
|
|
7
|
+
return [prefix, separator, v7()].filter(function (v) {
|
|
8
8
|
return !!v;
|
|
9
9
|
}).join("");
|
|
10
10
|
}
|
|
11
|
+
export function uuidVersion(id) {
|
|
12
|
+
return version(id);
|
|
13
|
+
}
|
|
11
14
|
export function toArray(data) {
|
|
12
15
|
if (!data) {
|
|
13
16
|
return [];
|
|
@@ -16,4 +19,11 @@ export function toArray(data) {
|
|
|
16
19
|
} else {
|
|
17
20
|
return [data];
|
|
18
21
|
}
|
|
22
|
+
}
|
|
23
|
+
export function isLocalhost() {
|
|
24
|
+
return window.location.hostname == "localhost";
|
|
25
|
+
}
|
|
26
|
+
export function isMobile() {
|
|
27
|
+
var userAgent = navigator.userAgent;
|
|
28
|
+
return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Mobile/i.test(userAgent);
|
|
19
29
|
}
|
|
@@ -9,7 +9,7 @@ import { PageLayout } from "./page-layout";
|
|
|
9
9
|
import React, { Component } from "react";
|
|
10
10
|
import { ReactRender } from "../../components/react-render";
|
|
11
11
|
import { renderElement } from "./page-render";
|
|
12
|
-
import {
|
|
12
|
+
import { uuid } from "../common";
|
|
13
13
|
export function showFormDataManagerGroup(_x) {
|
|
14
14
|
return _showFormDataManagerGroup.apply(this, arguments);
|
|
15
15
|
}
|
|
@@ -82,7 +82,7 @@ var FormDataManagerRender = /*#__PURE__*/function (_Component) {
|
|
|
82
82
|
}, /*#__PURE__*/React.createElement(ReactRender, _extends({}, restProps, {
|
|
83
83
|
components: window._components || window.components || window.__components,
|
|
84
84
|
schema: {
|
|
85
|
-
id:
|
|
85
|
+
id: uuid(),
|
|
86
86
|
componentName: "Page",
|
|
87
87
|
props: {},
|
|
88
88
|
state: {},
|
|
@@ -9,9 +9,9 @@ import { PageLayout } from "./page-layout";
|
|
|
9
9
|
import React, { Component } from "react";
|
|
10
10
|
import { PageLoadSchema } from "./page-load-schema";
|
|
11
11
|
import { ReactRender } from "../../components/react-render";
|
|
12
|
-
import { forEachFormSchema } from "../cache/schema";
|
|
13
12
|
import { cloneDataView } from "./page-schema-utils";
|
|
14
13
|
import { renderElement } from "./page-render";
|
|
14
|
+
import { forEachSchema } from "../api/schema.util";
|
|
15
15
|
export function showFormDataManager(_x) {
|
|
16
16
|
return _showFormDataManager.apply(this, arguments);
|
|
17
17
|
}
|
|
@@ -87,7 +87,7 @@ var FormDataManagerRender = /*#__PURE__*/function (_Component) {
|
|
|
87
87
|
}, function (schema) {
|
|
88
88
|
var fdmSchema = schema.children[0].fdmSchema;
|
|
89
89
|
if (form !== null && form !== void 0 && form.fieldId) {
|
|
90
|
-
|
|
90
|
+
forEachSchema(schema, function (field) {
|
|
91
91
|
if (form.fieldId == field.props.fieldId) {
|
|
92
92
|
fdmSchema = field.fdmSchema;
|
|
93
93
|
return false;
|
|
@@ -9,8 +9,8 @@ import { PageLayout } from "./page-layout";
|
|
|
9
9
|
import { renderElement } from "./page-render";
|
|
10
10
|
import React, { Component } from "react";
|
|
11
11
|
import { ReactRender } from "../../components/react-render";
|
|
12
|
-
import { v4 } from "uuid";
|
|
13
12
|
import { PageLoadSchema } from "./page-load-schema";
|
|
13
|
+
import { uuid } from "../common";
|
|
14
14
|
export function showFormGroup(_x) {
|
|
15
15
|
return _showFormGroup.apply(this, arguments);
|
|
16
16
|
}
|
|
@@ -78,7 +78,7 @@ var FormGroupRender = /*#__PURE__*/function (_Component) {
|
|
|
78
78
|
return /*#__PURE__*/React.createElement(ReactRender, _extends({}, restProps, {
|
|
79
79
|
components: window._components || window.components || window.__components,
|
|
80
80
|
schema: {
|
|
81
|
-
id:
|
|
81
|
+
id: uuid(),
|
|
82
82
|
componentName: "Page",
|
|
83
83
|
props: {},
|
|
84
84
|
state: {},
|
|
@@ -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, url, page;
|
|
19
|
+
var container, onClose, props, _options$form, paths, mode, dataId, params, _options$form2, url, page;
|
|
20
20
|
return _regeneratorRuntime.wrap(function (_context) {
|
|
21
21
|
while (1) switch (_context.prev = _context.next) {
|
|
22
22
|
case 0:
|
|
@@ -28,10 +28,20 @@ function _showForm() {
|
|
|
28
28
|
paths = window.location.pathname.split("/");
|
|
29
29
|
mode = options.mode, dataId = options.dataId;
|
|
30
30
|
params = new URLSearchParams();
|
|
31
|
+
if ((_options$form = options.form) !== null && _options$form !== void 0 && _options$form.id) {
|
|
32
|
+
params.set("pageId", (_options$form2 = options.form) === null || _options$form2 === void 0 ? void 0 : _options$form2.id);
|
|
33
|
+
}
|
|
34
|
+
if (mode) {
|
|
35
|
+
params.set("mode", mode);
|
|
36
|
+
}
|
|
31
37
|
if (dataId) {
|
|
32
38
|
params.set("dataId", dataId);
|
|
33
39
|
}
|
|
34
|
-
url = "/" + paths[1] + "/
|
|
40
|
+
url = "/" + paths[1] + "/pages?" + params.toString();
|
|
41
|
+
if (paths[1] == "workPlatform") {
|
|
42
|
+
url = "/pages?" + params.toString();
|
|
43
|
+
}
|
|
44
|
+
//const url = `/${paths[1]}/${paths[2]}/${options.form?.id}/${mode}?${params.toString()}`;
|
|
35
45
|
_context.next = 1;
|
|
36
46
|
return openPage(url, url);
|
|
37
47
|
case 1:
|
|
@@ -2,8 +2,9 @@ import _Drawer from "antd/es/drawer";
|
|
|
2
2
|
import _Modal from "antd/es/modal";
|
|
3
3
|
import _extends from "@babel/runtime/helpers/extends";
|
|
4
4
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
|
|
5
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
5
6
|
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
|
|
6
|
-
var _excluded = ["
|
|
7
|
+
var _excluded = ["children"];
|
|
7
8
|
import React, { Component } from "react";
|
|
8
9
|
import { LoadMaterials } from "../../components/load-materials";
|
|
9
10
|
export var PageLayout = /*#__PURE__*/function (_Component) {
|
|
@@ -22,7 +23,7 @@ export var PageLayout = /*#__PURE__*/function (_Component) {
|
|
|
22
23
|
return Math.min(window.innerWidth, 1600);
|
|
23
24
|
};
|
|
24
25
|
_this.handleResize = function () {
|
|
25
|
-
if (_this.
|
|
26
|
+
if (_this.layout == "drawer") {
|
|
26
27
|
_this.setState({
|
|
27
28
|
width: _this.getWith()
|
|
28
29
|
});
|
|
@@ -41,9 +42,9 @@ export var PageLayout = /*#__PURE__*/function (_Component) {
|
|
|
41
42
|
};
|
|
42
43
|
_proto.render = function render() {
|
|
43
44
|
var _this$props = this.props,
|
|
44
|
-
layout = _this$props.layout,
|
|
45
45
|
children = _this$props.children,
|
|
46
46
|
extraProps = _objectWithoutPropertiesLoose(_this$props, _excluded);
|
|
47
|
+
var layout = this.layout;
|
|
47
48
|
var state = this.state;
|
|
48
49
|
var restProps = _extends({}, extraProps, {
|
|
49
50
|
children: undefined,
|
|
@@ -72,11 +73,27 @@ export var PageLayout = /*#__PURE__*/function (_Component) {
|
|
|
72
73
|
restProps.styles.body.height = "calc(100vh - 120px)";
|
|
73
74
|
return /*#__PURE__*/React.createElement(_Modal, restProps, loadChildren);
|
|
74
75
|
} else if (layout == "drawer") {
|
|
75
|
-
|
|
76
|
+
if (window.isMobile) {
|
|
77
|
+
restProps.placement = "bottom";
|
|
78
|
+
}
|
|
79
|
+
return /*#__PURE__*/React.createElement(_Drawer, _extends({}, restProps, {
|
|
80
|
+
height: "85vh"
|
|
81
|
+
}), loadChildren);
|
|
76
82
|
}
|
|
77
83
|
return loadChildren;
|
|
78
84
|
};
|
|
79
|
-
return PageLayout
|
|
85
|
+
return _createClass(PageLayout, [{
|
|
86
|
+
key: "layout",
|
|
87
|
+
get: function get() {
|
|
88
|
+
var layout = this.props.layout;
|
|
89
|
+
if (window.isMobile) {
|
|
90
|
+
if (layout == "modal") {
|
|
91
|
+
return "drawer";
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return layout;
|
|
95
|
+
}
|
|
96
|
+
}]);
|
|
80
97
|
}(Component);
|
|
81
98
|
function LoadMaterialChildren(props) {
|
|
82
99
|
return /*#__PURE__*/React.createElement(LoadMaterials, null, props.children);
|
|
@@ -1,56 +1,48 @@
|
|
|
1
1
|
import _Result from "antd/es/result";
|
|
2
2
|
import _message from "antd/es/message";
|
|
3
|
-
import { useEffect, useState } from "react";
|
|
3
|
+
import { Fragment, useEffect, useState } from "react";
|
|
4
4
|
import { getSchema } from "../api";
|
|
5
|
-
import { PageLoading } from "../../components/page-loading";
|
|
6
5
|
import { getSchemaFromCache } from "../api/schema-api";
|
|
6
|
+
import { hideLoading, showLoading } from "./index";
|
|
7
7
|
export function PageLoadSchema(props) {
|
|
8
8
|
var pageId = props.pageId,
|
|
9
9
|
children = props.children;
|
|
10
10
|
var cache = getSchemaFromCache(pageId);
|
|
11
|
-
var _useState = useState(
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
var _useState2 = useState(
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
var _useState3 = useState(),
|
|
18
|
-
errorMsg = _useState3[0],
|
|
19
|
-
setErrorMsg = _useState3[1];
|
|
11
|
+
var _useState = useState(cache === null || cache === void 0 ? void 0 : cache.data),
|
|
12
|
+
schema = _useState[0],
|
|
13
|
+
setSchema = _useState[1];
|
|
14
|
+
var _useState2 = useState(),
|
|
15
|
+
errorMsg = _useState2[0],
|
|
16
|
+
setErrorMsg = _useState2[1];
|
|
20
17
|
useEffect(function () {
|
|
21
|
-
if (cache) {
|
|
18
|
+
if (cache !== null && cache !== void 0 && cache.success) {
|
|
22
19
|
return;
|
|
23
20
|
}
|
|
24
21
|
if (pageId) {
|
|
22
|
+
showLoading().then();
|
|
25
23
|
getSchema(pageId).then(function (res) {
|
|
26
24
|
if (res.success) {
|
|
27
|
-
|
|
28
|
-
setSchema(res.data);
|
|
25
|
+
setSchema(res === null || res === void 0 ? void 0 : res.data);
|
|
29
26
|
} else {
|
|
30
|
-
setErrorMsg(res.message);
|
|
27
|
+
setErrorMsg(res === null || res === void 0 ? void 0 : res.message);
|
|
31
28
|
}
|
|
29
|
+
})["finally"](function () {
|
|
30
|
+
hideLoading().then();
|
|
32
31
|
});
|
|
33
32
|
} else {
|
|
34
|
-
|
|
35
|
-
setErrorMsg("
|
|
36
|
-
|
|
37
|
-
_message.error("页面id不可为空!").then();
|
|
33
|
+
hideLoading().then();
|
|
34
|
+
setErrorMsg("参数错误:页面id不可为空!");
|
|
35
|
+
_message.error("参数错误:页面id不可为空!").then();
|
|
38
36
|
}
|
|
39
37
|
}, []);
|
|
40
|
-
if (
|
|
38
|
+
if (schema) {
|
|
41
39
|
return children(schema);
|
|
42
40
|
}
|
|
43
|
-
if (
|
|
44
|
-
return /*#__PURE__*/React.createElement(PageLoading, {
|
|
45
|
-
loading: true,
|
|
46
|
-
background: "rgba(255, 255, 255, 0)"
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
if (!schema) {
|
|
41
|
+
if (errorMsg) {
|
|
50
42
|
return /*#__PURE__*/React.createElement(_Result, {
|
|
51
43
|
status: 500,
|
|
52
44
|
title: errorMsg
|
|
53
45
|
});
|
|
54
46
|
}
|
|
55
|
-
return
|
|
47
|
+
return /*#__PURE__*/React.createElement(Fragment, null);
|
|
56
48
|
}
|
|
@@ -4,6 +4,8 @@ export interface ShowPageProps {
|
|
|
4
4
|
pageId: string;
|
|
5
5
|
layout?: PageLayoutType;
|
|
6
6
|
onClose?: () => void | Promise<void>;
|
|
7
|
+
extraProps?: any;
|
|
8
|
+
afterLoadSchema?: (schema: any) => void;
|
|
7
9
|
pageRef?: (page: any) => void;
|
|
8
10
|
}
|
|
9
11
|
export declare function show(options: ShowPageProps): Promise<any | any[]>;
|
|
@@ -44,6 +44,7 @@ var PageRender = /*#__PURE__*/function (_Component) {
|
|
|
44
44
|
}
|
|
45
45
|
_this = _Component.call.apply(_Component, [this].concat(args)) || this;
|
|
46
46
|
_this.layoutRef = void 0;
|
|
47
|
+
_this.schema = void 0;
|
|
47
48
|
return _this;
|
|
48
49
|
}
|
|
49
50
|
_inheritsLoose(PageRender, _Component);
|
|
@@ -72,6 +73,10 @@ var PageRender = /*#__PURE__*/function (_Component) {
|
|
|
72
73
|
}, /*#__PURE__*/React.createElement(PageLoadSchema, {
|
|
73
74
|
pageId: pageId
|
|
74
75
|
}, function (schema) {
|
|
76
|
+
_this2.schema = schema;
|
|
77
|
+
if (_this2.props.pageRef) {
|
|
78
|
+
_this2.props.pageRef(_this2);
|
|
79
|
+
}
|
|
75
80
|
return /*#__PURE__*/React.createElement(ReactRender, _extends({
|
|
76
81
|
schema: schema,
|
|
77
82
|
components: window._components || window.components || window.__components
|
|
@@ -64,7 +64,7 @@ function _print() {
|
|
|
64
64
|
return _context2.abrupt("return");
|
|
65
65
|
case 2:
|
|
66
66
|
_context2.next = 3;
|
|
67
|
-
return openPrint(templateId);
|
|
67
|
+
return openPrint(templateId, options);
|
|
68
68
|
case 3:
|
|
69
69
|
iw = _context2.sent;
|
|
70
70
|
if (iw) {
|
|
@@ -74,8 +74,6 @@ function _print() {
|
|
|
74
74
|
_message.error("\u6253\u5370\u5931\u8D25!\u6253\u5370\u7A97\u53E3\u4E0D\u53EF\u4E3A\u7A7A!");
|
|
75
75
|
return _context2.abrupt("return");
|
|
76
76
|
case 4:
|
|
77
|
-
// @ts-ignore
|
|
78
|
-
iw.printOptions = options;
|
|
79
77
|
_context2.next = 6;
|
|
80
78
|
break;
|
|
81
79
|
case 5:
|
|
@@ -93,39 +91,50 @@ function _print() {
|
|
|
93
91
|
}));
|
|
94
92
|
return _print.apply(this, arguments);
|
|
95
93
|
}
|
|
96
|
-
function openPrint(_x3) {
|
|
94
|
+
function openPrint(_x3, _x4) {
|
|
97
95
|
return _openPrint.apply(this, arguments);
|
|
98
96
|
}
|
|
99
97
|
function _openPrint() {
|
|
100
|
-
_openPrint = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4(templateId) {
|
|
98
|
+
_openPrint = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4(templateId, options) {
|
|
99
|
+
var url;
|
|
101
100
|
return _regeneratorRuntime.wrap(function (_context4) {
|
|
102
101
|
while (1) switch (_context4.prev = _context4.next) {
|
|
103
102
|
case 0:
|
|
103
|
+
url = "/print/" + templateId;
|
|
104
104
|
return _context4.abrupt("return", new Promise(/*#__PURE__*/function () {
|
|
105
105
|
var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(resolve, reject) {
|
|
106
|
-
var
|
|
106
|
+
var printWindow, iframe;
|
|
107
107
|
return _regeneratorRuntime.wrap(function (_context3) {
|
|
108
108
|
while (1) switch (_context3.prev = _context3.next) {
|
|
109
109
|
case 0:
|
|
110
110
|
iframe = document.createElement("iframe");
|
|
111
|
-
iframe.src =
|
|
112
|
-
iframe.
|
|
111
|
+
iframe.src = url;
|
|
112
|
+
iframe.className = "print-iframe";
|
|
113
113
|
document.body.appendChild(iframe);
|
|
114
|
-
|
|
115
|
-
if (
|
|
114
|
+
printWindow = iframe.contentWindow;
|
|
115
|
+
if (printWindow) {
|
|
116
116
|
_context3.next = 1;
|
|
117
117
|
break;
|
|
118
118
|
}
|
|
119
119
|
reject("创建Iframe失败!");
|
|
120
120
|
return _context3.abrupt("return");
|
|
121
121
|
case 1:
|
|
122
|
-
|
|
123
|
-
|
|
122
|
+
// @ts-ignore
|
|
123
|
+
window.printWindow = printWindow;
|
|
124
|
+
printWindow.onload = function () {
|
|
125
|
+
// @ts-ignore
|
|
126
|
+
printWindow.printOptions = options;
|
|
124
127
|
};
|
|
125
|
-
|
|
126
|
-
|
|
128
|
+
printWindow.addEventListener("beforeprint", function () {});
|
|
129
|
+
printWindow.addEventListener("afterprint", function () {
|
|
127
130
|
hideLoading();
|
|
128
|
-
|
|
131
|
+
setTimeout(function () {
|
|
132
|
+
resolve(printWindow);
|
|
133
|
+
if (window.__debug) {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
iframe.remove();
|
|
137
|
+
}, 100);
|
|
129
138
|
});
|
|
130
139
|
case 2:
|
|
131
140
|
case "end":
|
|
@@ -133,7 +142,7 @@ function _openPrint() {
|
|
|
133
142
|
}
|
|
134
143
|
}, _callee3);
|
|
135
144
|
}));
|
|
136
|
-
return function (
|
|
145
|
+
return function (_x5, _x6) {
|
|
137
146
|
return _ref.apply(this, arguments);
|
|
138
147
|
};
|
|
139
148
|
}()));
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
interface ScanCodeOptions {
|
|
2
|
+
onlyFromCamera?: boolean;
|
|
3
|
+
openUrl?: boolean;
|
|
4
|
+
}
|
|
5
|
+
interface ScanCodeResult {
|
|
6
|
+
result: string;
|
|
7
|
+
}
|
|
8
|
+
declare class UniBridge {
|
|
9
|
+
private callbacks;
|
|
10
|
+
navigateTo(src: string): void;
|
|
11
|
+
scanCode(options: ScanCodeOptions): Promise<ScanCodeResult>;
|
|
12
|
+
getBarHeight(): Promise<unknown>;
|
|
13
|
+
getLocation(options: {}): Promise<unknown>;
|
|
14
|
+
private doAction;
|
|
15
|
+
private receiveMessage;
|
|
16
|
+
}
|
|
17
|
+
export declare const uniBridge: UniBridge;
|
|
18
|
+
export {};
|