@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.
@@ -0,0 +1,132 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
3
+ import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
4
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
5
+ var _excluded = ["layout", "form", "onClose"],
6
+ _excluded2 = ["container", "onClose"];
7
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
8
+ import { PageLayout } from "./page-layout";
9
+ import ReactDOM from "react-dom";
10
+ import React, { Component } from "react";
11
+ import { PageLoadSchema } from "./page-load-schema";
12
+ import { ReactRender } from "../../components/react-render";
13
+ import { openPage } from "./index";
14
+ import { forEachFormSchema } from "../cache/schema";
15
+ export function showFormDataManager(_x) {
16
+ return _showFormDataManager.apply(this, arguments);
17
+ }
18
+ function _showFormDataManager() {
19
+ _showFormDataManager = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(options) {
20
+ var container, onClose, restProps, unmount, _options$form, paths, mode, params, url, page;
21
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
22
+ while (1) switch (_context2.prev = _context2.next) {
23
+ case 0:
24
+ container = options.container, onClose = options.onClose, restProps = _objectWithoutPropertiesLoose(options, _excluded2); //容器不存在需要手动取消挂载
25
+ unmount = !container;
26
+ if (container) {
27
+ _context2.next = 15;
28
+ break;
29
+ }
30
+ if (!(options.layout == "page")) {
31
+ _context2.next = 13;
32
+ break;
33
+ }
34
+ paths = window.location.pathname.split("/");
35
+ mode = options.mode;
36
+ params = new URLSearchParams();
37
+ url = "/" + paths[1] + "/" + paths[2] + "/" + ((_options$form = options.form) === null || _options$form === void 0 ? void 0 : _options$form.id) + "/" + mode + "?" + params.toString();
38
+ _context2.next = 10;
39
+ return openPage(url, url);
40
+ case 10:
41
+ page = _context2.sent;
42
+ console.debug("openPage", page);
43
+ return _context2.abrupt("return");
44
+ case 13:
45
+ container = document.createElement("div");
46
+ document.body.append(container);
47
+ case 15:
48
+ ReactDOM.render( /*#__PURE__*/React.createElement(FormRender, _extends({}, restProps, {
49
+ onClose: /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
50
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
51
+ while (1) switch (_context.prev = _context.next) {
52
+ case 0:
53
+ if (unmount) {
54
+ //等待动画结束
55
+ setTimeout(function () {
56
+ var _container;
57
+ //取消挂载
58
+ ReactDOM.unmountComponentAtNode(container);
59
+ //移除
60
+ (_container = container) === null || _container === void 0 ? void 0 : _container.remove();
61
+ }, 1000);
62
+ }
63
+ onClose === null || onClose === void 0 ? void 0 : onClose();
64
+ case 2:
65
+ case "end":
66
+ return _context.stop();
67
+ }
68
+ }, _callee);
69
+ }))
70
+ })), container);
71
+ case 16:
72
+ case "end":
73
+ return _context2.stop();
74
+ }
75
+ }, _callee2);
76
+ }));
77
+ return _showFormDataManager.apply(this, arguments);
78
+ }
79
+ var FormRender = /*#__PURE__*/function (_Component) {
80
+ function FormRender() {
81
+ var _this;
82
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
83
+ args[_key] = arguments[_key];
84
+ }
85
+ _this = _Component.call.apply(_Component, [this].concat(args)) || this;
86
+ _this.layoutRef = void 0;
87
+ return _this;
88
+ }
89
+ _inheritsLoose(FormRender, _Component);
90
+ var _proto = FormRender.prototype;
91
+ _proto.render = function render() {
92
+ var _this2 = this;
93
+ var self = this;
94
+ var _this$props = this.props,
95
+ layout = _this$props.layout,
96
+ form = _this$props.form,
97
+ onClose = _this$props.onClose,
98
+ restProps = _objectWithoutPropertiesLoose(_this$props, _excluded);
99
+ // @ts-ignore
100
+ restProps.layout = layout || "drawer";
101
+ // @ts-ignore
102
+ restProps.onClose = function () {
103
+ var _self$layoutRef;
104
+ (_self$layoutRef = self.layoutRef) === null || _self$layoutRef === void 0 ? void 0 : _self$layoutRef.close();
105
+ onClose === null || onClose === void 0 ? void 0 : onClose();
106
+ };
107
+ return /*#__PURE__*/React.createElement(PageLayout, {
108
+ layout: layout,
109
+ ref: function ref(layout) {
110
+ return _this2.layoutRef = layout;
111
+ }
112
+ }, /*#__PURE__*/React.createElement(PageLoadSchema, {
113
+ pageId: form === null || form === void 0 ? void 0 : form.id
114
+ }, function (schema) {
115
+ var fdmSchema = schema.children[0].fdmSchema;
116
+ if (form !== null && form !== void 0 && form.fieldId) {
117
+ forEachFormSchema(schema, function (field) {
118
+ if (form.fieldId == field.props.fieldId) {
119
+ fdmSchema = field.fdmSchema;
120
+ return false;
121
+ }
122
+ return true;
123
+ });
124
+ }
125
+ return /*#__PURE__*/React.createElement(ReactRender, _extends({
126
+ schema: schema,
127
+ components: window._components || window.components || window.__components
128
+ }, restProps));
129
+ }));
130
+ };
131
+ return FormRender;
132
+ }(Component);
@@ -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
+ }
@@ -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
  }
