@zhubangyun/lowcode-core 5.5.85 → 5.6.191

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.
@@ -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
@@ -0,0 +1,3 @@
1
+ [componentname="Page"] {
2
+ height: 100%;
3
+ }
@@ -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
- handleFormSchema(res.data);
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 6:
37
+ case 8:
34
38
  case "end":
35
39
  return _context.stop();
36
40
  }
@@ -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, associationFields, fieldIdMap;
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 7:
71
+ case 8:
70
72
  case "end":
71
73
  return _context.stop();
72
74
  }
@@ -74,6 +76,171 @@ 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, key, keys;
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
+ if (field) {
189
+ key = field.getFieldPaths();
190
+ findField.props.fieldProps.associationAttributes.push({
191
+ key: key,
192
+ value: associationAttribute === null || associationAttribute === void 0 ? void 0 : associationAttribute[1]
193
+ });
194
+ //向关联表单中注册关联属性填充 结束
195
+ //设置关联属性默认值 开始
196
+ keys = field.getFieldPaths().split(".");
197
+ keys.pop();
198
+ if (keys.length > 0) {
199
+ keys = keys.map(function (item) {
200
+ return "parent";
201
+ });
202
+ keys.push(associationAttribute[0]);
203
+ keys.push(associationAttribute[1]);
204
+ attrField.props.defaultValue = {
205
+ "type": "express",
206
+ "value": keys.join("?.")
207
+ };
208
+ console.log(attrField);
209
+ }
210
+ }
211
+ //设置关联属性默认值 结束
212
+ case 17:
213
+ case "end":
214
+ return _context2.stop();
215
+ }
216
+ }, _loop);
217
+ });
218
+ _i = 0, _associationAttribute = associationAttributeFields;
219
+ case 10:
220
+ if (!(_i < _associationAttribute.length)) {
221
+ _context4.next = 18;
222
+ break;
223
+ }
224
+ return _context4.delegateYield(_loop(), "t0", 12);
225
+ case 12:
226
+ _ret = _context4.t0;
227
+ if (!_ret) {
228
+ _context4.next = 15;
229
+ break;
230
+ }
231
+ return _context4.abrupt("return", _ret.v);
232
+ case 15:
233
+ _i++;
234
+ _context4.next = 10;
235
+ break;
236
+ case 18:
237
+ case "end":
238
+ return _context4.stop();
239
+ }
240
+ }, _callee3);
241
+ }));
242
+ return _handleAssociationForm.apply(this, arguments);
243
+ }
77
244
  export function forEachFormSchema(schema, callback) {
78
245
  var _schema$children;
79
246
  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 +249,55 @@ export function forEachFormSchema(schema, callback) {
82
249
  forEachFormSchema(child, callback);
83
250
  }
84
251
  });
85
- }
252
+ }
253
+ var FormFieldSchema = /*#__PURE__*/function () {
254
+ function FormFieldSchema(schema, parent) {
255
+ var _schema$children2,
256
+ _this = this;
257
+ this.fieldId = void 0;
258
+ this.componentName = void 0;
259
+ this.parent = void 0;
260
+ this.schema = void 0;
261
+ this.children = void 0;
262
+ this.schema = schema;
263
+ this.parent = parent;
264
+ this.children = [];
265
+ this.fieldId = schema.props.fieldId;
266
+ this.componentName = schema.componentName;
267
+ (_schema$children2 = schema.children) === null || _schema$children2 === void 0 ? void 0 : _schema$children2.forEach(function (item) {
268
+ _this.children.push(new FormFieldSchema(item, _this));
269
+ });
270
+ }
271
+ var _proto = FormFieldSchema.prototype;
272
+ _proto.findFieldById = function findFieldById(fieldId) {
273
+ if (this.fieldId == fieldId) {
274
+ return this;
275
+ }
276
+ for (var _iterator = _createForOfIteratorHelperLoose(this.children), _step; !(_step = _iterator()).done;) {
277
+ var _child = _step.value;
278
+ if (_child.findFieldById(fieldId)) {
279
+ return _child.findFieldById(fieldId);
280
+ }
281
+ }
282
+ return null;
283
+ };
284
+ _proto.getFieldPaths = function getFieldPaths() {
285
+ var paths = [];
286
+ function loopParent(field) {
287
+ if (field !== null && field !== void 0 && field.parent) {
288
+ paths.push(field.parent);
289
+ loopParent(field.parent);
290
+ }
291
+ }
292
+ loopParent(this);
293
+ paths.reverse();
294
+ paths = paths.filter(function (item) {
295
+ return ["SubFormField"].includes(item.componentName);
296
+ });
297
+ paths.push(this);
298
+ return paths.map(function (item) {
299
+ return item.fieldId;
300
+ }).join(".");
301
+ };
302
+ return FormFieldSchema;
303
+ }();
@@ -5,7 +5,8 @@ exports.PageLoading = PageLoading;
5
5
  require("./index.less");
