@zhubangyun/lowcode-core 5.10.221 → 5.12.90

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 +47 -47
  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 +10 -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 +10 -1
  24. package/es/utils/page/page-form-data-manager-group.js +3 -7
  25. package/es/utils/page/page-form-data-manager.d.ts +49 -7
  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 +47 -47
  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 +10 -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 +10 -1
  58. package/lib/utils/page/page-form-data-manager-group.js +3 -7
  59. package/lib/utils/page/page-form-data-manager.d.ts +49 -7
  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
@@ -1,19 +1,59 @@
1
1
  import { PageLayoutType } from "./page-layout";
2
- import { FilterRule } from "../api/rest-api";
3
- export type PageFormDataManagerModeType = "associationField" | "dataManager" | "selectOne" | "selectMore";
2
+ import { FilterRule, OrderRule } from "../api/rest-api";
3
+ import { FormInstance } from "antd";
4
+ export type PageFormDataManagerModeType = "associationField" | "dataManager" | "selectOne" | "selectMany";
5
+ interface FillRule {
6
+ key: string;
7
+ value: string;
8
+ }
9
+ export interface DataView {
10
+ form?: {
11
+ id?: string;
12
+ fieldId?: string;
13
+ };
14
+ labelField?: string;
15
+ secondaryLabelFields?: string[];
16
+ fieldWidth?: Record<string, number>;
17
+ filterRules: FilterRule[];
18
+ hiddenFields: string[];
19
+ searchFields: FilterRule[];
20
+ orderRules: OrderRule[];
21
+ fillRules?: {
22
+ mainRules: FillRule[];
23
+ tableRules: FillRule[];
24
+ };
25
+ showFields: {
26
+ key: string;
27
+ fixed?: boolean;
28
+ }[];
29
+ onSearch?: (params: any, form?: FormInstance) => void;
30
+ onLoadData?: (data: any[], form?: FormInstance) => void;
31
+ callbacks?: {
32
+ beforeSearch?: string;
33
+ afterSearch?: string;
34
+ beforeExport?: string;
35
+ };
36
+ customActions?: {
37
+ enable?: boolean;
38
+ defaults?: string[];
39
+ toolbarLeftOptions?: string[];
40
+ toolbarRightOptions?: string[];
41
+ footerLeftOptions?: string[];
42
+ footerRightOptions?: string[];
43
+ rowOptions?: string[];
44
+ };
45
+ }
4
46
  export interface ShowPageFormDataManagerProps {
5
47
  container?: HTMLDivElement;
6
48
  layout?: PageLayoutType;
49
+ title?: string;
7
50
  form?: {
8
51
  id: string;
9
52
  fieldId?: string;
10
53
  };
11
54
  mode?: PageFormDataManagerModeType;
12
- dataView?: {
13
- filterRules?: FilterRule[];
14
- searchFields?: FilterRule[];
15
- orderRules?: any[];
16
- };
55
+ dataView?: DataView;
56
+ defaultSelectedRows?: any[];
17
57
  extraProps?: any;
18
58
  onClose?: () => void | Promise<void>;
19
59
  onSearch?: (params: any[]) => void | Promise<void>;
@@ -21,5 +61,7 @@ export interface ShowPageFormDataManagerProps {
21
61
  data: any[];
22
62
  total: number;
23
63
  }) => void | Promise<void>;
64
+ pageRef?: (page: any) => void;
24
65
  }
25
66
  export declare function showFormDataManager(options: ShowPageFormDataManagerProps): Promise<any | any[]>;
67
+ export {};
@@ -92,6 +92,7 @@ var FormDataManagerRender = /*#__PURE__*/function (_Component) {
92
92
  return true;
93
93
  });
94
94
  }
