@nocobase/client 0.7.2-alpha.5 → 0.7.3-alpha.1

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 (93) hide show
  1. package/es/block-provider/FormBlockProvider.js +8 -3
  2. package/es/block-provider/TableSelectorProvider.js +41 -13
  3. package/es/block-provider/hooks/index.d.ts +6 -0
  4. package/es/block-provider/hooks/index.js +145 -63
  5. package/es/collection-manager/CollectionField.js +5 -3
  6. package/es/collection-manager/interfaces/input.js +103 -0
  7. package/es/collection-manager/interfaces/integer.js +63 -0
  8. package/es/collection-manager/interfaces/markdown.js +34 -0
  9. package/es/collection-manager/interfaces/number.js +55 -0
  10. package/es/collection-manager/interfaces/password.js +35 -1
  11. package/es/collection-manager/interfaces/percent.js +97 -0
  12. package/es/collection-manager/interfaces/richText.js +34 -0
  13. package/es/collection-manager/interfaces/textarea.js +34 -0
  14. package/es/file-manager/FileStorageShortcut.js +2 -2
  15. package/es/locale/en_US.d.ts +5 -0
  16. package/es/locale/en_US.js +6 -1
  17. package/es/locale/zh_CN.d.ts +23 -0
  18. package/es/locale/zh_CN.js +24 -1
  19. package/es/plugin-manager/PluginManager.js +8 -4
  20. package/es/schema-component/antd/action/Action.Modal.js +1 -1
  21. package/es/schema-component/antd/form-item/FormItem.js +156 -3
  22. package/es/schema-component/antd/grid/Grid.js +72 -6
  23. package/es/schema-component/antd/input-number/InputNumber.d.ts +1 -5
  24. package/es/schema-component/antd/input-number/InputNumber.js +25 -1
  25. package/es/schema-component/antd/kanban/Kanban.Card.Designer.js +20 -14
  26. package/es/schema-component/antd/menu/Menu.js +6 -3
  27. package/es/schema-component/antd/percent/Percent.js +2 -2
  28. package/es/schema-component/antd/record-picker/InputRecordPicker.js +27 -13
  29. package/es/schema-component/antd/record-picker/ReadPrettyRecordPicker.js +4 -2
  30. package/es/schema-component/antd/table/Table.Array.js +2 -2
  31. package/es/schema-component/antd/table/Table.Void.js +11 -1
  32. package/es/schema-component/antd/table-v2/Table.js +1 -4
  33. package/es/schema-component/antd/time-picker/ReadPretty.js +11 -5
  34. package/es/schema-component/hooks/useDesignable.js +21 -21
  35. package/es/schema-component/hooks/useProps.js +1 -1
  36. package/es/schema-initializer/buttons/FormItemInitializers.js +14 -3
  37. package/es/schema-initializer/buttons/ReadPrettyFormActionInitializers.js +8 -0
  38. package/es/schema-initializer/buttons/ReadPrettyFormItemInitializers.js +14 -3
  39. package/es/schema-initializer/buttons/RecordBlockInitializers.js +32 -3
  40. package/es/schema-initializer/buttons/TableActionInitializers.js +11 -0
  41. package/es/schema-initializer/components/assigned-field/AssignedField.d.ts +4 -0
  42. package/es/schema-initializer/components/assigned-field/AssignedField.js +253 -69
  43. package/es/schema-initializer/items/index.d.ts +2 -0
  44. package/es/schema-initializer/items/index.js +46 -1
  45. package/es/schema-initializer/utils.js +6 -2
  46. package/es/system-settings/SystemSettingsShortcut.js +35 -12
  47. package/lib/block-provider/FormBlockProvider.js +7 -2
  48. package/lib/block-provider/TableSelectorProvider.js +41 -13
  49. package/lib/block-provider/hooks/index.d.ts +6 -0
  50. package/lib/block-provider/hooks/index.js +154 -65
  51. package/lib/collection-manager/CollectionField.js +5 -2
  52. package/lib/collection-manager/interfaces/input.js +104 -0
  53. package/lib/collection-manager/interfaces/integer.js +65 -0
  54. package/lib/collection-manager/interfaces/markdown.js +35 -0
  55. package/lib/collection-manager/interfaces/number.js +56 -0
  56. package/lib/collection-manager/interfaces/password.js +36 -1
  57. package/lib/collection-manager/interfaces/percent.js +99 -0
  58. package/lib/collection-manager/interfaces/richText.js +35 -0
  59. package/lib/collection-manager/interfaces/textarea.js +35 -0
  60. package/lib/file-manager/FileStorageShortcut.js +1 -1
  61. package/lib/locale/en_US.d.ts +5 -0
  62. package/lib/locale/en_US.js +6 -1
  63. package/lib/locale/zh_CN.d.ts +23 -0
  64. package/lib/locale/zh_CN.js +24 -1
  65. package/lib/plugin-manager/PluginManager.js +8 -3
  66. package/lib/schema-component/antd/action/Action.Modal.js +1 -1
  67. package/lib/schema-component/antd/form-item/FormItem.js +165 -5
  68. package/lib/schema-component/antd/grid/Grid.js +69 -3
  69. package/lib/schema-component/antd/input-number/InputNumber.d.ts +1 -5
  70. package/lib/schema-component/antd/input-number/InputNumber.js +29 -2
  71. package/lib/schema-component/antd/kanban/Kanban.Card.Designer.js +20 -14
  72. package/lib/schema-component/antd/menu/Menu.js +6 -3
  73. package/lib/schema-component/antd/percent/Percent.js +2 -2
  74. package/lib/schema-component/antd/record-picker/InputRecordPicker.js +27 -12
  75. package/lib/schema-component/antd/record-picker/ReadPrettyRecordPicker.js +3 -1
  76. package/lib/schema-component/antd/table/Table.Array.js +2 -2
  77. package/lib/schema-component/antd/table/Table.Void.js +11 -1
  78. package/lib/schema-component/antd/table-v2/Table.js +1 -4
  79. package/lib/schema-component/antd/time-picker/ReadPretty.js +10 -3
  80. package/lib/schema-component/hooks/useDesignable.js +21 -21
  81. package/lib/schema-component/hooks/useProps.js +1 -1
  82. package/lib/schema-initializer/buttons/FormItemInitializers.js +14 -2
  83. package/lib/schema-initializer/buttons/ReadPrettyFormActionInitializers.js +8 -0
  84. package/lib/schema-initializer/buttons/ReadPrettyFormItemInitializers.js +14 -2
  85. package/lib/schema-initializer/buttons/RecordBlockInitializers.js +34 -4
  86. package/lib/schema-initializer/buttons/TableActionInitializers.js +11 -0
  87. package/lib/schema-initializer/components/assigned-field/AssignedField.d.ts +4 -0
  88. package/lib/schema-initializer/components/assigned-field/AssignedField.js +254 -66
  89. package/lib/schema-initializer/items/index.d.ts +2 -0
  90. package/lib/schema-initializer/items/index.js +52 -1
  91. package/lib/schema-initializer/utils.js +6 -2
  92. package/lib/system-settings/SystemSettingsShortcut.js +37 -13
  93. package/package.json +6 -4