6
6
  function PageLoading(props) {
7
7
  var loading = props.loading,
8
- background = props.background,
8
+ _props$background = props.background,
9
+ background = _props$background === void 0 ? "#f1f1f1" : _props$background,
9
10
  children = props.children;
10
11
  return /*#__PURE__*/React.createElement("div", {
11
12
  className: "page-loading-wrapper",
package/lib/index.less CHANGED
@@ -0,0 +1,3 @@
1
+ [componentname="Page"] {
2
+ height: 100%;
3
+ }
@@ -30,11 +30,15 @@ var SchemaCache = exports.SchemaCache = /*#__PURE__*/function (_SingletonInstanc
30
30
  });
31
31
  case 3:
32
32
  res = _context.sent;
33
- if (res.success) {
34
- (0, _schema.handleFormSchema)(res.data);
33
+ if (!res.success) {
34
+ _context.next = 7;
35
+ break;
35
36
  }
37
+ _context.next = 7;
38
+ return (0, _schema.handleFormSchema)(res.data);
39
+ case 7:
36
40
  return _context.abrupt("return", res);
37
- case 6:
41
+ case 8:
38
42
  case "end":
39
43
  return _context.stop();
40
44
  }
@@ -5,26 +5,29 @@ exports.__esModule = true;
5
5
  exports.forEachFormSchema = forEachFormSchema;
6
6
  exports.handleFormSchema = handleFormSchema;
7
7
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
8
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
8
9
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
10
+ var _index = _interopRequireDefault(require("../index"));
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; }
9
14
  function handleFormSchema(_x) {
10
15
  return _handleFormSchema.apply(this, arguments);
11
- }
12
- /**
13
- * 遍历schema
14
- * @param schema
15
- * @param callback 返回true 继续往下遍历
16
- */
16
+ } //处理关联表单
17
17
  function _handleFormSchema() {
18
18
  _handleFormSchema = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(schema) {
19
- var fdmItems, associationFields, fieldIdMap;
19
+ var fdmItems, fieldIdMap;
20
20
  return _regenerator["default"].wrap(function _callee$(_context) {
21
21
  while (1) switch (_context.prev = _context.next) {
22
22
  case 0:
23
23
  fdmItems = [];
24
- associationFields = [];
25
24
  fieldIdMap = new Map();
26
25
  schema.state = schema.state || {};
27
26
  schema.methods = schema.methods || {};
27
+ _context.next = 6;
28
+ return handleAssociationForm(schema);
29
+ case 6:
30
+ //初次处理
28
31
  forEachFormSchema(schema, function (field) {
29
32
  if (field.fdmSchema) {
30
33
  var _field$fdmSchema, _field$fdmSchema2;
@@ -39,11 +42,9 @@ function _handleFormSchema() {
39
42
  delete copyField.children;
40
43
  fieldIdMap.set(field.props.fieldId, copyField);
41
44
  }
42
- if (field.componentName == "AssociationField") {
43
- associationFields.push(field);
44
- }
45
45
  return true;
46
46
  });
47
+
47
48
  //处理查询列
48
49
  fdmItems.forEach(function (fdmField) {
49
50
  forEachFormSchema(fdmField.fdmSchema, function (field) {
@@ -71,7 +72,7 @@ function _handleFormSchema() {
71
72
  return true;
72
73
  });
73
74
  });
74
- case 7:
75
+ case 8:
75
76
  case "end":
76
77
  return _context.stop();
77
78
  }
@@ -79,6 +80,171 @@ function _handleFormSchema() {
79
80
  }));
80
81
  return _handleFormSchema.apply(this, arguments);
81
82
  }
83
+ function handleAssociationForm(_x2) {
84
+ return _handleAssociationForm.apply(this, arguments);
85
+ }
86
+ /**
87
+ * 遍历schema
88
+ * @param schema
89
+ * @param callback 返回true 继续往下遍历
90
+ */
91
+ function _handleAssociationForm() {
92
+ _handleAssociationForm = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(schema) {
93
+ var rootSchema, associationFields, associationAttributeFields, schemaMap, getSchema, _getSchema, _loop, _ret, _i, _associationAttribute;
94
+ return _regenerator["default"].wrap(function _callee3$(_context4) {
95
+ while (1) switch (_context4.prev = _context4.next) {
96
+ case 0:
97
+ _getSchema = function _getSchema3() {
98
+ _getSchema = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(id) {
99
+ var res;
100
+ return _regenerator["default"].wrap(function _callee2$(_context3) {
101
+ while (1) switch (_context3.prev = _context3.next) {
102
+ case 0:
103
+ if (!schemaMap[id]) {
104
+ _context3.next = 2;
105
+ break;
106
+ }
107
+ return _context3.abrupt("return", schemaMap[id]);
108
+ case 2:
109
+ _context3.next = 4;
110
+ return _index["default"].api.getSchema(id);
111
+ case 4:
112
+ res = _context3.sent;
113
+ schemaMap[id] = res.data;
114
+ return _context3.abrupt("return", schemaMap[id]);
115
+ case 7:
116
+ case "end":
117
+ return _context3.stop();
118
+ }
119
+ }, _callee2);
120
+ }));
121
+ return _getSchema.apply(this, arguments);
122
+ };
123
+ getSchema = function _getSchema2(_x3) {
124
+ return _getSchema.apply(this, arguments);
125
+ };
126
+ //跟schema
127
+ rootSchema = new FormFieldSchema(schema.children[0], null); //关联表单单选
128
+ associationFields = []; //关联属性
129
+ associationAttributeFields = [];
130
+ forEachFormSchema(schema, function (field) {
131
+ if (field.componentName == "AssociationField") {
132
+ associationFields.push(field);
133
+ }
134
+ if (field.componentName == "AssociationAttributeField") {
135
+ associationAttributeFields.push(field);
136
+ }
137
+ return true;
138
+ });
139
+ //处理关联属性schema
140
+ schemaMap = {};
141
+ schemaMap[schema.id] = schema;
142
+
143
+ //从缓存中获取schema
144
+
145
+ //处理关联属性 赋值schema
146
+ _loop = /*#__PURE__*/_regenerator["default"].mark(function _loop() {
147
+ var _attrField$props, _attrField$props$fiel, _findField$props, _findField$props$fiel;
148
+ var attrField, associationAttribute, findField, associationForm, associationFormSchema, associationAttributeField, field, key, keys;
149
+ return _regenerator["default"].wrap(function _loop$(_context2) {
150
+ while (1) switch (_context2.prev = _context2.next) {
151
+ case 0:
152
+ attrField = _associationAttribute[_i];
153
+ 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;
154
+ if (associationAttribute) {
155
+ _context2.next = 4;
156
+ break;
157
+ }
158
+ return _context2.abrupt("return", {
159
+ v: void 0
160
+ });
161
+ case 4:
162
+ findField = associationFields.find(function (assi) {
163
+ return assi.props.fieldId == (associationAttribute === null || associationAttribute === void 0 ? void 0 : associationAttribute[0]);
164
+ });
165
+ 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;
166
+ if (associationForm) {
167
+ _context2.next = 8;
168
+ break;
169
+ }
170
+ return _context2.abrupt("return", {
171
+ v: void 0
172
+ });
173
+ case 8:
174
+ _context2.next = 10;
175
+ return getSchema(associationForm.id);
176
+ case 10:
177
+ associationFormSchema = _context2.sent;
178
+ //向关联属性中注册 schema 开始
179
+ associationAttributeField = null;
180
+ forEachFormSchema(associationFormSchema, function (field) {
181
+ if (field.props.fieldId == (associationAttribute === null || associationAttribute === void 0 ? void 0 : associationAttribute[1])) {
182
+ associationAttributeField = (0, _extends2["default"])({}, field);
183
+ return false;
184
+ }
185
+ return true;
186
+ });
187
+ attrField.props.fieldProps.associationAttributeField = associationAttributeField;
188
+ //向关联属性中注册 schema 结束
189
+ //向关联表单中注册关联属性填充 开始
190
+ findField.props.fieldProps.associationAttributes = findField.props.fieldProps.associationAttributes || [];
191
+ field = rootSchema.findFieldById(attrField.props.fieldId);
192
+ if (field) {
193
+ key = field.getFieldPaths();
194
+ findField.props.fieldProps.associationAttributes.push({
195
+ key: key,
196
+ value: associationAttribute === null || associationAttribute === void 0 ? void 0 : associationAttribute[1]
197
+ });
198
+ //向关联表单中注册关联属性填充 结束
199
+ //设置关联属性默认值 开始
200
+ keys = field.getFieldPaths().split(".");
201
+ keys.pop();
202
+ if (keys.length > 0) {
203
+ keys = keys.map(function (item) {
204
+ return "parent";
205
+ });
206
+ keys.push(associationAttribute[0]);
207
+ keys.push(associationAttribute[1]);
208
+ attrField.props.defaultValue = {
209
+ "type": "express",
210
+ "value": keys.join("?.")
211
+ };
212
+ console.log(attrField);
213
+ }
214
+ }
215
+ //设置关联属性默认值 结束
216
+ case 17:
217
+ case "end":
218
+ return _context2.stop();
219
+ }
220
+ }, _loop);
221
+ });
222
+ _i = 0, _associationAttribute = associationAttributeFields;
223
+ case 10:
224
+ if (!(_i < _associationAttribute.length)) {
225
+ _context4.next = 18;
226
+ break;
227
+ }
228
+ return _context4.delegateYield(_loop(), "t0", 12);
229
+ case 12:
230
+ _ret = _context4.t0;
231
+ if (!_ret) {
232
+ _context4.next = 15;
233
+ break;
234
+ }
235
+ return _context4.abrupt("return", _ret.v);
236
+ case 15:
237
+ _i++;
238
+ _context4.next = 10;
239
+ break;
240
+ case 18:
241
+ case "end":
242
+ return _context4.stop();
243
+ }
244
+ }, _callee3);
245
+ }));
246
+ return _handleAssociationForm.apply(this, arguments);
247
+ }
82
248
  function forEachFormSchema(schema, callback) {
83
249
  var _schema$children;
84
250
  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) {
@@ -87,4 +253,55 @@ function forEachFormSchema(schema, callback) {
87
253
  forEachFormSchema(child, callback);
88
254
  }
89
255
  });
