@zhubangyun/lowcode-core 6.3.20 → 6.4.4

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 (65) hide show
  1. package/es/index.d.ts +1 -1
  2. package/es/index.js +5 -5
  3. package/es/index.less +0 -1
  4. package/es/utils/api/form-api/form-api.assemble-entity.js +9 -3
  5. package/es/utils/api/form-api/form-api.utils.js +13 -19
  6. package/es/utils/api/form-api.d.ts +0 -1
  7. package/es/utils/api/form-api.js +4 -37
  8. package/es/utils/api/index.d.ts +6 -1
  9. package/es/utils/api/rest-api.d.ts +2 -0
  10. package/es/utils/api/rest-api.js +125 -108
  11. package/es/utils/api/script-api.d.ts +1 -1
  12. package/es/utils/cache/cache.load-data.d.ts +1 -0
  13. package/es/utils/cache/cache.load-data.js +41 -0
  14. package/es/utils/cache/cache.page-permission.d.ts +1 -0
  15. package/es/utils/cache/cache.page-permission.js +28 -0
  16. package/es/utils/cache/cache.page-print.d.ts +1 -0
  17. package/es/utils/cache/cache.page-print.js +25 -0
  18. package/es/utils/cache/cache.page-schema.d.ts +1 -0
  19. package/es/utils/cache/cache.page-schema.js +96 -0
  20. package/es/utils/cache/cache.print.js +0 -0
  21. package/es/utils/cache/index.d.ts +5 -6
  22. package/es/utils/cache/index.js +19 -32
  23. package/es/utils/cache/index_db_cache.d.ts +11 -6
  24. package/es/utils/cache/index_db_cache.js +57 -5
  25. package/es/utils/page/index.js +1 -1
  26. package/es/utils/page/page-form-data-manager.d.ts +2 -1
  27. package/es/utils/page/page-form-group.js +10 -4
  28. package/es/utils/page/page-layout.d.ts +1 -1
  29. package/es/utils/page/page-load-schema.js +33 -15
  30. package/es/utils/page/page-render.js +5 -1
  31. package/es/utils/page/page-schema-utils.js +18 -2
  32. package/es/utils/page/print-form.js +2 -4
  33. package/lib/index.d.ts +1 -1
  34. package/lib/index.js +6 -6
  35. package/lib/index.less +0 -1
  36. package/lib/utils/api/form-api/form-api.assemble-entity.js +9 -3
  37. package/lib/utils/api/form-api/form-api.utils.js +13 -19
  38. package/lib/utils/api/form-api.d.ts +0 -1
  39. package/lib/utils/api/form-api.js +4 -37
  40. package/lib/utils/api/index.d.ts +6 -1
  41. package/lib/utils/api/rest-api.d.ts +2 -0
  42. package/lib/utils/api/rest-api.js +125 -108
  43. package/lib/utils/api/script-api.d.ts +1 -1
  44. package/lib/utils/cache/cache.load-data.d.ts +1 -0
  45. package/lib/utils/cache/cache.load-data.js +44 -0
  46. package/lib/utils/cache/cache.page-permission.d.ts +1 -0
  47. package/lib/utils/cache/cache.page-permission.js +33 -0
  48. package/lib/utils/cache/cache.page-print.d.ts +1 -0
  49. package/lib/utils/cache/cache.page-print.js +30 -0
  50. package/lib/utils/cache/cache.page-schema.d.ts +1 -0
  51. package/lib/utils/cache/cache.page-schema.js +101 -0
  52. package/lib/utils/cache/cache.print.js +1 -0
  53. package/lib/utils/cache/index.d.ts +5 -6
  54. package/lib/utils/cache/index.js +23 -35
  55. package/lib/utils/cache/index_db_cache.d.ts +11 -6
  56. package/lib/utils/cache/index_db_cache.js +61 -6
  57. package/lib/utils/page/index.js +1 -1
  58. package/lib/utils/page/page-form-data-manager.d.ts +2 -1
  59. package/lib/utils/page/page-form-group.js +10 -4
  60. package/lib/utils/page/page-layout.d.ts +1 -1
  61. package/lib/utils/page/page-load-schema.js +32 -14
  62. package/lib/utils/page/page-render.js +5 -1
  63. package/lib/utils/page/page-schema-utils.js +18 -2
  64. package/lib/utils/page/print-form.js +2 -4
  65. package/package.json +1 -1