@@ -7,7 +7,7 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
7
7
  import { createForm } from '@formily/core';
8
8
  import { useField } from '@formily/react';
9
9
  import { Spin } from 'antd';
10
- import React, { createContext, useContext, useEffect, useMemo } from 'react';
10
+ import React, { createContext, useContext, useEffect, useMemo, useRef } from 'react';
11
11
  import { BlockProvider, useBlockRequestContext } from './BlockProvider';
12
12
  export var FormBlockContext = /*#__PURE__*/createContext({});
13
13
 
@@ -25,6 +25,8 @@ var InternalFormBlockProvider = function InternalFormBlockProvider(props) {
25
25
  resource = _useBlockRequestConte.resource,
26
26
  service = _useBlockRequestConte.service;
27
27
 
28
+ var formBlockRef = useRef();
29
+
28
30
  if (service.loading) {
29
31
  return /*#__PURE__*/React.createElement(Spin, null);
30
32
  }
@@ -36,9 +38,12 @@ var InternalFormBlockProvider = function InternalFormBlockProvider(props) {
36
38
  field: field,
37
39
  service: service,
38
40
  resource: resource,
39
- updateAssociationValues: []
41
+ updateAssociationValues: [],
42
+ formBlockRef: formBlockRef
40
43
  }
41
- }, props.children);
44
+ }, /*#__PURE__*/React.createElement("div", {
45
+ ref: formBlockRef
46
+ }, props.children));
42
47
  };
43
48
 
