@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
package/es/utils/cache/schema.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
2
1
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
3
2
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
4
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."); }
|
|
@@ -9,32 +8,31 @@ export function handleFormSchema(_x) {
|
|
|
9
8
|
return _handleFormSchema.apply(this, arguments);
|
|
10
9
|
}
|
|
11
10
|
|
|
12
|
-
|
|
11
|
+
/**
|
|
12
|
+
* 处理数据管理关联属性
|
|
13
|
+
* @param rootSchema
|
|
14
|
+
* @param fdmSchema
|
|
15
|
+
*/
|
|
13
16
|
function _handleFormSchema() {
|
|
14
17
|
_handleFormSchema = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(schema) {
|
|
15
|
-
var fdmItems, fieldIdMap;
|
|
18
|
+
var formFieldSchema, fdmItems, fieldIdMap, _i, _fdmItems, fdmField;
|
|
16
19
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
17
20
|
while (1) switch (_context.prev = _context.next) {
|
|
18
21
|
case 0:
|
|
19
|
-
if (!(schema.
|
|
22
|
+
if (!((schema === null || schema === void 0 ? void 0 : schema.componentName) != "Page")) {
|
|
20
23
|
_context.next = 2;
|
|
21
24
|
break;
|
|
22
25
|
}
|
|
23
26
|
return _context.abrupt("return");
|
|
24
27
|
case 2:
|
|
25
|
-
|
|
26
|
-
_context.next = 4;
|
|
27
|
-
break;
|
|
28
|
-
}
|
|
29
|
-
return _context.abrupt("return");
|
|
30
|
-
case 4:
|
|
28
|
+
formFieldSchema = new FormFieldSchema(schema.children[0], null);
|
|
31
29
|
fdmItems = [];
|
|
32
30
|
fieldIdMap = new Map();
|
|
33
31
|
schema.state = schema.state || {};
|
|
34
32
|
schema.methods = schema.methods || {};
|
|
35
|
-
_context.next =
|
|
36
|
-
return handleAssociationForm(schema);
|
|
37
|
-
case
|
|
33
|
+
_context.next = 9;
|
|
34
|
+
return handleAssociationForm(formFieldSchema, schema);
|
|
35
|
+
case 9:
|
|
38
36
|
//初次处理
|
|
39
37
|
forEachFormSchema(schema, function (field) {
|
|
40
38
|
if (field.fdmSchema) {
|
|
@@ -43,7 +41,6 @@ function _handleFormSchema() {
|
|
|
43
41
|
field.fdmSchema.props = ((_field$fdmSchema = field.fdmSchema) === null || _field$fdmSchema === void 0 ? void 0 : _field$fdmSchema.props) || {};
|
|
44
42
|
field.fdmSchema.props.style = ((_field$fdmSchema2 = field.fdmSchema) === null || _field$fdmSchema2 === void 0 ? void 0 : _field$fdmSchema2.props.style) || {};
|
|
45
43
|
field.fdmSchema.props.style.height = "100%";
|
|
46
|
-
field.fdmSchema.props.label = field.props.label;
|
|
47
44
|
}
|
|
48
45
|
if (field.props.fieldId) {
|
|
49
46
|
//删除children防止循环
|
|
@@ -55,33 +52,57 @@ function _handleFormSchema() {
|
|
|
55
52
|
});
|
|
56
53
|
|
|
57
54
|
//处理查询列
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
55
|
+
_i = 0, _fdmItems = fdmItems;
|
|
56
|
+
case 11:
|
|
57
|
+
if (!(_i < _fdmItems.length)) {
|
|
58
|
+
_context.next = 19;
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
61
|
+
fdmField = _fdmItems[_i];
|
|
62
|
+
_context.next = 15;
|
|
63
|
+
return handleFdmAssociationAttributeFields(formFieldSchema, fdmField.fdmSchema);
|
|
64
|
+
case 15:
|
|
65
|
+
forEachFormSchema(fdmField.fdmSchema, function (field) {
|
|
66
|
+
var _field$props;
|
|
67
|
+
var findSchema = fieldIdMap.get((_field$props = field.props) === null || _field$props === void 0 ? void 0 : _field$props.fieldId);
|
|
68
|
+
if (findSchema) {
|
|
69
|
+
field.componentName = findSchema.componentName;
|
|
70
|
+
field.props = Object.assign({}, JSON.parse(JSON.stringify(findSchema.props)), field.props);
|
|
71
|
+
//处理子表查询
|
|
72
|
+
if (findSchema.componentName == "SubFormField") {
|
|
73
|
+
if (findSchema.fdmSchema) {
|
|
74
|
+
var subFormFdmSchema = JSON.parse(JSON.stringify(findSchema.fdmSchema));
|
|
75
|
+
forEachFormSchema(subFormFdmSchema, function (field) {
|
|
76
|
+
if (field.componentName === "PageFdm") {
|
|
77
|
+
field.props.layout = "inline";
|
|
78
|
+
}
|
|
79
|
+
return true;
|
|
80
|
+
});
|
|
81
|
+
// @ts-ignore
|
|
82
|
+
field.props.fdmSchema = subFormFdmSchema;
|
|
83
|
+
field.children = subFormFdmSchema.children[0].children;
|
|
84
|
+
field.children = field.children.filter(function (item) {
|
|
85
|
+
return !item.props.hideInSubTable;
|
|
86
|
+
});
|
|
87
|
+
//处理子列隐藏
|
|
88
|
+
forEachFormSchema(field, function (subField) {
|
|
89
|
+
if (Array.isArray(subField.children)) {
|
|
90
|
+
subField.children = subField.children.filter(function (item) {
|
|
91
|
+
return !item.props.hideInSubTable;
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
return true;
|
|
95
|
+
});
|
|
79
96
|
}
|
|
80
97
|
}
|
|
81
|
-
|
|
82
|
-
|
|
98
|
+
}
|
|
99
|
+
return true;
|
|
83
100
|
});
|
|
84
|
-
case
|
|
101
|
+
case 16:
|
|
102
|
+
_i++;
|
|
103
|
+
_context.next = 11;
|
|
104
|
+
break;
|
|
105
|
+
case 19:
|
|
85
106
|
case "end":
|
|
86
107
|
return _context.stop();
|
|
87
108
|
}
|
|
@@ -89,159 +110,204 @@ function _handleFormSchema() {
|
|
|
89
110
|
}));
|
|
90
111
|
return _handleFormSchema.apply(this, arguments);
|
|
91
112
|
}
|
|
92
|
-
function
|
|
113
|
+
function handleFdmAssociationAttributeFields(_x2, _x3) {
|
|
114
|
+
return _handleFdmAssociationAttributeFields.apply(this, arguments);
|
|
115
|
+
} //处理关联表单
|
|
116
|
+
function _handleFdmAssociationAttributeFields() {
|
|
117
|
+
_handleFdmAssociationAttributeFields = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(rootSchema, fdmSchema) {
|
|
118
|
+
var associationAttributeFields, _i2, _associationAttribute, _attrField$props, attrField, associationAttribute, cloneSchema;
|
|
119
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
120
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
121
|
+
case 0:
|
|
122
|
+
//关联属性
|
|
123
|
+
associationAttributeFields = [];
|
|
124
|
+
forEachFormSchema(fdmSchema, function (field) {
|
|
125
|
+
if (field.componentName == "FdmAssociationFieldColumn") {
|
|
126
|
+
associationAttributeFields.push(field);
|
|
127
|
+
}
|
|
128
|
+
return true;
|
|
129
|
+
});
|
|
130
|
+
_i2 = 0, _associationAttribute = associationAttributeFields;
|
|
131
|
+
case 3:
|
|
132
|
+
if (!(_i2 < _associationAttribute.length)) {
|
|
133
|
+
_context2.next = 13;
|
|
134
|
+
break;
|
|
135
|
+
}
|
|
136
|
+
attrField = _associationAttribute[_i2];
|
|
137
|
+
associationAttribute = (_attrField$props = attrField.props) === null || _attrField$props === void 0 ? void 0 : _attrField$props.associationAttribute;
|
|
138
|
+
_context2.next = 8;
|
|
139
|
+
return cloneAssociationAttributeFieldSchema(rootSchema, associationAttribute);
|
|
140
|
+
case 8:
|
|
141
|
+
cloneSchema = _context2.sent;
|
|
142
|
+
if (cloneSchema) {
|
|
143
|
+
//向关联属性中注册 fieldSchema 架构会将 associationAttributeField schema 转换成 jsx
|
|
144
|
+
attrField.componentName = cloneSchema.componentName;
|
|
145
|
+
attrField.props = Object.assign({}, JSON.parse(JSON.stringify(cloneSchema.props)), attrField.props);
|
|
146
|
+
attrField.props.fieldId = associationAttribute.join(".");
|
|
147
|
+
}
|
|
148
|
+
case 10:
|
|
149
|
+
_i2++;
|
|
150
|
+
_context2.next = 3;
|
|
151
|
+
break;
|
|
152
|
+
case 13:
|
|
153
|
+
case "end":
|
|
154
|
+
return _context2.stop();
|
|
155
|
+
}
|
|
156
|
+
}, _callee2);
|
|
157
|
+
}));
|
|
158
|
+
return _handleFdmAssociationAttributeFields.apply(this, arguments);
|
|
159
|
+
}
|
|
160
|
+
function handleAssociationForm(_x4, _x5) {
|
|
93
161
|
return _handleAssociationForm.apply(this, arguments);
|
|
94
162
|
}
|
|
95
|
-
/**
|
|
96
|
-
* 遍历schema
|
|
97
|
-
* @param schema
|
|
98
|
-
* @param callback 返回true 继续往下遍历
|
|
99
|
-
*/
|
|
100
163
|
function _handleAssociationForm() {
|
|
101
|
-
_handleAssociationForm = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(schema) {
|
|
102
|
-
var
|
|
103
|
-
return _regeneratorRuntime.wrap(function _callee3$(
|
|
104
|
-
while (1) switch (
|
|
164
|
+
_handleAssociationForm = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(rootSchema, schema) {
|
|
165
|
+
var associationAttributeFields, _i3, _associationAttribute2, _attrField$props2, _attrField$props2$fie, attrField, associationAttribute, cloneSchema;
|
|
166
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
167
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
105
168
|
case 0:
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
var res;
|
|
109
|
-
return _regeneratorRuntime.wrap(function _callee2$(_context3) {
|
|
110
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
111
|
-
case 0:
|
|
112
|
-
if (!schemaMap[id]) {
|
|
113
|
-
_context3.next = 2;
|
|
114
|
-
break;
|
|
115
|
-
}
|
|
116
|
-
return _context3.abrupt("return", schemaMap[id]);
|
|
117
|
-
case 2:
|
|
118
|
-
_context3.next = 4;
|
|
119
|
-
return utils.api.getSchema(id);
|
|
120
|
-
case 4:
|
|
121
|
-
res = _context3.sent;
|
|
122
|
-
schemaMap[id] = res.data;
|
|
123
|
-
return _context3.abrupt("return", schemaMap[id]);
|
|
124
|
-
case 7:
|
|
125
|
-
case "end":
|
|
126
|
-
return _context3.stop();
|
|
127
|
-
}
|
|
128
|
-
}, _callee2);
|
|
129
|
-
}));
|
|
130
|
-
return _getSchema.apply(this, arguments);
|
|
131
|
-
};
|
|
132
|
-
getSchema = function _getSchema2(_x3) {
|
|
133
|
-
return _getSchema.apply(this, arguments);
|
|
134
|
-
};
|
|
135
|
-
//跟schema
|
|
136
|
-
rootSchema = new FormFieldSchema(schema.children[0], null); //关联表单单选
|
|
137
|
-
associationFields = []; //关联属性
|
|
138
|
-
associationAttributeFields = [];
|
|
169
|
+
//关联属性
|
|
170
|
+
associationAttributeFields = []; //关联查询
|
|
139
171
|
forEachFormSchema(schema, function (field) {
|
|
140
|
-
if (field.componentName == "AssociationField") {
|
|
141
|
-
associationFields.push(field);
|
|
142
|
-
}
|
|
143
172
|
if (field.componentName == "AssociationAttributeField") {
|
|
144
173
|
associationAttributeFields.push(field);
|
|
145
174
|
}
|
|
146
175
|
return true;
|
|
147
176
|
});
|
|
148
|
-
//处理关联属性schema
|
|
149
|
-
schemaMap = {};
|
|
150
|
-
schemaMap[schema.id] = schema;
|
|
151
|
-
|
|
152
|
-
//从缓存中获取schema
|
|
153
177
|
|
|
154
178
|
//处理关联属性 赋值schema
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
160
|
-
case 0:
|
|
161
|
-
attrField = _associationAttribute[_i];
|
|
162
|
-
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;
|
|
163
|
-
if (associationAttribute) {
|
|
164
|
-
_context2.next = 4;
|
|
165
|
-
break;
|
|
166
|
-
}
|
|
167
|
-
return _context2.abrupt("return", {
|
|
168
|
-
v: void 0
|
|
169
|
-
});
|
|
170
|
-
case 4:
|
|
171
|
-
findField = associationFields.find(function (assi) {
|
|
172
|
-
return assi.props.fieldId == (associationAttribute === null || associationAttribute === void 0 ? void 0 : associationAttribute[0]);
|
|
173
|
-
});
|
|
174
|
-
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;
|
|
175
|
-
if (associationForm) {
|
|
176
|
-
_context2.next = 8;
|
|
177
|
-
break;
|
|
178
|
-
}
|
|
179
|
-
return _context2.abrupt("return", {
|
|
180
|
-
v: void 0
|
|
181
|
-
});
|
|
182
|
-
case 8:
|
|
183
|
-
_context2.next = 10;
|
|
184
|
-
return getSchema(associationForm.id);
|
|
185
|
-
case 10:
|
|
186
|
-
associationFormSchema = _context2.sent;
|
|
187
|
-
//向关联属性中注册 schema 开始
|
|
188
|
-
associationAttributeField = null;
|
|
189
|
-
forEachFormSchema(associationFormSchema, function (field) {
|
|
190
|
-
if (field.props.fieldId == (associationAttribute === null || associationAttribute === void 0 ? void 0 : associationAttribute[1])) {
|
|
191
|
-
associationAttributeField = _extends({}, field);
|
|
192
|
-
return false;
|
|
193
|
-
}
|
|
194
|
-
return true;
|
|
195
|
-
});
|
|
196
|
-
attrField.props.fieldProps.associationAttributeField = associationAttributeField;
|
|
197
|
-
//向关联属性中注册 schema 结束
|
|
198
|
-
//向关联表单中注册关联属性填充 开始
|
|
199
|
-
findField.props.fieldProps.associationAttributes = findField.props.fieldProps.associationAttributes || [];
|
|
200
|
-
field = rootSchema.findFieldById(attrField.props.fieldId);
|
|
201
|
-
associationField = rootSchema.findFieldById(associationAttribute[0]);
|
|
202
|
-
if (field && associationField) {
|
|
203
|
-
depth1 = field.getFieldPaths().split(".").length;
|
|
204
|
-
depth2 = associationField.getFieldPaths().split(".").length;
|
|
205
|
-
attrField.props.fieldProps.associationDepth = depth1 - depth2;
|
|
206
|
-
findField.props.fieldProps.associationAttributes.push({
|
|
207
|
-
key: field.getFieldPaths(),
|
|
208
|
-
value: associationAttribute === null || associationAttribute === void 0 ? void 0 : associationAttribute[1]
|
|
209
|
-
});
|
|
210
|
-
//向关联表单中注册关联属性填充 结束
|
|
211
|
-
}
|
|
212
|
-
//设置关联属性默认值 结束
|
|
213
|
-
case 18:
|
|
214
|
-
case "end":
|
|
215
|
-
return _context2.stop();
|
|
216
|
-
}
|
|
217
|
-
}, _loop);
|
|
218
|
-
});
|
|
219
|
-
_i = 0, _associationAttribute = associationAttributeFields;
|
|
220
|
-
case 10:
|
|
221
|
-
if (!(_i < _associationAttribute.length)) {
|
|
222
|
-
_context4.next = 18;
|
|
179
|
+
_i3 = 0, _associationAttribute2 = associationAttributeFields;
|
|
180
|
+
case 3:
|
|
181
|
+
if (!(_i3 < _associationAttribute2.length)) {
|
|
182
|
+
_context3.next = 13;
|
|
223
183
|
break;
|
|
224
184
|
}
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
185
|
+
attrField = _associationAttribute2[_i3];
|
|
186
|
+
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;
|
|
187
|
+
_context3.next = 8;
|
|
188
|
+
return cloneAssociationAttributeFieldSchema(rootSchema, associationAttribute);
|
|
189
|
+
case 8:
|
|
190
|
+
cloneSchema = _context3.sent;
|
|
191
|
+
if (cloneSchema) {
|
|
192
|
+
//向关联属性中注册 fieldSchema 架构会将 associationAttributeField schema 转换成 jsx
|
|
193
|
+
attrField.props.fieldProps.associationAttributeField = cloneSchema;
|
|
231
194
|
}
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
_context4.next = 10;
|
|
195
|
+
case 10:
|
|
196
|
+
_i3++;
|
|
197
|
+
_context3.next = 3;
|
|
236
198
|
break;
|
|
237
|
-
case
|
|
199
|
+
case 13:
|
|
238
200
|
case "end":
|
|
239
|
-
return
|
|
201
|
+
return _context3.stop();
|
|
240
202
|
}
|
|
241
203
|
}, _callee3);
|
|
242
204
|
}));
|
|
243
205
|
return _handleAssociationForm.apply(this, arguments);
|
|
244
206
|
}
|
|
207
|
+
function cloneAssociationAttributeFieldSchema(_x6, _x7) {
|
|
208
|
+
return _cloneAssociationAttributeFieldSchema.apply(this, arguments);
|
|
209
|
+
}
|
|
210
|
+
function _cloneAssociationAttributeFieldSchema() {
|
|
211
|
+
_cloneAssociationAttributeFieldSchema = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(rootSchema, associationAttribute) {
|
|
212
|
+
var associationFormSchema;
|
|
213
|
+
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
214
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
215
|
+
case 0:
|
|
216
|
+
if (Array.isArray(associationAttribute)) {
|
|
217
|
+
_context4.next = 2;
|
|
218
|
+
break;
|
|
219
|
+
}
|
|
220
|
+
return _context4.abrupt("return", null);
|
|
221
|
+
case 2:
|
|
222
|
+
_context4.next = 4;
|
|
223
|
+
return getSchemaByAssociationFieldId(rootSchema, associationAttribute === null || associationAttribute === void 0 ? void 0 : associationAttribute[0]);
|
|
224
|
+
case 4:
|
|
225
|
+
associationFormSchema = _context4.sent;
|
|
226
|
+
if (!associationFormSchema) {
|
|
227
|
+
_context4.next = 7;
|
|
228
|
+
break;
|
|
229
|
+
}
|
|
230
|
+
return _context4.abrupt("return", findFieldSchema(associationFormSchema, associationAttribute === null || associationAttribute === void 0 ? void 0 : associationAttribute[1]));
|
|
231
|
+
case 7:
|
|
232
|
+
return _context4.abrupt("return", null);
|
|
233
|
+
case 8:
|
|
234
|
+
case "end":
|
|
235
|
+
return _context4.stop();
|
|
236
|
+
}
|
|
237
|
+
}, _callee4);
|
|
238
|
+
}));
|
|
239
|
+
return _cloneAssociationAttributeFieldSchema.apply(this, arguments);
|
|
240
|
+
}
|
|
241
|
+
function getSchemaByAssociationFieldId(_x8, _x9) {
|
|
242
|
+
return _getSchemaByAssociationFieldId.apply(this, arguments);
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* 从schema中查找field
|
|
246
|
+
* @param schema
|
|
247
|
+
* @param fieldId
|
|
248
|
+
*/
|
|
249
|
+
function _getSchemaByAssociationFieldId() {
|
|
250
|
+
_getSchemaByAssociationFieldId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(rootSchema, associationFieldId) {
|
|
251
|
+
var lastFieldId, associationFormSchema, _findAssociationField, _findAssociationField2, _findAssociationField3, findAssociationField, formId;
|
|
252
|
+
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
253
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
254
|
+
case 0:
|
|
255
|
+
if (associationFieldId) {
|
|
256
|
+
_context5.next = 2;
|
|
257
|
+
break;
|
|
258
|
+
}
|
|
259
|
+
return _context5.abrupt("return", null);
|
|
260
|
+
case 2:
|
|
261
|
+
lastFieldId = associationFieldId.split(".").pop();
|
|
262
|
+
associationFormSchema = null;
|
|
263
|
+
if (!(lastFieldId == "parent")) {
|
|
264
|
+
_context5.next = 8;
|
|
265
|
+
break;
|
|
266
|
+
}
|
|
267
|
+
associationFormSchema = rootSchema.schema;
|
|
268
|
+
_context5.next = 15;
|
|
269
|
+
break;
|
|
270
|
+
case 8:
|
|
271
|
+
findAssociationField = findFieldSchema(rootSchema.schema, lastFieldId);
|
|
272
|
+
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;
|
|
273
|
+
if (formId) {
|
|
274
|
+
_context5.next = 12;
|
|
275
|
+
break;
|
|
276
|
+
}
|
|
277
|
+
return _context5.abrupt("return", null);
|
|
278
|
+
case 12:
|
|
279
|
+
_context5.next = 14;
|
|
280
|
+
return utils.api.getSchema(formId);
|
|
281
|
+
case 14:
|
|
282
|
+
associationFormSchema = _context5.sent.data;
|
|
283
|
+
case 15:
|
|
284
|
+
return _context5.abrupt("return", associationFormSchema);
|
|
285
|
+
case 16:
|
|
286
|
+
case "end":
|
|
287
|
+
return _context5.stop();
|
|
288
|
+
}
|
|
289
|
+
}, _callee5);
|
|
290
|
+
}));
|
|
291
|
+
return _getSchemaByAssociationFieldId.apply(this, arguments);
|
|
292
|
+
}
|
|
293
|
+
function findFieldSchema(schema, fieldId) {
|
|
294
|
+
var associationAttributeField = null;
|
|
295
|
+
forEachFormSchema(schema, function (field) {
|
|
296
|
+
if (field.props.fieldId == fieldId) {
|
|
297
|
+
//深拷贝
|
|
298
|
+
associationAttributeField = JSON.parse(JSON.stringify(field));
|
|
299
|
+
return false;
|
|
300
|
+
}
|
|
301
|
+
return true;
|
|
302
|
+
});
|
|
303
|
+
return associationAttributeField;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* 遍历schema
|
|
308
|
+
* @param schema
|
|
309
|
+
* @param callback 返回true 继续往下遍历
|
|
310
|
+
*/
|
|
245
311
|
export function forEachFormSchema(schema, callback) {
|
|
246
312
|
var _schema$children;
|
|
247
313
|
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) {
|
|
@@ -301,4 +367,36 @@ var FormFieldSchema = /*#__PURE__*/function () {
|
|
|
301
367
|
}).join(".");
|
|
302
368
|
};
|
|
303
369
|
return FormFieldSchema;
|
|
304
|
-
}();
|
|
370
|
+
}();
|
|
371
|
+
export function getAdminFormSchema(_x10) {
|
|
372
|
+
return _getAdminFormSchema.apply(this, arguments);
|
|
373
|
+
}
|
|
374
|
+
function _getAdminFormSchema() {
|
|
375
|
+
_getAdminFormSchema = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(id) {
|
|
376
|
+
var res, schema;
|
|
377
|
+
return _regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
378
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
379
|
+
case 0:
|
|
380
|
+
_context6.next = 2;
|
|
381
|
+
return utils.api.getSchema(id, true);
|
|
382
|
+
case 2:
|
|
383
|
+
res = _context6.sent;
|
|
384
|
+
if (!res.success) {
|
|
385
|
+
_context6.next = 8;
|
|
386
|
+
break;
|
|
387
|
+
}
|
|
388
|
+
schema = JSON.parse(JSON.stringify(res.data));
|
|
389
|
+
_context6.next = 7;
|
|
390
|
+
return handleFormSchema(schema);
|
|
391
|
+
case 7:
|
|
392
|
+
return _context6.abrupt("return", schema);
|
|
393
|
+
case 8:
|
|
394
|
+
return _context6.abrupt("return", null);
|
|
395
|
+
case 9:
|
|
396
|
+
case "end":
|
|
397
|
+
return _context6.stop();
|
|
398
|
+
}
|
|
399
|
+
}, _callee6);
|
|
400
|
+
}));
|
|
401
|
+
return _getAdminFormSchema.apply(this, arguments);
|
|
402
|
+
}
|
|
@@ -61,7 +61,7 @@ function _loadMaterials() {
|
|
|
61
61
|
}
|
|
62
62
|
return _context2.abrupt("return");
|
|
63
63
|
case 3:
|
|
64
|
-
urls = ["prop-types/15.8.1/prop-types.min.js", "lodash/4.
|
|
64
|
+
urls = ["prop-types/15.8.1/prop-types.min.js", "lodash/4.17.15/lodash.min.js", "dayjs/dayjs.min.js", "antd/latest/reset.css", "antd/latest/antd.min.js", "antdIcon/1.0.0/antdIcon.min.js", "lowcode/core/index.js", "lowcode/core/index.css", "lowcode/materials/root/view.js", "lowcode/materials/root/view.css", "lowcode/materials/antd/view.js", "lowcode/materials/antd/view.css", "lowcode/materials/antd-pro/view.js", "lowcode/materials/antd-pro/view.css", "lowcode/icon-font/app/iconfont.js"];
|
|
65
65
|
_context2.next = 6;
|
|
66
66
|
return (0, _common.loadPlugins)(urls.map(function (url) {
|
|
67
67
|
return "https://cdn.zhiyunhe.com/plugin/" + url;
|
package/lib/style.js
CHANGED
|
@@ -9,7 +9,7 @@ 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(
|
|
12
|
+
search(searchParams?: RestSearchParams): Promise<ManyResult<DataType>>;
|
|
13
13
|
getById(id: string, options?: BaseRequestOptions<DataType>): Promise<OneResult<DataType>>;
|
|
14
14
|
save(data: DataType, options?: BaseRequestOptions<DataType>): Promise<OneResult<DataType>>;
|
|
15
15
|
create(data: DataType, options?: BaseRequestOptions<DataType>): Promise<OneResult<DataType>>;
|
|
@@ -28,7 +28,7 @@ var RestFormApi = exports.RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
|
28
28
|
_proto.initialize = /*#__PURE__*/function () {
|
|
29
29
|
var _initialize = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
|
|
30
30
|
var _this2 = this;
|
|
31
|
-
var _this$schema$
|
|
31
|
+
var _this$schema$children, _this$schema$children2, res;
|
|
32
32
|
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
33
33
|
while (1) switch (_context.prev = _context.next) {
|
|
34
34
|
case 0:
|
|
@@ -45,7 +45,7 @@ var RestFormApi = exports.RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
|
45
45
|
res = _context.sent;
|
|
46
46
|
this.schema = res.data;
|
|
47
47
|
this.initialized = !!this.schema;
|
|
48
|
-
this.title = (_this$schema$
|
|
48
|
+
this.title = (_this$schema$children = this.schema.children[0]) === null || _this$schema$children === void 0 ? void 0 : (_this$schema$children2 = _this$schema$children.props) === null || _this$schema$children2 === void 0 ? void 0 : _this$schema$children2.label;
|
|
49
49
|
if (this.fieldId) {
|
|
50
50
|
JSON.stringify(this.schema, function (key, value) {
|
|
51
51
|
var _value$props;
|
|
@@ -113,13 +113,13 @@ var RestFormApi = exports.RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
|
113
113
|
return handleRequestConfig;
|
|
114
114
|
}();
|
|
115
115
|
_proto.search = /*#__PURE__*/function () {
|
|
116
|
-
var _search = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(
|
|
117
|
-
var
|
|
118
|
-
var config, res;
|
|
116
|
+
var _search = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(searchParams) {
|
|
117
|
+
var _searchParams, _searchParams2;
|
|
118
|
+
var config, res, start;
|
|
119
119
|
return _regenerator["default"].wrap(function _callee3$(_context3) {
|
|
120
120
|
while (1) switch (_context3.prev = _context3.next) {
|
|
121
121
|
case 0:
|
|
122
|
-
|
|
122
|
+
searchParams = searchParams || {};
|
|
123
123
|
config = {
|
|
124
124
|
params: {
|
|
125
125
|
description: this.title + "\u67E5\u8BE2",
|
|
@@ -130,19 +130,21 @@ var RestFormApi = exports.RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
|
130
130
|
_context3.next = 4;
|
|
131
131
|
return this.handleRequestConfig(config);
|
|
132
132
|
case 4:
|
|
133
|
-
|
|
133
|
+
searchParams.filterRules = (0, _formApi.handleFilterRules)(((_searchParams = searchParams) === null || _searchParams === void 0 ? void 0 : _searchParams.filterRules) || [], {
|
|
134
134
|
filterNullValue: false
|
|
135
135
|
});
|
|
136
|
-
|
|
136
|
+
searchParams.searchFields = (0, _formApi.handleFilterRules)(((_searchParams2 = searchParams) === null || _searchParams2 === void 0 ? void 0 : _searchParams2.searchFields) || [], {
|
|
137
137
|
filterNullValue: true
|
|
138
138
|
});
|
|
139
139
|
_context3.next = 8;
|
|
140
|
-
return this.request.post("search",
|
|
140
|
+
return this.request.post("search", searchParams, config);
|
|
141
141
|
case 8:
|
|
142
142
|
res = _context3.sent;
|
|
143
|
+
start = Date.now();
|
|
143
144
|
(0, _formApi.assembleAssociationField)(res.data, res.refs);
|
|
145
|
+
console.debug("form.search:" + (Date.now() - start), res);
|
|
144
146
|
return _context3.abrupt("return", res);
|
|
145
|
-
case
|
|
147
|
+
case 13:
|
|
146
148
|
case "end":
|
|
147
149
|
return _context3.stop();
|
|
148
150
|
}
|
|
@@ -155,7 +157,7 @@ var RestFormApi = exports.RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
|
155
157
|
}();
|
|
156
158
|
_proto.getById = /*#__PURE__*/function () {
|
|
157
159
|
var _getById = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(id, options) {
|
|
158
|
-
var res;
|
|
160
|
+
var res, start;
|
|
159
161
|
return _regenerator["default"].wrap(function _callee4$(_context4) {
|
|
160
162
|
while (1) switch (_context4.prev = _context4.next) {
|
|
161
163
|
case 0:
|
|
@@ -163,10 +165,11 @@ var RestFormApi = exports.RestFormApi = /*#__PURE__*/function (_RestApi) {
|
|
|
163
165
|
return _RestApi.prototype.getById.call(this, id, options);
|
|
164
166
|
case 2:
|
|
165
167
|
res = _context4.sent;
|
|
168
|
+
start = Date.now();
|
|
166
169
|
(0, _formApi.assembleAssociationField)(res.data, res.refs);
|
|
167
|
-
console.debug("formApi.getById", res);
|
|
170
|
+
console.debug("formApi.getById" + (Date.now() - start), res);
|
|
168
171
|
return _context4.abrupt("return", res);
|
|
169
|
-
case
|
|
172
|
+
case 7:
|
|
170
173
|
case "end":
|
|
171
174
|
return _context4.stop();
|
|
172
175
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { BaseType, FilterRule, Refs } from "./rest-api";
|
|
2
2
|
export declare function convertSaveData(data: any): any;
|
|
3
|
+
export declare function assembleAssociationFieldV2(data: BaseType | BaseType[], refs?: Refs): void;
|
|
4
|
+
export declare function assembleAssociationFieldDataV2(data: BaseType | BaseType[], dataMap: Map<string, BaseType>): void;
|
|
3
5
|
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
6
|
export declare function handleFilterRules(filters: FilterRule[], options: {
|
|
6
7
|
filterNullValue: boolean;
|
|
7
|
-
}):
|
|
8
|
+
}): FilterRule[];
|