@zhubangyun/lowcode-core 5.10.221 → 5.12.10

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.
Files changed (69) hide show
  1. package/es/index.less +10 -0
  2. package/es/utils/api/file-api.d.ts +17 -5
  3. package/es/utils/api/file-api.js +10 -7
  4. package/es/utils/api/form-api.js +33 -44
  5. package/es/utils/api/form-api.utils.d.ts +5 -5
  6. package/es/utils/api/form-api.utils.js +55 -36
  7. package/es/utils/api/index.d.ts +4 -3
  8. package/es/utils/api/index.js +9 -2
  9. package/es/utils/api/rest-api.d.ts +6 -5
  10. package/es/utils/api/rest-api.js +1 -1
  11. package/es/utils/api/schema.util.d.ts +14 -0
  12. package/es/utils/api/schema.util.js +32 -0
  13. package/es/utils/api/script-api.js +1 -1
  14. package/es/utils/api/user-info.d.ts +16 -6
  15. package/es/utils/api/user-info.js +31 -20
  16. package/es/utils/cache/index.js +21 -11
  17. package/es/utils/cache/schema.d.ts +0 -2
  18. package/es/utils/cache/schema.js +0 -388
  19. package/es/utils/formIds.d.ts +3 -0
  20. package/es/utils/formIds.js +3 -0
  21. package/es/utils/page/index.d.ts +2 -0
  22. package/es/utils/page/index.js +2 -0
  23. package/es/utils/page/page-form-data-manager-group.d.ts +2 -0
  24. package/es/utils/page/page-form-data-manager-group.js +3 -7
  25. package/es/utils/page/page-form-data-manager.d.ts +2 -1
  26. package/es/utils/page/page-form-data-manager.js +1 -0
  27. package/es/utils/page/page-form-group.d.ts +17 -0
  28. package/es/utils/page/page-form-group.js +97 -0
  29. package/es/utils/page/page-form.d.ts +2 -1
  30. package/es/utils/page/page-form.js +3 -3
  31. package/es/utils/page/page-render.js +1 -2
  32. package/es/utils/page/page-show.d.ts +1 -0
  33. package/es/utils/page/print-form.d.ts +8 -0
  34. package/es/utils/page/print-form.js +147 -0
  35. package/lib/index.less +10 -0
  36. package/lib/utils/api/file-api.d.ts +17 -5
  37. package/lib/utils/api/file-api.js +10 -7
  38. package/lib/utils/api/form-api.js +33 -44
  39. package/lib/utils/api/form-api.utils.d.ts +5 -5
  40. package/lib/utils/api/form-api.utils.js +55 -36
  41. package/lib/utils/api/index.d.ts +4 -3
  42. package/lib/utils/api/index.js +10 -3
  43. package/lib/utils/api/rest-api.d.ts +6 -5
  44. package/lib/utils/api/rest-api.js +1 -1
  45. package/lib/utils/api/schema.util.d.ts +14 -0
  46. package/lib/utils/api/schema.util.js +37 -0
  47. package/lib/utils/api/script-api.js +1 -1
  48. package/lib/utils/api/user-info.d.ts +16 -6
  49. package/lib/utils/api/user-info.js +32 -21
  50. package/lib/utils/cache/index.js +20 -9
  51. package/lib/utils/cache/schema.d.ts +0 -2
  52. package/lib/utils/cache/schema.js +0 -390
  53. package/lib/utils/formIds.d.ts +3 -0
  54. package/lib/utils/formIds.js +7 -0
  55. package/lib/utils/page/index.d.ts +2 -0
  56. package/lib/utils/page/index.js +7 -1
  57. package/lib/utils/page/page-form-data-manager-group.d.ts +2 -0
  58. package/lib/utils/page/page-form-data-manager-group.js +3 -7
  59. package/lib/utils/page/page-form-data-manager.d.ts +2 -1
  60. package/lib/utils/page/page-form-data-manager.js +1 -0
  61. package/lib/utils/page/page-form-group.d.ts +17 -0
  62. package/lib/utils/page/page-form-group.js +104 -0
  63. package/lib/utils/page/page-form.d.ts +2 -1
  64. package/lib/utils/page/page-form.js +3 -3
  65. package/lib/utils/page/page-render.js +1 -2
  66. package/lib/utils/page/page-show.d.ts +1 -0
  67. package/lib/utils/page/print-form.d.ts +8 -0
  68. package/lib/utils/page/print-form.js +153 -0
  69. package/package.json +1 -1