95
+ fdmSchema.app = schema.app;
95
96
  return /*#__PURE__*/React.createElement(ReactRender, _extends({}, restProps, {
96
97
  schema: fdmSchema,
97
98
  components: window._components || window.components || window.__components
@@ -0,0 +1,17 @@
1
+ import { PageLayoutType } from "./page-layout";
2
+ import { PageFormModeType } from "./page-form";
3
+ export interface ShowFormGroupProps {
4
+ container?: HTMLDivElement;
5
+ layout?: PageLayoutType;
6
+ form?: {
7
+ id: string;
8
+ fieldId?: string;
9
+ };
10
+ items?: any[];
11
+ mode?: PageFormModeType;
12
+ onSubmitOk?: (data: any) => void;
13
+ onRemoveOk?: () => void;
14
+ onClose?: () => void | Promise<void>;
15
+ pageRef?: (page: any) => void;
16
+ }
17
+ export declare function showFormGroup(options: ShowFormGroupProps): Promise<any>;
@@ -0,0 +1,97 @@
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", "items", "onClose"],
6
+ _excluded2 = ["container", "onClose"];
7
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
8
+ import { PageLayout } from "./page-layout";
9
+ import { renderElement } from "./page-render";
10
+ import React, { Component } from "react";
11
+ import { ReactRender } from "../../components/react-render";
12
+ import { v4 } from "uuid";
13
+ import { PageLoadSchema } from "./page-load-schema";
14
+ export function showFormGroup(_x) {
15
+ return _showFormGroup.apply(this, arguments);
16
+ }
17
+ function _showFormGroup() {
18
+ _showFormGroup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(options) {
19
+ var container, onClose, props;
20
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
21
+ while (1) switch (_context.prev = _context.next) {
22
+ case 0:
23
+ container = options.container, onClose = options.onClose, props = _objectWithoutPropertiesLoose(options, _excluded2);
24
+ return _context.abrupt("return", renderElement({
25
+ container: container,
26
+ onClose: onClose,
27
+ element: {
28
+ component: FormGroupRender,
29
+ props: props
30
+ }
31
+ }));
32
+ case 2:
33
+ case "end":
34
+ return _context.stop();
35
+ }
36
+ }, _callee);
37
+ }));
38
+ return _showFormGroup.apply(this, arguments);
39
+ }
40
+ var FormGroupRender = /*#__PURE__*/function (_Component) {
41
+ function FormGroupRender() {
42
+ var _this;
43
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
44
+ args[_key] = arguments[_key];
45
+ }
46
+ _this = _Component.call.apply(_Component, [this].concat(args)) || this;
47
+ _this.layoutRef = void 0;
48
+ return _this;
49
+ }
50
+ _inheritsLoose(FormGroupRender, _Component);
51
+ var _proto = FormGroupRender.prototype;
52
+ _proto.render = function render() {
53
+ var _this2 = this;
54
+ var self = this;
55
+ var _this$props = this.props,
56
+ layout = _this$props.layout,
57
+ form = _this$props.form,
58
+ items = _this$props.items,
59
+ onClose = _this$props.onClose,
60
+ restProps = _objectWithoutPropertiesLoose(_this$props, _excluded);
61
+ // @ts-ignore
62
+ restProps.layout = layout || "modal";
63
+ // @ts-ignore
64
+ restProps.onClose = function () {
65
+ var _self$layoutRef;
66
+ (_self$layoutRef = self.layoutRef) === null || _self$layoutRef === void 0 ? void 0 : _self$layoutRef.close();
67
+ onClose === null || onClose === void 0 ? void 0 : onClose();
68
+ };
69
+ return /*#__PURE__*/React.createElement(PageLayout, {
70
+ layout: layout,
71
+ ref: function ref(layout) {
72
+ return _this2.layoutRef = layout;
73
+ }
74
+ }, /*#__PURE__*/React.createElement(PageLoadSchema, {
75
+ pageId: form === null || form === void 0 ? void 0 : form.id
76
+ }, function (schema) {
77
+ return /*#__PURE__*/React.createElement(ReactRender, _extends({}, restProps, {
78
+ components: window._components || window.components || window.__components,
79
+ schema: {
80
+ id: v4(),
81
+ componentName: "Page",
82
+ props: {},
83
+ state: {},
84
+ children: [{
85
+ componentName: "PageFormGroup",
86
+ props: {
87
+ title: schema.label,
88
+ form: form,
89
+ items: items
90
+ }
91
+ }]
92
+ }
93
+ }));
94
+ }));
95
+ };
96
+ return FormGroupRender;
97
+ }(Component);
@@ -10,8 +10,9 @@ export interface ShowFormProps {
10
10
  mode?: PageFormModeType;
11
11
  lockMode?: boolean;
12
12
  dataId?: string;
13
- onSubmitOk?: () => void;
13
+ onSubmitOk?: (data: any) => void;
14
14
  onRemoveOk?: () => void;
15
15
  onClose?: () => void | Promise<void>;
16
+ pageRef?: (page: any) => void;
16
17
  }
17
18
  export declare function showForm(options: ShowFormProps): Promise<any>;
@@ -16,7 +16,7 @@ export function showForm(_x) {
16
16
  }