90
- }
256
+ }
257
+ var FormFieldSchema = /*#__PURE__*/function () {
258
+ function FormFieldSchema(schema, parent) {
259
+ var _schema$children2,
260
+ _this = this;
261
+ this.fieldId = void 0;
262
+ this.componentName = void 0;
263
+ this.parent = void 0;
264
+ this.schema = void 0;
265
+ this.children = void 0;
266
+ this.schema = schema;
267
+ this.parent = parent;
268
+ this.children = [];
269
+ this.fieldId = schema.props.fieldId;
270
+ this.componentName = schema.componentName;
271
+ (_schema$children2 = schema.children) === null || _schema$children2 === void 0 ? void 0 : _schema$children2.forEach(function (item) {
272
+ _this.children.push(new FormFieldSchema(item, _this));
273
+ });
274
+ }
275
+ var _proto = FormFieldSchema.prototype;
276
+ _proto.findFieldById = function findFieldById(fieldId) {
277
+ if (this.fieldId == fieldId) {
278
+ return this;
279
+ }
280
+ for (var _iterator = _createForOfIteratorHelperLoose(this.children), _step; !(_step = _iterator()).done;) {
281
+ var _child = _step.value;
282
+ if (_child.findFieldById(fieldId)) {
283
+ return _child.findFieldById(fieldId);
284
+ }
285
+ }
286
+ return null;
287
+ };
288
+ _proto.getFieldPaths = function getFieldPaths() {
289
+ var paths = [];
290
+ function loopParent(field) {
291
+ if (field !== null && field !== void 0 && field.parent) {
292
+ paths.push(field.parent);
293
+ loopParent(field.parent);
294
+ }
295
+ }
296
+ loopParent(this);
297
+ paths.reverse();
298
+ paths = paths.filter(function (item) {
299
+ return ["SubFormField"].includes(item.componentName);
300
+ });
301
+ paths.push(this);
302
+ return paths.map(function (item) {
303
+ return item.fieldId;
304
+ }).join(".");
305
+ };
306
+ return FormFieldSchema;
307
+ }();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zhubangyun/lowcode-core",
3
- "version": "5.5.085",
3
+ "version": "5.6.191",
4
4
  "description": "低代码核心",
5
5
  "files": [
6
6
  "lib",