@@ -60,7 +60,7 @@ export declare class RestApi<DataType> extends BaseRestApi<DataType> {
60
60
  constructor(uri: string, options?: RestApiOptions);
61
61
  handleRequestConfig(config: AxiosRequestConfig): Promise<void>;
62
62
  }
63
- export interface BaseType {
63
+ export interface IBaseEntity {
64
64
  /**
65
65
  * 对象id
66
66
  */
@@ -103,19 +103,20 @@ export interface BaseResult<DataType> {
103
103
  refs?: Refs;
104
104
  }
105
105
  export interface Ref {
106
+ label: string;
106
107
  form: {
107
108
  id: string;
108
109
  fieldId?: string;
110
+ label: string;
109
111
  };
110
- fieldIds: string[];
111
- data: BaseType[];
112
+ data: IBaseEntity[];
112
113
  }
113
114
  export type Refs = Ref[];
114
115
  export interface OneResult<DataType> extends BaseResult<DataType> {
115
- data: DataType & BaseType;
116
+ data: DataType & IBaseEntity;
116
117
  }
117
118
  export interface ManyResult<DataType> extends BaseResult<DataType> {
118
- data: (DataType & BaseType)[];
119
+ data: (DataType & IBaseEntity)[];
119
120
  total: number;
120
121
  }
121
122
  export interface BaseRequestOptions<DataType> {
@@ -23,7 +23,7 @@ var BaseRestApi = exports.BaseRestApi = /*#__PURE__*/function () {
23
23
  this.request = _axios["default"].create({
24
24
  baseURL: "/api/" + uri,
25
25
  // 基础URL
26
- timeout: 10000,
26
+ timeout: 60000,
27
27
  // 请求超时时间(毫秒)
28
28
  headers: {
29
29
  'Content-Type': 'application/json;charset=UTF-8'
@@ -0,0 +1,14 @@
1
+ /**
2
+ * 遍历schema
3
+ * @param schema
4
+ * @param callback 返回true 继续往下遍历
5
+ */
6
+ export declare function forEachSchema(schema: Schema, callback: (child: Schema, index: number, children: any[]) => boolean): void;
7
+ export declare function forEachFormSchema(schema: Schema, fdm: boolean, callback: (child: Schema) => void): void;
8
+ interface Schema {
9
+ componentName: string;
10
+ props: any;
11
+ children?: Schema[];
12
+ fdmSchema?: Schema;
13
+ }
14
+ export {};
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.forEachFormSchema = forEachFormSchema;
5
+ exports.forEachSchema = forEachSchema;
6
+ /**
7
+ * 遍历schema
8
+ * @param schema
9
+ * @param callback 返回true 继续往下遍历
10
+ */
11
+ function forEachSchema(schema, callback) {
12
+ var _schema$children;
13
+ 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) {
14
+ var ctn = callback(child, index, children);
15
+ if (ctn) {
16
+ forEachSchema(child, callback);
17
+ }
18
+ });
19
+ }
20
+ function forEachFormSchema(schema, fdm, callback) {
21
+ forEachSchema(schema, function (child) {
22
+ if (["PageForm", "SubFormField"].includes(child.componentName)) {
23
+ callback(child);
24
+ if (fdm) {
25
+ if (child.fdmSchema) {
26
+ forEachSchema(child.fdmSchema, function (fdmChild) {
27
+ if (fdmChild.componentName == "PageFdm") {
28
+ callback(child);
29
+ }
30
+ return true;
31
+ });
32
+ }
33
+ }
34
+ }
35
+ return true;
36
+ });
37
+ }
@@ -17,7 +17,7 @@ function _loadDts() {
17
17
  case 0:
18
18
  _context.prev = 0;
19
19
  _context.next = 3;
20
- return (0, _index.getFormApi)("form_bea7fcc6376c4461965237056f970fb7");
20
+ return (0, _index.getFormApi)("c40772eb-864b-42bb-ae31-9921d8ede97f");
21
21
  case 3:
22
22
  api = _context.sent;
23
23
  _context.next = 6;
@@ -1,9 +1,19 @@
1
- export interface UserInfo {
2
- userId: string;
3
- userName: string;
1
+ import { IBaseEntity } from "./rest-api";
2
+ export interface Userinfo {
3
+ id: string;
4
+ label: string;
5
+ username: string;
4
6
  staffId: string;
5
7
  staffName: string;
6
- roleIds: string[];
7
- deptIds: string[];
8
+ form: {
9
+ id: string;
10
+ };
11
+ depts: IBaseEntity[];
12
+ roles: IBaseEntity[];
13
+ corp: {
14
+ id: string;
15
+ name: string;
16
+ shortName: string;
17
+ };
8
18
  }
9
- export declare function loadUserInfo(): Promise<UserInfo | false>;
19
+ export declare function getUserinfo(): Promise<Userinfo | null>;
@@ -2,43 +2,54 @@
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
4
  exports.__esModule = true;
5
- exports.loadUserInfo = loadUserInfo;
5
+ exports.getUserinfo = getUserinfo;
6
6
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
7
- var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
8
7
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
9
8
  var _index = require("./index");
10
- function loadUserInfo() {
11
- return _loadUserInfo.apply(this, arguments);
9
+ var userinfoKey = "userinfo";
10
+ function getUserinfo() {
11
+ return _getUserinfo.apply(this, arguments);
12
12
  }
13
- function _loadUserInfo() {
14
- _loadUserInfo = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
15
- var res;
13
+ function _getUserinfo() {
14
+ _getUserinfo = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
15
+ var userinfo, cache, res;
16
16
  return _regenerator["default"].wrap(function _callee$(_context) {
17
17
  while (1) switch (_context.prev = _context.next) {
18
18
  case 0:
19
- if (!window.userInfo) {
20
- _context.next = 4;
19
+ userinfo = null;
20
+ cache = sessionStorage.getItem(userinfoKey);
21
+ if (cache) {
22
+ try {
23
+ userinfo = JSON.parse(cache);
24
+ } catch (e) {}
25
+ }
26
+ if (userinfo) {
27
+ _context.next = 8;
21
28
  break;
22
29
  }
23
- return _context.abrupt("return", (0, _extends2["default"])({}, window.userInfo));
24
- case 4:
25
30
  _context.next = 6;
26
- return _index.apiRequest.get("userInfo");
31
+ return _index.apiRequest.get("auths/userinfo");
27
32
  case 6:
28
33
  res = _context.sent;
29
- if (!res.success) {
30
- _context.next = 12;
31
- break;
34
+ if (res.success) {
35
+ sessionStorage.setItem(userinfoKey, JSON.stringify(res.data));
36
+ userinfo = res.data;
37
+ }
38
+ case 8:
39
+ if (userinfo) {
40
+ Object.defineProperty(window, "userinfo", {
41
+ value: userinfo
42
+ });
43
+ Object.defineProperty(window, "corp", {
44
+ value: userinfo.corp
45
+ });
32
46
  }
33
- window.userInfo = res.data;
34
- return _context.abrupt("return", (0, _extends2["default"])({}, res.data));
35
- case 12:
36
- return _context.abrupt("return", false);
37
- case 13:
47
+ return _context.abrupt("return", userinfo);
48
+ case 10:
38
49
  case "end":
39
50
  return _context.stop();
40
51
  }
41
52
  }, _callee);
42
53
  }));
43
- return _loadUserInfo.apply(this, arguments);
54
+ return _getUserinfo.apply(this, arguments);
44
55
  }
@@ -8,7 +8,7 @@ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/
8
8
  var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));
9
9
  var _SingletonInstanceMap3 = require("../common/SingletonInstanceMap");
10
10
  var _api = require("../api");
11
- var _schema = require("./schema");
11
+ var _schema = require("../api/schema.util");
12
12
  var SchemaCache = exports.SchemaCache = /*#__PURE__*/function (_SingletonInstanceMap) {
13
13
  function SchemaCache() {
14
14
  return _SingletonInstanceMap.apply(this, arguments) || this;
@@ -17,7 +17,7 @@ var SchemaCache = exports.SchemaCache = /*#__PURE__*/function (_SingletonInstanc
17
17
  var _proto = SchemaCache.prototype;
18
18
  _proto.createInstance = /*#__PURE__*/function () {
19
19
  var _createInstance = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(key, options) {
20
- var mock, pageId, res;
20
+ var mock, pageId, schemaRes, schema, permissionRes, permission;
21
21
  return _regenerator["default"].wrap(function _callee$(_context) {
22
22
  while (1) switch (_context.prev = _context.next) {
23
23
  case 0:
@@ -29,16 +29,27 @@ var SchemaCache = exports.SchemaCache = /*#__PURE__*/function (_SingletonInstanc
29
29
  }
30
30
  });
31
31
  case 3:
32
- res = _context.sent;
33
- if (!res.success) {
34
- _context.next = 7;
32
+ schemaRes = _context.sent;
33
+ schema = schemaRes.data;
34
+ if (!(typeof schema == "object")) {
35
+ _context.next = 11;
35
36
  break;
36
37
  }
37
- _context.next = 7;
38
- return (0, _schema.handleFormSchema)(res.data);
39
- case 7:
40
- return _context.abrupt("return", res);
38
+ _context.next = 8;
39
+ return _api.apiRequest.get("pages/" + pageId + "/permission");
41
40
  case 8:
41
+ permissionRes = _context.sent;
42
+ permission = permissionRes.data;
43
+ if (typeof permission == "object") {
44
+ (0, _schema.forEachFormSchema)(schema, true, function (child) {
45
+ child.props = child.props || {};
46
+ child.props.permission = permission;
47
+ });
48
+ }
49
+ case 11:
50
+ console.log("schemaRes", schemaRes);
51
+ return _context.abrupt("return", schemaRes);
52
+ case 13:
42
53
  case "end":
43
54
  return _context.stop();
44
55
  }
@@ -1,8 +1,6 @@
1
- export declare function handleFormSchema(schema: any): Promise<void>;
2
1
  /**
3
2
  * 遍历schema
4
3
  * @param schema
5
4
  * @param callback 返回true 继续往下遍历
6
5
  */
7
6
  export declare function forEachFormSchema(schema: any, callback: (child: any, index: number, children: any[]) => boolean): void;
8
- export declare function getAdminFormSchema(id: string): Promise<any>;
@@ -1,314 +1,7 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
3
  exports.__esModule = true;
5
4
  exports.forEachFormSchema = forEachFormSchema;
6
- exports.getAdminFormSchema = getAdminFormSchema;
7
- exports.handleFormSchema = handleFormSchema;
8
- var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
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; }
14
- function handleFormSchema(_x) {
15
- return _handleFormSchema.apply(this, arguments);
16
- }
17
- /**
18
- * 处理数据管理关联属性
19
- * @param rootSchema
20
- * @param fdmSchema
21
- */
22
- function _handleFormSchema() {
23
- _handleFormSchema = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(schema) {
24
- var formFieldSchema, fdmItems, fieldIdMap, _i, _fdmItems, fdmField;
25
- return _regenerator["default"].wrap(function _callee$(_context) {
26
- while (1) switch (_context.prev = _context.next) {
27
- case 0:
28
- if (!((schema === null || schema === void 0 ? void 0 : schema.componentName) != "Page")) {
29
- _context.next = 2;
30
- break;
31
- }
32
- return _context.abrupt("return");
33
- case 2:
34
- formFieldSchema = new FormFieldSchema(schema.children[0], null);
35
- fdmItems = [];
36
- fieldIdMap = new Map();
37
- schema.state = schema.state || {};
38
- schema.methods = schema.methods || {};
39
- _context.next = 9;
40
- return handleAssociationForm(formFieldSchema, schema);
41
- case 9:
42
- //初次处理
43
- forEachFormSchema(schema, function (field) {
44
- if (field.fdmSchema) {
45
- var _field$fdmSchema, _field$fdmSchema2;
46
- fdmItems.push(field);
47
- field.fdmSchema.props = ((_field$fdmSchema = field.fdmSchema) === null || _field$fdmSchema === void 0 ? void 0 : _field$fdmSchema.props) || {};
48
- field.fdmSchema.props.style = ((_field$fdmSchema2 = field.fdmSchema) === null || _field$fdmSchema2 === void 0 ? void 0 : _field$fdmSchema2.props.style) || {};
49
- field.fdmSchema.props.style.height = "100%";
50
- }
51
- if (field.props.fieldId) {
52
- //删除children防止循环
53
- var copyField = JSON.parse(JSON.stringify(field));
54
- delete copyField.children;
55
- fieldIdMap.set(field.props.fieldId, copyField);
56
- }
57
- return true;
58
- });
59
-
60
- //处理查询列
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
- });
102
- }
103
- }
104
- }
105
- return true;
106
- });
107
- case 16:
108
- _i++;
109
- _context.next = 11;
110
- break;
111
- case 19:
112
- case "end":
113
- return _context.stop();
114
- }
115
- }, _callee);
116
- }));
117
- return _handleFormSchema.apply(this, arguments);
118
- }
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) {
167
- return _handleAssociationForm.apply(this, arguments);
168
- }
169
- function _handleAssociationForm() {
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) {
174
- case 0:
175
- //关联属性
176
- associationAttributeFields = []; //关联查询
177
- forEachFormSchema(schema, function (field) {
178
- if (field.componentName == "AssociationAttributeField") {
179
- associationAttributeFields.push(field);
180
- }
181
- return true;
182
- });
183
-
184
- //处理关联属性 赋值schema
185
- _i3 = 0, _associationAttribute2 = associationAttributeFields;
186
- case 3:
187
- if (!(_i3 < _associationAttribute2.length)) {
188
- _context3.next = 13;
189
- break;
190
- }
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;
200
- }
201
- case 10:
202
- _i3++;
203
- _context3.next = 3;
204
- break;
205
- case 13:
206
- case "end":
207
- return _context3.stop();
208
- }
209
- }, _callee3);
210
- }));
211
- return _handleAssociationForm.apply(this, arguments);
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
5
  /**
313
6
  * 遍历schema
314
7
  * @param schema
@@ -322,87 +15,4 @@ function forEachFormSchema(schema, callback) {
322
15
  forEachFormSchema(child, callback);
323
16
  }
324
17
  });
325
- }
326
- var FormFieldSchema = /*#__PURE__*/function () {
327
- function FormFieldSchema(schema, parent) {
328
- var _schema$children2,
329
- _this = this;
330
- this.fieldId = void 0;
331
- this.componentName = void 0;
332
- this.parent = void 0;
333
- this.schema = void 0;
334
- this.children = void 0;
335
- this.schema = schema;
336
- this.parent = parent;
337
- this.children = [];
338
- this.fieldId = schema.props.fieldId;
339
- this.componentName = schema.componentName;
340
- (_schema$children2 = schema.children) === null || _schema$children2 === void 0 ? void 0 : _schema$children2.forEach(function (item) {
341
- _this.children.push(new FormFieldSchema(item, _this));
342
- });
343
- }
344
- var _proto = FormFieldSchema.prototype;
345
- _proto.findFieldById = function findFieldById(fieldId) {
346
- if (this.fieldId == fieldId) {
347
- return this;
348
- }
349
- for (var _iterator = _createForOfIteratorHelperLoose(this.children), _step; !(_step = _iterator()).done;) {
350
- var _child = _step.value;
351
- if (_child.findFieldById(fieldId)) {
352
- return _child.findFieldById(fieldId);
353
- }
354
- }
355
- return null;
356
- };
357
- _proto.getFieldPaths = function getFieldPaths() {
358
- var paths = [];
359
- function loopParent(field) {
360
- if (field !== null && field !== void 0 && field.parent) {
361
- paths.push(field.parent);
362
- loopParent(field.parent);
363
- }
364
- }
365
- loopParent(this);
366
- paths.reverse();
367
- paths = paths.filter(function (item) {
368
- return ["SubFormField"].includes(item.componentName);
369
- });
370
- paths.push(this);
371
- return paths.map(function (item) {
372
- return item.fieldId;
373
- }).join(".");
374
- };
375
- return FormFieldSchema;
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
18
  }
@@ -0,0 +1,3 @@
1
+ export declare const FormIds: {
2
+ printTemplate: string;
3
+ };