17
17
  function _showForm() {
18
18
  _showForm = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(options) {
19
- var container, onClose, props, _options$form, paths, mode, dataId, params, url, page;
19
+ var container, onClose, props, _options$form, paths, mode, dataId, params, url, _page;
20
20
  return _regeneratorRuntime.wrap(function _callee$(_context) {
21
21
  while (1) switch (_context.prev = _context.next) {
22
22
  case 0:
@@ -35,8 +35,8 @@ function _showForm() {
35
35
  _context.next = 9;
36
36
  return openPage(url, url);
37
37
  case 9:
38
- page = _context.sent;
39
- console.debug("openPage", page);
38
+ _page = _context.sent;
39
+ console.debug("openPage", _page);
40
40
  return _context.abrupt("return");
41
41
  case 12:
42
42
  return _context.abrupt("return", renderElement({
@@ -37,8 +37,7 @@ export function renderElement(options) {
37
37
  }
38
38
  }));
39
39
  root.render(element);
40
- return _context.abrupt("return", element);
41
- case 8:
40
+ case 7:
42
41
  case "end":
43
42
  return _context.stop();
44
43
  }
@@ -4,5 +4,6 @@ export interface ShowPageProps {
4
4
  pageId: string;
5
5
  layout?: PageLayoutType;
6
6
  onClose?: () => void | Promise<void>;
7
+ pageRef?: (page: any) => void;
7
8
  }
8
9
  export declare function show(options: ShowPageProps): Promise<any | any[]>;
@@ -0,0 +1,8 @@
1
+ interface PrintOptions {
2
+ templateId: string;
3
+ mode?: "print" | "export";
4
+ data: any;
5
+ }
6
+ export declare function getFormPrintTemplates(formId: string): Promise<any[]>;
7
+ export declare function print(options: PrintOptions): Promise<void>;
8
+ export {};
@@ -0,0 +1,147 @@
1
+ import _message from "antd/es/message";
2
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
4
+ import { apiRequest } from "../api";
5
+ import { FormIds } from "../formIds";
6
+ import { hideLoading, showLoading } from "./index";
7
+ export function getFormPrintTemplates(_x) {
8
+ return _getFormPrintTemplates.apply(this, arguments);
9
+ }
10
+ function _getFormPrintTemplates() {
11
+ _getFormPrintTemplates = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(formId) {
12
+ var res;
13
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
14
+ while (1) switch (_context.prev = _context.next) {
15
+ case 0:
16
+ _context.next = 2;
17
+ return apiRequest.get("forms/search", {
18
+ params: {
19
+ formId: FormIds.printTemplate,
20
+ filterRules: [{
21
+ key: "page",
22
+ operator: "eq",
23
+ value: formId
24
+ }],
25
+ pageSize: 1000
26
+ }
27
+ });
28
+ case 2:
29
+ res = _context.sent;
30
+ if (!res.success) {
31
+ _context.next = 7;
32
+ break;
33
+ }
34
+ return _context.abrupt("return", res.data);
35
+ case 7:
36
+ return _context.abrupt("return", []);
37
+ case 8:
38
+ case "end":
39
+ return _context.stop();
40
+ }
41
+ }, _callee);
42
+ }));
43
+ return _getFormPrintTemplates.apply(this, arguments);
44
+ }
45
+ export function print(_x2) {
46
+ return _print.apply(this, arguments);
47
+ }
48
+ function _print() {
49
+ _print = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(options) {
50
+ var templateId, iw;
51
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
52
+ while (1) switch (_context2.prev = _context2.next) {
53
+ case 0:
54
+ _context2.prev = 0;
55
+ _context2.next = 3;
56
+ return showLoading();
57
+ case 3:
58
+ templateId = options === null || options === void 0 ? void 0 : options.templateId;
59
+ if (templateId) {
60
+ _context2.next = 7;
61
+ break;
62
+ }
63
+ _message.error("\u6253\u5370\u5931\u8D25!\u6A21\u677Fid\u4E0D\u53EF\u4E3A\u7A7A!");
64
+ return _context2.abrupt("return");
65
+ case 7:
66
+ _context2.next = 9;
67
+ return openPrint(templateId);
68
+ case 9:
69
+ iw = _context2.sent;
70
+ if (iw) {
71
+ _context2.next = 13;
72
+ break;
73
+ }
74
+ _message.error("\u6253\u5370\u5931\u8D25!\u6253\u5370\u7A97\u53E3\u4E0D\u53EF\u4E3A\u7A7A!");
75
+ return _context2.abrupt("return");
76
+ case 13:
77
+ // @ts-ignore
78
+ iw.printOptions = options;
79
+ _context2.next = 19;
80
+ break;
81
+ case 16:
82
+ _context2.prev = 16;
83
+ _context2.t0 = _context2["catch"](0);
84
+ console.log("打印失败", _context2.t0);
85
+ case 19:
86
+ _context2.prev = 19;
87
+ return _context2.finish(19);
88
+ case 21:
89
+ case "end":
90
+ return _context2.stop();
91
+ }
92
+ }, _callee2, null, [[0, 16, 19, 21]]);
93
+ }));
94
+ return _print.apply(this, arguments);
95
+ }
96
+ function openPrint(_x3) {
97
+ return _openPrint.apply(this, arguments);
98
+ }
99
+ function _openPrint() {
100
+ _openPrint = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(templateId) {
101
+ return _regeneratorRuntime.wrap(function _callee4$(_context4) {
102
+ while (1) switch (_context4.prev = _context4.next) {
103
+ case 0:
104
+ return _context4.abrupt("return", new Promise( /*#__PURE__*/function () {
105
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(resolve, reject) {
106
+ var iframe, iframeWindow;
107
+ return _regeneratorRuntime.wrap(function _callee3$(_context3) {
108
+ while (1) switch (_context3.prev = _context3.next) {
109
+ case 0:
110
+ iframe = document.createElement("iframe");
111
+ iframe.src = "/print/" + templateId;
112
+ iframe.style.display = "none";
113
+ document.body.appendChild(iframe);
114
+ iframeWindow = iframe.contentWindow;
115
+ if (iframeWindow) {
116
+ _context3.next = 8;
117
+ break;
118
+ }
119
+ reject("创建Iframe失败!");
120
+ return _context3.abrupt("return");
121
+ case 8:
122
+ iframeWindow.onload = function () {
123
+ resolve(iframeWindow);
124
+ };
125
+ iframeWindow.addEventListener("beforeprint", function () {});
126
+ iframeWindow.addEventListener("afterprint", function () {
127
+ hideLoading();
128
+ iframe.remove();
129
+ });
130
+ case 11:
131
+ case "end":
132
+ return _context3.stop();
133
+ }
134
+ }, _callee3);
135
+ }));
136
+ return function (_x4, _x5) {
137
+ return _ref.apply(this, arguments);
138
+ };
139
+ }()));
140
+ case 1:
141
+ case "end":
142
+ return _context4.stop();
143
+ }
144
+ }, _callee4);
145
+ }));
146
+ return _openPrint.apply(this, arguments);
147
+ }
package/lib/index.less CHANGED
@@ -1,3 +1,13 @@
1
1
  [componentname="Page"] {
2
2
  height: 100%;
3
3
  }
