@zhubangyun/lowcode-core 5.6.214 → 5.8.110
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/page-loading/index.less +14 -12
- package/es/index.d.ts +2 -1
- package/es/index.js +13 -3
- package/es/style.js +2 -1
- package/es/utils/api/form-api.d.ts +1 -0
- package/es/utils/api/form-api.js +49 -66
- package/es/utils/api/form-api.utils.d.ts +7 -0
- package/es/utils/api/form-api.utils.js +128 -0
- package/es/utils/api/rest-api.d.ts +3 -0
- package/es/utils/api/rest-api.js +120 -13
- package/es/utils/cache/schema.js +15 -3
- package/es/utils/data/index.d.ts +1 -0
- package/es/utils/data/index.js +20 -0
- package/es/utils/page/page-form-data-manager.d.ts +7 -1
- package/es/utils/page/page-form-data-manager.js +10 -8
- package/es/utils/page/page-layout.js +9 -4
- package/es/utils/page/page-load-schema.js +2 -1
- package/lib/components/page-loading/index.less +14 -12
- package/lib/index.d.ts +2 -1
- package/lib/index.js +15 -3
- package/lib/style.js +2 -1
- package/lib/utils/api/form-api.d.ts +1 -0
- package/lib/utils/api/form-api.js +52 -69
- package/lib/utils/api/form-api.utils.d.ts +7 -0
- package/lib/utils/api/form-api.utils.js +136 -0
- package/lib/utils/api/rest-api.d.ts +3 -0
- package/lib/utils/api/rest-api.js +120 -13
- package/lib/utils/cache/schema.js +15 -3
- package/lib/utils/data/index.d.ts +1 -0
- package/lib/utils/data/index.js +24 -0
- package/lib/utils/page/page-form-data-manager.d.ts +7 -1
- package/lib/utils/page/page-form-data-manager.js +10 -8
- package/lib/utils/page/page-layout.js +9 -4
- package/lib/utils/page/page-load-schema.js +2 -1
- package/package.json +1 -1
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export function transformerId(value) {
|
|
2
|
+
if (value == null) {
|
|
3
|
+
return null;
|
|
4
|
+
}
|
|
5
|
+
if (Array.isArray(value)) {
|
|
6
|
+
return value.map(transformerId).filter(function (value) {
|
|
7
|
+
return !!value;
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
if (typeof value == "object") {
|
|
11
|
+
return (value === null || value === void 0 ? void 0 : value.id) || (value === null || value === void 0 ? void 0 : value.value) || value;
|
|
12
|
+
}
|
|
13
|
+
if (typeof value == "string") {
|
|
14
|
+
return value;
|
|
15
|
+
}
|
|
16
|
+
if (typeof value == "number") {
|
|
17
|
+
return value;
|
|
18
|
+
}
|
|
19
|
+
return (value === null || value === void 0 ? void 0 : value.id) || value.value || value;
|
|
20
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PageLayoutType } from "./page-layout";
|
|
2
|
-
export declare type PageFormDataManagerModeType = "dataManager" | "selectOne" | "selectMore";
|
|
2
|
+
export declare type PageFormDataManagerModeType = "associationField" | "dataManager" | "selectOne" | "selectMore";
|
|
3
3
|
export interface ShowPageFormDataManagerProps {
|
|
4
4
|
container?: HTMLDivElement;
|
|
5
5
|
layout?: PageLayoutType;
|
|
@@ -8,6 +8,12 @@ export interface ShowPageFormDataManagerProps {
|
|
|
8
8
|
fieldId?: string;
|
|
9
9
|
};
|
|
10
10
|
mode?: PageFormDataManagerModeType;
|
|
11
|
+
extraProps?: any;
|
|
11
12
|
onClose?: () => void | Promise<void>;
|
|
13
|
+
onSearch?: (params: any[]) => void | Promise<void>;
|
|
14
|
+
onLoadData?: (response: {
|
|
15
|
+
data: any[];
|
|
16
|
+
total: number;
|
|
17
|
+
}) => void | Promise<void>;
|
|
12
18
|
}
|
|
13
19
|
export declare function showFormDataManager(options: ShowPageFormDataManagerProps): Promise<any | any[]>;
|
|
@@ -22,7 +22,7 @@ function _showFormDataManager() {
|
|
|
22
22
|
case 0:
|
|
23
23
|
return _context3.abrupt("return", new Promise( /*#__PURE__*/function () {
|
|
24
24
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(resolve, reject) {
|
|
25
|
-
var container, onClose, restProps, unmount, _options$form, paths, mode,
|
|
25
|
+
var container, onClose, restProps, unmount, _options$form, paths, mode, _params, url, page;
|
|
26
26
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
27
27
|
while (1) switch (_context2.prev = _context2.next) {
|
|
28
28
|
case 0:
|
|
@@ -38,8 +38,8 @@ function _showFormDataManager() {
|
|
|
38
38
|
}
|
|
39
39
|
paths = window.location.pathname.split("/");
|
|
40
40
|
mode = options.mode;
|
|
41
|
-
|
|
42
|
-
url = "/" + paths[1] + "/" + paths[2] + "/" + ((_options$form = options.form) === null || _options$form === void 0 ? void 0 : _options$form.id) + "/" + mode + "?" +
|
|
41
|
+
_params = new URLSearchParams();
|
|
42
|
+
url = "/" + paths[1] + "/" + paths[2] + "/" + ((_options$form = options.form) === null || _options$form === void 0 ? void 0 : _options$form.id) + "/" + mode + "?" + _params.toString();
|
|
43
43
|
_context2.next = 10;
|
|
44
44
|
return openPage(url, url);
|
|
45
45
|
case 10:
|
|
@@ -59,18 +59,19 @@ function _showFormDataManager() {
|
|
|
59
59
|
while (1) switch (_context.prev = _context.next) {
|
|
60
60
|
case 0:
|
|
61
61
|
resolve(null);
|
|
62
|
+
setTimeout(function () {
|
|
63
|
+
ReactDOM.unmountComponentAtNode(container);
|
|
64
|
+
}, 10);
|
|
62
65
|
if (unmount) {
|
|
63
66
|
//等待动画结束
|
|
64
67
|
setTimeout(function () {
|
|
65
68
|
var _container;
|
|
66
|
-
//取消挂载
|
|
67
|
-
ReactDOM.unmountComponentAtNode(container);
|
|
68
69
|
//移除
|
|
69
70
|
(_container = container) === null || _container === void 0 ? void 0 : _container.remove();
|
|
70
|
-
},
|
|
71
|
+
}, 100);
|
|
71
72
|
}
|
|
72
73
|
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
73
|
-
case
|
|
74
|
+
case 4:
|
|
74
75
|
case "end":
|
|
75
76
|
return _context.stop();
|
|
76
77
|
}
|
|
@@ -116,8 +117,9 @@ var FormDataManagerRender = /*#__PURE__*/function (_Component) {
|
|
|
116
117
|
onSelectOk = _this$props.onSelectOk,
|
|
117
118
|
onClose = _this$props.onClose,
|
|
118
119
|
restProps = _objectWithoutPropertiesLoose(_this$props, _excluded);
|
|
120
|
+
|
|
119
121
|
// @ts-ignore
|
|
120
|
-
restProps.layout = layout || "
|
|
122
|
+
restProps.layout = layout || "modal";
|
|
121
123
|
// @ts-ignore
|
|
122
124
|
restProps.onClose = function () {
|
|
123
125
|
var _self$layoutRef;
|
|
@@ -15,12 +15,14 @@ export var PageLayout = /*#__PURE__*/function (_Component) {
|
|
|
15
15
|
});
|
|
16
16
|
};
|
|
17
17
|
_this.getWith = function () {
|
|
18
|
-
return Math.min(window.innerWidth,
|
|
18
|
+
return Math.min(window.innerWidth, 1600);
|
|
19
19
|
};
|
|
20
20
|
_this.handleResize = function () {
|
|
21
|
-
_this.
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
if (_this.props.layout == "drawer") {
|
|
22
|
+
_this.setState({
|
|
23
|
+
width: _this.getWith()
|
|
24
|
+
});
|
|
25
|
+
}
|
|
24
26
|
};
|
|
25
27
|
_this.state.width = _this.getWith();
|
|
26
28
|
return _this;
|
|
@@ -44,6 +46,7 @@ export var PageLayout = /*#__PURE__*/function (_Component) {
|
|
|
44
46
|
onClose: this.close,
|
|
45
47
|
footer: false,
|
|
46
48
|
closable: false,
|
|
49
|
+
style: {},
|
|
47
50
|
styles: {
|
|
48
51
|
header: {
|
|
49
52
|
display: "none"
|
|
@@ -58,6 +61,8 @@ export var PageLayout = /*#__PURE__*/function (_Component) {
|
|
|
58
61
|
maskClosable: false
|
|
59
62
|
};
|
|
60
63
|
if (layout == "modal") {
|
|
64
|
+
restProps.style.top = 64;
|
|
65
|
+
restProps.styles.body.maxHeight = "calc(100vh - 180px)";
|
|
61
66
|
return /*#__PURE__*/React.createElement(_Modal, restProps, children);
|
|
62
67
|
} else if (layout == "drawer") {
|
|
63
68
|
return /*#__PURE__*/React.createElement(_Drawer, restProps, children);
|
|
@@ -1,28 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
height: 100vh;
|
|
5
|
-
top: 0;
|
|
6
|
-
left: 0;
|
|
1
|
+
.page-loading {
|
|
2
|
+
width: 100%;
|
|
3
|
+
height: 100%;
|
|
7
4
|
z-index: 10;
|
|
8
|
-
background:
|
|
5
|
+
background: rgba(255, 255, 255, 0.5);
|
|
9
6
|
display: flex;
|
|
10
7
|
justify-content: center;
|
|
11
8
|
align-items: center;
|
|
12
9
|
overflow: hidden;
|
|
13
10
|
}
|
|
14
11
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
12
|
+
|
|
13
|
+
#fullscreen-loading {
|
|
14
|
+
position: fixed;
|
|
15
|
+
width: 100vw;
|
|
16
|
+
height: 100vh;
|
|
17
|
+
top: 0;
|
|
18
|
+
left: 0;
|
|
19
|
+
z-index: 100000;
|
|
20
|
+
background: rgba(255, 255, 255, 0.5);
|
|
20
21
|
display: flex;
|
|
21
22
|
justify-content: center;
|
|
22
23
|
align-items: center;
|
|
23
24
|
overflow: hidden;
|
|
24
25
|
}
|
|
25
26
|
|
|
27
|
+
|
|
26
28
|
.atom-spinner, .atom-spinner * {
|
|
27
29
|
box-sizing: border-box;
|
|
28
30
|
}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import "./index.less";
|
|
2
2
|
import utils from "./utils";
|
|
3
|
+
import * as lodash from "lodash";
|
|
3
4
|
export { LoadMaterials } from "./components/load-materials";
|
|
4
5
|
export { PageLoading } from "./components/page-loading";
|
|
5
6
|
export { RestApi, RestFormApi, apiRequest } from "./utils/api";
|
|
6
7
|
export { Layout } from "./components/layout";
|
|
7
8
|
export { ReactRender } from "./components/react-render";
|
|
8
|
-
export { utils };
|
|
9
|
+
export { utils, lodash };
|
package/lib/index.js
CHANGED
|
@@ -2,12 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
exports.__esModule = true;
|
|
5
|
-
exports.apiRequest = exports.RestFormApi = exports.RestApi = exports.PageLoading = exports.LoadMaterials = exports.Layout = void 0;
|
|
5
|
+
exports.lodash = exports.apiRequest = exports.RestFormApi = exports.RestApi = exports.PageLoading = exports.LoadMaterials = exports.Layout = void 0;
|
|
6
6
|
require("./index.less");
|
|
7
7
|
var _utils = _interopRequireDefault(require("./utils"));
|
|
8
8
|
exports.utils = _utils["default"];
|
|
9
9
|
var _reactRender = require("./components/react-render");
|
|
10
10
|
exports.ReactRender = _reactRender.ReactRender;
|
|
11
|
+
var lodash = _interopRequireWildcard(require("lodash"));
|
|
12
|
+
exports.lodash = lodash;
|
|
11
13
|
var _loadMaterials = require("./components/load-materials");
|
|
12
14
|
exports.LoadMaterials = _loadMaterials.LoadMaterials;
|
|
13
15
|
var _pageLoading = require("./components/page-loading");
|
|
@@ -18,7 +20,17 @@ exports.RestFormApi = _api.RestFormApi;
|
|
|
18
20
|
exports.apiRequest = _api.apiRequest;
|
|
19
21
|
var _layout = require("./components/layout");
|
|
20
22
|
exports.Layout = _layout.Layout;
|
|
23
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
24
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
|
21
25
|
// @ts-ignore
|
|
22
|
-
window.
|
|
26
|
+
window.__ReactRender = _reactRender.ReactRender;
|
|
23
27
|
// @ts-ignore
|
|
24
|
-
window.
|
|
28
|
+
if (window._) {
|
|
29
|
+
// @ts-ignore
|
|
30
|
+
window.lodash = window._;
|
|
31
|
+
}
|
|
32
|
+
// @ts-ignore
|
|
33
|
+
if (!window.utils) {
|
|
34
|
+
// @ts-ignore
|
|
35
|
+
window.utils = _utils["default"];
|
|
36
|
+
}
|
package/lib/style.js
CHANGED
|
@@ -14,4 +14,5 @@ export declare class RestFormApi<DataType> extends RestApi<DataType> {
|
|
|
14
14
|
save(data: DataType, options?: BaseRequestOptions<DataType>): Promise<OneResult<DataType>>;
|
|
15
15
|
create(data: DataType, options?: BaseRequestOptions<DataType>): Promise<OneResult<DataType>>;
|
|
16
16
|
update(id: string, data: DataType, options?: BaseRequestOptions<DataType>): Promise<OneResult<DataType>>;
|
|
17
|
+
serviceUpdate(data: DataType, options?: BaseRequestOptions<DataType>): Promise<import("axios").AxiosResponse<any, any>>;
|
|
17
18
|
}
|
|
@@ -8,9 +8,7 @@ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/
|
|
|
8
8
|
var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));
|
|
9
9
|
var _restApi = require("./rest-api");
|
|
10
10
|
var _index = require("./index");
|
|
11
|
-
|
|
12
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
13
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
11
|
+
var _formApi = require("./form-api.utils");
|
|
14
12
|
var RestFormApi = exports.RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
15
13
|
function RestFormApi(formId, fieldId, mock) {
|
|
16
14
|
var _this;
|
|
@@ -30,7 +28,7 @@ var RestFormApi = exports.RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
|
30
28
|
_proto.initialize = /*#__PURE__*/function () {
|
|
31
29
|
var _initialize = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
|
|
32
30
|
var _this2 = this;
|
|
33
|
-
var res;
|
|
31
|
+
var _this$schema$props, res;
|
|
34
32
|
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
35
33
|
while (1) switch (_context.prev = _context.next) {
|
|
36
34
|
case 0:
|
|
@@ -47,7 +45,7 @@ var RestFormApi = exports.RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
|
47
45
|
res = _context.sent;
|
|
48
46
|
this.schema = res.data;
|
|
49
47
|
this.initialized = !!this.schema;
|
|
50
|
-
this.title = this.schema.label;
|
|
48
|
+
this.title = (_this$schema$props = this.schema.props) === null || _this$schema$props === void 0 ? void 0 : _this$schema$props.label;
|
|
51
49
|
if (this.fieldId) {
|
|
52
50
|
JSON.stringify(this.schema, function (key, value) {
|
|
53
51
|
var _value$props;
|
|
@@ -95,6 +93,7 @@ var RestFormApi = exports.RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
|
95
93
|
return this.initialize();
|
|
96
94
|
case 2:
|
|
97
95
|
config.params = config.params || {};
|
|
96
|
+
config.params.description = "" + this.title;
|
|
98
97
|
config.params.formId = this.formId;
|
|
99
98
|
if (this.fieldId) {
|
|
100
99
|
config.params.fieldId = this.fieldId;
|
|
@@ -102,7 +101,7 @@ var RestFormApi = exports.RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
|
102
101
|
if (this.mock) {
|
|
103
102
|
config.params.mock = this.mock;
|
|
104
103
|
}
|
|
105
|
-
case
|
|
104
|
+
case 7:
|
|
106
105
|
case "end":
|
|
107
106
|
return _context2.stop();
|
|
108
107
|
}
|
|
@@ -115,17 +114,35 @@ var RestFormApi = exports.RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
|
115
114
|
}();
|
|
116
115
|
_proto.search = /*#__PURE__*/function () {
|
|
117
116
|
var _search = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(params) {
|
|
118
|
-
var
|
|
117
|
+
var _params, _params2;
|
|
118
|
+
var config, res;
|
|
119
119
|
return _regenerator["default"].wrap(function _callee3$(_context3) {
|
|
120
120
|
while (1) switch (_context3.prev = _context3.next) {
|
|
121
121
|
case 0:
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
122
|
+
params = params || {};
|
|
123
|
+
config = {
|
|
124
|
+
params: {
|
|
125
|
+
description: this.title + "\u67E5\u8BE2",
|
|
126
|
+
formId: this.formId,
|
|
127
|
+
fieldId: this.fieldId
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
_context3.next = 4;
|
|
131
|
+
return this.handleRequestConfig(config);
|
|
132
|
+
case 4:
|
|
133
|
+
params.filterRules = (0, _formApi.handleFilterRules)(((_params = params) === null || _params === void 0 ? void 0 : _params.filterRules) || [], {
|
|
134
|
+
filterNullValue: false
|
|
135
|
+
});
|
|
136
|
+
params.searchFields = (0, _formApi.handleFilterRules)(((_params2 = params) === null || _params2 === void 0 ? void 0 : _params2.searchFields) || [], {
|
|
137
|
+
filterNullValue: true
|
|
138
|
+
});
|
|
139
|
+
_context3.next = 8;
|
|
140
|
+
return this.request.post("search", params, config);
|
|
141
|
+
case 8:
|
|
125
142
|
res = _context3.sent;
|
|
126
|
-
|
|
143
|
+
(0, _formApi.assembleAssociationField)(res.data, res.refs);
|
|
127
144
|
return _context3.abrupt("return", res);
|
|
128
|
-
case
|
|
145
|
+
case 11:
|
|
129
146
|
case "end":
|
|
130
147
|
return _context3.stop();
|
|
131
148
|
}
|
|
@@ -146,9 +163,10 @@ var RestFormApi = exports.RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
|
146
163
|
return _RestApi.prototype.getById.call(this, id, options);
|
|
147
164
|
case 2:
|
|
148
165
|
res = _context4.sent;
|
|
149
|
-
|
|
166
|
+
(0, _formApi.assembleAssociationField)(res.data, res.refs);
|
|
167
|
+
console.debug("formApi.getById", res);
|
|
150
168
|
return _context4.abrupt("return", res);
|
|
151
|
-
case
|
|
169
|
+
case 6:
|
|
152
170
|
case "end":
|
|
153
171
|
return _context4.stop();
|
|
154
172
|
}
|
|
@@ -164,7 +182,7 @@ var RestFormApi = exports.RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
|
164
182
|
return _regenerator["default"].wrap(function _callee5$(_context5) {
|
|
165
183
|
while (1) switch (_context5.prev = _context5.next) {
|
|
166
184
|
case 0:
|
|
167
|
-
return _context5.abrupt("return", _RestApi.prototype.save.call(this, convertSaveData(data), options));
|
|
185
|
+
return _context5.abrupt("return", _RestApi.prototype.save.call(this, (0, _formApi.convertSaveData)(data), options));
|
|
168
186
|
case 1:
|
|
169
187
|
case "end":
|
|
170
188
|
return _context5.stop();
|
|
@@ -181,7 +199,7 @@ var RestFormApi = exports.RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
|
181
199
|
return _regenerator["default"].wrap(function _callee6$(_context6) {
|
|
182
200
|
while (1) switch (_context6.prev = _context6.next) {
|
|
183
201
|
case 0:
|
|
184
|
-
return _context6.abrupt("return", _RestApi.prototype.create.call(this, convertSaveData(data), options));
|
|
202
|
+
return _context6.abrupt("return", _RestApi.prototype.create.call(this, (0, _formApi.convertSaveData)(data), options));
|
|
185
203
|
case 1:
|
|
186
204
|
case "end":
|
|
187
205
|
return _context6.stop();
|
|
@@ -198,7 +216,7 @@ var RestFormApi = exports.RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
|
198
216
|
return _regenerator["default"].wrap(function _callee7$(_context7) {
|
|
199
217
|
while (1) switch (_context7.prev = _context7.next) {
|
|
200
218
|
case 0:
|
|
201
|
-
return _context7.abrupt("return", _RestApi.prototype.update.call(this, id, convertSaveData(data), options));
|
|
219
|
+
return _context7.abrupt("return", _RestApi.prototype.update.call(this, id, (0, _formApi.convertSaveData)(data), options));
|
|
202
220
|
case 1:
|
|
203
221
|
case "end":
|
|
204
222
|
return _context7.stop();
|
|
@@ -210,57 +228,22 @@ var RestFormApi = exports.RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
|
210
228
|
}
|
|
211
229
|
return update;
|
|
212
230
|
}();
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
function
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
}));
|
|
223
|
-
}
|
|
224
|
-
function assembleAssociationField(data, refs) {
|
|
225
|
-
if (!data || !refs) return;
|
|
226
|
-
var fieldIdDataMap = new Map();
|
|
227
|
-
for (var _iterator = _createForOfIteratorHelperLoose(refs), _step; !(_step = _iterator()).done;) {
|
|
228
|
-
var ref = _step.value;
|
|
229
|
-
var dataMap = new Map();
|
|
230
|
-
for (var _iterator2 = _createForOfIteratorHelperLoose(ref.data), _step2; !(_step2 = _iterator2()).done;) {
|
|
231
|
-
var datum = _step2.value;
|
|
232
|
-
dataMap.set(datum.id, datum);
|
|
233
|
-
}
|
|
234
|
-
for (var _iterator3 = _createForOfIteratorHelperLoose(ref.fieldIds), _step3; !(_step3 = _iterator3()).done;) {
|
|
235
|
-
var fieldId = _step3.value;
|
|
236
|
-
fieldIdDataMap.set(fieldId + "Id", dataMap);
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
var jsonText = JSON.stringify(data, function (key, value) {
|
|
240
|
-
if (value !== null && value !== void 0 && value.id) {
|
|
241
|
-
var _loop = function _loop() {
|
|
242
|
-
var fieldIdName = _Object$keys[_i];
|
|
243
|
-
var dataMap = fieldIdDataMap.get(fieldIdName);
|
|
244
|
-
if (dataMap) {
|
|
245
|
-
var fieldIdValue = value[fieldIdName];
|
|
246
|
-
var fieldValue = null;
|
|
247
|
-
if (Array.isArray(fieldIdValue)) {
|
|
248
|
-
fieldValue = fieldIdValue.map(function (id) {
|
|
249
|
-
return dataMap.get(id);
|
|
250
|
-
}).filter(function (v) {
|
|
251
|
-
return !!v;
|
|
252
|
-
});
|
|
253
|
-
} else if (typeof fieldIdValue == "string") {
|
|
254
|
-
fieldValue = dataMap.get(fieldIdValue);
|
|
255
|
-
}
|
|
256
|
-
value[fieldIdName.slice(0, -2)] = fieldValue;
|
|
231
|
+
_proto.serviceUpdate = /*#__PURE__*/function () {
|
|
232
|
+
var _serviceUpdate = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee8(data, options) {
|
|
233
|
+
return _regenerator["default"].wrap(function _callee8$(_context8) {
|
|
234
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
235
|
+
case 0:
|
|
236
|
+
return _context8.abrupt("return", this.request.post("serviceUpdate", data));
|
|
237
|
+
case 1:
|
|
238
|
+
case "end":
|
|
239
|
+
return _context8.stop();
|
|
257
240
|
}
|
|
258
|
-
};
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
241
|
+
}, _callee8, this);
|
|
242
|
+
}));
|
|
243
|
+
function serviceUpdate(_x12, _x13) {
|
|
244
|
+
return _serviceUpdate.apply(this, arguments);
|
|
262
245
|
}
|
|
263
|
-
return
|
|
264
|
-
});
|
|
265
|
-
return
|
|
266
|
-
}
|
|
246
|
+
return serviceUpdate;
|
|
247
|
+
}();
|
|
248
|
+
return RestFormApi;
|
|
249
|
+
}(_restApi.RestApi);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { BaseType, FilterRule, Refs } from "./rest-api";
|
|
2
|
+
export declare function convertSaveData(data: any): any;
|
|
3
|
+
export declare function assembleAssociationField(data: BaseType | BaseType[], refs?: Refs): void;
|
|
4
|
+
export declare function assembleAssociationFieldValue(data: BaseType | BaseType[], fieldIdDataMap: Map<string, Map<string, BaseType>>, prefixKey?: string): void;
|
|
5
|
+
export declare function handleFilterRules(filters: FilterRule[], options: {
|
|
6
|
+
filterNullValue: boolean;
|
|
7
|
+
}): any;
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
exports.__esModule = true;
|
|
5
|
+
exports.assembleAssociationField = assembleAssociationField;
|
|
6
|
+
exports.assembleAssociationFieldValue = assembleAssociationFieldValue;
|
|
7
|
+
exports.convertSaveData = convertSaveData;
|
|
8
|
+
exports.handleFilterRules = handleFilterRules;
|
|
9
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
|
+
var _data = require("../data");
|
|
11
|
+
function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
12
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
13
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
14
|
+
function convertSaveData(data) {
|
|
15
|
+
if (!data) return data;
|
|
16
|
+
return JSON.parse(JSON.stringify(data, function (key, value) {
|
|
17
|
+
if (key == "parent") {
|
|
18
|
+
return value === null || value === void 0 ? void 0 : value.id;
|
|
19
|
+
}
|
|
20
|
+
return value;
|
|
21
|
+
}));
|
|
22
|
+
}
|
|
23
|
+
function assembleAssociationField(data, refs) {
|
|
24
|
+
if (!data || !refs) return;
|
|
25
|
+
var fieldIdDataMap = new Map();
|
|
26
|
+
for (var _iterator = _createForOfIteratorHelperLoose(refs), _step; !(_step = _iterator()).done;) {
|
|
27
|
+
var ref = _step.value;
|
|
28
|
+
var dataMap = new Map();
|
|
29
|
+
for (var _iterator4 = _createForOfIteratorHelperLoose(ref.data), _step4; !(_step4 = _iterator4()).done;) {
|
|
30
|
+
var datum = _step4.value;
|
|
31
|
+
dataMap.set(datum.id, datum);
|
|
32
|
+
}
|
|
33
|
+
for (var _iterator5 = _createForOfIteratorHelperLoose(ref.fieldIds), _step5; !(_step5 = _iterator5()).done;) {
|
|
34
|
+
var fieldId = _step5.value;
|
|
35
|
+
fieldIdDataMap.set(fieldId + "Id", dataMap);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
//组装refs的关联属性
|
|
39
|
+
for (var _iterator2 = _createForOfIteratorHelperLoose(refs), _step2; !(_step2 = _iterator2()).done;) {
|
|
40
|
+
var _ref = _step2.value;
|
|
41
|
+
var key = _ref.form.id;
|
|
42
|
+
if (_ref.form.fieldId) {
|
|
43
|
+
key += "." + _ref.form.fieldId;
|
|
44
|
+
}
|
|
45
|
+
assembleAssociationFieldValue(_ref.data, fieldIdDataMap, key);
|
|
46
|
+
}
|
|
47
|
+
function loopAssembleAssociation(values) {
|
|
48
|
+
if (!Array.isArray(values)) {
|
|
49
|
+
if (values !== null && values !== void 0 && values.id) {
|
|
50
|
+
loopAssembleAssociation([values]);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
if (Array.isArray(values)) {
|
|
54
|
+
var _values$;
|
|
55
|
+
if ((_values$ = values[0]) !== null && _values$ !== void 0 && _values$.id) {
|
|
56
|
+
assembleAssociationFieldValue(values, fieldIdDataMap);
|
|
57
|
+
//处理子表
|
|
58
|
+
for (var _iterator3 = _createForOfIteratorHelperLoose(values), _step3; !(_step3 = _iterator3()).done;) {
|
|
59
|
+
var value = _step3.value;
|
|
60
|
+
for (var _i = 0, _Object$values = Object.values(value); _i < _Object$values.length; _i++) {
|
|
61
|
+
var subValues = _Object$values[_i];
|
|
62
|
+
if (Array.isArray(subValues)) {
|
|
63
|
+
loopAssembleAssociation(subValues);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
loopAssembleAssociation(data);
|
|
71
|
+
}
|
|
72
|
+
function assembleAssociationFieldValue(data, fieldIdDataMap, prefixKey) {
|
|
73
|
+
var arrayData = [];
|
|
74
|
+
if (Array.isArray(data)) {
|
|
75
|
+
arrayData = data;
|
|
76
|
+
} else if (typeof data == "object") {
|
|
77
|
+
arrayData = [data];
|
|
78
|
+
}
|
|
79
|
+
for (var _iterator6 = _createForOfIteratorHelperLoose(arrayData), _step6; !(_step6 = _iterator6()).done;) {
|
|
80
|
+
var item = _step6.value;
|
|
81
|
+
var _loop = function _loop() {
|
|
82
|
+
var fieldIdName = _Object$keys[_i2];
|
|
83
|
+
var fieldIdKey = fieldIdName;
|
|
84
|
+
if (prefixKey) {
|
|
85
|
+
fieldIdKey = prefixKey + "." + fieldIdName;
|
|
86
|
+
}
|
|
87
|
+
var dataMap = fieldIdDataMap.get(fieldIdKey);
|
|
88
|
+
if (dataMap) {
|
|
89
|
+
var fieldIdValue = item[fieldIdName];
|
|
90
|
+
var fieldValue = null;
|
|
91
|
+
if (Array.isArray(fieldIdValue)) {
|
|
92
|
+
// @ts-ignore
|
|
93
|
+
fieldValue = fieldIdValue.map(function (id) {
|
|
94
|
+
return dataMap.get(id);
|
|
95
|
+
}).filter(function (v) {
|
|
96
|
+
return !!v;
|
|
97
|
+
});
|
|
98
|
+
} else if (typeof fieldIdValue == "string") {
|
|
99
|
+
fieldValue = dataMap.get(fieldIdValue);
|
|
100
|
+
}
|
|
101
|
+
item[fieldIdName.slice(0, -2)] = fieldValue;
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
for (var _i2 = 0, _Object$keys = Object.keys(item); _i2 < _Object$keys.length; _i2++) {
|
|
105
|
+
_loop();
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
function handleFilterRules(filters, options) {
|
|
110
|
+
var filterNullValue = options.filterNullValue;
|
|
111
|
+
if (Array.isArray(filters)) {
|
|
112
|
+
var cloneRules = filters.filter(function (rule) {
|
|
113
|
+
return !!rule;
|
|
114
|
+
}).map(function (rule) {
|
|
115
|
+
return (0, _extends2["default"])({}, rule, {
|
|
116
|
+
value: (0, _data.transformerId)(rule.value),
|
|
117
|
+
rules: handleFilterRules(rule.rules || [], options)
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
if (filterNullValue) {
|
|
121
|
+
cloneRules = cloneRules.filter(function (rule) {
|
|
122
|
+
if (rule.value == null) {
|
|
123
|
+
if (rule.operator != "isNull" && rule.operator != "isNotNull") {
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return true;
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
if (cloneRules.length == 0) {
|
|
131
|
+
return undefined;
|
|
132
|
+
}
|
|
133
|
+
} else {
|
|
134
|
+
return undefined;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
@@ -22,6 +22,8 @@ export interface RestSearchParams {
|
|
|
22
22
|
page?: number;
|
|
23
23
|
pageSize?: number;
|
|
24
24
|
filterRules?: FilterRule[];
|
|
25
|
+
searchFields?: FilterRule[];
|
|
26
|
+
orderRules?: any[];
|
|
25
27
|
}
|
|
26
28
|
export declare abstract class BaseRestApi<DataType> {
|
|
27
29
|
uri: string;
|
|
@@ -49,6 +51,7 @@ export declare abstract class BaseRestApi<DataType> {
|
|
|
49
51
|
* 通过id删除
|
|
50
52
|
*/
|
|
51
53
|
deleteById(id: string, options?: BaseRequestOptions<DataType>): Promise<OneResult<DataType>>;
|
|
54
|
+
delete(data: any | any[], options?: BaseRequestOptions<DataType>): Promise<OneResult<DataType>>;
|
|
52
55
|
private showError;
|
|
53
56
|
}
|
|
54
57
|
export declare class RestApi<DataType> extends BaseRestApi<DataType> {
|