@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
|
@@ -19,6 +19,10 @@ export var ReactRender = /*#__PURE__*/function (_PureComponent) {
|
|
|
19
19
|
_proto.render = function render() {
|
|
20
20
|
var _this2 = this;
|
|
21
21
|
var components = this.props.components || window._components;
|
|
22
|
+
if (!components.Page) {
|
|
23
|
+
// @ts-ignore
|
|
24
|
+
components["Page"] = Page;
|
|
25
|
+
}
|
|
22
26
|
return /*#__PURE__*/React.createElement(ReactRenderFactory, _extends({
|
|
23
27
|
key: this.key
|
|
24
28
|
}, this.props, {
|
|
@@ -36,4 +40,10 @@ export var ReactRender = /*#__PURE__*/function (_PureComponent) {
|
|
|
36
40
|
}));
|
|
37
41
|
};
|
|
38
42
|
return ReactRender;
|
|
39
|
-
}(PureComponent);
|
|
43
|
+
}(PureComponent);
|
|
44
|
+
function Page(props) {
|
|
45
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
46
|
+
className: "lce-page",
|
|
47
|
+
style: props.style
|
|
48
|
+
}, props.children);
|
|
49
|
+
}
|
package/es/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
1
|
+
import _message from "antd/es/message";
|
|
3
2
|
import "./index.less";
|
|
4
3
|
import { ReactRender } from "./components/react-render";
|
|
5
4
|
import * as lodash from "lodash";
|
|
@@ -10,6 +9,9 @@ export { Layout } from "./components/layout";
|
|
|
10
9
|
export { ReactRender } from "./components/react-render";
|
|
11
10
|
import utils from "./utils/index";
|
|
12
11
|
import { uniBridge } from "./utils/uni-bridge";
|
|
12
|
+
import { initBarHeight } from "./init/init.bar-height";
|
|
13
|
+
import { initScrollSize } from "./init/init.scroll-size";
|
|
14
|
+
import { initMobileClass } from "./init/init.mobile-class";
|
|
13
15
|
// @ts-ignore
|
|
14
16
|
window.__ReactRender = ReactRender;
|
|
15
17
|
// @ts-ignore
|
|
@@ -22,41 +24,17 @@ if (!window.utils) {
|
|
|
22
24
|
// @ts-ignore
|
|
23
25
|
window.utils = utils;
|
|
24
26
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
var classList = window.document.body.classList;
|
|
28
|
-
if (!classList.contains("mobile")) {
|
|
29
|
-
classList.add("mobile");
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
var bar_height_key = "bar_height";
|
|
27
|
+
initMobileClass();
|
|
28
|
+
|
|
33
29
|
// @ts-ignore
|
|
34
30
|
utils.uniBridge = uniBridge;
|
|
35
31
|
// @ts-ignore
|
|
36
32
|
window.uniBridge = uniBridge;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
while (1) switch (_context.prev = _context.next) {
|
|
42
|
-
case 0:
|
|
43
|
-
_context.next = 1;
|
|
44
|
-
return uniBridge.getBarHeight();
|
|
45
|
-
case 1:
|
|
46
|
-
height = _context.sent;
|
|
47
|
-
localStorage.setItem(bar_height_key, height);
|
|
48
|
-
updateBarHeight();
|
|
49
|
-
case 2:
|
|
50
|
-
case "end":
|
|
51
|
-
return _context.stop();
|
|
52
|
-
}
|
|
53
|
-
}, _callee);
|
|
54
|
-
})), 100);
|
|
33
|
+
_message.config({
|
|
34
|
+
top: 150,
|
|
35
|
+
duration: 5,
|
|
36
|
+
maxCount: 3
|
|
55
37
|
});
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
document.documentElement.style.setProperty('--bar-height', localStorage.getItem(bar_height_key));
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
updateBarHeight();
|
|
38
|
+
initBarHeight();
|
|
39
|
+
initScrollSize();
|
|
62
40
|
export { utils, lodash };
|
package/es/index.less
CHANGED
|
@@ -1,7 +1,18 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
--scroll-bar-width: 15px;
|
|
3
|
+
--scroll-bar-height: 15px;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.ant-table-cell-scrollbar {
|
|
7
|
+
padding: 0 !important;
|
|
8
|
+
width: var(--scroll-bar-width);
|
|
9
|
+
}
|
|
10
|
+
|
|
1
11
|
[componentname="Page"] {
|
|
2
12
|
height: 100%;
|
|
3
13
|
}
|
|
4
14
|
|
|
15
|
+
|
|
5
16
|
ul {
|
|
6
17
|
margin-bottom: 0;
|
|
7
18
|
padding-left: 0;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function initBarHeight(): void;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
3
|
+
import { uniBridge } from "../utils/uni-bridge";
|
|
4
|
+
var bar_height_key = "bar_height";
|
|
5
|
+
export function initBarHeight() {
|
|
6
|
+
updateBarHeight();
|
|
7
|
+
window.onload = function () {
|
|
8
|
+
setTimeout(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
9
|
+
var height;
|
|
10
|
+
return _regeneratorRuntime.wrap(function (_context) {
|
|
11
|
+
while (1) switch (_context.prev = _context.next) {
|
|
12
|
+
case 0:
|
|
13
|
+
if (!window.uni) {
|
|
14
|
+
_context.next = 2;
|
|
15
|
+
break;
|
|
16
|
+
}
|
|
17
|
+
_context.next = 1;
|
|
18
|
+
return uniBridge.getBarHeight();
|
|
19
|
+
case 1:
|
|
20
|
+
height = _context.sent;
|
|
21
|
+
localStorage.setItem(bar_height_key, height);
|
|
22
|
+
updateBarHeight();
|
|
23
|
+
case 2:
|
|
24
|
+
case "end":
|
|
25
|
+
return _context.stop();
|
|
26
|
+
}
|
|
27
|
+
}, _callee);
|
|
28
|
+
})), 100);
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
function updateBarHeight() {
|
|
32
|
+
var style = document.documentElement.style;
|
|
33
|
+
var barHeight = localStorage.getItem(bar_height_key);
|
|
34
|
+
if (barHeight) {
|
|
35
|
+
style.setProperty('--bar-height', barHeight);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function initMobileClass(): void;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { isMobile } from "../utils/common";
|
|
2
|
+
export function initMobileClass() {
|
|
3
|
+
window.isMobile = isMobile();
|
|
4
|
+
if (window.isMobile) {
|
|
5
|
+
var classList = window.document.body.classList;
|
|
6
|
+
if (!classList.contains("mobile")) {
|
|
7
|
+
classList.add("mobile");
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
var scrollbarSize = {};
|
|
2
|
+
|
|
3
|
+
// @ts-ignore
|
|
4
|
+
window.scrollbarSize = scrollbarSize;
|
|
5
|
+
export function initScrollSize() {
|
|
6
|
+
var size = getScrollbarSize();
|
|
7
|
+
var style = document.documentElement.style;
|
|
8
|
+
style.setProperty('--scroll-bar-height', size.height + "px");
|
|
9
|
+
style.setProperty('--scroll-bar-width', size.width + "px");
|
|
10
|
+
}
|
|
11
|
+
export function getScrollbarSize() {
|
|
12
|
+
if (typeof scrollbarSize.height == "number" && typeof scrollbarSize.width == "number") {
|
|
13
|
+
return scrollbarSize;
|
|
14
|
+
}
|
|
15
|
+
var outer = document.createElement('div');
|
|
16
|
+
outer.style.cssText = "\n visibility: hidden;\n overflow: scroll;\n position: absolute;\n top: -9999px;\n width: 50px;\n height: 50px;\n ";
|
|
17
|
+
document.body.appendChild(outer);
|
|
18
|
+
var inner = document.createElement('div');
|
|
19
|
+
inner.style.width = '100%';
|
|
20
|
+
inner.style.height = '100%';
|
|
21
|
+
outer.appendChild(inner);
|
|
22
|
+
scrollbarSize.width = outer.offsetWidth - inner.offsetWidth;
|
|
23
|
+
scrollbarSize.height = outer.offsetHeight - inner.offsetHeight;
|
|
24
|
+
document.body.removeChild(outer);
|
|
25
|
+
return scrollbarSize;
|
|
26
|
+
}
|
package/es/style.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import 'antd/es/message/style';
|
|
1
2
|
import 'antd/es/config-provider/style';
|
|
2
3
|
|
|
3
4
|
import 'antd/es/notification/style';
|
|
4
5
|
import 'antd/es/modal/style';
|
|
5
|
-
import 'antd/es/message/style';
|
|
6
6
|
import 'antd/es/typography/style';
|
|
7
7
|
import 'antd/es/drawer/style';
|
|
8
8
|
import 'antd/es/result/style';
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
function _createForOfIteratorHelperLoose(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (t) return (t = t.call(r)).next.bind(t); if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var o = 0; return function () { return o >= r.length ? { done: !0 } : { done: !1, value: r[o++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
2
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
3
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
4
|
+
import { FormApiEntityMap } from "./form-api.entity-map";
|
|
5
|
+
import { dataToLabel, safeGet } from "./form-api.utils";
|
|
6
|
+
export function formApiAssembleEntity(data, refs) {
|
|
7
|
+
if (!data || !refs) return;
|
|
8
|
+
var dataMap = new FormApiEntityMap();
|
|
9
|
+
for (var _iterator = _createForOfIteratorHelperLoose(refs), _step; !(_step = _iterator()).done;) {
|
|
10
|
+
var ref = _step.value;
|
|
11
|
+
ref.label = ref.form.label;
|
|
12
|
+
dataMap.addEntities(ref.data);
|
|
13
|
+
}
|
|
14
|
+
assembleRefs(refs, dataMap);
|
|
15
|
+
var dataArray = Array.isArray(data) ? data : [data];
|
|
16
|
+
assembleData(dataArray, dataMap);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* 装配数据
|
|
21
|
+
*/
|
|
22
|
+
function assembleData(data, dataMap) {
|
|
23
|
+
for (var _iterator2 = _createForOfIteratorHelperLoose(data), _step2; !(_step2 = _iterator2()).done;) {
|
|
24
|
+
var item = _step2.value;
|
|
25
|
+
assembleObject(item, dataMap, {
|
|
26
|
+
maxDepth: 5,
|
|
27
|
+
depth: 1
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* 装配相关数据
|
|
34
|
+
*/
|
|
35
|
+
function assembleRefs(refs, dataMap) {
|
|
36
|
+
for (var _iterator3 = _createForOfIteratorHelperLoose(refs), _step3; !(_step3 = _iterator3()).done;) {
|
|
37
|
+
var ref = _step3.value;
|
|
38
|
+
ref.label = ref.form.label;
|
|
39
|
+
var data = ref.data;
|
|
40
|
+
for (var _iterator4 = _createForOfIteratorHelperLoose(data), _step4; !(_step4 = _iterator4()).done;) {
|
|
41
|
+
var item = _step4.value;
|
|
42
|
+
assembleObject(item, dataMap, {
|
|
43
|
+
maxDepth: 2,
|
|
44
|
+
depth: 1
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function assembleObject(values, dataMap, options) {
|
|
50
|
+
var depth = options.depth,
|
|
51
|
+
maxDepth = options.maxDepth;
|
|
52
|
+
if (options.depth >= options.maxDepth) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
if (dataMap.isEntity(values)) {
|
|
56
|
+
handleEntityLabel(values);
|
|
57
|
+
}
|
|
58
|
+
for (var _i = 0, _Object$keys = Object.keys(values); _i < _Object$keys.length; _i++) {
|
|
59
|
+
var key = _Object$keys[_i];
|
|
60
|
+
var value = values[key];
|
|
61
|
+
if (Array.isArray(value)) {
|
|
62
|
+
if (dataMap.needLoad(value[0])) {
|
|
63
|
+
//需要加载的属性
|
|
64
|
+
values[key] = value.map(function (item) {
|
|
65
|
+
if (dataMap.hasEntity(item)) {
|
|
66
|
+
return dataMap.getEntity(item);
|
|
67
|
+
}
|
|
68
|
+
return item;
|
|
69
|
+
});
|
|
70
|
+
} else if (dataMap.isEntity(value[0])) {
|
|
71
|
+
//子表属性
|
|
72
|
+
for (var _iterator5 = _createForOfIteratorHelperLoose(value), _step5; !(_step5 = _iterator5()).done;) {
|
|
73
|
+
var valueElement = _step5.value;
|
|
74
|
+
assembleObject(valueElement, dataMap, {
|
|
75
|
+
maxDepth: maxDepth,
|
|
76
|
+
depth: depth + 1
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
} else if (typeof value == "object") {
|
|
81
|
+
if (dataMap.needLoad(value)) {
|
|
82
|
+
if (dataMap.hasEntity(value)) {
|
|
83
|
+
values[key] = dataMap.getEntity(value);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
function handleEntityLabel(data) {
|
|
90
|
+
var _data$form;
|
|
91
|
+
var labelField = data === null || data === void 0 ? void 0 : (_data$form = data.form) === null || _data$form === void 0 ? void 0 : _data$form.labelField;
|
|
92
|
+
if (labelField) {
|
|
93
|
+
data.label = dataToLabel(safeGet(data, labelField));
|
|
94
|
+
}
|
|
95
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { IBaseEntity } from "../rest-api";
|
|
2
|
+
export declare class FormApiEntityMap {
|
|
3
|
+
dataMap: Map<string, IBaseEntity>;
|
|
4
|
+
hasEntity(entity: IBaseEntity): boolean;
|
|
5
|
+
getEntity(entity: IBaseEntity): IBaseEntity;
|
|
6
|
+
addEntity(entity: IBaseEntity): void;
|
|
7
|
+
addEntities(entities: IBaseEntity[]): void;
|
|
8
|
+
isEntity(value: any): boolean;
|
|
9
|
+
needLoad(entity: IBaseEntity): boolean;
|
|
10
|
+
destroy(): void;
|
|
11
|
+
private createEntityKey;
|
|
12
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export var FormApiEntityMap = /*#__PURE__*/function () {
|
|
2
|
+
function FormApiEntityMap() {
|
|
3
|
+
this.dataMap = new Map();
|
|
4
|
+
}
|
|
5
|
+
var _proto = FormApiEntityMap.prototype;
|
|
6
|
+
_proto.hasEntity = function hasEntity(entity) {
|
|
7
|
+
var key = this.createEntityKey(entity);
|
|
8
|
+
return this.dataMap.has(key);
|
|
9
|
+
};
|
|
10
|
+
_proto.getEntity = function getEntity(entity) {
|
|
11
|
+
var key = this.createEntityKey(entity);
|
|
12
|
+
return this.dataMap.get(key);
|
|
13
|
+
};
|
|
14
|
+
_proto.addEntity = function addEntity(entity) {
|
|
15
|
+
var key = this.createEntityKey(entity);
|
|
16
|
+
this.dataMap.set(key, entity);
|
|
17
|
+
};
|
|
18
|
+
_proto.addEntities = function addEntities(entities) {
|
|
19
|
+
var _this = this;
|
|
20
|
+
entities === null || entities === void 0 ? void 0 : entities.forEach(function (item) {
|
|
21
|
+
return _this.addEntity(item);
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
_proto.isEntity = function isEntity(value) {
|
|
25
|
+
if (value == null) {
|
|
26
|
+
return false;
|
|
27
|
+
} else if (Array.isArray(value)) {
|
|
28
|
+
return false;
|
|
29
|
+
} else if (typeof value == "object") {
|
|
30
|
+
var _value$form;
|
|
31
|
+
return !!value.id && !!((_value$form = value.form) !== null && _value$form !== void 0 && _value$form.id);
|
|
32
|
+
}
|
|
33
|
+
return false;
|
|
34
|
+
};
|
|
35
|
+
_proto.needLoad = function needLoad(entity) {
|
|
36
|
+
return this.isEntity(entity) && entity._load == false;
|
|
37
|
+
};
|
|
38
|
+
_proto.destroy = function destroy() {
|
|
39
|
+
this.dataMap.clear();
|
|
40
|
+
};
|
|
41
|
+
_proto.createEntityKey = function createEntityKey(entity) {
|
|
42
|
+
var _entity$form, _entity$form2;
|
|
43
|
+
var key = (_entity$form = entity.form) === null || _entity$form === void 0 ? void 0 : _entity$form.id;
|
|
44
|
+
if ((_entity$form2 = entity.form) !== null && _entity$form2 !== void 0 && _entity$form2.fieldId) {
|
|
45
|
+
key += "." + entity.form.fieldId;
|
|
46
|
+
}
|
|
47
|
+
return key + "." + entity.id;
|
|
48
|
+
};
|
|
49
|
+
return FormApiEntityMap;
|
|
50
|
+
}();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FilterRule, IBaseEntity, Refs } from "
|
|
1
|
+
import { FilterRule, IBaseEntity, Refs } from "../rest-api";
|
|
2
2
|
export declare function convertSaveData(data: any): any;
|
|
3
3
|
export declare function dataToLabel(value: any): any;
|
|
4
4
|
export declare function assembleAssociationFieldV2(data: IBaseEntity | IBaseEntity[], refs?: Refs): void;
|
|
@@ -9,7 +9,8 @@ export declare function assembleAssociationFieldV2(data: IBaseEntity | IBaseEnti
|
|
|
9
9
|
*/
|
|
10
10
|
export declare function assembleAssociationFieldDataV2(data: IBaseEntity | IBaseEntity[], dataMap: Map<string, IBaseEntity>): void;
|
|
11
11
|
export declare function handleEntityLabel(data: IBaseEntity | IBaseEntity[]): void;
|
|
12
|
-
export declare function assembleAssociationField(data: IBaseEntity | IBaseEntity[], refs?: Refs):
|
|
12
|
+
export declare function assembleAssociationField(data: IBaseEntity | IBaseEntity[], refs?: Refs): number;
|
|
13
13
|
export declare function handleFilterRules(filters: FilterRule[], options: {
|
|
14
14
|
filterNullValue: boolean;
|
|
15
15
|
}): FilterRule[];
|
|
16
|
+
export declare function safeGet(value: any, key: string | null): any;
|
|
@@ -2,16 +2,37 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
2
2
|
function _createForOfIteratorHelperLoose(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (t) return (t = t.call(r)).next.bind(t); if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var o = 0; return function () { return o >= r.length ? { done: !0 } : { done: !1, value: r[o++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
3
|
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
4
4
|
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
5
|
-
import { transformerId } from "
|
|
5
|
+
import { transformerId } from "../../data";
|
|
6
|
+
import { isLocalhost } from "../../common";
|
|
7
|
+
import { formApiAssembleEntity } from "./form-api.assemble-entity";
|
|
8
|
+
import { isTemplateHost } from "../../util.common";
|
|
6
9
|
var SimpleSerialFieldNames = ["parent", "instance"];
|
|
7
10
|
export function convertSaveData(data) {
|
|
8
11
|
if (!data) return data;
|
|
12
|
+
var seen = new WeakSet(); // WeakSet 只存储对象,非常适合检测引用
|
|
9
13
|
return JSON.parse(JSON.stringify(data, function (key, value) {
|
|
10
|
-
if (
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
if (value == null) {
|
|
15
|
+
return null;
|
|
16
|
+
} else if (Array.isArray(value)) {
|
|
17
|
+
return value;
|
|
18
|
+
} else if (typeof value == "object") {
|
|
19
|
+
if (SimpleSerialFieldNames.includes(key)) {
|
|
20
|
+
var id = value === null || value === void 0 ? void 0 : value.id;
|
|
21
|
+
return id ? {
|
|
22
|
+
id: id
|
|
23
|
+
} : undefined;
|
|
24
|
+
} else if (seen.has(value)) {
|
|
25
|
+
if (value.id) {
|
|
26
|
+
return {
|
|
27
|
+
id: value.id
|
|
28
|
+
};
|
|
29
|
+
} else {
|
|
30
|
+
return value;
|
|
31
|
+
}
|
|
32
|
+
} else {
|
|
33
|
+
seen.add(value);
|
|
34
|
+
}
|
|
35
|
+
return value;
|
|
15
36
|
}
|
|
16
37
|
return value;
|
|
17
38
|
}));
|
|
@@ -150,7 +171,13 @@ function valueToFormDataArray(value) {
|
|
|
150
171
|
}
|
|
151
172
|
}
|
|
152
173
|
export function assembleAssociationField(data, refs) {
|
|
174
|
+
var start = Date.now();
|
|
175
|
+
if (isLocalhost() || isTemplateHost()) {
|
|
176
|
+
formApiAssembleEntity(data, refs);
|
|
177
|
+
return Date.now() - start;
|
|
178
|
+
}
|
|
153
179
|
assembleAssociationFieldV2(data, refs);
|
|
180
|
+
return Date.now() - start;
|
|
154
181
|
}
|
|
155
182
|
export function handleFilterRules(filters, options) {
|
|
156
183
|
var filterNullValue = options.filterNullValue;
|
|
@@ -159,13 +186,19 @@ export function handleFilterRules(filters, options) {
|
|
|
159
186
|
return !!rule;
|
|
160
187
|
}).map(function (rule) {
|
|
161
188
|
return _extends({}, rule, {
|
|
162
|
-
value: transformerId(rule.value
|
|
189
|
+
value: transformerId(rule.value, {
|
|
190
|
+
includeNull: true
|
|
191
|
+
}),
|
|
163
192
|
rules: handleFilterRules(rule.rules || [], options)
|
|
164
193
|
});
|
|
165
194
|
});
|
|
166
195
|
if (filterNullValue) {
|
|
167
196
|
cloneRules = cloneRules.filter(function (rule) {
|
|
168
197
|
if (rule.value == null) {
|
|
198
|
+
var _rule$rules;
|
|
199
|
+
if ((_rule$rules = rule.rules) !== null && _rule$rules !== void 0 && _rule$rules.length) {
|
|
200
|
+
return true;
|
|
201
|
+
}
|
|
169
202
|
if (rule.operator != "isNull" && rule.operator != "isNotNull") {
|
|
170
203
|
return false;
|
|
171
204
|
}
|
|
@@ -181,7 +214,7 @@ export function handleFilterRules(filters, options) {
|
|
|
181
214
|
return undefined;
|
|
182
215
|
}
|
|
183
216
|
}
|
|
184
|
-
function safeGet(value, key) {
|
|
217
|
+
export function safeGet(value, key) {
|
|
185
218
|
if (typeof value !== "object") {
|
|
186
219
|
return null;
|
|
187
220
|
}
|
|
@@ -16,5 +16,6 @@ export declare class RestFormApi<DataType> extends RestApi<DataType> {
|
|
|
16
16
|
save(data: DataType, options?: BaseRequestOptions<DataType>): Promise<OneResult<DataType>>;
|
|
17
17
|
create(data: DataType, options?: BaseRequestOptions<DataType>): Promise<OneResult<DataType>>;
|
|
18
18
|
update(id: string, data: DataType, options?: BaseRequestOptions<DataType>): Promise<OneResult<DataType>>;
|
|
19
|
+
fieldFilters(searchParams?: RestSearchParams): Promise<ManyResult<DataType>>;
|
|
19
20
|
serviceUpdate(data: DataType, options?: BaseRequestOptions<DataType>): Promise<import("axios").AxiosResponse<any, any, {}>>;
|
|
20
21
|
}
|