@zhubangyun/lowcode-core 5.5.85 → 5.6.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/page-loading/index.js +2 -1
- package/es/index.less +3 -0
- package/es/utils/api/form-api.d.ts +6 -1
- package/es/utils/api/form-api.js +153 -1
- package/es/utils/api/rest-api.d.ts +10 -0
- package/es/utils/cache/index.js +7 -3
- package/es/utils/cache/schema.js +232 -12
- package/es/utils/page/index.d.ts +1 -0
- package/es/utils/page/index.js +1 -0
- package/es/utils/page/page-form-data-manager.d.ts +15 -0
- package/es/utils/page/page-form-data-manager.js +132 -0
- package/lib/components/page-loading/index.js +2 -1
- package/lib/index.less +3 -0
- package/lib/utils/api/form-api.d.ts +6 -1
- package/lib/utils/api/form-api.js +153 -1
- package/lib/utils/api/rest-api.d.ts +10 -0
- package/lib/utils/cache/index.js +7 -3
- package/lib/utils/cache/schema.js +232 -13
- package/lib/utils/page/index.d.ts +1 -0
- package/lib/utils/page/index.js +3 -1
- package/lib/utils/page/page-form-data-manager.d.ts +15 -0
- package/lib/utils/page/page-form-data-manager.js +139 -0
- package/package.json +1 -1
- package/es/utils/api/form-instance.d.ts +0 -26
- package/es/utils/api/form-instance.js +0 -100
- package/lib/utils/api/form-instance.d.ts +0 -26
- package/lib/utils/api/form-instance.js +0 -105
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import "./index.less";
|
|
2
2
|
export function PageLoading(props) {
|
|
3
3
|
var loading = props.loading,
|
|
4
|
-
background = props.background,
|
|
4
|
+
_props$background = props.background,
|
|
5
|
+
background = _props$background === void 0 ? "#f1f1f1" : _props$background,
|
|
5
6
|
children = props.children;
|
|
6
7
|
return /*#__PURE__*/React.createElement("div", {
|
|
7
8
|
className: "page-loading-wrapper",
|
package/es/index.less
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RestApi } from "./rest-api";
|
|
1
|
+
import { BaseRequestOptions, ManyResult, OneResult, RestApi, RestSearchParams } from "./rest-api";
|
|
2
2
|
import { AxiosRequestConfig } from "axios";
|
|
3
3
|
export declare class RestFormApi<DataType> extends RestApi<DataType> {
|
|
4
4
|
private readonly formId;
|
|
@@ -9,4 +9,9 @@ export declare class RestFormApi<DataType> extends RestApi<DataType> {
|
|
|
9
9
|
constructor(formId: string, fieldId?: string, mock?: boolean);
|
|
10
10
|
initialize(): Promise<boolean>;
|
|
11
11
|
handleRequestConfig(config: AxiosRequestConfig): Promise<void>;
|
|
12
|
+
search(params?: RestSearchParams): Promise<ManyResult<DataType>>;
|
|
13
|
+
getById(id: string, options?: BaseRequestOptions<DataType>): Promise<OneResult<DataType>>;
|
|
14
|
+
save(data: DataType, options?: BaseRequestOptions<DataType>): Promise<OneResult<DataType>>;
|
|
15
|
+
create(data: DataType, options?: BaseRequestOptions<DataType>): Promise<OneResult<DataType>>;
|
|
16
|
+
update(id: string, data: DataType, options?: BaseRequestOptions<DataType>): Promise<OneResult<DataType>>;
|
|
12
17
|
}
|
package/es/utils/api/form-api.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
2
|
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
|
|
3
|
+
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."); }
|
|
4
|
+
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); }
|
|
5
|
+
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; }
|
|
3
6
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
4
7
|
import { RestApi } from "./rest-api";
|
|
5
8
|
import { getSchema } from "./index";
|
|
@@ -105,5 +108,154 @@ export var RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
|
105
108
|
}
|
|
106
109
|
return handleRequestConfig;
|
|
107
110
|
}();
|
|
111
|
+
_proto.search = /*#__PURE__*/function () {
|
|
112
|
+
var _search = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(params) {
|
|
113
|
+
var res;
|
|
114
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
115
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
116
|
+
case 0:
|
|
117
|
+
_context3.next = 2;
|
|
118
|
+
return _RestApi.prototype.search.call(this, params);
|
|
119
|
+
case 2:
|
|
120
|
+
res = _context3.sent;
|
|
121
|
+
res.data = assembleAssociationField(res.data, res.refs);
|
|
122
|
+
return _context3.abrupt("return", res);
|
|
123
|
+
case 5:
|
|
124
|
+
case "end":
|
|
125
|
+
return _context3.stop();
|
|
126
|
+
}
|
|
127
|
+
}, _callee3, this);
|
|
128
|
+
}));
|
|
129
|
+
function search(_x2) {
|
|
130
|
+
return _search.apply(this, arguments);
|
|
131
|
+
}
|
|
132
|
+
return search;
|
|
133
|
+
}();
|
|
134
|
+
_proto.getById = /*#__PURE__*/function () {
|
|
135
|
+
var _getById = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(id, options) {
|
|
136
|
+
var res;
|
|
137
|
+
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
138
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
139
|
+
case 0:
|
|
140
|
+
_context4.next = 2;
|
|
141
|
+
return _RestApi.prototype.getById.call(this, id, options);
|
|
142
|
+
case 2:
|
|
143
|
+
res = _context4.sent;
|
|
144
|
+
res.data = assembleAssociationField(res.data, res.refs);
|
|
145
|
+
return _context4.abrupt("return", res);
|
|
146
|
+
case 5:
|
|
147
|
+
case "end":
|
|
148
|
+
return _context4.stop();
|
|
149
|
+
}
|
|
150
|
+
}, _callee4, this);
|
|
151
|
+
}));
|
|
152
|
+
function getById(_x3, _x4) {
|
|
153
|
+
return _getById.apply(this, arguments);
|
|
154
|
+
}
|
|
155
|
+
return getById;
|
|
156
|
+
}();
|
|
157
|
+
_proto.save = /*#__PURE__*/function () {
|
|
158
|
+
var _save = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(data, options) {
|
|
159
|
+
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
160
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
161
|
+
case 0:
|
|
162
|
+
return _context5.abrupt("return", _RestApi.prototype.save.call(this, convertSaveData(data), options));
|
|
163
|
+
case 1:
|
|
164
|
+
case "end":
|
|
165
|
+
return _context5.stop();
|
|
166
|
+
}
|
|
167
|
+
}, _callee5, this);
|
|
168
|
+
}));
|
|
169
|
+
function save(_x5, _x6) {
|
|
170
|
+
return _save.apply(this, arguments);
|
|
171
|
+
}
|
|
172
|
+
return save;
|
|
173
|
+
}();
|
|
174
|
+
_proto.create = /*#__PURE__*/function () {
|
|
175
|
+
var _create = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(data, options) {
|
|
176
|
+
return _regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
177
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
178
|
+
case 0:
|
|
179
|
+
return _context6.abrupt("return", _RestApi.prototype.create.call(this, convertSaveData(data), options));
|
|
180
|
+
case 1:
|
|
181
|
+
case "end":
|
|
182
|
+
return _context6.stop();
|
|
183
|
+
}
|
|
184
|
+
}, _callee6, this);
|
|
185
|
+
}));
|
|
186
|
+
function create(_x7, _x8) {
|
|
187
|
+
return _create.apply(this, arguments);
|
|
188
|
+
}
|
|
189
|
+
return create;
|
|
190
|
+
}();
|
|
191
|
+
_proto.update = /*#__PURE__*/function () {
|
|
192
|
+
var _update = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(id, data, options) {
|
|
193
|
+
return _regeneratorRuntime.wrap(function _callee7$(_context7) {
|
|
194
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
195
|
+
case 0:
|
|
196
|
+
return _context7.abrupt("return", _RestApi.prototype.update.call(this, id, convertSaveData(data), options));
|
|
197
|
+
case 1:
|
|
198
|
+
case "end":
|
|
199
|
+
return _context7.stop();
|
|
200
|
+
}
|
|
201
|
+
}, _callee7, this);
|
|
202
|
+
}));
|
|
203
|
+
function update(_x9, _x10, _x11) {
|
|
204
|
+
return _update.apply(this, arguments);
|
|
205
|
+
}
|
|
206
|
+
return update;
|
|
207
|
+
}();
|
|
108
208
|
return RestFormApi;
|
|
109
|
-
}(RestApi);
|
|
209
|
+
}(RestApi);
|
|
210
|
+
function convertSaveData(data) {
|
|
211
|
+
if (!data) return data;
|
|
212
|
+
return JSON.parse(JSON.stringify(data, function (key, value) {
|
|
213
|
+
if (key == "parent") {
|
|
214
|
+
return value === null || value === void 0 ? void 0 : value.id;
|
|
215
|
+
}
|
|
216
|
+
return value;
|
|
217
|
+
}));
|
|
218
|
+
}
|
|
219
|
+
function assembleAssociationField(data, refs) {
|
|
220
|
+
if (!data || !refs) return;
|
|
221
|
+
var fieldIdDataMap = new Map();
|
|
222
|
+
for (var _iterator = _createForOfIteratorHelperLoose(refs), _step; !(_step = _iterator()).done;) {
|
|
223
|
+
var ref = _step.value;
|
|
224
|
+
var dataMap = new Map();
|
|
225
|
+
for (var _iterator2 = _createForOfIteratorHelperLoose(ref.data), _step2; !(_step2 = _iterator2()).done;) {
|
|
226
|
+
var datum = _step2.value;
|
|
227
|
+
dataMap.set(datum.id, datum);
|
|
228
|
+
}
|
|
229
|
+
for (var _iterator3 = _createForOfIteratorHelperLoose(ref.fieldIds), _step3; !(_step3 = _iterator3()).done;) {
|
|
230
|
+
var fieldId = _step3.value;
|
|
231
|
+
fieldIdDataMap.set(fieldId + "Id", dataMap);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
var jsonText = JSON.stringify(data, function (key, value) {
|
|
235
|
+
if (value !== null && value !== void 0 && value.id) {
|
|
236
|
+
var _loop = function _loop() {
|
|
237
|
+
var fieldIdName = _Object$keys[_i];
|
|
238
|
+
var dataMap = fieldIdDataMap.get(fieldIdName);
|
|
239
|
+
if (dataMap) {
|
|
240
|
+
var fieldIdValue = value[fieldIdName];
|
|
241
|
+
var fieldValue = null;
|
|
242
|
+
if (Array.isArray(fieldIdValue)) {
|
|
243
|
+
fieldValue = fieldIdValue.map(function (id) {
|
|
244
|
+
return dataMap.get(id);
|
|
245
|
+
}).filter(function (v) {
|
|
246
|
+
return !!v;
|
|
247
|
+
});
|
|
248
|
+
} else if (typeof fieldIdValue == "string") {
|
|
249
|
+
fieldValue = dataMap.get(fieldIdValue);
|
|
250
|
+
}
|
|
251
|
+
value[fieldIdName.slice(0, -2)] = fieldValue;
|
|
252
|
+
}
|
|
253
|
+
};
|
|
254
|
+
for (var _i = 0, _Object$keys = Object.keys(value); _i < _Object$keys.length; _i++) {
|
|
255
|
+
_loop();
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
return value;
|
|
259
|
+
});
|
|
260
|
+
return JSON.parse(jsonText);
|
|
261
|
+
}
|
|
@@ -87,7 +87,17 @@ export interface BaseType {
|
|
|
87
87
|
export interface BaseResult<DataType> {
|
|
88
88
|
success: boolean;
|
|
89
89
|
message?: string;
|
|
90
|
+
refs?: Refs;
|
|
90
91
|
}
|
|
92
|
+
export interface Ref {
|
|
93
|
+
form: {
|
|
94
|
+
id: string;
|
|
95
|
+
fieldId?: string;
|
|
96
|
+
};
|
|
97
|
+
fieldIds: string[];
|
|
98
|
+
data: BaseType[];
|
|
99
|
+
}
|
|
100
|
+
export declare type Refs = Ref[];
|
|
91
101
|
export interface OneResult<DataType> extends BaseResult<DataType> {
|
|
92
102
|
data: DataType & BaseType;
|
|
93
103
|
}
|
package/es/utils/cache/index.js
CHANGED
|
@@ -26,11 +26,15 @@ export var SchemaCache = /*#__PURE__*/function (_SingletonInstanceMap) {
|
|
|
26
26
|
});
|
|
27
27
|
case 3:
|
|
28
28
|
res = _context.sent;
|
|
29
|
-
if (res.success) {
|
|
30
|
-
|
|
29
|
+
if (!res.success) {
|
|
30
|
+
_context.next = 7;
|
|
31
|
+
break;
|
|
31
32
|
}
|
|
33
|
+
_context.next = 7;
|
|
34
|
+
return handleFormSchema(res.data);
|
|
35
|
+
case 7:
|
|
32
36
|
return _context.abrupt("return", res);
|
|
33
|
-
case
|
|
37
|
+
case 8:
|
|
34
38
|
case "end":
|
|
35
39
|
return _context.stop();
|
|
36
40
|
}
|
package/es/utils/cache/schema.js
CHANGED
|
@@ -1,25 +1,29 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
1
2
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
3
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
4
|
+
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."); }
|
|
5
|
+
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); }
|
|
6
|
+
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; }
|
|
7
|
+
import utils from "../index";
|
|
3
8
|
export function handleFormSchema(_x) {
|
|
4
9
|
return _handleFormSchema.apply(this, arguments);
|
|
5
10
|
}
|
|
6
11
|
|
|
7
|
-
|
|
8
|
-
* 遍历schema
|
|
9
|
-
* @param schema
|
|
10
|
-
* @param callback 返回true 继续往下遍历
|
|
11
|
-
*/
|
|
12
|
+
//处理关联表单
|
|
12
13
|
function _handleFormSchema() {
|
|
13
14
|
_handleFormSchema = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(schema) {
|
|
14
|
-
var fdmItems,
|
|
15
|
+
var fdmItems, fieldIdMap;
|
|
15
16
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
16
17
|
while (1) switch (_context.prev = _context.next) {
|
|
17
18
|
case 0:
|
|
18
19
|
fdmItems = [];
|
|
19
|
-
associationFields = [];
|
|
20
20
|
fieldIdMap = new Map();
|
|
21
21
|
schema.state = schema.state || {};
|
|
22
22
|
schema.methods = schema.methods || {};
|
|
23
|
+
_context.next = 6;
|
|
24
|
+
return handleAssociationForm(schema);
|
|
25
|
+
case 6:
|
|
26
|
+
//初次处理
|
|
23
27
|
forEachFormSchema(schema, function (field) {
|
|
24
28
|
if (field.fdmSchema) {
|
|
25
29
|
var _field$fdmSchema, _field$fdmSchema2;
|
|
@@ -34,11 +38,9 @@ function _handleFormSchema() {
|
|
|
34
38
|
delete copyField.children;
|
|
35
39
|
fieldIdMap.set(field.props.fieldId, copyField);
|
|
36
40
|
}
|
|
37
|
-
if (field.componentName == "AssociationField") {
|
|
38
|
-
associationFields.push(field);
|
|
39
|
-
}
|
|
40
41
|
return true;
|
|
41
42
|
});
|
|
43
|
+
|
|
42
44
|
//处理查询列
|
|
43
45
|
fdmItems.forEach(function (fdmField) {
|
|
44
46
|
forEachFormSchema(fdmField.fdmSchema, function (field) {
|
|
@@ -66,7 +68,7 @@ function _handleFormSchema() {
|
|
|
66
68
|
return true;
|
|
67
69
|
});
|
|
68
70
|
});
|
|
69
|
-
case
|
|
71
|
+
case 8:
|
|
70
72
|
case "end":
|
|
71
73
|
return _context.stop();
|
|
72
74
|
}
|
|
@@ -74,6 +76,173 @@ function _handleFormSchema() {
|
|
|
74
76
|
}));
|
|
75
77
|
return _handleFormSchema.apply(this, arguments);
|
|
76
78
|
}
|
|
79
|
+
function handleAssociationForm(_x2) {
|
|
80
|
+
return _handleAssociationForm.apply(this, arguments);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* 遍历schema
|
|
84
|
+
* @param schema
|
|
85
|
+
* @param callback 返回true 继续往下遍历
|
|
86
|
+
*/
|
|
87
|
+
function _handleAssociationForm() {
|
|
88
|
+
_handleAssociationForm = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(schema) {
|
|
89
|
+
var rootSchema, associationFields, associationAttributeFields, schemaMap, getSchema, _getSchema, _loop, _ret, _i, _associationAttribute;
|
|
90
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context4) {
|
|
91
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
92
|
+
case 0:
|
|
93
|
+
_getSchema = function _getSchema3() {
|
|
94
|
+
_getSchema = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(id) {
|
|
95
|
+
var res;
|
|
96
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context3) {
|
|
97
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
98
|
+
case 0:
|
|
99
|
+
if (!schemaMap[id]) {
|
|
100
|
+
_context3.next = 2;
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
103
|
+
return _context3.abrupt("return", schemaMap[id]);
|
|
104
|
+
case 2:
|
|
105
|
+
_context3.next = 4;
|
|
106
|
+
return utils.api.getSchema(id);
|
|
107
|
+
case 4:
|
|
108
|
+
res = _context3.sent;
|
|
109
|
+
schemaMap[id] = res.data;
|
|
110
|
+
return _context3.abrupt("return", schemaMap[id]);
|
|
111
|
+
case 7:
|
|
112
|
+
case "end":
|
|
113
|
+
return _context3.stop();
|
|
114
|
+
}
|
|
115
|
+
}, _callee2);
|
|
116
|
+
}));
|
|
117
|
+
return _getSchema.apply(this, arguments);
|
|
118
|
+
};
|
|
119
|
+
getSchema = function _getSchema2(_x3) {
|
|
120
|
+
return _getSchema.apply(this, arguments);
|
|
121
|
+
};
|
|
122
|
+
//跟schema
|
|
123
|
+
rootSchema = new FormFieldSchema(schema.children[0], null); //关联表单单选
|
|
124
|
+
associationFields = []; //关联属性
|
|
125
|
+
associationAttributeFields = [];
|
|
126
|
+
forEachFormSchema(schema, function (field) {
|
|
127
|
+
if (field.componentName == "AssociationField") {
|
|
128
|
+
associationFields.push(field);
|
|
129
|
+
}
|
|
130
|
+
if (field.componentName == "AssociationAttributeField") {
|
|
131
|
+
associationAttributeFields.push(field);
|
|
132
|
+
}
|
|
133
|
+
return true;
|
|
134
|
+
});
|
|
135
|
+
//处理关联属性schema
|
|
136
|
+
schemaMap = {};
|
|
137
|
+
schemaMap[schema.id] = schema;
|
|
138
|
+
|
|
139
|
+
//从缓存中获取schema
|
|
140
|
+
|
|
141
|
+
//处理关联属性 赋值schema
|
|
142
|
+
_loop = /*#__PURE__*/_regeneratorRuntime.mark(function _loop() {
|
|
143
|
+
var _attrField$props, _attrField$props$fiel, _findField$props, _findField$props$fiel;
|
|
144
|
+
var attrField, associationAttribute, findField, associationForm, associationFormSchema, associationAttributeField, field, associationField, depth1, depth2;
|
|
145
|
+
return _regeneratorRuntime.wrap(function _loop$(_context2) {
|
|
146
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
147
|
+
case 0:
|
|
148
|
+
attrField = _associationAttribute[_i];
|
|
149
|
+
associationAttribute = (_attrField$props = attrField.props) === null || _attrField$props === void 0 ? void 0 : (_attrField$props$fiel = _attrField$props.fieldProps) === null || _attrField$props$fiel === void 0 ? void 0 : _attrField$props$fiel.associationAttribute;
|
|
150
|
+
if (associationAttribute) {
|
|
151
|
+
_context2.next = 4;
|
|
152
|
+
break;
|
|
153
|
+
}
|
|
154
|
+
return _context2.abrupt("return", {
|
|
155
|
+
v: void 0
|
|
156
|
+
});
|
|
157
|
+
case 4:
|
|
158
|
+
findField = associationFields.find(function (assi) {
|
|
159
|
+
return assi.props.fieldId == (associationAttribute === null || associationAttribute === void 0 ? void 0 : associationAttribute[0]);
|
|
160
|
+
});
|
|
161
|
+
associationForm = findField === null || findField === void 0 ? void 0 : (_findField$props = findField.props) === null || _findField$props === void 0 ? void 0 : (_findField$props$fiel = _findField$props.fieldProps) === null || _findField$props$fiel === void 0 ? void 0 : _findField$props$fiel.associationForm;
|
|
162
|
+
if (associationForm) {
|
|
163
|
+
_context2.next = 8;
|
|
164
|
+
break;
|
|
165
|
+
}
|
|
166
|
+
return _context2.abrupt("return", {
|
|
167
|
+
v: void 0
|
|
168
|
+
});
|
|
169
|
+
case 8:
|
|
170
|
+
_context2.next = 10;
|
|
171
|
+
return getSchema(associationForm.id);
|
|
172
|
+
case 10:
|
|
173
|
+
associationFormSchema = _context2.sent;
|
|
174
|
+
//向关联属性中注册 schema 开始
|
|
175
|
+
associationAttributeField = null;
|
|
176
|
+
forEachFormSchema(associationFormSchema, function (field) {
|
|
177
|
+
if (field.props.fieldId == (associationAttribute === null || associationAttribute === void 0 ? void 0 : associationAttribute[1])) {
|
|
178
|
+
associationAttributeField = _extends({}, field);
|
|
179
|
+
return false;
|
|
180
|
+
}
|
|
181
|
+
return true;
|
|
182
|
+
});
|
|
183
|
+
attrField.props.fieldProps.associationAttributeField = associationAttributeField;
|
|
184
|
+
//向关联属性中注册 schema 结束
|
|
185
|
+
//向关联表单中注册关联属性填充 开始
|
|
186
|
+
findField.props.fieldProps.associationAttributes = findField.props.fieldProps.associationAttributes || [];
|
|
187
|
+
field = rootSchema.findFieldById(attrField.props.fieldId);
|
|
188
|
+
associationField = rootSchema.findFieldById(associationAttribute[0]);
|
|
189
|
+
if (field && associationField) {
|
|
190
|
+
depth1 = field.getFieldPaths().split(".").length;
|
|
191
|
+
depth2 = associationField.getFieldPaths().split(".").length;
|
|
192
|
+
attrField.props.fieldProps.associationDepth = depth1 - depth2;
|
|
193
|
+
/* findField.props.fieldProps.associationAttributes.push({
|
|
194
|
+
key: key,
|
|
195
|
+
value: associationAttribute?.[1]
|
|
196
|
+
})
|
|
197
|
+
console.log(field.getFieldPaths())
|
|
198
|
+
//向关联表单中注册关联属性填充 结束
|
|
199
|
+
//设置关联属性默认值 开始
|
|
200
|
+
let keys = field.getFieldPaths().split(".");
|
|
201
|
+
keys.pop();
|
|
202
|
+
attrField.props.fieldProps.associationDepth = keys.length;
|
|
203
|
+
if (keys.length > 0) {
|
|
204
|
+
keys = keys.map(item => "parent");
|
|
205
|
+
keys.push(associationAttribute[0])
|
|
206
|
+
keys.push(associationAttribute[1])
|
|
207
|
+
attrField.props.defaultValue = {
|
|
208
|
+
"type": "express",
|
|
209
|
+
"value": keys.join("?.")
|
|
210
|
+
}
|
|
211
|
+
}*/
|
|
212
|
+
}
|
|
213
|
+
//设置关联属性默认值 结束
|
|
214
|
+
case 18:
|
|
215
|
+
case "end":
|
|
216
|
+
return _context2.stop();
|
|
217
|
+
}
|
|
218
|
+
}, _loop);
|
|
219
|
+
});
|
|
220
|
+
_i = 0, _associationAttribute = associationAttributeFields;
|
|
221
|
+
case 10:
|
|
222
|
+
if (!(_i < _associationAttribute.length)) {
|
|
223
|
+
_context4.next = 18;
|
|
224
|
+
break;
|
|
225
|
+
}
|
|
226
|
+
return _context4.delegateYield(_loop(), "t0", 12);
|
|
227
|
+
case 12:
|
|
228
|
+
_ret = _context4.t0;
|
|
229
|
+
if (!_ret) {
|
|
230
|
+
_context4.next = 15;
|
|
231
|
+
break;
|
|
232
|
+
}
|
|
233
|
+
return _context4.abrupt("return", _ret.v);
|
|
234
|
+
case 15:
|
|
235
|
+
_i++;
|
|
236
|
+
_context4.next = 10;
|
|
237
|
+
break;
|
|
238
|
+
case 18:
|
|
239
|
+
case "end":
|
|
240
|
+
return _context4.stop();
|
|
241
|
+
}
|
|
242
|
+
}, _callee3);
|
|
243
|
+
}));
|
|
244
|
+
return _handleAssociationForm.apply(this, arguments);
|
|
245
|
+
}
|
|
77
246
|
export function forEachFormSchema(schema, callback) {
|
|
78
247
|
var _schema$children;
|
|
79
248
|
schema === null || schema === void 0 ? void 0 : (_schema$children = schema.children) === null || _schema$children === void 0 ? void 0 : _schema$children.forEach(function (child, index, children) {
|
|
@@ -82,4 +251,55 @@ export function forEachFormSchema(schema, callback) {
|
|
|
82
251
|
forEachFormSchema(child, callback);
|
|
83
252
|
}
|
|
84
253
|
});
|
|
85
|
-
}
|
|
254
|
+
}
|
|
255
|
+
var FormFieldSchema = /*#__PURE__*/function () {
|
|
256
|
+
function FormFieldSchema(schema, parent) {
|
|
257
|
+
var _schema$children2,
|
|
258
|
+
_this = this;
|
|
259
|
+
this.fieldId = void 0;
|
|
260
|
+
this.componentName = void 0;
|
|
261
|
+
this.parent = void 0;
|
|
262
|
+
this.schema = void 0;
|
|
263
|
+
this.children = void 0;
|
|
264
|
+
this.schema = schema;
|
|
265
|
+
this.parent = parent;
|
|
266
|
+
this.children = [];
|
|
267
|
+
this.fieldId = schema.props.fieldId;
|
|
268
|
+
this.componentName = schema.componentName;
|
|
269
|
+
(_schema$children2 = schema.children) === null || _schema$children2 === void 0 ? void 0 : _schema$children2.forEach(function (item) {
|
|
270
|
+
_this.children.push(new FormFieldSchema(item, _this));
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
var _proto = FormFieldSchema.prototype;
|
|
274
|
+
_proto.findFieldById = function findFieldById(fieldId) {
|
|
275
|
+
if (this.fieldId == fieldId) {
|
|
276
|
+
return this;
|
|
277
|
+
}
|
|
278
|
+
for (var _iterator = _createForOfIteratorHelperLoose(this.children), _step; !(_step = _iterator()).done;) {
|
|
279
|
+
var _child = _step.value;
|
|
280
|
+
if (_child.findFieldById(fieldId)) {
|
|
281
|
+
return _child.findFieldById(fieldId);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
return null;
|
|
285
|
+
};
|
|
286
|
+
_proto.getFieldPaths = function getFieldPaths() {
|
|
287
|
+
var paths = [];
|
|
288
|
+
function loopParent(field) {
|
|
289
|
+
if (field !== null && field !== void 0 && field.parent) {
|
|
290
|
+
paths.push(field.parent);
|
|
291
|
+
loopParent(field.parent);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
loopParent(this);
|
|
295
|
+
paths.reverse();
|
|
296
|
+
paths = paths.filter(function (item) {
|
|
297
|
+
return ["SubFormField"].includes(item.componentName);
|
|
298
|
+
});
|
|
299
|
+
paths.push(this);
|
|
300
|
+
return paths.map(function (item) {
|
|
301
|
+
return item.fieldId;
|
|
302
|
+
}).join(".");
|
|
303
|
+
};
|
|
304
|
+
return FormFieldSchema;
|
|
305
|
+
}();
|
package/es/utils/page/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { showForm } from "./page-form";
|
|
2
|
+
export { showFormDataManager } from "./page-form-data-manager";
|
|
2
3
|
export declare function showLoading(): Promise<void>;
|
|
3
4
|
export declare function hideLoading(): Promise<void>;
|
|
4
5
|
export declare function openPage(url: string, target?: string): Promise<any>;
|
package/es/utils/page/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
2
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
3
3
|
export { showForm } from "./page-form";
|
|
4
|
+
export { showFormDataManager } from "./page-form-data-manager";
|
|
4
5
|
var timerRef;
|
|
5
6
|
function debounceHide() {
|
|
6
7
|
if (timerRef) {
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { PageLayoutType } from "./page-layout";
|
|
2
|
+
export declare type PageFormDataManagerModeType = "dataManager" | "selectOne" | "selectMore";
|
|
3
|
+
export interface ShowPageFormDataManagerProps {
|
|
4
|
+
container?: HTMLDivElement;
|
|
5
|
+
layout?: PageLayoutType;
|
|
6
|
+
form?: {
|
|
7
|
+
id: string;
|
|
8
|
+
fieldId?: string;
|
|
9
|
+
};
|
|
10
|
+
mode?: PageFormDataManagerModeType;
|
|
11
|
+
onSubmitOk?: () => void;
|
|
12
|
+
onRemoveOk?: () => void;
|
|
13
|
+
onClose?: () => void | Promise<void>;
|
|
14
|
+
}
|
|
15
|
+
export declare function showFormDataManager(options: ShowPageFormDataManagerProps): Promise<void>;
|