4
+
5
+ ul {
6
+ margin-bottom: 0;
7
+ padding-left: 0;
8
+ list-style: none;
9
+ }
10
+
11
+ .page-content {
12
+ overflow: hidden;
13
+ }
@@ -1,7 +1,19 @@
1
+ /// <reference types="node" />
1
2
  import { AxiosProgressEvent } from "axios";
2
- export declare function upload(file: any, options?: {
3
- onProgress: (evt: AxiosProgressEvent) => void;
4
- onFinished: () => void;
5
- onError: (e: any) => void;
6
- }): Promise<void>;
3
+ interface File {
4
+ id?: string;
5
+ size?: number;
6
+ name?: string;
7
+ type?: string;
8
+ status?: "done" | "uploading" | "error";
9
+ url: string;
10
+ percent?: number;
11
+ buffer?: Buffer;
12
+ }
13
+ export declare function upload(file: File, options?: {
14
+ onProgress?: (evt: AxiosProgressEvent) => void;
15
+ onFinished?: () => void;
16
+ onError?: (e: any) => void;
17
+ }): Promise<File>;
7
18
  export declare function update(file: any): Promise<void>;
19
+ export {};
@@ -20,10 +20,11 @@ function _upload() {
20
20
  _context.next = 2;
21
21
  break;
22
22
  }
23
- return _context.abrupt("return");
23
+ return _context.abrupt("return", file);
24
24
  case 2:
25
25
  _context.next = 4;