@@ -0,0 +1,96 @@
1
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
3
+ function _createForOfIteratorHelperLoose(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (t) return (t = t.call(r)).next.bind(t); if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var o = 0; return function () { return o >= r.length ? { done: !0 } : { done: !1, value: r[o++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
5
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
6
+ import { page_schema_store } from "./index_db_cache";
7
+ import { getPagePermission } from "./cache.page-permission";
8
+ import { getPagePrintTemplates } from "./cache.page-print";
9
+ import { findFdmSchemas, findFormSchemas, findLoadRefSchemas } from "../api/schema.util";
10
+ var pageSchemaCacheMap = new Map();
11
+ export function loadPageSchema(_x) {
12
+ return _loadPageSchema.apply(this, arguments);
13
+ }
14
+ function _loadPageSchema() {
15
+ _loadPageSchema = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(pageId) {
16
+ var schema, permission, printTemplates, handleCommonSchema, cloneSchema, refs, _iterator, _step, _ref$props, _ref$props$fieldProps, _ref$props$fieldProps2, ref, refPageId;
17
+ return _regeneratorRuntime.wrap(function (_context) {
18
+ while (1) switch (_context.prev = _context.next) {
19
+ case 0:
20
+ handleCommonSchema = function _handleCommonSchema(schema) {
21
+ schema.props = schema.props || {};
22
+ schema.props.permission = permission;
23
+ schema.props.printTemplates = printTemplates;
24
+ };
25
+ if (!pageSchemaCacheMap.has(pageId)) {
26
+ _context.next = 1;
27
+ break;
28
+ }
29
+ return _context.abrupt("return", pageSchemaCacheMap.get(pageId));
30
+ case 1:
31
+ _context.next = 2;
32
+ return page_schema_store.get(pageId);
33
+ case 2:
34
+ schema = _context.sent;
35
+ if (schema) {
36
+ _context.next = 3;
37
+ break;
38
+ }
39
+ return _context.abrupt("return", null);
40
+ case 3:
41
+ _context.next = 4;
42
+ return getPagePermission(pageId);
43
+ case 4:
44
+ permission = _context.sent;
45
+ _context.next = 5;
46
+ return getPagePrintTemplates(pageId);
47
+ case 5:
48
+ printTemplates = _context.sent;
49
+ //循环处理表单和子表单
50
+ findFormSchemas(schema).forEach(function (formSchema) {
51
+ handleCommonSchema(formSchema);
52
+ findFdmSchemas(formSchema.fdmSchema).forEach(function (fdmSchema) {
53
+ handleCommonSchema(fdmSchema);
54
+ fdmSchema.props.form.label = formSchema.props.label;
55
+ });
56
+ });
57
+
58
+ //传入formElement 表单特殊运用
59
+ cloneSchema = JSON.parse(JSON.stringify(schema));
60
+ findFormSchemas(schema).forEach(function (formSchema) {
61
+ findFdmSchemas(formSchema.fdmSchema).forEach(function (fdmSchema) {
62
+ fdmSchema.props.formElement = cloneSchema;
63
+ });
64
+ });
65
+
66
+ //加载相关表
67
+ refs = findLoadRefSchemas(schema);
68
+ _iterator = _createForOfIteratorHelperLoose(refs);
69
+ case 6:
70
+ if ((_step = _iterator()).done) {
71
+ _context.next = 8;
72
+ break;
73
+ }
74
+ ref = _step.value;
75
+ refPageId = (_ref$props = ref.props) === null || _ref$props === void 0 ? void 0 : (_ref$props$fieldProps = _ref$props.fieldProps) === null || _ref$props$fieldProps === void 0 ? void 0 : (_ref$props$fieldProps2 = _ref$props$fieldProps.associationForm) === null || _ref$props$fieldProps2 === void 0 ? void 0 : _ref$props$fieldProps2.id;
76
+ if (!(typeof refPageId == "string" && refPageId !== pageId)) {
77
+ _context.next = 7;
78
+ break;
79
+ }
80
+ if (pageSchemaCacheMap.has(refPageId)) {
81
+ _context.next = 7;
82
+ break;
83
+ }
84
+ _context.next = 7;
85
+ return loadPageSchema(refPageId);
86
+ case 7:
87
+ _context.next = 6;
88
+ break;
89
+ case 8:
90
+ case "end":
91
+ return _context.stop();
92
+ }
93
+ }, _callee);
94
+ }));
95
+ return _loadPageSchema.apply(this, arguments);
96
+ }
File without changes
@@ -1,5 +1,7 @@
1
1
  import { SingletonInstanceMap } from "../common/SingletonInstanceMap";
2
2
  import { RestFormApi } from "../api";
3
+ export { initialize } from "./index_db_cache";
4
+ export { db_cache } from "./index_db_cache";
3
5
  export declare class SchemaCache extends SingletonInstanceMap<any, {
4
6
  mock?: boolean;
5
7
  pageId: string;
@@ -7,11 +9,8 @@ export declare class SchemaCache extends SingletonInstanceMap<any, {
7
9
  createInstance(key: string, options: any): Promise<any>;
8
10
  }
9
11
  export declare const schema: SchemaCache;
10
- export declare class FormApiCache extends SingletonInstanceMap<RestFormApi<any>, {
11
- formId: string;
12
- fieldId?: string;
13
- mock?: boolean;
14
- }> {
15
- createInstance(key: string, options?: any): Promise<RestFormApi<any>>;
12
+ export declare class FormApiCache {
13
+ cache: Map<string, RestFormApi<any>>;
14
+ getInstance(key: string, options?: any): RestFormApi<any>;
16
15
  }
17
16
  export declare const formApi: FormApiCache;
@@ -7,6 +7,8 @@ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length)
7
7
  import { SingletonInstanceMap } from "../common/SingletonInstanceMap";
8
8
  import { apiRequest, RestFormApi } from "../api";
9
9
  import { findFdmSchemas, findFormSchemas, findLoadRefSchemas } from "../api/schema.util";
10
+ export { initialize } from "./index_db_cache";
11
+ export { db_cache } from "./index_db_cache";
10
12
  export var SchemaCache = /*#__PURE__*/function (_SingletonInstanceMap) {
11
13
  function SchemaCache() {
12
14
  return _SingletonInstanceMap.apply(this, arguments) || this;
@@ -15,7 +17,7 @@ export var SchemaCache = /*#__PURE__*/function (_SingletonInstanceMap) {
15
17
  var _proto = SchemaCache.prototype;
16
18
  _proto.createInstance = /*#__PURE__*/function () {
17
19
  var _createInstance = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(key, options) {
18
- var mock, pageId, params, schemaRes, schema, handleCommonSchema, permission, printTemplates, workflow, cloneSchema, refs, _iterator, _step, _ref$props, _ref$props$fieldProps, _ref$props$fieldProps2, ref, refPageId, _key, _t;
20
+ var mock, pageId, params, schemaRes, schema, handleCommonSchema, permission, printTemplates, cloneSchema, refs, _iterator, _step, _ref$props, _ref$props$fieldProps, _ref$props$fieldProps2, ref, refPageId, _key, _t;
19
21
  return _regeneratorRuntime.wrap(function (_context) {
20
22
  while (1) switch (_context.prev = _context.next) {
21
23
  case 0:
@@ -39,11 +41,9 @@ export var SchemaCache = /*#__PURE__*/function (_SingletonInstanceMap) {
39
41
  schema.props = schema.props || {};
40
42
  schema.props.permission = permission;
41
43
  schema.props.printTemplates = printTemplates;
42
- schema.props.workflow = workflow;
43
44
  };
44
45
  //处理权限
45
46
  permission = null; //处理打印
46
- workflow = null;
47
47
  if (location.pathname.startsWith("/print")) {
48
48
  _context.next = 6;
49
49
  break;
@@ -127,38 +127,25 @@ export var SchemaCache = /*#__PURE__*/function (_SingletonInstanceMap) {
127
127
  return SchemaCache;
128
128
  }(SingletonInstanceMap);
129
129
  export var schema = new SchemaCache();
130
- export var FormApiCache = /*#__PURE__*/function (_SingletonInstanceMap2) {
130
+ export var FormApiCache = /*#__PURE__*/function () {
131
131
  function FormApiCache() {
132
- return _SingletonInstanceMap2.apply(this, arguments) || this;
132
+ this.cache = new Map();
133
133
  }
134
- _inheritsLoose(FormApiCache, _SingletonInstanceMap2);
135
134
  var _proto2 = FormApiCache.prototype;
136
- _proto2.createInstance = /*#__PURE__*/function () {
137
- var _createInstance2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(key, options) {
138
- var _options, formId, fieldId, mock, formApi;
139
- return _regeneratorRuntime.wrap(function (_context2) {
140
- while (1) switch (_context2.prev = _context2.next) {
141
- case 0:
142
- if (options === void 0) {
143
- options = {};
144
- }
145
- _options = options, formId = _options.formId, fieldId = _options.fieldId, mock = _options.mock;
146
- formApi = new RestFormApi(formId, fieldId, mock);
147
- _context2.next = 1;
148
- return formApi.initialize();
149
- case 1:
150
- return _context2.abrupt("return", formApi);
151
- case 2:
152
- case "end":
153
- return _context2.stop();
154
- }
155
- }, _callee2);
156
- }));
157
- function createInstance(_x3, _x4) {
158
- return _createInstance2.apply(this, arguments);
135
+ _proto2.getInstance = function getInstance(key, options) {
136
+ if (options === void 0) {
137
+ options = {};
159
138
  }
160
- return createInstance;
161
- }();
139
+ if (!this.cache.has(key)) {
140
+ var _options = options,
141
+ formId = _options.formId,
142
+ fieldId = _options.fieldId,
143
+ mock = _options.mock;
144
+ var _formApi = new RestFormApi(formId, fieldId, mock);
145
+ this.cache.set(key, _formApi);
146
+ }
147
+ return this.cache.get(key);
148
+ };
162
149
  return FormApiCache;
163
- }(SingletonInstanceMap);
150
+ }();
164
151
  export var formApi = new FormApiCache();
@@ -1,9 +1,14 @@
1
1
  import { Dexie, type EntityTable } from "dexie";
2
- export interface Friend {
3
- page_id: string;
4
- schema: any;
2
+ export interface BaseData {
3
+ id: string;
4
+ value: any;
5
5
  }
6
- declare const db_cache: Dexie & {
7
- page_schemas: EntityTable<Friend, 'page_id'>;
6
+ export declare const db_cache: Dexie & {
7
+ page_schema: EntityTable<BaseData, 'id'>;
8
+ page_permission: EntityTable<BaseData, 'id'>;
9
+ page_print: EntityTable<BaseData, 'id'>;
8
10
  };
9
- export default db_cache;
11
+ export declare const page_schema_store: EntityTable<BaseData, "id", import("dexie").InsertType<BaseData, "id">>;
12
+ export declare const page_permission_store: EntityTable<BaseData, "id", import("dexie").InsertType<BaseData, "id">>;
13
+ export declare const page_print_store: EntityTable<BaseData, "id", import("dexie").InsertType<BaseData, "id">>;
14
+ export declare function initialize(): Promise<void>;
@@ -1,7 +1,59 @@
1
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
+ var _window$version$schem, _window$version, _window$version$permi, _window$version2, _window$version$print, _window$version3;
3
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
1
4
  import { Dexie } from "dexie";
2
- var db_cache = new Dexie('cache');
3
- db_cache.version(1).stores({
4
- page_schemas: 'page_id,schema'
5
+ export var db_cache = new Dexie('cache');
6
+ db_cache.version((_window$version$schem = (_window$version = window.version) === null || _window$version === void 0 ? void 0 : _window$version.schema) !== null && _window$version$schem !== void 0 ? _window$version$schem : 1).stores({
7
+ page_schema: 'id,value'
5
8
  });
6
- var page_schemas = db_cache.page_schemas;
7
- export default db_cache;
9
+ db_cache.version((_window$version$permi = (_window$version2 = window.version) === null || _window$version2 === void 0 ? void 0 : _window$version2.permission) !== null && _window$version$permi !== void 0 ? _window$version$permi : 1).stores({
10
+ page_permission: 'id,value'
11
+ });
12
+ db_cache.version((_window$version$print = (_window$version3 = window.version) === null || _window$version3 === void 0 ? void 0 : _window$version3.print) !== null && _window$version$print !== void 0 ? _window$version$print : 1).stores({
13
+ page_print: 'id,value'
14
+ });
15
+ export var page_schema_store = db_cache.page_schema;
16
+ export var page_permission_store = db_cache.page_permission;
17
+ export var page_print_store = db_cache.page_print;
18
+ export function initialize() {
19
+ return _initialize.apply(this, arguments);
20
+ }
21
+ function _initialize() {
22
+ _initialize = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
23
+ var count, schemas, _t;
24
+ return _regeneratorRuntime.wrap(function (_context) {
25
+ while (1) switch (_context.prev = _context.next) {
26
+ case 0:
27
+ _context.prev = 0;
28
+ _context.next = 1;
29
+ return page_schema_store.count();
30
+ case 1:
31
+ count = _context.sent;
32
+ if (!(count == 0)) {
33
+ _context.next = 3;
34
+ break;
35
+ }
36
+ _context.next = 2;
37
+ return cacheLoadSchemas();
38
+ case 2:
39
+ schemas = _context.sent;
40
+ try {
41
+ db_cache.page_schema.bulkAdd(schemas);
42
+ } catch (e) {
43
+ console.error("加载缓存失败!", e);
44
+ }
45
+ case 3:
46
+ _context.next = 5;
47
+ break;
48
+ case 4:
49
+ _context.prev = 4;
50
+ _t = _context["catch"](0);
51
+ console.log(_t);
52
+ case 5:
53
+ case "end":
54
+ return _context.stop();
55
+ }
56
+ }, _callee, null, [[0, 4]]);
57
+ }));
58
+ return _initialize.apply(this, arguments);
59
+ }
@@ -74,7 +74,7 @@ export function openPage(_x, _x2) {
74
74
  function _openPage() {
75
75
  _openPage = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(url, target) {
76
76
  var _window$parent;
77
- var page, func;
77
+ var func;
78
78
  return _regeneratorRuntime.wrap(function (_context3) {
79
79
  while (1) switch (_context3.prev = _context3.next) {
80
80
  case 0:
@@ -6,6 +6,7 @@ interface FillRule {
6
6
  key: string;
7
7
  value: string;
8
8
  }
9
+ export type DefaultActionType = "add" | "edit" | "remove" | "temporary" | "print" | "copy" | "comment";
9
10
  export interface DataView {
10
11
  form?: {
11
12
  id?: string;
@@ -36,7 +37,7 @@ export interface DataView {
36
37
  };
37
38
  customActions?: {
38
39
  enable?: boolean;
39
- defaults?: string[];
40
+ defaults?: DefaultActionType[];
40
41
  toolbarLeftOptions?: string[];
41
42
  toolbarRightOptions?: string[];
42
43
  footerLeftOptions?: string[];
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
3
3
  import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
4
4
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
5
- var _excluded = ["layout", "form", "items", "onClose"],
5
+ var _excluded = ["layout", "form", "onClose", "onSubmitOk"],
6
6
  _excluded2 = ["container", "onClose"];
7
7
  import _regeneratorRuntime from "@babel/runtime/regenerator";
8
8
  import { PageLayout } from "./page-layout";
@@ -55,8 +55,8 @@ var FormGroupRender = /*#__PURE__*/function (_Component) {
55
55
  var _this$props = this.props,
56
56
  layout = _this$props.layout,
57
57
  form = _this$props.form,
58
- items = _this$props.items,
59
58
  onClose = _this$props.onClose,
59
+ onSubmitOk = _this$props.onSubmitOk,
60
60
  restProps = _objectWithoutPropertiesLoose(_this$props, _excluded);
61
61
  // @ts-ignore
62
62
  restProps.layout = layout || "modal";
@@ -66,6 +66,12 @@ var FormGroupRender = /*#__PURE__*/function (_Component) {
66
66
  (_self$layoutRef = self.layoutRef) === null || _self$layoutRef === void 0 ? void 0 : _self$layoutRef.close();
67
67
  onClose === null || onClose === void 0 ? void 0 : onClose();
68
68
  };
69
+ // @ts-ignore
70
+ restProps.onSubmitOk = function (data) {
71
+ var _self$layoutRef2;
72
+ onSubmitOk === null || onSubmitOk === void 0 ? void 0 : onSubmitOk(data);
73
+ (_self$layoutRef2 = self.layoutRef) === null || _self$layoutRef2 === void 0 ? void 0 : _self$layoutRef2.close();
74
+ };
69
75
  return /*#__PURE__*/React.createElement(PageLayout, {
70
76
  ref: function ref(layout) {
71
77
  return _this2.layoutRef = layout;
@@ -85,9 +91,9 @@ var FormGroupRender = /*#__PURE__*/function (_Component) {
85
91
  children: [{
86
92
  componentName: "PageFormGroup",
87
93
  props: {
94
+ mode: "show",
88
95
  title: schema.label,
89
- form: form,
90
- items: items
96
+ form: form
91
97
  }
92
98
  }]
93
99
  }
@@ -1,5 +1,5 @@
1
1
  import { Component } from "react";
2
- export type PageLayoutType = "page" | "modal" | "drawer";
2
+ export type PageLayoutType = "page" | "modal" | "drawer" | "blank";
3
3
  interface PageLayoutProps {
4
4
  container?: any;
5
5
  layout?: PageLayoutType;
@@ -1,25 +1,28 @@
1
1
  import _Result from "antd/es/result";
2
2
  import _message from "antd/es/message";
3
- import { Fragment, useEffect, useState } from "react";
3
+ import { useEffect, useState } from "react";
4
4
  import { getSchema } from "../api";
5
5
  import { getSchemaFromCache } from "../api/schema-api";
6
- import { hideLoading, showLoading } from "./index";
6
+ import { PageLoading } from "../../components/page-loading";
7
7
  export function PageLoadSchema(props) {
8
8
  var pageId = props.pageId,
9
9
  children = props.children;
10
10
  var cache = getSchemaFromCache(pageId);
11
- var _useState = useState(cache === null || cache === void 0 ? void 0 : cache.data),
12
- schema = _useState[0],
13
- setSchema = _useState[1];
14
- var _useState2 = useState(),
15
- errorMsg = _useState2[0],
16
- setErrorMsg = _useState2[1];
11
+ var _useState = useState(false),
12
+ loading = _useState[0],
13
+ setLoading = _useState[1];
14
+ var _useState2 = useState(cache === null || cache === void 0 ? void 0 : cache.data),
15
+ schema = _useState2[0],
16
+ setSchema = _useState2[1];
17
+ var _useState3 = useState(),
18
+ errorMsg = _useState3[0],
19
+ setErrorMsg = _useState3[1];
17
20
  useEffect(function () {
18
21
  if (cache !== null && cache !== void 0 && cache.success) {
19
22
  return;
20
23
  }
21
24
  if (pageId) {
22
- showLoading().then();
25
+ setLoading(true);
23
26
  getSchema(pageId).then(function (res) {
24
27
  if (res.success) {
25
28
  setSchema(res === null || res === void 0 ? void 0 : res.data);
@@ -27,22 +30,37 @@ export function PageLoadSchema(props) {
27
30
  setErrorMsg(res === null || res === void 0 ? void 0 : res.message);
28
31
  }
29
32
  })["finally"](function () {
30
- hideLoading().then();
33
+ setLoading(false);
31
34
  });
32
35
  } else {
33
- hideLoading().then();
36
+ setLoading(false);
34
37
  setErrorMsg("参数错误:页面id不可为空!");
35
38
  _message.error("参数错误:页面id不可为空!").then();
36
39
  }
37
40
  }, []);
38
- if (schema) {
39
- return children(schema);
40
- }
41
41
  if (errorMsg) {
42
42
  return /*#__PURE__*/React.createElement(_Result, {
43
43
  status: 500,
44
44
  title: errorMsg
45
45
  });
46
46
  }
47
- return /*#__PURE__*/React.createElement(Fragment, null);
47
+ if (schema) {
48
+ return children(schema);
49
+ }
50
+ if (loading) {
51
+ return /*#__PURE__*/React.createElement(PageLoading, {
52
+ loading: loading
53
+ }, /*#__PURE__*/React.createElement("div", {
54
+ style: {
55
+ width: "100%",
56
+ height: "100%"
57
+ }
58
+ }));
59
+ }
60
+ return /*#__PURE__*/React.createElement("div", {
61
+ style: {
62
+ width: "100%",
63
+ height: "100%"
64
+ }
65
+ });
48
66
  }
@@ -20,10 +20,14 @@ export function renderElement(options) {
20
20
  root = createRoot(container);
21
21
  element = /*#__PURE__*/createElement(component, _extends({}, props, {
22
22
  onSelectOk: function onSelectOk(data) {
23
+ if (props.onSelectOk) {
24
+ var _props$onSelectOk;
25
+ (_props$onSelectOk = props.onSelectOk) === null || _props$onSelectOk === void 0 ? void 0 : _props$onSelectOk.call(props, data || null);
26
+ }
23
27
  resolve(data || null);
24
28
  },
25
29
  onClose: function onClose() {
26
- resolve(null);
30
+ resolve(undefined);
27
31
  //等待动画结束
28
32
  setTimeout(function () {
29
33
  root.unmount();
@@ -1,4 +1,18 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
+ function replacer(key, value) {
3
+ if (value == null) {
4
+ return null;
5
+ } else if (Array.isArray(value)) {
6
+ return value;
7
+ } else if (value !== null && value !== void 0 && value.id) {
8
+ return {
9
+ id: value.id,
10
+ label: value.label,
11
+ form: value.form
12
+ };
13
+ }
14
+ return value;
15
+ }
2
16
  export function cloneDataView(dataView, extraProps) {
3
17
  if (!dataView) {
4
18
  return {};
@@ -61,10 +75,12 @@ function compileFilterRules(rules) {
61
75
  value = "undefined";
62
76
  }
63
77
  } else if (rule.valueType == "value" || rule.valueType == "column" || !rule.valueType || typeof value === "object") {
64
- value = JSON.stringify(value);
78
+ value = JSON.stringify(value, replacer);
65
79
  }
66
80
  scripts.push("\"key\":\"" + rule.key + "\",");
67
- scripts.push("\"valueType\":\"" + rule.valueType + "\",");
81
+ if (rule.valueType != null) {
82
+ scripts.push("\"valueType\":\"" + rule.valueType + "\",");
83
+ }
68
84
  scripts.push("\"operator\":\"" + rule.operator + "\",");
69
85
  scripts.push("\"value\":" + value + ",");
70
86
  }
@@ -127,6 +127,8 @@ function _openPrint() {
127
127
  iframe.src = url;
128
128
  iframe.className = "print-iframe";
129
129
  iframe.onload = function () {
130
+ // @ts-ignore
131
+ iframe.contentWindow.__mock = window.__mock;
130
132
  // @ts-ignore
131
133
  iframe.contentWindow.printOptions = options;
132
134
  };
@@ -141,10 +143,6 @@ function _openPrint() {
141
143
  case 1:
142
144
  // @ts-ignore
143
145
  window.printWindow = printWindow;
144
- printWindow.onload = function () {
145
- // @ts-ignore
146
- printWindow.printOptions = options;
147
- };
148
146
  printWindow.addEventListener("beforeprint", function () {});
149
147
  printWindow.addEventListener("afterprint", /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
150
148
  var _printWindow, printer, _printWindow2, doc, html;
package/lib/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import "./index.less";
2
2
  import * as lodash from "lodash";
3
+ import utils from "./utils/index";
3
4
  export { LoadMaterials } from "./components/load-materials";
4
5
  export { PageLoading } from "./components/page-loading";
5
6
  export { RestApi, RestFormApi, apiRequest } from "./utils/api";
6
7
  export { Layout } from "./components/layout";
7
8
  export { ReactRender } from "./components/react-render";
8
- import utils from "./utils/index";
9
9
  export { utils, lodash };
package/lib/index.js CHANGED
@@ -9,6 +9,12 @@ var _reactRender = require("./components/react-render");
9
9
  exports.ReactRender = _reactRender.ReactRender;
10
10
  var lodash = _interopRequireWildcard(require("lodash"));
11
11
  exports.lodash = lodash;
12
+ var _index2 = _interopRequireDefault(require("./utils/index"));
13
+ exports.utils = _index2["default"];
14
+ var _uniBridge = require("./utils/uni-bridge");
15
+ var _init = require("./init/init.bar-height");
16
+ var _init2 = require("./init/init.scroll-size");
17
+ var _init3 = require("./init/init.mobile-class");
12
18
  var _loadMaterials = require("./components/load-materials");
13
19
  exports.LoadMaterials = _loadMaterials.LoadMaterials;
14
20
  var _pageLoading = require("./components/page-loading");
@@ -19,12 +25,6 @@ exports.RestFormApi = _api.RestFormApi;
19
25
  exports.apiRequest = _api.apiRequest;
20
26
  var _layout = require("./components/layout");
21
27
  exports.Layout = _layout.Layout;
22
- var _index2 = _interopRequireDefault(require("./utils/index"));
23
- exports.utils = _index2["default"];
24
- var _uniBridge = require("./utils/uni-bridge");
25
- var _init = require("./init/init.bar-height");
26
- var _init2 = require("./init/init.scroll-size");
27
- var _init3 = require("./init/init.mobile-class");
28
28
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
29
29
  // @ts-ignore
30
30
  window.__ReactRender = _reactRender.ReactRender;
package/lib/index.less CHANGED
@@ -12,7 +12,6 @@
12
12
  height: 100%;
13
13
  }
14
14
 
15
-
16
15
  ul {
17
16
  margin-bottom: 0;
18
17
  padding-left: 0;
@@ -27,7 +27,7 @@ function assembleData(data, dataMap) {
27
27
  for (var _iterator2 = _createForOfIteratorHelperLoose(data), _step2; !(_step2 = _iterator2()).done;) {
28
28
  var item = _step2.value;
29
29
  assembleObject(item, dataMap, {
30
- maxDepth: 5,
30
+ maxDepth: 3,
31
31
  depth: 1
32
32
  });
33
33
  }
@@ -44,7 +44,7 @@ function assembleRefs(refs, dataMap) {
44
44
  for (var _iterator4 = _createForOfIteratorHelperLoose(data), _step4; !(_step4 = _iterator4()).done;) {
45
45
  var item = _step4.value;
46
46
  assembleObject(item, dataMap, {
47
- maxDepth: 2,
47
+ maxDepth: 3,
48
48
  depth: 1
49
49
  });
50
50
  }
@@ -77,7 +77,7 @@ function assembleObject(values, dataMap, options) {
77
77
  var valueElement = _step5.value;
78
78
  assembleObject(valueElement, dataMap, {
79
79
  maxDepth: maxDepth,
80
- depth: depth + 1
80
+ depth: depth
81
81
  });
82
82
  }
83
83
  }
@@ -86,6 +86,12 @@ function assembleObject(values, dataMap, options) {
86
86
  if (dataMap.hasEntity(value)) {
87
87
  values[key] = dataMap.getEntity(value);
88
88
  }
89
+ } else if (key == "parent") {
90
+ //values.parent = dataMap.getEntity(value);
91
+ Object.defineProperty(values, "parent", {
92
+ value: dataMap.getEntity(value),
93
+ writable: true
94
+ });
89
95
  }
90
96
  }
91
97
  }