@zhubangyun/lowcode-core 5.10.91 → 5.10.211
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/log-error-content.js +2 -2
- package/es/components/react-render/index.d.ts +1 -1
- package/es/components/react-render/index.js +4 -2
- package/es/utils/api/form-api.utils.d.ts +5 -0
- package/es/utils/api/form-api.utils.js +39 -9
- package/es/utils/api/schema-api.js +12 -4
- package/es/utils/page/page-load-schema.js +3 -3
- package/es/utils/page/page-render.js +2 -1
- package/lib/components/log-error-content.js +2 -2
- package/lib/components/react-render/index.d.ts +1 -1
- package/lib/components/react-render/index.js +5 -3
- package/lib/utils/api/form-api.utils.d.ts +5 -0
- package/lib/utils/api/form-api.utils.js +39 -9
- package/lib/utils/api/schema-api.js +12 -4
- package/lib/utils/page/page-load-schema.js +3 -3
- package/lib/utils/page/page-render.js +2 -1
- package/package.json +1 -1
|
@@ -16,10 +16,10 @@ export function LogErrorContent(props) {
|
|
|
16
16
|
_Modal.destroyAll();
|
|
17
17
|
_message.destroy();
|
|
18
18
|
_notification.destroy();
|
|
19
|
-
(_window$utils = window.utils) === null || _window$utils === void 0 ? void 0 : _window$utils.showForm({
|
|
19
|
+
(_window$utils = window.utils) === null || _window$utils === void 0 ? void 0 : _window$utils.page.showForm({
|
|
20
20
|
layout: "modal",
|
|
21
21
|
form: {
|
|
22
|
-
id: "
|
|
22
|
+
id: "40120d0c-2b35-4ae7-8711-acae048f1a0"
|
|
23
23
|
},
|
|
24
24
|
mode: "detail",
|
|
25
25
|
dataId: props.requestId
|
|
@@ -3,5 +3,5 @@ import { IRendererProps } from "@zhubangyun/lowcode-render-core/lib/types";
|
|
|
3
3
|
export declare class ReactRender extends PureComponent<IRendererProps & {}> {
|
|
4
4
|
key: string;
|
|
5
5
|
node: any;
|
|
6
|
-
render(): import("react").JSX.Element;
|
|
6
|
+
render(utils?: any): import("react").JSX.Element;
|
|
7
7
|
}
|
|
@@ -3,7 +3,6 @@ import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
|
|
|
3
3
|
import { PureComponent } from 'react';
|
|
4
4
|
import { createFetchHandler } from "@alilc/lowcode-datasource-fetch-handler";
|
|
5
5
|
import ReactRenderFactory from "./react-render-factory";
|
|
6
|
-
import utils from "../../utils";
|
|
7
6
|
export var ReactRender = /*#__PURE__*/function (_PureComponent) {
|
|
8
7
|
function ReactRender() {
|
|
9
8
|
var _this;
|
|
@@ -17,8 +16,11 @@ export var ReactRender = /*#__PURE__*/function (_PureComponent) {
|
|
|
17
16
|
}
|
|
18
17
|
_inheritsLoose(ReactRender, _PureComponent);
|
|
19
18
|
var _proto = ReactRender.prototype;
|
|
20
|
-
_proto.render = function render() {
|
|
19
|
+
_proto.render = function render(utils) {
|
|
21
20
|
var _this2 = this;
|
|
21
|
+
if (utils === void 0) {
|
|
22
|
+
utils = window.utils;
|
|
23
|
+
}
|
|
22
24
|
var components = this.props.components || window._components;
|
|
23
25
|
return /*#__PURE__*/React.createElement(ReactRenderFactory, _extends({
|
|
24
26
|
key: this.key
|
|
@@ -3,6 +3,11 @@ export declare function convertSaveData(data: any): any;
|
|
|
3
3
|
export declare function handleEntityLabel(data: BaseType | BaseType[]): void;
|
|
4
4
|
export declare function dataToLabel(value: any): any;
|
|
5
5
|
export declare function assembleAssociationFieldV2(data: BaseType | BaseType[], refs?: Refs): void;
|
|
6
|
+
/**
|
|
7
|
+
* 加载字段
|
|
8
|
+
* @param data
|
|
9
|
+
* @param dataMap
|
|
10
|
+
*/
|
|
6
11
|
export declare function assembleAssociationFieldDataV2(data: BaseType | BaseType[], dataMap: Map<string, BaseType>): void;
|
|
7
12
|
export declare function assembleAssociationField(data: BaseType | BaseType[], refs?: Refs): void;
|
|
8
13
|
export declare function handleFilterRules(filters: FilterRule[], options: {
|
|
@@ -33,7 +33,7 @@ export function handleEntityLabel(data) {
|
|
|
33
33
|
var labelField = (_item$form = item.form) === null || _item$form === void 0 ? void 0 : _item$form.labelField;
|
|
34
34
|
if (labelField) {
|
|
35
35
|
// @ts-ignore
|
|
36
|
-
var value = item
|
|
36
|
+
var value = safeGet(item, labelField);
|
|
37
37
|
item.label = dataToLabel(value);
|
|
38
38
|
}
|
|
39
39
|
}
|
|
@@ -87,6 +87,7 @@ export function assembleAssociationFieldV2(data, refs) {
|
|
|
87
87
|
return loopAssembleAssociation(item);
|
|
88
88
|
});
|
|
89
89
|
} else if (value !== null && value !== void 0 && value.id) {
|
|
90
|
+
handleEntityLabel(value);
|
|
90
91
|
assembleAssociationFieldDataV2(value, dataMap);
|
|
91
92
|
//处理子表
|
|
92
93
|
for (var _i = 0, _Object$values = Object.values(value); _i < _Object$values.length; _i++) {
|
|
@@ -98,8 +99,13 @@ export function assembleAssociationFieldV2(data, refs) {
|
|
|
98
99
|
}
|
|
99
100
|
}
|
|
100
101
|
loopAssembleAssociation(data);
|
|
101
|
-
handleEntityLabel(data);
|
|
102
102
|
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* 加载字段
|
|
106
|
+
* @param data
|
|
107
|
+
* @param dataMap
|
|
108
|
+
*/
|
|
103
109
|
export function assembleAssociationFieldDataV2(data, dataMap) {
|
|
104
110
|
if (data == null) {
|
|
105
111
|
return;
|
|
@@ -109,14 +115,16 @@ export function assembleAssociationFieldDataV2(data, dataMap) {
|
|
|
109
115
|
return assembleAssociationFieldDataV2(item, dataMap);
|
|
110
116
|
});
|
|
111
117
|
} else {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
var key = getDataKey(data);
|
|
116
|
-
var value = dataMap.get(key);
|
|
117
|
-
if (value) {
|
|
118
|
-
Object.assign(data, value);
|
|
118
|
+
if (data._load == false) {
|
|
119
|
+
var _data$form3;
|
|
120
|
+
if (data !== null && data !== void 0 && (_data$form3 = data.form) !== null && _data$form3 !== void 0 && _data$form3.id && data !== null && data !== void 0 && data.id) {
|
|
119
121
|
delete data._load;
|
|
122
|
+
var key = getDataKey(data);
|
|
123
|
+
var value = dataMap.get(key);
|
|
124
|
+
if (value) {
|
|
125
|
+
Object.assign(data, value);
|
|
126
|
+
delete data._load;
|
|
127
|
+
}
|
|
120
128
|
}
|
|
121
129
|
}
|
|
122
130
|
}
|
|
@@ -152,4 +160,26 @@ export function handleFilterRules(filters, options) {
|
|
|
152
160
|
} else {
|
|
153
161
|
return undefined;
|
|
154
162
|
}
|
|
163
|
+
}
|
|
164
|
+
function safeGet(value, key) {
|
|
165
|
+
if (typeof value !== "object") {
|
|
166
|
+
return null;
|
|
167
|
+
}
|
|
168
|
+
if (typeof key !== "string") {
|
|
169
|
+
return null;
|
|
170
|
+
}
|
|
171
|
+
if (!value || !key) return undefined;
|
|
172
|
+
var paths = key.split(".");
|
|
173
|
+
function safeGetValue(v) {
|
|
174
|
+
if (typeof v !== "object") {
|
|
175
|
+
return v;
|
|
176
|
+
}
|
|
177
|
+
if (paths.length) {
|
|
178
|
+
var k = paths.shift();
|
|
179
|
+
return safeGetValue(v === null || v === void 0 ? void 0 : v[k]);
|
|
180
|
+
} else {
|
|
181
|
+
return v;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return safeGetValue(value);
|
|
155
185
|
}
|
|
@@ -10,15 +10,16 @@ function _getSchema() {
|
|
|
10
10
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
11
11
|
while (1) switch (_context.prev = _context.next) {
|
|
12
12
|
case 0:
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
mock = getMock(mock);
|
|
14
|
+
key = mock ? pageId + ":mock" : pageId;
|
|
15
|
+
_context.next = 4;
|
|
15
16
|
return schema.getInstance(key, {
|
|
16
17
|
mock: mock,
|
|
17
18
|
pageId: pageId
|
|
18
19
|
});
|
|
19
|
-
case 3:
|
|
20
|
-
return _context.abrupt("return", _context.sent);
|
|
21
20
|
case 4:
|
|
21
|
+
return _context.abrupt("return", _context.sent);
|
|
22
|
+
case 5:
|
|
22
23
|
case "end":
|
|
23
24
|
return _context.stop();
|
|
24
25
|
}
|
|
@@ -30,6 +31,13 @@ export function getSchemaFromCache(pageId, mock) {
|
|
|
30
31
|
if (!pageId) {
|
|
31
32
|
return null;
|
|
32
33
|
}
|
|
34
|
+
mock = getMock(mock);
|
|
33
35
|
var key = mock ? pageId + "_mock" : pageId;
|
|
34
36
|
return schema.get(key);
|
|
37
|
+
}
|
|
38
|
+
function getMock(mock) {
|
|
39
|
+
if (typeof mock !== "boolean") {
|
|
40
|
+
mock = !!window.__mock;
|
|
41
|
+
}
|
|
42
|
+
return mock;
|
|
35
43
|
}
|
|
@@ -8,10 +8,10 @@ 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(
|
|
11
|
+
var _useState = useState(!cache),
|
|
12
12
|
loading = _useState[0],
|
|
13
13
|
setLoading = _useState[1];
|
|
14
|
-
var _useState2 = useState(),
|
|
14
|
+
var _useState2 = useState(cache === null || cache === void 0 ? void 0 : cache.data),
|
|
15
15
|
schema = _useState2[0],
|
|
16
16
|
setSchema = _useState2[1];
|
|
17
17
|
var _useState3 = useState(),
|
|
@@ -38,7 +38,7 @@ export function PageLoadSchema(props) {
|
|
|
38
38
|
}
|
|
39
39
|
}, []);
|
|
40
40
|
if (cache) {
|
|
41
|
-
return children(
|
|
41
|
+
return children(cache.data);
|
|
42
42
|
}
|
|
43
43
|
if (loading) {
|
|
44
44
|
return /*#__PURE__*/React.createElement(PageLoading, {
|
|
@@ -36,8 +36,9 @@ export function renderElement(options) {
|
|
|
36
36
|
_onClose === null || _onClose === void 0 ? void 0 : _onClose();
|
|
37
37
|
}
|
|
38
38
|
}));
|
|
39
|
+
console.log("渲染", container, root, element);
|
|
39
40
|
root.render(element);
|
|
40
|
-
case
|
|
41
|
+
case 8:
|
|
41
42
|
case "end":
|
|
42
43
|
return _context.stop();
|
|
43
44
|
}
|
|
@@ -21,10 +21,10 @@ function LogErrorContent(props) {
|
|
|
21
21
|
_modal["default"].destroyAll();
|
|
22
22
|
_message2["default"].destroy();
|
|
23
23
|
_notification2["default"].destroy();
|
|
24
|
-
(_window$utils = window.utils) === null || _window$utils === void 0 ? void 0 : _window$utils.showForm({
|
|
24
|
+
(_window$utils = window.utils) === null || _window$utils === void 0 ? void 0 : _window$utils.page.showForm({
|
|
25
25
|
layout: "modal",
|
|
26
26
|
form: {
|
|
27
|
-
id: "
|
|
27
|
+
id: "40120d0c-2b35-4ae7-8711-acae048f1a0"
|
|
28
28
|
},
|
|
29
29
|
mode: "detail",
|
|
30
30
|
dataId: props.requestId
|
|
@@ -3,5 +3,5 @@ import { IRendererProps } from "@zhubangyun/lowcode-render-core/lib/types";
|
|
|
3
3
|
export declare class ReactRender extends PureComponent<IRendererProps & {}> {
|
|
4
4
|
key: string;
|
|
5
5
|
node: any;
|
|
6
|
-
render(): import("react").JSX.Element;
|
|
6
|
+
render(utils?: any): import("react").JSX.Element;
|
|
7
7
|
}
|
|
@@ -8,7 +8,6 @@ var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inh
|
|
|
8
8
|
var _react = require("react");
|
|
9
9
|
var _lowcodeDatasourceFetchHandler = require("@alilc/lowcode-datasource-fetch-handler");
|
|
10
10
|
var _reactRenderFactory = _interopRequireDefault(require("./react-render-factory"));
|
|
11
|
-
var _utils = _interopRequireDefault(require("../../utils"));
|
|
12
11
|
var ReactRender = exports.ReactRender = /*#__PURE__*/function (_PureComponent) {
|
|
13
12
|
function ReactRender() {
|
|
14
13
|
var _this;
|
|
@@ -22,8 +21,11 @@ var ReactRender = exports.ReactRender = /*#__PURE__*/function (_PureComponent) {
|
|
|
22
21
|
}
|
|
23
22
|
(0, _inheritsLoose2["default"])(ReactRender, _PureComponent);
|
|
24
23
|
var _proto = ReactRender.prototype;
|
|
25
|
-
_proto.render = function render() {
|
|
24
|
+
_proto.render = function render(utils) {
|
|
26
25
|
var _this2 = this;
|
|
26
|
+
if (utils === void 0) {
|
|
27
|
+
utils = window.utils;
|
|
28
|
+
}
|
|
27
29
|
var components = this.props.components || window._components;
|
|
28
30
|
return /*#__PURE__*/React.createElement(_reactRenderFactory["default"], (0, _extends2["default"])({
|
|
29
31
|
key: this.key
|
|
@@ -34,7 +36,7 @@ var ReactRender = exports.ReactRender = /*#__PURE__*/function (_PureComponent) {
|
|
|
34
36
|
thisRequiredInJSE: true,
|
|
35
37
|
components: components,
|
|
36
38
|
appHelper: {
|
|
37
|
-
utils:
|
|
39
|
+
utils: utils,
|
|
38
40
|
requestHandlersMap: {
|
|
39
41
|
fetch: (0, _lowcodeDatasourceFetchHandler.createFetchHandler)()
|
|
40
42
|
}
|
|
@@ -3,6 +3,11 @@ export declare function convertSaveData(data: any): any;
|
|
|
3
3
|
export declare function handleEntityLabel(data: BaseType | BaseType[]): void;
|
|
4
4
|
export declare function dataToLabel(value: any): any;
|
|
5
5
|
export declare function assembleAssociationFieldV2(data: BaseType | BaseType[], refs?: Refs): void;
|
|
6
|
+
/**
|
|
7
|
+
* 加载字段
|
|
8
|
+
* @param data
|
|
9
|
+
* @param dataMap
|
|
10
|
+
*/
|
|
6
11
|
export declare function assembleAssociationFieldDataV2(data: BaseType | BaseType[], dataMap: Map<string, BaseType>): void;
|
|
7
12
|
export declare function assembleAssociationField(data: BaseType | BaseType[], refs?: Refs): void;
|
|
8
13
|
export declare function handleFilterRules(filters: FilterRule[], options: {
|
|
@@ -44,7 +44,7 @@ function handleEntityLabel(data) {
|
|
|
44
44
|
var labelField = (_item$form = item.form) === null || _item$form === void 0 ? void 0 : _item$form.labelField;
|
|
45
45
|
if (labelField) {
|
|
46
46
|
// @ts-ignore
|
|
47
|
-
var value = item
|
|
47
|
+
var value = safeGet(item, labelField);
|
|
48
48
|
item.label = dataToLabel(value);
|
|
49
49
|
}
|
|
50
50
|
}
|
|
@@ -98,6 +98,7 @@ function assembleAssociationFieldV2(data, refs) {
|
|
|
98
98
|
return loopAssembleAssociation(item);
|
|
99
99
|
});
|
|
100
100
|
} else if (value !== null && value !== void 0 && value.id) {
|
|
101
|
+
handleEntityLabel(value);
|
|
101
102
|
assembleAssociationFieldDataV2(value, dataMap);
|
|
102
103
|
//处理子表
|
|
103
104
|
for (var _i = 0, _Object$values = Object.values(value); _i < _Object$values.length; _i++) {
|
|
@@ -109,8 +110,13 @@ function assembleAssociationFieldV2(data, refs) {
|
|
|
109
110
|
}
|
|
110
111
|
}
|
|
111
112
|
loopAssembleAssociation(data);
|
|
112
|
-
handleEntityLabel(data);
|
|
113
113
|
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* 加载字段
|
|
117
|
+
* @param data
|
|
118
|
+
* @param dataMap
|
|
119
|
+
*/
|
|
114
120
|
function assembleAssociationFieldDataV2(data, dataMap) {
|
|
115
121
|
if (data == null) {
|
|
116
122
|
return;
|
|
@@ -120,14 +126,16 @@ function assembleAssociationFieldDataV2(data, dataMap) {
|
|
|
120
126
|
return assembleAssociationFieldDataV2(item, dataMap);
|
|
121
127
|
});
|
|
122
128
|
} else {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
var key = getDataKey(data);
|
|
127
|
-
var value = dataMap.get(key);
|
|
128
|
-
if (value) {
|
|
129
|
-
Object.assign(data, value);
|
|
129
|
+
if (data._load == false) {
|
|
130
|
+
var _data$form3;
|
|
131
|
+
if (data !== null && data !== void 0 && (_data$form3 = data.form) !== null && _data$form3 !== void 0 && _data$form3.id && data !== null && data !== void 0 && data.id) {
|
|
130
132
|
delete data._load;
|
|
133
|
+
var key = getDataKey(data);
|
|
134
|
+
var value = dataMap.get(key);
|
|
135
|
+
if (value) {
|
|
136
|
+
Object.assign(data, value);
|
|
137
|
+
delete data._load;
|
|
138
|
+
}
|
|
131
139
|
}
|
|
132
140
|
}
|
|
133
141
|
}
|
|
@@ -163,4 +171,26 @@ function handleFilterRules(filters, options) {
|
|
|
163
171
|
} else {
|
|
164
172
|
return undefined;
|
|
165
173
|
}
|
|
174
|
+
}
|
|
175
|
+
function safeGet(value, key) {
|
|
176
|
+
if (typeof value !== "object") {
|
|
177
|
+
return null;
|
|
178
|
+
}
|
|
179
|
+
if (typeof key !== "string") {
|
|
180
|
+
return null;
|
|
181
|
+
}
|
|
182
|
+
if (!value || !key) return undefined;
|
|
183
|
+
var paths = key.split(".");
|
|
184
|
+
function safeGetValue(v) {
|
|
185
|
+
if (typeof v !== "object") {
|
|
186
|
+
return v;
|
|
187
|
+
}
|
|
188
|
+
if (paths.length) {
|
|
189
|
+
var k = paths.shift();
|
|
190
|
+
return safeGetValue(v === null || v === void 0 ? void 0 : v[k]);
|
|
191
|
+
} else {
|
|
192
|
+
return v;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
return safeGetValue(value);
|
|
166
196
|
}
|
|
@@ -16,15 +16,16 @@ function _getSchema() {
|
|
|
16
16
|
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
17
17
|
while (1) switch (_context.prev = _context.next) {
|
|
18
18
|
case 0:
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
mock = getMock(mock);
|
|
20
|
+
key = mock ? pageId + ":mock" : pageId;
|
|
21
|
+
_context.next = 4;
|
|
21
22
|
return _cache.schema.getInstance(key, {
|
|
22
23
|
mock: mock,
|
|
23
24
|
pageId: pageId
|
|
24
25
|
});
|
|
25
|
-
case 3:
|
|
26
|
-
return _context.abrupt("return", _context.sent);
|
|
27
26
|
case 4:
|
|
27
|
+
return _context.abrupt("return", _context.sent);
|
|
28
|
+
case 5:
|
|
28
29
|
case "end":
|
|
29
30
|
return _context.stop();
|
|
30
31
|
}
|
|
@@ -36,6 +37,13 @@ function getSchemaFromCache(pageId, mock) {
|
|
|
36
37
|
if (!pageId) {
|
|
37
38
|
return null;
|
|
38
39
|
}
|
|
40
|
+
mock = getMock(mock);
|
|
39
41
|
var key = mock ? pageId + "_mock" : pageId;
|
|
40
42
|
return _cache.schema.get(key);
|
|
43
|
+
}
|
|
44
|
+
function getMock(mock) {
|
|
45
|
+
if (typeof mock !== "boolean") {
|
|
46
|
+
mock = !!window.__mock;
|
|
47
|
+
}
|
|
48
|
+
return mock;
|
|
41
49
|
}
|
|
@@ -13,10 +13,10 @@ function PageLoadSchema(props) {
|
|
|
13
13
|
var pageId = props.pageId,
|
|
14
14
|
children = props.children;
|
|
15
15
|
var cache = (0, _schemaApi.getSchemaFromCache)(pageId);
|
|
16
|
-
var _useState = (0, _react.useState)(
|
|
16
|
+
var _useState = (0, _react.useState)(!cache),
|
|
17
17
|
loading = _useState[0],
|
|
18
18
|
setLoading = _useState[1];
|
|
19
|
-
var _useState2 = (0, _react.useState)(),
|
|
19
|
+
var _useState2 = (0, _react.useState)(cache === null || cache === void 0 ? void 0 : cache.data),
|
|
20
20
|
schema = _useState2[0],
|
|
21
21
|
setSchema = _useState2[1];
|
|
22
22
|
var _useState3 = (0, _react.useState)(),
|
|
@@ -43,7 +43,7 @@ function PageLoadSchema(props) {
|
|
|
43
43
|
}
|
|
44
44
|
}, []);
|
|
45
45
|
if (cache) {
|
|
46
|
-
return children(
|
|
46
|
+
return children(cache.data);
|
|
47
47
|
}
|
|
48
48
|
if (loading) {
|
|
49
49
|
return /*#__PURE__*/React.createElement(_pageLoading.PageLoading, {
|
|
@@ -41,8 +41,9 @@ function renderElement(options) {
|
|
|
41
41
|
_onClose === null || _onClose === void 0 ? void 0 : _onClose();
|
|
42
42
|
}
|
|
43
43
|
}));
|
|
44
|
+
console.log("渲染", container, root, element);
|
|
44
45
|
root.render(element);
|
|
45
|
-
case
|
|
46
|
+
case 8:
|
|
46
47
|
case "end":
|
|
47
48
|
return _context.stop();
|
|
48
49
|
}
|