@@ -8,6 +8,9 @@ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/
8
8
  var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));
9
9
  var _restApi = require("./rest-api");
10
10
  var _index = require("./index");
11
+ 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; }
11
14
  var RestFormApi = exports.RestFormApi = /*#__PURE__*/function (_RestApi) {
12
15
  function RestFormApi(formId, fieldId, mock) {
13
16
  var _this;
@@ -110,5 +113,154 @@ var RestFormApi = exports.RestFormApi = /*#__PURE__*/function (_RestApi) {
110
113
  }
111
114
  return handleRequestConfig;
112
115
  }();
116
+ _proto.search = /*#__PURE__*/function () {
117
+ var _search = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(params) {
118
+ var res;
119
+ return _regenerator["default"].wrap(function _callee3$(_context3) {
120
+ while (1) switch (_context3.prev = _context3.next) {
121
+ case 0:
122
+ _context3.next = 2;
123
+ return _RestApi.prototype.search.call(this, params);
124
+ case 2:
125
+ res = _context3.sent;
126
+ res.data = assembleAssociationField(res.data, res.refs);
127
+ return _context3.abrupt("return", res);
128
+ case 5:
129
+ case "end":
130
+ return _context3.stop();
131
+ }
132
+ }, _callee3, this);
133
+ }));
134
+ function search(_x2) {
135
+ return _search.apply(this, arguments);
136
+ }
137
+ return search;
138
+ }();
139
+ _proto.getById = /*#__PURE__*/function () {
140
+ var _getById = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(id, options) {
141
+ var res;
142
+ return _regenerator["default"].wrap(function _callee4$(_context4) {
143
+ while (1) switch (_context4.prev = _context4.next) {
144
+ case 0:
145
+ _context4.next = 2;
146
+ return _RestApi.prototype.getById.call(this, id, options);
147
+ case 2:
148
+ res = _context4.sent;
149
+ res.data = assembleAssociationField(res.data, res.refs);
150
+ return _context4.abrupt("return", res);
151
+ case 5:
152
+ case "end":
153
+ return _context4.stop();
154
+ }
155
+ }, _callee4, this);
156
+ }));
157
+ function getById(_x3, _x4) {
158
+ return _getById.apply(this, arguments);
159
+ }
160
+ return getById;
161
+ }();
162
+ _proto.save = /*#__PURE__*/function () {
163
+ var _save = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5(data, options) {
164
+ return _regenerator["default"].wrap(function _callee5$(_context5) {
165
+ while (1) switch (_context5.prev = _context5.next) {
166
+ case 0:
167
+ return _context5.abrupt("return", _RestApi.prototype.save.call(this, convertSaveData(data), options));
168
+ case 1:
169
+ case "end":
170
+ return _context5.stop();
171
+ }
172
+ }, _callee5, this);
173
+ }));
174
+ function save(_x5, _x6) {
175
+ return _save.apply(this, arguments);
176
+ }
177
+ return save;
178
+ }();
179
+ _proto.create = /*#__PURE__*/function () {
180
+ var _create = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee6(data, options) {
181
+ return _regenerator["default"].wrap(function _callee6$(_context6) {
182
+ while (1) switch (_context6.prev = _context6.next) {
183
+ case 0:
184
+ return _context6.abrupt("return", _RestApi.prototype.create.call(this, convertSaveData(data), options));
185
+ case 1:
186
+ case "end":
187
+ return _context6.stop();
188
+ }
189
+ }, _callee6, this);
190
+ }));
191
+ function create(_x7, _x8) {
192
+ return _create.apply(this, arguments);
193
+ }
194
+ return create;
195
+ }();
196
+ _proto.update = /*#__PURE__*/function () {
197
+ var _update = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee7(id, data, options) {
198
+ return _regenerator["default"].wrap(function _callee7$(_context7) {
199
+ while (1) switch (_context7.prev = _context7.next) {
200
+ case 0:
201
+ return _context7.abrupt("return", _RestApi.prototype.update.call(this, id, convertSaveData(data), options));
202
+ case 1:
203
+ case "end":
204
+ return _context7.stop();
205
+ }
206
+ }, _callee7, this);
207
+ }));
208
+ function update(_x9, _x10, _x11) {
209
+ return _update.apply(this, arguments);
210
+ }
211
+ return update;
212
+ }();
113
213
  return RestFormApi;
