@zhubangyun/lowcode-core 5.8.110 → 5.8.291
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/components/load-materials/index.js +1 -1
- package/es/style.js +1 -0
- package/es/utils/api/form-api.d.ts +1 -1
- package/es/utils/api/form-api.js +16 -13
- package/es/utils/api/form-api.utils.d.ts +3 -2
- package/es/utils/api/form-api.utils.js +88 -17
- package/es/utils/api/rest-api.d.ts +6 -0
- package/es/utils/api/rest-api.js +12 -7
- package/es/utils/cache/schema.d.ts +1 -0
- package/es/utils/cache/schema.js +268 -170
- package/lib/components/load-materials/index.js +1 -1
- package/lib/style.js +1 -0
- package/lib/utils/api/form-api.d.ts +1 -1
- package/lib/utils/api/form-api.js +16 -13
- package/lib/utils/api/form-api.utils.d.ts +3 -2
- package/lib/utils/api/form-api.utils.js +89 -17
- package/lib/utils/api/rest-api.d.ts +6 -0
- package/lib/utils/api/rest-api.js +12 -7
- package/lib/utils/cache/schema.d.ts +1 -0
- package/lib/utils/cache/schema.js +270 -170
- package/package.json +1 -1
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
exports.__esModule = true;
|
|
5
5
|
exports.forEachFormSchema = forEachFormSchema;
|
|
6
|
+
exports.getAdminFormSchema = getAdminFormSchema;
|
|
6
7
|
exports.handleFormSchema = handleFormSchema;
|
|
7
8
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
8
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
9
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
10
|
var _index = _interopRequireDefault(require("../index"));
|
|
11
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."); }
|
|
@@ -13,32 +13,32 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
13
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
14
|
function handleFormSchema(_x) {
|
|
15
15
|
return _handleFormSchema.apply(this, arguments);
|
|
16
|
-
}
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* 处理数据管理关联属性
|
|
19
|
+
* @param rootSchema
|
|
20
|
+
* @param fdmSchema
|
|
21
|
+
*/
|
|
17
22
|
function _handleFormSchema() {
|
|
18
23
|
_handleFormSchema = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(schema) {
|
|
19
|
-
var fdmItems, fieldIdMap;
|
|
24
|
+
var formFieldSchema, fdmItems, fieldIdMap, _i, _fdmItems, fdmField;
|
|
20
25
|
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
21
26
|
while (1) switch (_context.prev = _context.next) {
|
|
22
27
|
case 0:
|
|
23
|
-
if (!(schema.
|
|
28
|
+
if (!((schema === null || schema === void 0 ? void 0 : schema.componentName) != "Page")) {
|
|
24
29
|
_context.next = 2;
|
|
25
30
|
break;
|
|
26
31
|
}
|
|
27
32
|
return _context.abrupt("return");
|
|
28
33
|
case 2:
|
|
29
|
-
|
|
30
|
-
_context.next = 4;
|
|
31
|
-
break;
|
|
32
|
-
}
|
|
33
|
-
return _context.abrupt("return");
|
|
34
|
-
case 4:
|
|
34
|
+
formFieldSchema = new FormFieldSchema(schema.children[0], null);
|
|
35
35
|
fdmItems = [];
|
|
36
36
|
fieldIdMap = new Map();
|
|
37
37
|
schema.state = schema.state || {};
|
|
38
38
|
schema.methods = schema.methods || {};
|
|
39
|
-
_context.next =
|
|
40
|
-
return handleAssociationForm(schema);
|
|
41
|
-
case
|
|
39
|
+
_context.next = 9;
|
|
40
|
+
return handleAssociationForm(formFieldSchema, schema);
|
|
41
|
+
case 9:
|
|
42
42
|
//初次处理
|
|
43
43
|
forEachFormSchema(schema, function (field) {
|
|
44
44
|
if (field.fdmSchema) {
|
|
@@ -47,7 +47,6 @@ function _handleFormSchema() {
|
|
|
47
47
|
field.fdmSchema.props = ((_field$fdmSchema = field.fdmSchema) === null || _field$fdmSchema === void 0 ? void 0 : _field$fdmSchema.props) || {};
|
|
48
48
|
field.fdmSchema.props.style = ((_field$fdmSchema2 = field.fdmSchema) === null || _field$fdmSchema2 === void 0 ? void 0 : _field$fdmSchema2.props.style) || {};
|
|
49
49
|
field.fdmSchema.props.style.height = "100%";
|
|
50
|
-
field.fdmSchema.props.label = field.props.label;
|
|
51
50
|
}
|
|
52
51
|
if (field.props.fieldId) {
|
|
53
52
|
//删除children防止循环
|
|
@@ -59,33 +58,57 @@ function _handleFormSchema() {
|
|
|
59
58
|
});
|
|
60
59
|
|
|
61
60
|
//处理查询列
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
61
|
+
_i = 0, _fdmItems = fdmItems;
|
|
62
|
+
case 11:
|
|
63
|
+
if (!(_i < _fdmItems.length)) {
|
|
64
|
+
_context.next = 19;
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
fdmField = _fdmItems[_i];
|
|
68
|
+
_context.next = 15;
|
|
69
|
+
return handleFdmAssociationAttributeFields(formFieldSchema, fdmField.fdmSchema);
|
|
70
|
+
case 15:
|
|
71
|
+
forEachFormSchema(fdmField.fdmSchema, function (field) {
|
|
72
|
+
var _field$props;
|
|
73
|
+
var findSchema = fieldIdMap.get((_field$props = field.props) === null || _field$props === void 0 ? void 0 : _field$props.fieldId);
|
|
74
|
+
if (findSchema) {
|
|
75
|
+
field.componentName = findSchema.componentName;
|
|
76
|
+
field.props = Object.assign({}, JSON.parse(JSON.stringify(findSchema.props)), field.props);
|
|
77
|
+
//处理子表查询
|
|
78
|
+
if (findSchema.componentName == "SubFormField") {
|
|
79
|
+
if (findSchema.fdmSchema) {
|
|
80
|
+
var subFormFdmSchema = JSON.parse(JSON.stringify(findSchema.fdmSchema));
|
|
81
|
+
forEachFormSchema(subFormFdmSchema, function (field) {
|
|
82
|
+
if (field.componentName === "PageFdm") {
|
|
83
|
+
field.props.layout = "inline";
|
|
84
|
+
}
|
|
85
|
+
return true;
|
|
86
|
+
});
|
|
87
|
+
// @ts-ignore
|
|
88
|
+
field.props.fdmSchema = subFormFdmSchema;
|
|
89
|
+
field.children = subFormFdmSchema.children[0].children;
|
|
90
|
+
field.children = field.children.filter(function (item) {
|
|
91
|
+
return !item.props.hideInSubTable;
|
|
92
|
+
});
|
|
93
|
+
//处理子列隐藏
|
|
94
|
+
forEachFormSchema(field, function (subField) {
|
|
95
|
+
if (Array.isArray(subField.children)) {
|
|
96
|
+
subField.children = subField.children.filter(function (item) {
|
|
97
|
+
return !item.props.hideInSubTable;
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
return true;
|
|
101
|
+
});
|
|
83
102
|
}
|
|
84
103
|
}
|
|
85
|
-
|
|
86
|
-
|
|
104
|
+
}
|
|
105
|
+
return true;
|
|
87
106
|
});
|
|
88
|
-
case
|
|
107
|
+
case 16:
|
|
108
|
+
_i++;
|
|
109
|
+
_context.next = 11;
|
|
110
|
+
break;
|
|
111
|
+
case 19:
|
|
89
112
|
case "end":
|
|
90
113
|
return _context.stop();
|
|
91
114
|
}
|
|
@@ -93,159 +116,204 @@ function _handleFormSchema() {
|
|
|
93
116
|
}));
|
|
94
117
|
return _handleFormSchema.apply(this, arguments);
|
|
95
118
|
}
|
|
96
|
-
function
|
|
119
|
+
function handleFdmAssociationAttributeFields(_x2, _x3) {
|
|
120
|
+
return _handleFdmAssociationAttributeFields.apply(this, arguments);
|
|
121
|
+
} //处理关联表单
|
|
122
|
+
function _handleFdmAssociationAttributeFields() {
|
|
123
|
+
_handleFdmAssociationAttributeFields = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(rootSchema, fdmSchema) {
|
|
124
|
+
var associationAttributeFields, _i2, _associationAttribute, _attrField$props, attrField, associationAttribute, cloneSchema;
|
|
125
|
+
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
126
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
127
|
+
case 0:
|
|
128
|
+
//关联属性
|
|
129
|
+
associationAttributeFields = [];
|
|
130
|
+
forEachFormSchema(fdmSchema, function (field) {
|
|
131
|
+
if (field.componentName == "FdmAssociationFieldColumn") {
|
|
132
|
+
associationAttributeFields.push(field);
|
|
133
|
+
}
|
|
134
|
+
return true;
|
|
135
|
+
});
|
|
136
|
+
_i2 = 0, _associationAttribute = associationAttributeFields;
|
|
137
|
+
case 3:
|
|
138
|
+
if (!(_i2 < _associationAttribute.length)) {
|
|
139
|
+
_context2.next = 13;
|
|
140
|
+
break;
|
|
141
|
+
}
|
|
142
|
+
attrField = _associationAttribute[_i2];
|
|
143
|
+
associationAttribute = (_attrField$props = attrField.props) === null || _attrField$props === void 0 ? void 0 : _attrField$props.associationAttribute;
|
|
144
|
+
_context2.next = 8;
|
|
145
|
+
return cloneAssociationAttributeFieldSchema(rootSchema, associationAttribute);
|
|
146
|
+
case 8:
|
|
147
|
+
cloneSchema = _context2.sent;
|
|
148
|
+
if (cloneSchema) {
|
|
149
|
+
//向关联属性中注册 fieldSchema 架构会将 associationAttributeField schema 转换成 jsx
|
|
150
|
+
attrField.componentName = cloneSchema.componentName;
|
|
151
|
+
attrField.props = Object.assign({}, JSON.parse(JSON.stringify(cloneSchema.props)), attrField.props);
|
|
152
|
+
attrField.props.fieldId = associationAttribute.join(".");
|
|
153
|
+
}
|
|
154
|
+
case 10:
|
|
155
|
+
_i2++;
|
|
156
|
+
_context2.next = 3;
|
|
157
|
+
break;
|
|
158
|
+
case 13:
|
|
159
|
+
case "end":
|
|
160
|
+
return _context2.stop();
|
|
161
|
+
}
|
|
162
|
+
}, _callee2);
|
|
163
|
+
}));
|
|
164
|
+
return _handleFdmAssociationAttributeFields.apply(this, arguments);
|
|
165
|
+
}
|
|
166
|
+
function handleAssociationForm(_x4, _x5) {
|
|
97
167
|
return _handleAssociationForm.apply(this, arguments);
|
|
98
168
|
}
|
|
99
|
-
/**
|
|
100
|
-
* 遍历schema
|
|
101
|
-
* @param schema
|
|
102
|
-
* @param callback 返回true 继续往下遍历
|
|
103
|
-
*/
|
|
104
169
|
function _handleAssociationForm() {
|
|
105
|
-
_handleAssociationForm = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(schema) {
|
|
106
|
-
var
|
|
107
|
-
return _regenerator["default"].wrap(function _callee3$(
|
|
108
|
-
while (1) switch (
|
|
170
|
+
_handleAssociationForm = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(rootSchema, schema) {
|
|
171
|
+
var associationAttributeFields, _i3, _associationAttribute2, _attrField$props2, _attrField$props2$fie, attrField, associationAttribute, cloneSchema;
|
|
172
|
+
return _regenerator["default"].wrap(function _callee3$(_context3) {
|
|
173
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
109
174
|
case 0:
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
var res;
|
|
113
|
-
return _regenerator["default"].wrap(function _callee2$(_context3) {
|
|
114
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
115
|
-
case 0:
|
|
116
|
-
if (!schemaMap[id]) {
|
|
117
|
-
_context3.next = 2;
|
|
118
|
-
break;
|
|
119
|
-
}
|
|
120
|
-
return _context3.abrupt("return", schemaMap[id]);
|
|
121
|
-
case 2:
|
|
122
|
-
_context3.next = 4;
|
|
123
|
-
return _index["default"].api.getSchema(id);
|
|
124
|
-
case 4:
|
|
125
|
-
res = _context3.sent;
|
|
126
|
-
schemaMap[id] = res.data;
|
|
127
|
-
return _context3.abrupt("return", schemaMap[id]);
|
|
128
|
-
case 7:
|
|
129
|
-
case "end":
|
|
130
|
-
return _context3.stop();
|
|
131
|
-
}
|
|
132
|
-
}, _callee2);
|
|
133
|
-
}));
|
|
134
|
-
return _getSchema.apply(this, arguments);
|
|
135
|
-
};
|
|
136
|
-
getSchema = function _getSchema2(_x3) {
|
|
137
|
-
return _getSchema.apply(this, arguments);
|
|
138
|
-
};
|
|
139
|
-
//跟schema
|
|
140
|
-
rootSchema = new FormFieldSchema(schema.children[0], null); //关联表单单选
|
|
141
|
-
associationFields = []; //关联属性
|
|
142
|
-
associationAttributeFields = [];
|
|
175
|
+
//关联属性
|
|
176
|
+
associationAttributeFields = []; //关联查询
|
|
143
177
|
forEachFormSchema(schema, function (field) {
|
|
144
|
-
if (field.componentName == "AssociationField") {
|
|
145
|
-
associationFields.push(field);
|
|
146
|
-
}
|
|
147
178
|
if (field.componentName == "AssociationAttributeField") {
|
|
148
179
|
associationAttributeFields.push(field);
|
|
149
180
|
}
|
|
150
181
|
return true;
|
|
151
182
|
});
|
|
152
|
-
//处理关联属性schema
|
|
153
|
-
schemaMap = {};
|
|
154
|
-
schemaMap[schema.id] = schema;
|
|
155
|
-
|
|
156
|
-
//从缓存中获取schema
|
|
157
183
|
|
|
158
184
|
//处理关联属性 赋值schema
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
164
|
-
case 0:
|
|
165
|
-
attrField = _associationAttribute[_i];
|
|
166
|
-
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;
|
|
167
|
-
if (associationAttribute) {
|
|
168
|
-
_context2.next = 4;
|
|
169
|
-
break;
|
|
170
|
-
}
|
|
171
|
-
return _context2.abrupt("return", {
|
|
172
|
-
v: void 0
|
|
173
|
-
});
|
|
174
|
-
case 4:
|
|
175
|
-
findField = associationFields.find(function (assi) {
|
|
176
|
-
return assi.props.fieldId == (associationAttribute === null || associationAttribute === void 0 ? void 0 : associationAttribute[0]);
|
|
177
|
-
});
|
|
178
|
-
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;
|
|
179
|
-
if (associationForm) {
|
|
180
|
-
_context2.next = 8;
|
|
181
|
-
break;
|
|
182
|
-
}
|
|
183
|
-
return _context2.abrupt("return", {
|
|
184
|
-
v: void 0
|
|
185
|
-
});
|
|
186
|
-
case 8:
|
|
187
|
-
_context2.next = 10;
|
|
188
|
-
return getSchema(associationForm.id);
|
|
189
|
-
case 10:
|
|
190
|
-
associationFormSchema = _context2.sent;
|
|
191
|
-
//向关联属性中注册 schema 开始
|
|
192
|
-
associationAttributeField = null;
|
|
193
|
-
forEachFormSchema(associationFormSchema, function (field) {
|
|
194
|
-
if (field.props.fieldId == (associationAttribute === null || associationAttribute === void 0 ? void 0 : associationAttribute[1])) {
|
|
195
|
-
associationAttributeField = (0, _extends2["default"])({}, field);
|
|
196
|
-
return false;
|
|
197
|
-
}
|
|
198
|
-
return true;
|
|
199
|
-
});
|
|
200
|
-
attrField.props.fieldProps.associationAttributeField = associationAttributeField;
|
|
201
|
-
//向关联属性中注册 schema 结束
|
|
202
|
-
//向关联表单中注册关联属性填充 开始
|
|
203
|
-
findField.props.fieldProps.associationAttributes = findField.props.fieldProps.associationAttributes || [];
|
|
204
|
-
field = rootSchema.findFieldById(attrField.props.fieldId);
|
|
205
|
-
associationField = rootSchema.findFieldById(associationAttribute[0]);
|
|
206
|
-
if (field && associationField) {
|
|
207
|
-
depth1 = field.getFieldPaths().split(".").length;
|
|
208
|
-
depth2 = associationField.getFieldPaths().split(".").length;
|
|
209
|
-
attrField.props.fieldProps.associationDepth = depth1 - depth2;
|
|
210
|
-
findField.props.fieldProps.associationAttributes.push({
|
|
211
|
-
key: field.getFieldPaths(),
|
|
212
|
-
value: associationAttribute === null || associationAttribute === void 0 ? void 0 : associationAttribute[1]
|
|
213
|
-
});
|
|
214
|
-
//向关联表单中注册关联属性填充 结束
|
|
215
|
-
}
|
|
216
|
-
//设置关联属性默认值 结束
|
|
217
|
-
case 18:
|
|
218
|
-
case "end":
|
|
219
|
-
return _context2.stop();
|
|
220
|
-
}
|
|
221
|
-
}, _loop);
|
|
222
|
-
});
|
|
223
|
-
_i = 0, _associationAttribute = associationAttributeFields;
|
|
224
|
-
case 10:
|
|
225
|
-
if (!(_i < _associationAttribute.length)) {
|
|
226
|
-
_context4.next = 18;
|
|
185
|
+
_i3 = 0, _associationAttribute2 = associationAttributeFields;
|
|
186
|
+
case 3:
|
|
187
|
+
if (!(_i3 < _associationAttribute2.length)) {
|
|
188
|
+
_context3.next = 13;
|
|
227
189
|
break;
|
|
228
190
|
}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
191
|
+
attrField = _associationAttribute2[_i3];
|
|
192
|
+
associationAttribute = (_attrField$props2 = attrField.props) === null || _attrField$props2 === void 0 ? void 0 : (_attrField$props2$fie = _attrField$props2.fieldProps) === null || _attrField$props2$fie === void 0 ? void 0 : _attrField$props2$fie.associationAttribute;
|
|
193
|
+
_context3.next = 8;
|
|
194
|
+
return cloneAssociationAttributeFieldSchema(rootSchema, associationAttribute);
|
|
195
|
+
case 8:
|
|
196
|
+
cloneSchema = _context3.sent;
|
|
197
|
+
if (cloneSchema) {
|
|
198
|
+
//向关联属性中注册 fieldSchema 架构会将 associationAttributeField schema 转换成 jsx
|
|
199
|
+
attrField.props.fieldProps.associationAttributeField = cloneSchema;
|
|
235
200
|
}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
_context4.next = 10;
|
|
201
|
+
case 10:
|
|
202
|
+
_i3++;
|
|
203
|
+
_context3.next = 3;
|
|
240
204
|
break;
|
|
241
|
-
case
|
|
205
|
+
case 13:
|
|
242
206
|
case "end":
|
|
243
|
-
return
|
|
207
|
+
return _context3.stop();
|
|
244
208
|
}
|
|
245
209
|
}, _callee3);
|
|
246
210
|
}));
|
|
247
211
|
return _handleAssociationForm.apply(this, arguments);
|
|
248
212
|
}
|
|
213
|
+
function cloneAssociationAttributeFieldSchema(_x6, _x7) {
|
|
214
|
+
return _cloneAssociationAttributeFieldSchema.apply(this, arguments);
|
|
215
|
+
}
|
|
216
|
+
function _cloneAssociationAttributeFieldSchema() {
|
|
217
|
+
_cloneAssociationAttributeFieldSchema = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(rootSchema, associationAttribute) {
|
|
218
|
+
var associationFormSchema;
|
|
219
|
+
return _regenerator["default"].wrap(function _callee4$(_context4) {
|
|
220
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
221
|
+
case 0:
|
|
222
|
+
if (Array.isArray(associationAttribute)) {
|
|
223
|
+
_context4.next = 2;
|
|
224
|
+
break;
|
|
225
|
+
}
|
|
226
|
+
return _context4.abrupt("return", null);
|
|
227
|
+
case 2:
|
|
228
|
+
_context4.next = 4;
|
|
229
|
+
return getSchemaByAssociationFieldId(rootSchema, associationAttribute === null || associationAttribute === void 0 ? void 0 : associationAttribute[0]);
|
|
230
|
+
case 4:
|
|
231
|
+
associationFormSchema = _context4.sent;
|
|
232
|
+
if (!associationFormSchema) {
|
|
233
|
+
_context4.next = 7;
|
|
234
|
+
break;
|
|
235
|
+
}
|
|
236
|
+
return _context4.abrupt("return", findFieldSchema(associationFormSchema, associationAttribute === null || associationAttribute === void 0 ? void 0 : associationAttribute[1]));
|
|
237
|
+
case 7:
|
|
238
|
+
return _context4.abrupt("return", null);
|
|
239
|
+
case 8:
|
|
240
|
+
case "end":
|
|
241
|
+
return _context4.stop();
|
|
242
|
+
}
|
|
243
|
+
}, _callee4);
|
|
244
|
+
}));
|
|
245
|
+
return _cloneAssociationAttributeFieldSchema.apply(this, arguments);
|
|
246
|
+
}
|
|
247
|
+
function getSchemaByAssociationFieldId(_x8, _x9) {
|
|
248
|
+
return _getSchemaByAssociationFieldId.apply(this, arguments);
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* 从schema中查找field
|
|
252
|
+
* @param schema
|
|
253
|
+
* @param fieldId
|
|
254
|
+
*/
|
|
255
|
+
function _getSchemaByAssociationFieldId() {
|
|
256
|
+
_getSchemaByAssociationFieldId = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5(rootSchema, associationFieldId) {
|
|
257
|
+
var lastFieldId, associationFormSchema, _findAssociationField, _findAssociationField2, _findAssociationField3, findAssociationField, formId;
|
|
258
|
+
return _regenerator["default"].wrap(function _callee5$(_context5) {
|
|
259
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
260
|
+
case 0:
|
|
261
|
+
if (associationFieldId) {
|
|
262
|
+
_context5.next = 2;
|
|
263
|
+
break;
|
|
264
|
+
}
|
|
265
|
+
return _context5.abrupt("return", null);
|
|
266
|
+
case 2:
|
|
267
|
+
lastFieldId = associationFieldId.split(".").pop();
|
|
268
|
+
associationFormSchema = null;
|
|
269
|
+
if (!(lastFieldId == "parent")) {
|
|
270
|
+
_context5.next = 8;
|
|
271
|
+
break;
|
|
272
|
+
}
|
|
273
|
+
associationFormSchema = rootSchema.schema;
|
|
274
|
+
_context5.next = 15;
|
|
275
|
+
break;
|
|
276
|
+
case 8:
|
|
277
|
+
findAssociationField = findFieldSchema(rootSchema.schema, lastFieldId);
|
|
278
|
+
formId = findAssociationField === null || findAssociationField === void 0 ? void 0 : (_findAssociationField = findAssociationField.props) === null || _findAssociationField === void 0 ? void 0 : (_findAssociationField2 = _findAssociationField.fieldProps) === null || _findAssociationField2 === void 0 ? void 0 : (_findAssociationField3 = _findAssociationField2.associationForm) === null || _findAssociationField3 === void 0 ? void 0 : _findAssociationField3.id;
|
|
279
|
+
if (formId) {
|
|
280
|
+
_context5.next = 12;
|
|
281
|
+
break;
|
|
282
|
+
}
|
|
283
|
+
return _context5.abrupt("return", null);
|
|
284
|
+
case 12:
|
|
285
|
+
_context5.next = 14;
|
|
286
|
+
return _index["default"].api.getSchema(formId);
|
|
287
|
+
case 14:
|
|
288
|
+
associationFormSchema = _context5.sent.data;
|
|
289
|
+
case 15:
|
|
290
|
+
return _context5.abrupt("return", associationFormSchema);
|
|
291
|
+
case 16:
|
|
292
|
+
case "end":
|
|
293
|
+
return _context5.stop();
|
|
294
|
+
}
|
|
295
|
+
}, _callee5);
|
|
296
|
+
}));
|
|
297
|
+
return _getSchemaByAssociationFieldId.apply(this, arguments);
|
|
298
|
+
}
|
|
299
|
+
function findFieldSchema(schema, fieldId) {
|
|
300
|
+
var associationAttributeField = null;
|
|
301
|
+
forEachFormSchema(schema, function (field) {
|
|
302
|
+
if (field.props.fieldId == fieldId) {
|
|
303
|
+
//深拷贝
|
|
304
|
+
associationAttributeField = JSON.parse(JSON.stringify(field));
|
|
305
|
+
return false;
|
|
306
|
+
}
|
|
307
|
+
return true;
|
|
308
|
+
});
|
|
309
|
+
return associationAttributeField;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* 遍历schema
|
|
314
|
+
* @param schema
|
|
315
|
+
* @param callback 返回true 继续往下遍历
|
|
316
|
+
*/
|
|
249
317
|
function forEachFormSchema(schema, callback) {
|
|
250
318
|
var _schema$children;
|
|
251
319
|
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) {
|
|
@@ -305,4 +373,36 @@ var FormFieldSchema = /*#__PURE__*/function () {
|
|
|
305
373
|
}).join(".");
|
|
306
374
|
};
|
|
307
375
|
return FormFieldSchema;
|
|
308
|
-
}();
|
|
376
|
+
}();
|
|
377
|
+
function getAdminFormSchema(_x10) {
|
|
378
|
+
return _getAdminFormSchema.apply(this, arguments);
|
|
379
|
+
}
|
|
380
|
+
function _getAdminFormSchema() {
|
|
381
|
+
_getAdminFormSchema = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee6(id) {
|
|
382
|
+
var res, schema;
|
|
383
|
+
return _regenerator["default"].wrap(function _callee6$(_context6) {
|
|
384
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
385
|
+
case 0:
|
|
386
|
+
_context6.next = 2;
|
|
387
|
+
return _index["default"].api.getSchema(id, true);
|
|
388
|
+
case 2:
|
|
389
|
+
res = _context6.sent;
|
|
390
|
+
if (!res.success) {
|
|
391
|
+
_context6.next = 8;
|
|
392
|
+
break;
|
|
393
|
+
}
|
|
394
|
+
schema = JSON.parse(JSON.stringify(res.data));
|
|
395
|
+
_context6.next = 7;
|
|
396
|
+
return handleFormSchema(schema);
|
|
397
|
+
case 7:
|
|
398
|
+
return _context6.abrupt("return", schema);
|
|
399
|
+
case 8:
|
|
400
|
+
return _context6.abrupt("return", null);
|
|
401
|
+
case 9:
|
|
402
|
+
case "end":
|
|
403
|
+
return _context6.stop();
|
|
404
|
+
}
|
|
405
|
+
}, _callee6);
|
|
406
|
+
}));
|
|
407
|
+
return _getAdminFormSchema.apply(this, arguments);
|
|
408
|
+
}
|