44
49
  export var FormBlockProvider = function FormBlockProvider(props) {
@@ -62,7 +62,8 @@ export var TableSelectorProvider = function TableSelectorProvider(props) {
62
62
  var ctx = useFormBlockContext();
63
63
 
64
64
  var _useCollectionManager2 = useCollectionManager(),
65
- getCollectionJoinField = _useCollectionManager2.getCollectionJoinField;
65
+ getCollectionJoinField = _useCollectionManager2.getCollectionJoinField,
66
+ getCollectionFields = _useCollectionManager2.getCollectionFields;
66
67
 
67
68
  var record = useRecord();
68
69
  var collectionFieldSchema = recursiveParent(fieldSchema, 'CollectionField'); // const value = ctx.form.query(collectionFieldSchema?.name).value();
@@ -84,16 +85,43 @@ export var TableSelectorProvider = function TableSelectorProvider(props) {
84
85
 
85
86
  if (collectionField) {
86
87
  if (['oho', 'o2m'].includes(collectionField.interface)) {
87
- params['filter'] = {
88
- $or: [_defineProperty({}, collectionField.foreignKey, {
88
+ if (record === null || record === void 0 ? void 0 : record[collectionField.sourceKey]) {
89
+ params['filter'] = {
90
+ $or: [_defineProperty({}, collectionField.foreignKey, {
91
+ $is: null
92
+ }), _defineProperty({}, collectionField.foreignKey, {
93
+ $eq: record === null || record === void 0 ? void 0 : record[collectionField.sourceKey]
94
+ })]
95
+ };
96
+ } else {
97
+ params['filter'] = _defineProperty({}, collectionField.foreignKey, {
89
98
  $is: null
90
- }), _defineProperty({}, collectionField.foreignKey, {
91
- $eq: record === null || record === void 0 ? void 0 : record[collectionField.sourceKey]
92
- })]
93
- };
99
+ });
100
+ }
94
101
  }
95
102
 
96
- if (['obo'].includes(collectionField.interface)) {}
103
+ if (['obo'].includes(collectionField.interface)) {
104
+ var fields = getCollectionFields(collectionField.target);
105
+ var targetField = fields.find(function (f) {
106
+ return f.foreignKey && f.foreignKey === collectionField.foreignKey;
107
+ });
108
+
109
+ if (targetField) {
110
+ if (record === null || record === void 0 ? void 0 : record[collectionField.foreignKey]) {
111
+ params['filter'] = {
112
+ $or: [_defineProperty({}, "".concat(targetField.name, ".").concat(targetField.foreignKey), {
113
+ $is: null
114
+ }), _defineProperty({}, "".concat(targetField.name, ".").concat(targetField.foreignKey), {
115
+ $eq: record === null || record === void 0 ? void 0 : record[collectionField.foreignKey]
116
+ })]
117
+ };
118
+ } else {
119
+ params['filter'] = _defineProperty({}, "".concat(targetField.name, ".").concat(targetField.foreignKey), {
120
+ $is: null
121
+ });
122
+ }
123
+ }
124
+ }
97
125
  }
98
126
 
99
127
  return /*#__PURE__*/React.createElement(BlockProvider, _objectSpread(_objectSpread({}, props), {}, {
@@ -140,14 +168,14 @@ export var useTableSelectorProps = function useTableSelectorProps() {
140
168
  ctx.field.data = (ctx === null || ctx === void 0 ? void 0 : (_ctx$field2 = ctx.field) === null || _ctx$field2 === void 0 ? void 0 : _ctx$field2.data) || {};
141
169
  ctx.field.data.selectedRowKeys = selectedRowKeys;
142
170
  },
143
- onRowDragEnd: function onRowDragEnd(_ref3) {
171
+ onRowDragEnd: function onRowDragEnd(_ref5) {
144
172
  return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
145
173
  var from, to;
146
174
  return regeneratorRuntime.wrap(function _callee$(_context) {
147
175
  while (1) {
148
176
  switch (_context.prev = _context.next) {
149
177
  case 0:
150
- from = _ref3.from, to = _ref3.to;
178
+ from = _ref5.from, to = _ref5.to;
151
179
  _context.next = 3;
152
180
  return ctx.resource.move({
153
181
  sourceId: from[ctx.rowKey || 'id'],
@@ -165,11 +193,11 @@ export var useTableSelectorProps = function useTableSelectorProps() {
165
193
  }, _callee);
166
194
  }))();
167
195
  },
168
- onChange: function onChange(_ref4) {
196
+ onChange: function onChange(_ref6) {
169
197
  var _ctx$service$params;
170
198
 
171
- var current = _ref4.current,
172
- pageSize = _ref4.pageSize;
199
+ var current = _ref6.current,
200
+ pageSize = _ref6.pageSize;
173
201
  ctx.service.run(_objectSpread(_objectSpread({}, (_ctx$service$params = ctx.service.params) === null || _ctx$service$params === void 0 ? void 0 : _ctx$service$params[0]), {}, {
174
202
  page: current,
175
203
  pageSize: pageSize
@@ -16,9 +16,15 @@ export declare const useUpdateActionProps: () => {
16
16
  export declare const useDestroyActionProps: () => {
17
17
  onClick(): Promise<void>;
18
18
  };
19
+ export declare const useDetailPrintActionProps: () => {
20
+ onClick(): Promise<void>;
21
+ };
19
22
  export declare const useBulkDestroyActionProps: () => {
20
23
  onClick(): Promise<void>;
21
24
  };
25
+ export declare const useRefreshActionProps: () => {
26
+ onClick(): Promise<void>;
27
+ };
22
28
  export declare const useDetailsPaginationProps: () => {
23
29
  simple: boolean;
24
30
  hidden: boolean;
@@ -10,12 +10,13 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar
10
10
 
11
11
  function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
12
12
 
13
- import { Schema as SchemaCompiler } from '@formily/json-schema';
14
13
  import { useField, useFieldSchema, useForm } from '@formily/react';
15
14
  import { message, Modal } from 'antd';
15
+ import parse from 'json-templates';
16
16
  import get from 'lodash/get';
17
17
  import { useTranslation } from 'react-i18next';
18
18
  import { useHistory } from 'react-router-dom';
19
+ import { useReactToPrint } from 'react-to-print';
19
20
  import { useFormBlockContext } from '../..';
20
21
  import { useAPIClient } from '../../api-client';
21
22
  import { useCollection } from '../../collection-manager';
@@ -141,6 +142,8 @@ function getFormValues(filterByTk, field, form, fieldNames, getField, resource)
141
142
  }
142
143
 
143
144
  export var useCreateActionProps = function useCreateActionProps() {
145
+ var _currentUserContext$d;
146
+
144
147
  var form = useForm();
145
148
 
146
149
  var _useBlockRequestConte = useBlockRequestContext(),
@@ -166,12 +169,15 @@ export var useCreateActionProps = function useCreateActionProps() {
166
169
 
167
170
  var compile = useCompile();
168
171
  var filterByTk = useFilterByTk();
172
+ var currentRecord = useRecord();
173
+ var currentUserContext = useCurrentUserContext();
174
+ var currentUser = currentUserContext === null || currentUserContext === void 0 ? void 0 : (_currentUserContext$d = currentUserContext.data) === null || _currentUserContext$d === void 0 ? void 0 : _currentUserContext$d.data;
169
175
  return {
170
176
  onClick: function onClick() {
171
177
  return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
172
178
  var _actionSchema$xActio;
173
179
 
174
- var fieldNames, _ref, assignedValues, onSuccess, overwriteValues, skipValidator, values, _parent$service, _parent$service$refre;
180
+ var fieldNames, _ref, _ref$assignedValues, originalAssignedValues, onSuccess, overwriteValues, skipValidator, assignedValues, values, _parent$service, _parent$service$refre;
175
181
 
176
182
  return regeneratorRuntime.wrap(function _callee2$(_context2) {
177
183
  while (1) {
@@ -180,39 +186,44 @@ export var useCreateActionProps = function useCreateActionProps() {
180
186
  fieldNames = fields.map(function (field) {
181
187
  return field.name;
182
188
  });
183
- _ref = (_actionSchema$xActio = actionSchema === null || actionSchema === void 0 ? void 0 : actionSchema['x-action-settings']) !== null && _actionSchema$xActio !== void 0 ? _actionSchema$xActio : {}, assignedValues = _ref.assignedValues, onSuccess = _ref.onSuccess, overwriteValues = _ref.overwriteValues, skipValidator = _ref.skipValidator;
189
+ _ref = (_actionSchema$xActio = actionSchema === null || actionSchema === void 0 ? void 0 : actionSchema['x-action-settings']) !== null && _actionSchema$xActio !== void 0 ? _actionSchema$xActio : {}, _ref$assignedValues = _ref.assignedValues, originalAssignedValues = _ref$assignedValues === void 0 ? {} : _ref$assignedValues, onSuccess = _ref.onSuccess, overwriteValues = _ref.overwriteValues, skipValidator = _ref.skipValidator;
190
+ assignedValues = parse(originalAssignedValues)({
191
+ currentTime: new Date(),
192
+ currentRecord: currentRecord,
193
+ currentUser: currentUser
194
+ });
184
195
 
185
196
  if (skipValidator) {
186
- _context2.next = 5;
197
+ _context2.next = 6;
187
198
  break;
188
199
  }
189
200
 
190
- _context2.next = 5;
201
+ _context2.next = 6;
191
202
  return form.submit();
192
203
 
193
- case 5:
204
+ case 6:
194
205
  values = getFormValues(filterByTk, field, form, fieldNames, getField, resource);
195
206
  actionField.data = field.data || {};
196
207
  actionField.data.loading = true;
197
- _context2.prev = 8;
198
- _context2.next = 11;
208
+ _context2.prev = 9;
209
+ _context2.next = 12;
199
210
  return resource.create({
200
211
  values: _objectSpread(_objectSpread(_objectSpread({}, values), overwriteValues), assignedValues)
201
212
  });
202
213
 
203
- case 11:
214
+ case 12:
204
215
  actionField.data.loading = false;
205
216
  __parent === null || __parent === void 0 ? void 0 : (_parent$service = __parent.service) === null || _parent$service === void 0 ? void 0 : (_parent$service$refre = _parent$service.refresh) === null || _parent$service$refre === void 0 ? void 0 : _parent$service$refre.call(_parent$service);
206
217
  setVisible === null || setVisible === void 0 ? void 0 : setVisible(false);
207
218
 
208
219
  if (onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess.successMessage) {
209
- _context2.next = 16;
220
+ _context2.next = 17;
210
221
  break;
211
222
  }
212
223
 
213
224
  return _context2.abrupt("return");
214
225
 
215
- case 16:
226
+ case 17:
216
227
  if (onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess.manualClose) {
217
228
  Modal.success({
218
229
  title: compile(onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess.successMessage),
@@ -253,25 +264,27 @@ export var useCreateActionProps = function useCreateActionProps() {
253
264
  message.success(compile(onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess.successMessage));
254
265
  }
255
266
 
256
- _context2.next = 22;
267
+ _context2.next = 23;
257
268
  break;
258
269
 
259
- case 19:
260
- _context2.prev = 19;
261
- _context2.t0 = _context2["catch"](8);
270
+ case 20:
271
+ _context2.prev = 20;
272
+ _context2.t0 = _context2["catch"](9);
262
273
  actionField.data.loading = false;
263
274
 
264
- case 22:
275
+ case 23:
265
276
  case "end":
266
277
  return _context2.stop();
267
278
  }
268
279
  }
269
- }, _callee2, null, [[8, 19]]);
280
+ }, _callee2, null, [[9, 20]]);
270
281
  }))();
271
282
  }
272
283
  };
273
284
  };
274
285
  export var useCustomizeUpdateActionProps = function useCustomizeUpdateActionProps() {
286
+ var _currentUserContext$d2;
287
+
275
288
  var _useBlockRequestConte2 = useBlockRequestContext(),
276
289
  resource = _useBlockRequestConte2.resource,
277
290
  __parent = _useBlockRequestConte2.__parent,
@@ -280,7 +293,8 @@ export var useCustomizeUpdateActionProps = function useCustomizeUpdateActionProp
280
293
  var filterByTk = useFilterByTk();
281
294
  var actionSchema = useFieldSchema();
282
295
  var currentRecord = useRecord();
283
- var ctx = useCurrentUserContext();
296
+ var currentUserContext = useCurrentUserContext();
297
+ var currentUser = currentUserContext === null || currentUserContext === void 0 ? void 0 : (_currentUserContext$d2 = currentUserContext.data) === null || _currentUserContext$d2 === void 0 ? void 0 : _currentUserContext$d2.data;
284
298
  var history = useHistory();
285
299
  var compile = useCompile();
286
300
  var form = useForm();
@@ -289,30 +303,35 @@ export var useCustomizeUpdateActionProps = function useCustomizeUpdateActionProp
289
303
  return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4() {
290
304
  var _actionSchema$xActio2, _service$refresh;
291
305
 
292
- var _ref2, assignedValues, onSuccess, skipValidator, _parent$service2, _parent$service2$refr;
306
+ var _ref2, _ref2$assignedValues, originalAssignedValues, onSuccess, skipValidator, assignedValues, _parent$service2, _parent$service2$refr;
293
307
 
294
308
  return regeneratorRuntime.wrap(function _callee4$(_context4) {
295
309
  while (1) {
296
310
  switch (_context4.prev = _context4.next) {
297
311
  case 0:
298
- _ref2 = (_actionSchema$xActio2 = actionSchema === null || actionSchema === void 0 ? void 0 : actionSchema['x-action-settings']) !== null && _actionSchema$xActio2 !== void 0 ? _actionSchema$xActio2 : {}, assignedValues = _ref2.assignedValues, onSuccess = _ref2.onSuccess, skipValidator = _ref2.skipValidator;
312
+ _ref2 = (_actionSchema$xActio2 = actionSchema === null || actionSchema === void 0 ? void 0 : actionSchema['x-action-settings']) !== null && _actionSchema$xActio2 !== void 0 ? _actionSchema$xActio2 : {}, _ref2$assignedValues = _ref2.assignedValues, originalAssignedValues = _ref2$assignedValues === void 0 ? {} : _ref2$assignedValues, onSuccess = _ref2.onSuccess, skipValidator = _ref2.skipValidator;
313
+ assignedValues = parse(originalAssignedValues)({
314
+ currentTime: new Date(),
315
+ currentRecord: currentRecord,
316
+ currentUser: currentUser
317
+ });
299
318
 
300
319
  if (!(skipValidator === false)) {
301
- _context4.next = 4;
320
+ _context4.next = 5;
302
321
  break;
303
322
  }
304
323
 
305
- _context4.next = 4;
324
+ _context4.next = 5;
306
325
  return form.submit();
307
326
 
308
- case 4:
309
- _context4.next = 6;
327
+ case 5:
328
+ _context4.next = 7;
310
329
  return resource.update({
311
330
  filterByTk: filterByTk,
312
331
  values: _objectSpread({}, assignedValues)
313
332
  });
314
333
 
315
- case 6:
334
+ case 7:
316
335
  service === null || service === void 0 ? void 0 : (_service$refresh = service.refresh) === null || _service$refresh === void 0 ? void 0 : _service$refresh.call(service);
317
336
 
318
337
  if (!(resource instanceof TableFieldResource)) {
@@ -320,13 +339,13 @@ export var useCustomizeUpdateActionProps = function useCustomizeUpdateActionProp
320
339
  }
321
340
 
322
341
  if (onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess.successMessage) {
323
- _context4.next = 10;
342
+ _context4.next = 11;
324
343
  break;
325
344
  }
326
345
 
327
346
  return _context4.abrupt("return");
328
347
 
329
- case 10:
348
+ case 11:
330
349
  if (onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess.manualClose) {
331
350
  Modal.success({
332
351
  title: compile(onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess.successMessage),
@@ -363,7 +382,7 @@ export var useCustomizeUpdateActionProps = function useCustomizeUpdateActionProp
363
382
  message.success(compile(onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess.successMessage));
364
383
  }
365
384
 
366
- case 11:
385
+ case 12:
367
386
  case "end":
368
387
  return _context4.stop();
369
388
  }
@@ -374,7 +393,7 @@ export var useCustomizeUpdateActionProps = function useCustomizeUpdateActionProp
374
393
  };
375
394
  };
376
395
  export var useCustomizeRequestActionProps = function useCustomizeRequestActionProps() {
377
- var _currentUserContext$d;
396
+ var _currentUserContext$d3;
378
397
 
379
398
  var apiClient = useAPIClient();
380
399
  var history = useHistory();
@@ -395,7 +414,7 @@ export var useCustomizeRequestActionProps = function useCustomizeRequestActionPr
395
414
 
396
415
  var currentRecord = useRecord();
397
416
  var currentUserContext = useCurrentUserContext();
398
- var currentUser = currentUserContext === null || currentUserContext === void 0 ? void 0 : (_currentUserContext$d = currentUserContext.data) === null || _currentUserContext$d === void 0 ? void 0 : _currentUserContext$d.data;
417
+ var currentUser = currentUserContext === null || currentUserContext === void 0 ? void 0 : (_currentUserContext$d3 = currentUserContext.data) === null || _currentUserContext$d3 === void 0 ? void 0 : _currentUserContext$d3.data;
399
418
  var actionField = useField();
400
419
 
401
420
  var _useActionContext2 = useActionContext(),
@@ -452,15 +471,15 @@ export var useCustomizeRequestActionProps = function useCustomizeRequestActionPr
452
471
  currentUser: currentUser
453
472
  }),
454
473
  method: requestSettings['method'],
455
- headers: SchemaCompiler.compile(headers, {
474
+ headers: parse(headers)({
456
475
  currentRecord: currentRecord,
457
476
  currentUser: currentUser
458
477
  }),
459
- params: SchemaCompiler.compile(params, {
478
+ params: parse(params)({
460
479
  currentRecord: currentRecord,
461
480
  currentUser: currentUser
462
481
  }),
463
- data: SchemaCompiler.compile(data, {
482
+ data: parse(data)({
464
483
  currentRecord: currentRecord,
465
484
  currentUser: currentUser
466
485
  })
@@ -544,6 +563,8 @@ export var useCustomizeRequestActionProps = function useCustomizeRequestActionPr
544
563
  };
545
564
  };
546
565
  export var useUpdateActionProps = function useUpdateActionProps() {
566
+ var _currentUserContext$d4;
567
+
547
568
  var form = useForm();
548
569
  var filterByTk = useFilterByTk();
549
570
 
@@ -557,7 +578,6 @@ export var useUpdateActionProps = function useUpdateActionProps() {
557
578
 
558
579
  var actionSchema = useFieldSchema();
559
580
  var history = useHistory();
560
- var record = useRecord();
561
581
 
562
582
  var _useCollection3 = useCollection(),
563
583
  fields = _useCollection3.fields,
@@ -569,43 +589,51 @@ export var useUpdateActionProps = function useUpdateActionProps() {
569
589
  var _useFormBlockContext = useFormBlockContext(),
570
590
  updateAssociationValues = _useFormBlockContext.updateAssociationValues;
571
591
 
592
+ var currentRecord = useRecord();
593
+ var currentUserContext = useCurrentUserContext();
594
+ var currentUser = currentUserContext === null || currentUserContext === void 0 ? void 0 : (_currentUserContext$d4 = currentUserContext.data) === null || _currentUserContext$d4 === void 0 ? void 0 : _currentUserContext$d4.data;
572
595
  return {
573
596
  onClick: function onClick() {
574
597
  return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee8() {
575
598
  var _actionSchema$xActio4;
576
599
 
577
- var _ref4, assignedValues, onSuccess, overwriteValues, skipValidator, fieldNames, values, _parent$service4, _parent$service4$refr, _parent$__parent, _parent$__parent$serv, _parent$__parent$serv2;
600
+ var _ref4, _ref4$assignedValues, originalAssignedValues, onSuccess, overwriteValues, skipValidator, assignedValues, fieldNames, values, _parent$service4, _parent$service4$refr, _parent$__parent, _parent$__parent$serv, _parent$__parent$serv2;
578
601
 
579
602
  return regeneratorRuntime.wrap(function _callee8$(_context8) {
580
603
  while (1) {
581
604
  switch (_context8.prev = _context8.next) {
582
605
  case 0:
583
- _ref4 = (_actionSchema$xActio4 = actionSchema === null || actionSchema === void 0 ? void 0 : actionSchema['x-action-settings']) !== null && _actionSchema$xActio4 !== void 0 ? _actionSchema$xActio4 : {}, assignedValues = _ref4.assignedValues, onSuccess = _ref4.onSuccess, overwriteValues = _ref4.overwriteValues, skipValidator = _ref4.skipValidator;
606
+ _ref4 = (_actionSchema$xActio4 = actionSchema === null || actionSchema === void 0 ? void 0 : actionSchema['x-action-settings']) !== null && _actionSchema$xActio4 !== void 0 ? _actionSchema$xActio4 : {}, _ref4$assignedValues = _ref4.assignedValues, originalAssignedValues = _ref4$assignedValues === void 0 ? {} : _ref4$assignedValues, onSuccess = _ref4.onSuccess, overwriteValues = _ref4.overwriteValues, skipValidator = _ref4.skipValidator;
607
+ assignedValues = parse(originalAssignedValues)({
608
+ currentTime: new Date(),
609
+ currentRecord: currentRecord,
610
+ currentUser: currentUser
611
+ });
584
612
 
585
613
  if (skipValidator) {
586
- _context8.next = 4;
614
+ _context8.next = 5;
587
615
  break;
588
616
  }
589
617
 
590
- _context8.next = 4;
618
+ _context8.next = 5;
591
619
  return form.submit();
592
620
 
593
- case 4:
621
+ case 5:
594
622
  fieldNames = fields.map(function (field) {
595
623
  return field.name;
596
624
  });
597
625
  values = getFormValues(filterByTk, field, form, fieldNames, getField, resource);
598
626
  actionField.data = field.data || {};
599
627
  actionField.data.loading = true;
600
- _context8.prev = 8;
601
- _context8.next = 11;
628
+ _context8.prev = 9;
629
+ _context8.next = 12;
602
630
  return resource.update({
603
631
  filterByTk: filterByTk,
604
632
  values: _objectSpread(_objectSpread(_objectSpread({}, values), overwriteValues), assignedValues),
605
633
  updateAssociationValues: updateAssociationValues
606
634
  });
607
635
 
608
- case 11:
636
+ case 12:
609
637
  actionField.data.loading = false;
610
638
 
611
639
  if (!(resource instanceof TableFieldResource)) {
@@ -616,13 +644,13 @@ export var useUpdateActionProps = function useUpdateActionProps() {
616
644
  setVisible === null || setVisible === void 0 ? void 0 : setVisible(false);
617
645
 
618
646
  if (onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess.successMessage) {
619
- _context8.next = 17;
647
+ _context8.next = 18;
620
648
  break;
621
649
  }
622
650
 
623
651
  return _context8.abrupt("return");
624
652
 
625
- case 17:
653
+ case 18:
626
654
  if (onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess.manualClose) {
627
655
  Modal.success({
628
656
  title: compile(onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess.successMessage),
@@ -663,20 +691,20 @@ export var useUpdateActionProps = function useUpdateActionProps() {
663
691
  message.success(compile(onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess.successMessage));
664
692
  }
665
693
 
666
- _context8.next = 23;
694
+ _context8.next = 24;
667
695
  break;
668
696
 
669
- case 20:
670
- _context8.prev = 20;
671
- _context8.t0 = _context8["catch"](8);
697
+ case 21:
698
+ _context8.prev = 21;
699
+ _context8.t0 = _context8["catch"](9);
672
700
  actionField.data.loading = false;
673
701
 
674
- case 23:
702
+ case 24:
675
703
  case "end":
676
704
  return _context8.stop();
677
705
  }
678
706
  }
679
- }, _callee8, null, [[8, 20]]);
707
+ }, _callee8, null, [[9, 21]]);
680
708
  }))();
681
709
  }
682
710
  };
@@ -715,6 +743,35 @@ export var useDestroyActionProps = function useDestroyActionProps() {
715
743
  }
716
744
  };
717
745
  };
746
+ export var useDetailPrintActionProps = function useDetailPrintActionProps() {
747
+ var _useFormBlockContext2 = useFormBlockContext(),
748
+ formBlockRef = _useFormBlockContext2.formBlockRef;
749
+
750
+ var printHandler = useReactToPrint({
751
+ content: function content() {
752
+ return formBlockRef.current;
753
+ },
754
+ pageStyle: "@media print {\n * {\n margin: 0;\n }\n div.ant-formily-layout>div:first-child {\n overflow: hidden; height: 0;\n }\n\n }"
755
+ });
756
+ return {
757
+ onClick: function onClick() {
758
+ return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee10() {
759
+ return regeneratorRuntime.wrap(function _callee10$(_context10) {
760
+ while (1) {
761
+ switch (_context10.prev = _context10.next) {
762
+ case 0:
763
+ printHandler();
764
+
765
+ case 1:
766
+ case "end":
767
+ return _context10.stop();
768
+ }
769
+ }
770
+ }, _callee10);
771
+ }))();
772
+ }
773
+ };
774
+ };
718
775
  export var useBulkDestroyActionProps = function useBulkDestroyActionProps() {
719
776
  var _useBlockRequestConte6 = useBlockRequestContext(),
720
777
  field = _useBlockRequestConte6.field;
@@ -725,22 +782,22 @@ export var useBulkDestroyActionProps = function useBulkDestroyActionProps() {
725
782
 
726
783
  return {
727
784
  onClick: function onClick() {
728
- return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee10() {
785
+ return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee11() {
729
786
  var _field$data, _field$data$selectedR, _field$data2, _service$refresh4;
730
787
 
731
- return regeneratorRuntime.wrap(function _callee10$(_context10) {
788
+ return regeneratorRuntime.wrap(function _callee11$(_context11) {
732
789
  while (1) {
733
- switch (_context10.prev = _context10.next) {
790
+ switch (_context11.prev = _context11.next) {
734
791
  case 0:
735
792
  if (field === null || field === void 0 ? void 0 : (_field$data = field.data) === null || _field$data === void 0 ? void 0 : (_field$data$selectedR = _field$data.selectedRowKeys) === null || _field$data$selectedR === void 0 ? void 0 : _field$data$selectedR.length) {
736
- _context10.next = 2;
793
+ _context11.next = 2;
737
794
  break;
738
795
  }
739
796
 
740
- return _context10.abrupt("return");
797
+ return _context11.abrupt("return");
741
798
 
742
799
  case 2:
743
- _context10.next = 4;
800
+ _context11.next = 4;
744
801
  return resource.destroy({
745
802
  filterByTk: (_field$data2 = field.data) === null || _field$data2 === void 0 ? void 0 : _field$data2.selectedRowKeys
746
803
  });
@@ -751,10 +808,35 @@ export var useBulkDestroyActionProps = function useBulkDestroyActionProps() {
751
808
 
752
809
  case 6:
753
810
  case "end":
754
- return _context10.stop();
811
+ return _context11.stop();
755
812
  }
756
813
  }
757
- }, _callee10);
814
+ }, _callee11);
815
+ }))();
816
+ }
817
+ };
818
+ };
819
+ export var useRefreshActionProps = function useRefreshActionProps() {
820
+ var _useBlockRequestConte8 = useBlockRequestContext(),
821
+ service = _useBlockRequestConte8.service;
822
+
823
+ return {
824
+ onClick: function onClick() {
825
+ return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee12() {
826
+ var _service$refresh5;
827
+
828
+ return regeneratorRuntime.wrap(function _callee12$(_context12) {
829
+ while (1) {
830
+ switch (_context12.prev = _context12.next) {
831
+ case 0:
832
+ service === null || service === void 0 ? void 0 : (_service$refresh5 = service.refresh) === null || _service$refresh5 === void 0 ? void 0 : _service$refresh5.call(service);
833
+
834
+ case 1:
835
+ case "end":
836
+ return _context12.stop();
837
+ }
838
+ }
839
+ }, _callee12);
758
840
  }))();
759
841
  }
760
842
  };
@@ -771,13 +853,13 @@ export var useDetailsPaginationProps = function useDetailsPaginationProps() {
771
853
  total: count,
772
854
  pageSize: 1,
773
855
  onChange: function onChange(page) {
774
- return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee11() {
856
+ return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee13() {
775
857
  var _ctx$service3, _ctx$service3$params;
776
858
 
777
859
  var params;
778
- return regeneratorRuntime.wrap(function _callee11$(_context11) {
860
+ return regeneratorRuntime.wrap(function _callee13$(_context13) {
779
861
  while (1) {
780
- switch (_context11.prev = _context11.next) {
862
+ switch (_context13.prev = _context13.next) {
781
863
  case 0:
782
864
  params = (_ctx$service3 = ctx.service) === null || _ctx$service3 === void 0 ? void 0 : (_ctx$service3$params = _ctx$service3.params) === null || _ctx$service3$params === void 0 ? void 0 : _ctx$service3$params[0];
783
865
  ctx.service.run(_objectSpread(_objectSpread({}, params), {}, {
@@ -786,10 +868,10 @@ export var useDetailsPaginationProps = function useDetailsPaginationProps() {
786
868
 
787
869
  case 2:
788
870
  case "end":
789
- return _context11.stop();
871
+ return _context13.stop();
790
872
  }
791
873
  }
792
- }, _callee11);
874
+ }, _callee13);
793
875
  }))();
794
876
  },
795
877
  style: {
@@ -9,7 +9,8 @@ import { merge } from '@formily/shared';
9
9
  import React, { useEffect } from 'react';
10
10
  import { useCompile, useComponent, useFormBlockContext } from '..';
11
11
  import { CollectionFieldProvider } from './CollectionFieldProvider';
12
- import { useCollectionField } from './hooks'; // TODO: 初步适配
12
+ import { useCollectionField } from './hooks';
13
+ import { concat } from 'lodash'; // TODO: 初步适配
13
14
 
14
15
  var InternalField = function InternalField(props) {
15
16
  var field = useField();
@@ -51,8 +52,9 @@ var InternalField = function InternalField(props) {
51
52
  setFieldProps('description', uiSchema.description);
52
53
  setFieldProps('initialValue', uiSchema.default);
53
54
 
54
- if (!field.validator && uiSchema['x-validator']) {
55
- field.validator = uiSchema['x-validator'];
55
+ if (!field.validator && (uiSchema['x-validator'] || fieldSchema['x-validator'])) {
56
+ var concatSchema = concat([], uiSchema['x-validator'] || [], fieldSchema['x-validator'] || []);
57
+ field.validator = concatSchema;
56
58
  }
57
59
 
58
60
  if (fieldSchema['x-disabled'] === true) {