26
26
  return _index.apiRequest.post("files/signature", {
27
+ id: file.id,
27
28
  size: file.size,
28
29
  name: file.name,
29
30
  type: file.type
@@ -41,7 +42,7 @@ function _upload() {
41
42
  file.status = "uploading";
42
43
  _context.prev = 10;
43
44
  _context.next = 13;
44
- return _index.apiRequest.put(ossFile.uploadUrl, file, {
45
+ return _index.apiRequest.put(ossFile.uploadUrl, (file === null || file === void 0 ? void 0 : file.buffer) || file, {
45
46
  headers: {
46
47
  'Content-Type': file.type
47
48
  },
@@ -54,18 +55,20 @@ function _upload() {
54
55
  }
55
56
  });
56
57
  case 13:
58
+ file.status = "done";
57
59
  options === null || options === void 0 ? void 0 : (_options$onFinished = options.onFinished) === null || _options$onFinished === void 0 ? void 0 : _options$onFinished.call(options);
58
- _context.next = 19;
60
+ _context.next = 21;
59
61
  break;
60
- case 16:
61
- _context.prev = 16;
62
+ case 17:
63
+ _context.prev = 17;
62
64
  _context.t0 = _context["catch"](10);
65
+ file.status = "error";
63
66
  options === null || options === void 0 ? void 0 : (_options$onError = options.onError) === null || _options$onError === void 0 ? void 0 : _options$onError.call(options, _context.t0);
64
- case 19:
67
+ case 21:
65
68
  case "end":
66
69
  return _context.stop();
67
70
  }
68
- }, _callee, null, [[10, 16]]);
71
+ }, _callee, null, [[10, 17]]);
69
72
  }));
70
73
  return _upload.apply(this, arguments);
71
74
  }
@@ -9,9 +9,9 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
9
9
  var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));
10
10
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
11
11
  var _restApi = require("./rest-api");
12
- var _index = require("./index");
13
12
  var _formApi = require("./form-api.utils");
14
13
  var _cache = require("../cache");
14
+ var _schemaApi = require("./schema-api");
15
15
  function getFormApi(_x, _x2, _x3) {
16
16
  return _getFormApi.apply(this, arguments);
17
17
  }