114
- }(_restApi.RestApi);
214
+ }(_restApi.RestApi);
215
+ function convertSaveData(data) {
216
+ if (!data) return data;
217
+ return JSON.parse(JSON.stringify(data, function (key, value) {
218
+ if (key == "parent") {
219
+ return value === null || value === void 0 ? void 0 : value.id;
220
+ }
221
+ return value;
222
+ }));
223
+ }
224
+ function assembleAssociationField(data, refs) {
225
+ if (!data || !refs) return;
226
+ var fieldIdDataMap = new Map();
227
+ for (var _iterator = _createForOfIteratorHelperLoose(refs), _step; !(_step = _iterator()).done;) {
228
+ var ref = _step.value;
229
+ var dataMap = new Map();
230
+ for (var _iterator2 = _createForOfIteratorHelperLoose(ref.data), _step2; !(_step2 = _iterator2()).done;) {
231
+ var datum = _step2.value;
232
+ dataMap.set(datum.id, datum);
233
+ }
234
+ for (var _iterator3 = _createForOfIteratorHelperLoose(ref.fieldIds), _step3; !(_step3 = _iterator3()).done;) {
235
+ var fieldId = _step3.value;
236
+ fieldIdDataMap.set(fieldId + "Id", dataMap);
237
+ }
238
+ }
239
+ var jsonText = JSON.stringify(data, function (key, value) {
240
+ if (value !== null && value !== void 0 && value.id) {
241
+ var _loop = function _loop() {
242
+ var fieldIdName = _Object$keys[_i];
243
+ var dataMap = fieldIdDataMap.get(fieldIdName);
244
+ if (dataMap) {
245
+ var fieldIdValue = value[fieldIdName];
246
+ var fieldValue = null;
247
+ if (Array.isArray(fieldIdValue)) {
248
+ fieldValue = fieldIdValue.map(function (id) {
249
+ return dataMap.get(id);
250
+ }).filter(function (v) {
251
+ return !!v;
252
+ });
253
+ } else if (typeof fieldIdValue == "string") {
254
+ fieldValue = dataMap.get(fieldIdValue);
255
+ }
256
+ value[fieldIdName.slice(0, -2)] = fieldValue;
257
+ }
258
+ };
259
+ for (var _i = 0, _Object$keys = Object.keys(value); _i < _Object$keys.length; _i++) {
260
+ _loop();
261
+ }
262
+ }
263
+ return value;
264
+ });
265
+ return JSON.parse(jsonText);
266
+ }
@@ -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
  }
