@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
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import _message from "antd/es/message";
|
|
2
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
3
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
4
|
+
var uniqueId = 0;
|
|
5
|
+
var UniBridge = /*#__PURE__*/function () {
|
|
6
|
+
function UniBridge() {
|
|
7
|
+
this.callbacks = {};
|
|
8
|
+
}
|
|
9
|
+
var _proto = UniBridge.prototype;
|
|
10
|
+
_proto.navigateTo = function navigateTo(src) {
|
|
11
|
+
var url = src;
|
|
12
|
+
if (!src.startsWith("http")) {
|
|
13
|
+
url = new URL(url, window.location.href).href;
|
|
14
|
+
}
|
|
15
|
+
uni.navigateTo({
|
|
16
|
+
url: "/pages/web-page/index?url=" + url
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
_proto.scanCode = /*#__PURE__*/function () {
|
|
20
|
+
var _scanCode = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(options) {
|
|
21
|
+
var _t;
|
|
22
|
+
return _regeneratorRuntime.wrap(function (_context) {
|
|
23
|
+
while (1) switch (_context.prev = _context.next) {
|
|
24
|
+
case 0:
|
|
25
|
+
_context.prev = 0;
|
|
26
|
+
_context.next = 1;
|
|
27
|
+
return this.doAction("scanCode", options);
|
|
28
|
+
case 1:
|
|
29
|
+
return _context.abrupt("return", _context.sent);
|
|
30
|
+
case 2:
|
|
31
|
+
_context.prev = 2;
|
|
32
|
+
_t = _context["catch"](0);
|
|
33
|
+
_message.error("");
|
|
34
|
+
throw _t;
|
|
35
|
+
case 3:
|
|
36
|
+
case "end":
|
|
37
|
+
return _context.stop();
|
|
38
|
+
}
|
|
39
|
+
}, _callee, this, [[0, 2]]);
|
|
40
|
+
}));
|
|
41
|
+
function scanCode(_x) {
|
|
42
|
+
return _scanCode.apply(this, arguments);
|
|
43
|
+
}
|
|
44
|
+
return scanCode;
|
|
45
|
+
}();
|
|
46
|
+
_proto.getBarHeight = /*#__PURE__*/function () {
|
|
47
|
+
var _getBarHeight = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
48
|
+
return _regeneratorRuntime.wrap(function (_context2) {
|
|
49
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
50
|
+
case 0:
|
|
51
|
+
return _context2.abrupt("return", this.doAction("getBarHeight", {}));
|
|
52
|
+
case 1:
|
|
53
|
+
case "end":
|
|
54
|
+
return _context2.stop();
|
|
55
|
+
}
|
|
56
|
+
}, _callee2, this);
|
|
57
|
+
}));
|
|
58
|
+
function getBarHeight() {
|
|
59
|
+
return _getBarHeight.apply(this, arguments);
|
|
60
|
+
}
|
|
61
|
+
return getBarHeight;
|
|
62
|
+
}();
|
|
63
|
+
_proto.getLocation = /*#__PURE__*/function () {
|
|
64
|
+
var _getLocation = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(options) {
|
|
65
|
+
return _regeneratorRuntime.wrap(function (_context3) {
|
|
66
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
67
|
+
case 0:
|
|
68
|
+
return _context3.abrupt("return", this.doAction("getLocation", {
|
|
69
|
+
type: 'wgs84'
|
|
70
|
+
}));
|
|
71
|
+
case 1:
|
|
72
|
+
case "end":
|
|
73
|
+
return _context3.stop();
|
|
74
|
+
}
|
|
75
|
+
}, _callee3, this);
|
|
76
|
+
}));
|
|
77
|
+
function getLocation(_x2) {
|
|
78
|
+
return _getLocation.apply(this, arguments);
|
|
79
|
+
}
|
|
80
|
+
return getLocation;
|
|
81
|
+
}();
|
|
82
|
+
_proto.doAction = /*#__PURE__*/function () {
|
|
83
|
+
var _doAction = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4(action, options) {
|
|
84
|
+
var _this = this;
|
|
85
|
+
var messageId;
|
|
86
|
+
return _regeneratorRuntime.wrap(function (_context4) {
|
|
87
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
88
|
+
case 0:
|
|
89
|
+
uniqueId++;
|
|
90
|
+
messageId = "msg_" + uniqueId + Date.now().toString(36);
|
|
91
|
+
return _context4.abrupt("return", new Promise(function (resolve, reject) {
|
|
92
|
+
_this.callbacks[messageId] = {
|
|
93
|
+
resolve: resolve,
|
|
94
|
+
reject: reject
|
|
95
|
+
};
|
|
96
|
+
console.log("postMessage", action, options);
|
|
97
|
+
uni.postMessage({
|
|
98
|
+
data: {
|
|
99
|
+
action: action,
|
|
100
|
+
messageId: messageId,
|
|
101
|
+
options: options
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
}));
|
|
105
|
+
case 1:
|
|
106
|
+
case "end":
|
|
107
|
+
return _context4.stop();
|
|
108
|
+
}
|
|
109
|
+
}, _callee4);
|
|
110
|
+
}));
|
|
111
|
+
function doAction(_x3, _x4) {
|
|
112
|
+
return _doAction.apply(this, arguments);
|
|
113
|
+
}
|
|
114
|
+
return doAction;
|
|
115
|
+
}();
|
|
116
|
+
_proto.receiveMessage = function receiveMessage(message) {
|
|
117
|
+
console.log('收到 UniApp 消息:', message);
|
|
118
|
+
var callback = this.callbacks[message.messageId];
|
|
119
|
+
if (callback) {
|
|
120
|
+
if (message.success) {
|
|
121
|
+
callback.resolve(message.data);
|
|
122
|
+
} else {
|
|
123
|
+
callback.reject(message.error || new Error('操作失败'));
|
|
124
|
+
}
|
|
125
|
+
delete this.callbacks[message.messageId];
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
return UniBridge;
|
|
129
|
+
}();
|
|
130
|
+
export var uniBridge = new UniBridge();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isTemplate(): boolean;
|
|
@@ -9,16 +9,23 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
9
9
|
var _pageLoading = require("../page-loading");
|
|
10
10
|
var _common = require("../../utils/common");
|
|
11
11
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
12
|
+
function getInit() {
|
|
13
|
+
if (window._components) {
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
if (window.AntdProMaterial) {
|
|
17
|
+
setComponents();
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
12
22
|
function LoadMaterials(props) {
|
|
13
|
-
var _useState = (0, _react.useState)(
|
|
23
|
+
var _useState = (0, _react.useState)(getInit()),
|
|
14
24
|
init = _useState[0],
|
|
15
25
|
setInit = _useState[1];
|
|
16
26
|
(0, _react.useEffect)(function () {
|
|
17
27
|
initialize().then();
|
|
18
28
|
}, []);
|
|
19
|
-
if (window._components) {
|
|
20
|
-
return props.children;
|
|
21
|
-
}
|
|
22
29
|
function initialize() {
|
|
23
30
|
return _initialize.apply(this, arguments);
|
|
24
31
|
}
|
|
@@ -27,11 +34,17 @@ function LoadMaterials(props) {
|
|
|
27
34
|
return _regenerator["default"].wrap(function (_context) {
|
|
28
35
|
while (1) switch (_context.prev = _context.next) {
|
|
29
36
|
case 0:
|
|
30
|
-
|
|
31
|
-
|
|
37
|
+
if (!init) {
|
|
38
|
+
_context.next = 1;
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
return _context.abrupt("return");
|
|
32
42
|
case 1:
|
|
33
|
-
|
|
43
|
+
_context.next = 2;
|
|
44
|
+
return loadMaterials();
|
|
34
45
|
case 2:
|
|
46
|
+
setInit(true);
|
|
47
|
+
case 3:
|
|
35
48
|
case "end":
|
|
36
49
|
return _context.stop();
|
|
37
50
|
}
|
|
@@ -52,35 +65,23 @@ function loadMaterials() {
|
|
|
52
65
|
}
|
|
53
66
|
function _loadMaterials() {
|
|
54
67
|
_loadMaterials = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee2() {
|
|
55
|
-
var
|
|
68
|
+
var urls;
|
|
56
69
|
return _regenerator["default"].wrap(function (_context2) {
|
|
57
70
|
while (1) switch (_context2.prev = _context2.next) {
|
|
58
71
|
case 0:
|
|
59
|
-
components = {};
|
|
60
72
|
if (!window._components) {
|
|
61
73
|
_context2.next = 1;
|
|
62
74
|
break;
|
|
63
75
|
}
|
|
64
76
|
return _context2.abrupt("return");
|
|
65
77
|
case 1:
|
|
66
|
-
urls = ["prop-types/15.8.1/prop-types.min.js", "lodash/4.17.15/lodash.min.js", "dayjs/dayjs.min.js", "
|
|
78
|
+
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"];
|
|
67
79
|
_context2.next = 2;
|
|
68
80
|
return (0, _common.loadPlugins)(urls.map(function (url) {
|
|
69
81
|
return "https://cdn.zhiyunhe.com/plugin/" + url;
|
|
70
82
|
}));
|
|
71
83
|
case 2:
|
|
72
|
-
|
|
73
|
-
var data = window[lib];
|
|
74
|
-
if (data) {
|
|
75
|
-
Object.entries(data).forEach(function (_ref) {
|
|
76
|
-
var key = _ref[0],
|
|
77
|
-
value = _ref[1];
|
|
78
|
-
// @ts-ignore
|
|
79
|
-
components[key] = value;
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
window._components = components;
|
|
84
|
+
setComponents();
|
|
84
85
|
case 3:
|
|
85
86
|
case "end":
|
|
86
87
|
return _context2.stop();
|
|
@@ -88,4 +89,19 @@ function _loadMaterials() {
|
|
|
88
89
|
}, _callee2);
|
|
89
90
|
}));
|
|
90
91
|
return _loadMaterials.apply(this, arguments);
|
|
92
|
+
}
|
|
93
|
+
function setComponents() {
|
|
94
|
+
var components = {};
|
|
95
|
+
["RootMaterial", "AntdMaterial", "AntdProMaterial"].forEach(function (lib) {
|
|
96
|
+
var data = window[lib];
|
|
97
|
+
if (data) {
|
|
98
|
+
Object.entries(data).forEach(function (_ref) {
|
|
99
|
+
var key = _ref[0],
|
|
100
|
+
value = _ref[1];
|
|
101
|
+
// @ts-ignore
|
|
102
|
+
components[key] = value;
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
window._components = components;
|
|
91
107
|
}
|
|
@@ -3,16 +3,19 @@
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
4
|
exports.PageLoading = PageLoading;
|
|
5
5
|
require("./index.less");
|
|
6
|
+
var _react = require("react");
|
|
6
7
|
function PageLoading(props) {
|
|
7
8
|
var loading = props.loading,
|
|
8
9
|
_props$background = props.background,
|
|
9
10
|
background = _props$background === void 0 ? "#f1f1f1" : _props$background,
|
|
10
11
|
children = props.children;
|
|
12
|
+
(0, _react.useEffect)(function () {}, [loading]);
|
|
11
13
|
return /*#__PURE__*/React.createElement("div", {
|
|
12
14
|
className: "page-loading-wrapper",
|
|
13
15
|
style: {
|
|
14
16
|
width: "100%",
|
|
15
|
-
height: "100%"
|
|
17
|
+
height: "100%",
|
|
18
|
+
background: "rgba(0,0,0,0)"
|
|
16
19
|
}
|
|
17
20
|
}, children, loading && /*#__PURE__*/React.createElement("div", {
|
|
18
21
|
className: "page-loading",
|
package/lib/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/lib/index.js
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
exports.__esModule = true;
|
|
5
5
|
exports.lodash = exports.apiRequest = exports.RestFormApi = exports.RestApi = exports.PageLoading = exports.LoadMaterials = exports.Layout = void 0;
|
|
6
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
7
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
6
8
|
require("./index.less");
|
|
7
|
-
var _utils = _interopRequireDefault(require("./utils"));
|
|
8
|
-
exports.utils = _utils["default"];
|
|
9
9
|
var _reactRender = require("./components/react-render");
|
|
10
10
|
exports.ReactRender = _reactRender.ReactRender;
|
|
11
11
|
var lodash = _interopRequireWildcard(require("lodash"));
|
|
@@ -20,6 +20,9 @@ exports.RestFormApi = _api.RestFormApi;
|
|
|
20
20
|
exports.apiRequest = _api.apiRequest;
|
|
21
21
|
var _layout = require("./components/layout");
|
|
22
22
|
exports.Layout = _layout.Layout;
|
|
23
|
+
var _index2 = _interopRequireDefault(require("./utils/index"));
|
|
24
|
+
exports.utils = _index2["default"];
|
|
25
|
+
var _uniBridge = require("./utils/uni-bridge");
|
|
23
26
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
24
27
|
// @ts-ignore
|
|
25
28
|
window.__ReactRender = _reactRender.ReactRender;
|
|
@@ -31,5 +34,42 @@ if (window._) {
|
|
|
31
34
|
// @ts-ignore
|
|
32
35
|
if (!window.utils) {
|
|
33
36
|
// @ts-ignore
|
|
34
|
-
window.utils =
|
|
35
|
-
}
|
|
37
|
+
window.utils = _index2["default"];
|
|
38
|
+
}
|
|
39
|
+
window.isMobile = _index2["default"].common.isMobile();
|
|
40
|
+
if (window.isMobile) {
|
|
41
|
+
var classList = window.document.body.classList;
|
|
42
|
+
if (!classList.contains("mobile")) {
|
|
43
|
+
classList.add("mobile");
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
var bar_height_key = "bar_height";
|
|
47
|
+
// @ts-ignore
|
|
48
|
+
_index2["default"].uniBridge = _uniBridge.uniBridge;
|
|
49
|
+
// @ts-ignore
|
|
50
|
+
window.uniBridge = _uniBridge.uniBridge;
|
|
51
|
+
window.addEventListener("load", function () {
|
|
52
|
+
setTimeout(/*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee() {
|
|
53
|
+
var height;
|
|
54
|
+
return _regenerator["default"].wrap(function (_context) {
|
|
55
|
+
while (1) switch (_context.prev = _context.next) {
|
|
56
|
+
case 0:
|
|
57
|
+
_context.next = 1;
|
|
58
|
+
return _uniBridge.uniBridge.getBarHeight();
|
|
59
|
+
case 1:
|
|
60
|
+
height = _context.sent;
|
|
61
|
+
localStorage.setItem(bar_height_key, height);
|
|
62
|
+
updateBarHeight();
|
|
63
|
+
case 2:
|
|
64
|
+
case "end":
|
|
65
|
+
return _context.stop();
|
|
66
|
+
}
|
|
67
|
+
}, _callee);
|
|
68
|
+
})), 100);
|
|
69
|
+
});
|
|
70
|
+
function updateBarHeight() {
|
|
71
|
+
if (localStorage.getItem(bar_height_key)) {
|
|
72
|
+
document.documentElement.style.setProperty('--bar-height', localStorage.getItem(bar_height_key));
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
updateBarHeight();
|
package/lib/index.less
CHANGED
package/lib/style.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
require('antd/lib/config-provider/style');
|
|
2
|
+
|
|
1
3
|
require('antd/lib/notification/style');
|
|
2
4
|
require('antd/lib/modal/style');
|
|
3
5
|
require('antd/lib/message/style');
|
|
4
6
|
require('antd/lib/typography/style');
|
|
5
7
|
require('antd/lib/drawer/style');
|
|
6
8
|
require('antd/lib/result/style');
|
|
7
|
-
require('antd/lib/config-provider/style');
|
|
8
|
-
|
|
9
9
|
require('./index.less');
|
|
@@ -12,6 +12,7 @@ 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>>;
|
|
@@ -12,14 +12,15 @@ var _restApi = require("./rest-api");
|
|
|
12
12
|
var _formApi = require("./form-api.utils");
|
|
13
13
|
var _cache = require("../cache");
|
|
14
14
|
var _schemaApi = require("./schema-api");
|
|
15
|
+
var _common = require("../common");
|
|
15
16
|
function getFormApi(_x, _x2, _x3) {
|
|
16
17
|
return _getFormApi.apply(this, arguments);
|
|
17
18
|
}
|
|
18
19
|
function _getFormApi() {
|
|
19
|
-
_getFormApi = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function
|
|
20
|
+
_getFormApi = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee0(formId, fieldId, mock) {
|
|
20
21
|
var key;
|
|
21
|
-
return _regenerator["default"].wrap(function (
|
|
22
|
-
while (1) switch (
|
|
22
|
+
return _regenerator["default"].wrap(function (_context0) {
|
|
23
|
+
while (1) switch (_context0.prev = _context0.next) {
|
|
23
24
|
case 0:
|
|
24
25
|
if (typeof mock != "boolean") {
|
|
25
26
|
if (typeof window.__mock == "boolean") {
|
|
@@ -29,16 +30,16 @@ function _getFormApi() {
|
|
|
29
30
|
key = [formId, fieldId, mock ? "mock" : ""].filter(function (key) {
|
|
30
31
|
return !!key;
|
|
31
32
|
}).join("_");
|
|
32
|
-
return
|
|
33
|
+
return _context0.abrupt("return", _cache.formApi.getInstance(key, {
|
|
33
34
|
mock: mock,
|
|
34
35
|
fieldId: fieldId,
|
|
35
36
|
formId: formId
|
|
36
37
|
}));
|
|
37
38
|
case 1:
|
|
38
39
|
case "end":
|
|
39
|
-
return
|
|
40
|
+
return _context0.stop();
|
|
40
41
|
}
|
|
41
|
-
},
|
|
42
|
+
}, _callee0);
|
|
42
43
|
}));
|
|
43
44
|
return _getFormApi.apply(this, arguments);
|
|
44
45
|
}
|
|
@@ -211,62 +212,100 @@ var RestFormApi = exports.RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
|
211
212
|
}
|
|
212
213
|
return getById;
|
|
213
214
|
}();
|
|
214
|
-
_proto.
|
|
215
|
-
var
|
|
215
|
+
_proto.labelToValue = /*#__PURE__*/function () {
|
|
216
|
+
var _labelToValue = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee5(data, options) {
|
|
217
|
+
var _this3 = this;
|
|
218
|
+
var config, res;
|
|
216
219
|
return _regenerator["default"].wrap(function (_context5) {
|
|
217
220
|
while (1) switch (_context5.prev = _context5.next) {
|
|
218
221
|
case 0:
|
|
219
|
-
|
|
222
|
+
config = {};
|
|
223
|
+
_context5.next = 1;
|
|
224
|
+
return this.handleRequestConfig(config);
|
|
220
225
|
case 1:
|
|
226
|
+
_context5.next = 2;
|
|
227
|
+
return this.request.post("labelToValue", data, config);
|
|
228
|
+
case 2:
|
|
229
|
+
res = _context5.sent;
|
|
230
|
+
if (Array.isArray(res.data)) {
|
|
231
|
+
res.data.forEach(function (item) {
|
|
232
|
+
item.id = (0, _common.uuid)();
|
|
233
|
+
item.form = {
|
|
234
|
+
id: _this3.formId,
|
|
235
|
+
fieldId: _this3.fieldId
|
|
236
|
+
};
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
(0, _formApi.assembleAssociationField)(res.data, res.refs);
|
|
240
|
+
console.debug("formApi.labelToValue", res);
|
|
241
|
+
return _context5.abrupt("return", res);
|
|
242
|
+
case 3:
|
|
221
243
|
case "end":
|
|
222
244
|
return _context5.stop();
|
|
223
245
|
}
|
|
224
246
|
}, _callee5, this);
|
|
225
247
|
}));
|
|
226
|
-
function
|
|
227
|
-
return
|
|
248
|
+
function labelToValue(_x8, _x9) {
|
|
249
|
+
return _labelToValue.apply(this, arguments);
|
|
228
250
|
}
|
|
229
|
-
return
|
|
251
|
+
return labelToValue;
|
|
230
252
|
}();
|
|
231
|
-
_proto.
|
|
232
|
-
var
|
|
253
|
+
_proto.save = /*#__PURE__*/function () {
|
|
254
|
+
var _save = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee6(data, options) {
|
|
233
255
|
return _regenerator["default"].wrap(function (_context6) {
|
|
234
256
|
while (1) switch (_context6.prev = _context6.next) {
|
|
235
257
|
case 0:
|
|
236
|
-
return _context6.abrupt("return", _RestApi.prototype.
|
|
258
|
+
return _context6.abrupt("return", _RestApi.prototype.save.call(this, (0, _formApi.convertSaveData)(data), options));
|
|
237
259
|
case 1:
|
|
238
260
|
case "end":
|
|
239
261
|
return _context6.stop();
|
|
240
262
|
}
|
|
241
263
|
}, _callee6, this);
|
|
242
264
|
}));
|
|
243
|
-
function
|
|
244
|
-
return
|
|
265
|
+
function save(_x0, _x1) {
|
|
266
|
+
return _save.apply(this, arguments);
|
|
245
267
|
}
|
|
246
|
-
return
|
|
268
|
+
return save;
|
|
247
269
|
}();
|
|
248
|
-
_proto.
|
|
249
|
-
var
|
|
270
|
+
_proto.create = /*#__PURE__*/function () {
|
|
271
|
+
var _create = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee7(data, options) {
|
|
250
272
|
return _regenerator["default"].wrap(function (_context7) {
|
|
251
273
|
while (1) switch (_context7.prev = _context7.next) {
|
|
252
274
|
case 0:
|
|
253
|
-
return _context7.abrupt("return", _RestApi.prototype.
|
|
275
|
+
return _context7.abrupt("return", _RestApi.prototype.create.call(this, (0, _formApi.convertSaveData)(data), options));
|
|
254
276
|
case 1:
|
|
255
277
|
case "end":
|
|
256
278
|
return _context7.stop();
|
|
257
279
|
}
|
|
258
280
|
}, _callee7, this);
|
|
259
281
|
}));
|
|
260
|
-
function
|
|
282
|
+
function create(_x10, _x11) {
|
|
283
|
+
return _create.apply(this, arguments);
|
|
284
|
+
}
|
|
285
|
+
return create;
|
|
286
|
+
}();
|
|
287
|
+
_proto.update = /*#__PURE__*/function () {
|
|
288
|
+
var _update = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee8(id, data, options) {
|
|
289
|
+
return _regenerator["default"].wrap(function (_context8) {
|
|
290
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
291
|
+
case 0:
|
|
292
|
+
return _context8.abrupt("return", _RestApi.prototype.update.call(this, id, (0, _formApi.convertSaveData)(data), options));
|
|
293
|
+
case 1:
|
|
294
|
+
case "end":
|
|
295
|
+
return _context8.stop();
|
|
296
|
+
}
|
|
297
|
+
}, _callee8, this);
|
|
298
|
+
}));
|
|
299
|
+
function update(_x12, _x13, _x14) {
|
|
261
300
|
return _update.apply(this, arguments);
|
|
262
301
|
}
|
|
263
302
|
return update;
|
|
264
303
|
}();
|
|
265
304
|
_proto.serviceUpdate = /*#__PURE__*/function () {
|
|
266
|
-
var _serviceUpdate = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function
|
|
305
|
+
var _serviceUpdate = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee9(data, options) {
|
|
267
306
|
var params;
|
|
268
|
-
return _regenerator["default"].wrap(function (
|
|
269
|
-
while (1) switch (
|
|
307
|
+
return _regenerator["default"].wrap(function (_context9) {
|
|
308
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
270
309
|
case 0:
|
|
271
310
|
params = {
|
|
272
311
|
formId: this.formId,
|
|
@@ -276,16 +315,16 @@ var RestFormApi = exports.RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
|
276
315
|
params.mock = true;
|
|
277
316
|
params.description = (this.title || "表单") + ".\u67E5\u8BE2";
|
|
278
317
|
}
|
|
279
|
-
return
|
|
318
|
+
return _context9.abrupt("return", this.request.post("serviceUpdate", data, {
|
|
280
319
|
params: params
|
|
281
320
|
}));
|
|
282
321
|
case 1:
|
|
283
322
|
case "end":
|
|
284
|
-
return
|
|
323
|
+
return _context9.stop();
|
|
285
324
|
}
|
|
286
|
-
},
|
|
325
|
+
}, _callee9, this);
|
|
287
326
|
}));
|
|
288
|
-
function serviceUpdate(
|
|
327
|
+
function serviceUpdate(_x15, _x16) {
|
|
289
328
|
return _serviceUpdate.apply(this, arguments);
|
|
290
329
|
}
|
|
291
330
|
return serviceUpdate;
|
package/lib/utils/api/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { AxiosResponse } from "axios";
|
|
1
2
|
export { RestApi } from "./rest-api";
|
|
2
3
|
export { getFormApi, RestFormApi } from "./form-api";
|
|
3
|
-
import { AxiosResponse } from "axios/index";
|
|
4
4
|
export { getSchema } from "./schema-api";
|
|
5
5
|
export { getUserinfo } from "./user-info";
|
|
6
6
|
export * as files from "./file-api";
|
package/lib/utils/api/index.js
CHANGED
|
@@ -36,7 +36,7 @@ export declare abstract class BaseRestApi<DataType> {
|
|
|
36
36
|
title: string;
|
|
37
37
|
request: AxiosInstance;
|
|
38
38
|
protected constructor(uri: string, options?: RestApiOptions);
|
|
39
|
-
abstract handleRequestConfig(config: AxiosRequestConfig): void
|
|
39
|
+
abstract handleRequestConfig(config: AxiosRequestConfig): Promise<void>;
|
|
40
40
|
search(params?: RestSearchParams): Promise<ManyResult<DataType>>;
|
|
41
41
|
/**
|
|
42
42
|
* 通过id获取
|
|
@@ -58,6 +58,8 @@ export declare abstract class BaseRestApi<DataType> {
|
|
|
58
58
|
*/
|
|
59
59
|
deleteById(id: string, options?: BaseRequestOptions<DataType>): Promise<OneResult<DataType>>;
|
|
60
60
|
delete(data: any | any[], options?: BaseRequestOptions<DataType>): Promise<OneResult<DataType>>;
|
|
61
|
+
export(data: any, options?: BaseRequestOptions<DataType>): Promise<OneResult<DataType>>;
|
|
62
|
+
import(data: any, options?: BaseRequestOptions<DataType>): Promise<OneResult<DataType>>;
|
|
61
63
|
showError(type: string, res: BaseResult<any>): Promise<void>;
|
|
62
64
|
}
|
|
63
65
|
export declare class RestApi<DataType> extends BaseRestApi<DataType> {
|