@@ -45,7 +45,7 @@ function _getFormApi() {
45
45
  var RestFormApi = exports.RestFormApi = /*#__PURE__*/function (_RestApi) {
46
46
  function RestFormApi(formId, fieldId, mock) {
47
47
  var _this;
48
- _this = _RestApi.call(this, "forms", {}) || this;
48
+ _this = _RestApi.call(this, "表单", {}) || this;
49
49
  _this.formId = void 0;
50
50
  _this.fieldId = void 0;
51
51
  _this.mock = void 0;
@@ -61,56 +61,46 @@ var RestFormApi = exports.RestFormApi = /*#__PURE__*/function (_RestApi) {
61
61
  _proto.initialize = /*#__PURE__*/function () {
62
62
  var _initialize = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
63
63
  var _this2 = this;
64
- var _this$schema$children, _this$schema$children2, res;
64
+ var res, _this$schema, _this$schema$children, _this$schema$children2;
65
65
  return _regenerator["default"].wrap(function _callee$(_context) {
66
66
  while (1) switch (_context.prev = _context.next) {
67
67
  case 0:
68
68
  if (!this.initialized) {
69
- _context.next = 4;
70
- break;
71
- }
72
- return _context.abrupt("return", true);
73
- case 4:
74
- _context.prev = 4;
75
- _context.next = 7;
76
- return (0, _index.getSchema)(this.formId, this.mock);
77
- case 7:
78
- res = _context.sent;
79
- this.schema = res.data;
80
- this.initialized = !!this.schema;
81
- this.title = (_this$schema$children = this.schema.children[0]) === null || _this$schema$children === void 0 ? void 0 : (_this$schema$children2 = _this$schema$children.props) === null || _this$schema$children2 === void 0 ? void 0 : _this$schema$children2.label;
82
- if (this.fieldId) {
83
- JSON.stringify(this.schema, function (key, value) {
84
- var _value$props;
85
- if (key == "fdmSchema") {
86
- return undefined;
87
- }
88
- if ((value === null || value === void 0 ? void 0 : (_value$props = value.props) === null || _value$props === void 0 ? void 0 : _value$props.fieldId) === _this2.fieldId) {
89
- if (value.props.label) {
90
- _this2.title += "." + value.props.label;
69
+ try {
70
+ res = (0, _schemaApi.getSchemaFromCache)(this.formId, this.mock);
71
+ this.schema = res === null || res === void 0 ? void 0 : res.data;
72
+ this.initialized = !!this.schema;
73
+ if (this.initialized) {
74
+ this.title = (_this$schema = this.schema) === null || _this$schema === void 0 ? void 0 : (_this$schema$children = _this$schema.children[0]) === null || _this$schema$children === void 0 ? void 0 : (_this$schema$children2 = _this$schema$children.props) === null || _this$schema$children2 === void 0 ? void 0 : _this$schema$children2.label;
75
+ if (this.fieldId) {
76
+ JSON.stringify(this.schema, function (key, value) {
77
+ var _value$props;
78
+ if (key == "fdmSchema") {
79
+ return undefined;
80
+ }
81
+ if ((value === null || value === void 0 ? void 0 : (_value$props = value.props) === null || _value$props === void 0 ? void 0 : _value$props.fieldId) === _this2.fieldId) {
82
+ if (value.props.label) {
83
+ _this2.title += "." + value.props.label;
84
+ }
85
+ }
86
+ return value;
87
+ });
91
88
  }
92
89
  }
93
- return value;
94
- });
90
+ } catch (e) {
91
+ console.log("获取schema失败!", {
92
+ formId: this.formId,
93
+ field: this.fieldId,
94
+ mock: this.mock
95
+ }, e);
96
+ }
95
97
  }
96
- _context.next = 18;
97
- break;
98
- case 14:
99
- _context.prev = 14;
100
- _context.t0 = _context["catch"](4);
101
- console.log("获取schema失败!", {
102
- formId: this.formId,
103
- field: this.fieldId,
104
- mock: this.mock
105
- }, _context.t0);
106
- throw _context.t0;
107
- case 18:
108
98
  return _context.abrupt("return", this.initialized);
109
- case 19:
99
+ case 2:
110
100
  case "end":
111
101
  return _context.stop();
112
102
  }
113
- }, _callee, this, [[4, 14]]);
103
+ }, _callee, this);
114
104
  }));
115
105
  function initialize() {
116
106
  return _initialize.apply(this, arguments);
@@ -160,7 +150,7 @@ var RestFormApi = exports.RestFormApi = /*#__PURE__*/function (_RestApi) {
160
150
  fieldId: this.fieldId
161
151
  };
162
152
  if (__mock) {
163
- params.description = "" + this.title;
153
+ params.description = (this.title || "表单") + ".\u67E5\u8BE2";
164
154
  }
165
155
  config = {
166
156
  params: params
@@ -197,7 +187,7 @@ var RestFormApi = exports.RestFormApi = /*#__PURE__*/function (_RestApi) {
197
187
  }();
198
188
  _proto.getById = /*#__PURE__*/function () {
199
189
  var _getById = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(id, options) {
200
- var res, start;
190
+ var res;
201
191
  return _regenerator["default"].wrap(function _callee4$(_context4) {
202
192
  while (1) switch (_context4.prev = _context4.next) {
203
193
  case 0:
@@ -205,11 +195,10 @@ var RestFormApi = exports.RestFormApi = /*#__PURE__*/function (_RestApi) {
205
195
  return _RestApi.prototype.getById.call(this, id, options);
206
196
  case 2:
207
197
  res = _context4.sent;
208
- start = Date.now();
209
198
  (0, _formApi.assembleAssociationField)(res.data, res.refs);
210
199
  console.debug("formApi.getById", res);
211
200
  return _context4.abrupt("return", res);
212
- case 7:
201
+ case 6:
213
202
  case "end":
214
203
  return _context4.stop();
215
204
  }
@@ -273,11 +262,22 @@ var RestFormApi = exports.RestFormApi = /*#__PURE__*/function (_RestApi) {
273
262
  }();
274
263
  _proto.serviceUpdate = /*#__PURE__*/function () {
275
264
  var _serviceUpdate = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee8(data, options) {
265
+ var params;
276
266
  return _regenerator["default"].wrap(function _callee8$(_context8) {
277
267
  while (1) switch (_context8.prev = _context8.next) {
278
268
  case 0:
279
- return _context8.abrupt("return", this.request.post("serviceUpdate", data));
280
- case 1:
269
+ params = {
270
+ formId: this.formId,
271
+ fieldId: this.fieldId
272
+ };
273
+ if (__mock) {
274
+ params.mock = true;
275
+ params.description = (this.title || "表单") + ".\u67E5\u8BE2";
276
+ }
277
+ return _context8.abrupt("return", this.request.post("serviceUpdate", data, {
278
+ params: params
279
+ }));
280
+ case 3:
281
281
  case "end":
282
282
  return _context8.stop();
283
283
  }