@@ -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,173 @@ 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, associationField, depth1, depth2;
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
+ associationField = rootSchema.findFieldById(associationAttribute[0]);
193
+ if (field && associationField) {
194
+ depth1 = field.getFieldPaths().split(".").length;
195
+ depth2 = associationField.getFieldPaths().split(".").length;
196
+ attrField.props.fieldProps.associationDepth = depth1 - depth2;
197
+ /* findField.props.fieldProps.associationAttributes.push({
198
+ key: key,
199
+ value: associationAttribute?.[1]
200
+ })
201
+ console.log(field.getFieldPaths())
202
+ //向关联表单中注册关联属性填充 结束
203
+ //设置关联属性默认值 开始
204
+ let keys = field.getFieldPaths().split(".");
205
+ keys.pop();
206
+ attrField.props.fieldProps.associationDepth = keys.length;
207
+ if (keys.length > 0) {
208
+ keys = keys.map(item => "parent");
209
+ keys.push(associationAttribute[0])
210
+ keys.push(associationAttribute[1])
211
+ attrField.props.defaultValue = {
212
+ "type": "express",
213
+ "value": keys.join("?.")
214
+ }
215
+ }*/
216
+ }
217
+ //设置关联属性默认值 结束
218
+ case 18:
219
+ case "end":
220
+ return _context2.stop();
221
+ }
222
+ }, _loop);
223
+ });
224
+ _i = 0, _associationAttribute = associationAttributeFields;
225
+ case 10:
226
+ if (!(_i < _associationAttribute.length)) {
227
+ _context4.next = 18;
228
+ break;
229
+ }
230
+ return _context4.delegateYield(_loop(), "t0", 12);
231
+ case 12:
232
+ _ret = _context4.t0;
233
+ if (!_ret) {
234
+ _context4.next = 15;
235
+ break;
236
+ }
237
+ return _context4.abrupt("return", _ret.v);
238
+ case 15:
239
+ _i++;
240
+ _context4.next = 10;
241
+ break;
242
+ case 18:
243
+ case "end":
244
+ return _context4.stop();
245
+ }
246
+ }, _callee3);
247
+ }));
248
+ return _handleAssociationForm.apply(this, arguments);
249
+ }
82
250
  function forEachFormSchema(schema, callback) {
83
251
  var _schema$children;
84
252
  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 +255,55 @@ function forEachFormSchema(schema, callback) {
87
255
  forEachFormSchema(child, callback);
88
256
  }
89
257
  });
90
- }
258
+ }
259
+ var FormFieldSchema = /*#__PURE__*/function () {
260
+ function FormFieldSchema(schema, parent) {
261
+ var _schema$children2,
262
+ _this = this;
263
+ this.fieldId = void 0;
264
+ this.componentName = void 0;
265
+ this.parent = void 0;
266
+ this.schema = void 0;
267
+ this.children = void 0;
268
+ this.schema = schema;
269
+ this.parent = parent;
270
+ this.children = [];
271
+ this.fieldId = schema.props.fieldId;
272
+ this.componentName = schema.componentName;
273
+ (_schema$children2 = schema.children) === null || _schema$children2 === void 0 ? void 0 : _schema$children2.forEach(function (item) {
274
+ _this.children.push(new FormFieldSchema(item, _this));
275
+ });
276
+ }
277
+ var _proto = FormFieldSchema.prototype;
278
+ _proto.findFieldById = function findFieldById(fieldId) {
279
+ if (this.fieldId == fieldId) {
280
+ return this;
281
+ }
282
+ for (var _iterator = _createForOfIteratorHelperLoose(this.children), _step; !(_step = _iterator()).done;) {
283
+ var _child = _step.value;
284
+ if (_child.findFieldById(fieldId)) {
285
+ return _child.findFieldById(fieldId);
286
+ }
287
+ }
288
+ return null;
289
+ };
290
+ _proto.getFieldPaths = function getFieldPaths() {
291
+ var paths = [];
292
+ function loopParent(field) {
293
+ if (field !== null && field !== void 0 && field.parent) {
294
+ paths.push(field.parent);
295
+ loopParent(field.parent);
296
+ }
297
+ }
298
+ loopParent(this);
299
+ paths.reverse();
300
+ paths = paths.filter(function (item) {
301
+ return ["SubFormField"].includes(item.componentName);
302
+ });
303
+ paths.push(this);
304
+ return paths.map(function (item) {
305
+ return item.fieldId;
306
+ }).join(".");
307
+ };
308
+ return FormFieldSchema;
309
+ }();
@@ -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>;