amis 1.9.1-beta.1 → 1.9.1-beta.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (248) hide show
  1. package/lib/RootRenderer.js +10 -2
  2. package/lib/RootRenderer.js.map +2 -2
  3. package/lib/Schema.d.ts +3 -2
  4. package/lib/Schema.js.map +1 -1
  5. package/lib/components/Alert2.d.ts +10 -10
  6. package/lib/components/Button.d.ts +11 -10
  7. package/lib/components/Button.js +2 -2
  8. package/lib/components/Button.js.map +2 -2
  9. package/lib/components/CalendarMobile.d.ts +40 -40
  10. package/lib/components/Checkbox.js +1 -1
  11. package/lib/components/Checkbox.js.map +2 -2
  12. package/lib/components/ContextMenu.d.ts +4 -0
  13. package/lib/components/ContextMenu.js +23 -7
  14. package/lib/components/ContextMenu.js.map +2 -2
  15. package/lib/components/DatePicker.d.ts +40 -40
  16. package/lib/components/DateRangePicker.d.ts +40 -40
  17. package/lib/components/Form.d.ts +22 -0
  18. package/lib/components/Form.js +44 -0
  19. package/lib/components/Form.js.map +13 -0
  20. package/lib/components/FormField.d.ts +65 -0
  21. package/lib/components/FormField.js +48 -0
  22. package/lib/components/FormField.js.map +13 -0
  23. package/lib/components/InputBox.d.ts +10 -10
  24. package/lib/components/InputBox.js +4 -3
  25. package/lib/components/InputBox.js.map +2 -2
  26. package/lib/components/InputBoxWithSuggestion.d.ts +280 -0
  27. package/lib/components/InputBoxWithSuggestion.js +65 -0
  28. package/lib/components/InputBoxWithSuggestion.js.map +13 -0
  29. package/lib/components/ListGroup.d.ts +10 -10
  30. package/lib/components/PickerContainer.d.ts +4 -2
  31. package/lib/components/PickerContainer.js +28 -5
  32. package/lib/components/PickerContainer.js.map +2 -2
  33. package/lib/components/Radios.d.ts +10 -10
  34. package/lib/components/ResultBox.d.ts +40 -40
  35. package/lib/components/SearchBox.d.ts +40 -40
  36. package/lib/components/Select.d.ts +195 -202
  37. package/lib/components/Select.js +7 -3
  38. package/lib/components/Select.js.map +2 -2
  39. package/lib/components/Textarea.d.ts +568 -2
  40. package/lib/components/Textarea.js +129 -1
  41. package/lib/components/Textarea.js.map +2 -2
  42. package/lib/components/Toast.js +11 -9
  43. package/lib/components/Toast.js.map +2 -2
  44. package/lib/components/UserSelect.d.ts +500 -0
  45. package/lib/components/UserSelect.js +559 -0
  46. package/lib/components/UserSelect.js.map +13 -0
  47. package/lib/components/UserTabSelect.d.ts +320 -0
  48. package/lib/components/UserTabSelect.js +163 -0
  49. package/lib/components/UserTabSelect.js.map +13 -0
  50. package/lib/components/WithRemoteConfig.d.ts +7 -0
  51. package/lib/components/WithRemoteConfig.js +17 -11
  52. package/lib/components/WithRemoteConfig.js.map +2 -2
  53. package/lib/components/calendar/DaysView.d.ts +26 -1
  54. package/lib/components/calendar/DaysView.js +48 -14
  55. package/lib/components/calendar/DaysView.js.map +2 -2
  56. package/lib/components/calendar/TimeView.d.ts +1 -1
  57. package/lib/components/calendar/TimeView.js +8 -2
  58. package/lib/components/calendar/TimeView.js.map +2 -2
  59. package/lib/components/icons.d.ts +7 -1
  60. package/lib/components/icons.js +17 -1
  61. package/lib/components/icons.js.map +2 -2
  62. package/lib/components/index.d.ts +2 -1
  63. package/lib/components/index.js +3 -1
  64. package/lib/components/index.js.map +2 -2
  65. package/lib/components/json-schema/Array.d.ts +3 -0
  66. package/lib/components/json-schema/Array.js +125 -0
  67. package/lib/components/json-schema/Array.js.map +13 -0
  68. package/lib/components/json-schema/Item.d.ts +3 -0
  69. package/lib/components/json-schema/Item.js +34 -0
  70. package/lib/components/json-schema/Item.js.map +13 -0
  71. package/lib/components/json-schema/Object.d.ts +3 -0
  72. package/lib/components/json-schema/Object.js +178 -0
  73. package/lib/components/json-schema/Object.js.map +13 -0
  74. package/lib/components/json-schema/index.d.ts +279 -0
  75. package/lib/components/json-schema/index.js +16 -0
  76. package/lib/components/json-schema/index.js.map +13 -0
  77. package/lib/components/schema-editor/Array.js +2 -2
  78. package/lib/components/schema-editor/Array.js.map +2 -2
  79. package/lib/components/schema-editor/Common.d.ts +2 -0
  80. package/lib/components/schema-editor/Common.js +39 -3
  81. package/lib/components/schema-editor/Common.js.map +2 -2
  82. package/lib/components/schema-editor/Object.js +2 -2
  83. package/lib/components/schema-editor/Object.js.map +2 -2
  84. package/lib/components/schema-editor/index.d.ts +45 -41
  85. package/lib/components/schema-editor/index.js +5 -5
  86. package/lib/components/schema-editor/index.js.map +2 -2
  87. package/lib/hooks/use-validation-resolver.d.ts +1 -0
  88. package/lib/hooks/use-validation-resolver.js +49 -0
  89. package/lib/hooks/use-validation-resolver.js.map +13 -0
  90. package/lib/icons/department.js +17 -0
  91. package/lib/icons/menu.js +9 -0
  92. package/lib/icons/post.js +15 -0
  93. package/lib/icons/role.js +14 -0
  94. package/lib/icons/user-remove.js +12 -0
  95. package/lib/index.d.ts +2 -0
  96. package/lib/index.js +3 -1
  97. package/lib/index.js.map +2 -2
  98. package/lib/locale/de-DE.js +11 -1
  99. package/lib/locale/de-DE.js.map +2 -2
  100. package/lib/locale/en-US.js +12 -1
  101. package/lib/locale/en-US.js.map +2 -2
  102. package/lib/locale/zh-CN.js +14 -3
  103. package/lib/locale/zh-CN.js.map +2 -2
  104. package/lib/renderers/Action.js +25 -11
  105. package/lib/renderers/Action.js.map +2 -2
  106. package/lib/renderers/CRUD.js +5 -1
  107. package/lib/renderers/CRUD.js.map +2 -2
  108. package/lib/renderers/Dialog.js +9 -3
  109. package/lib/renderers/Dialog.js.map +2 -2
  110. package/lib/renderers/Drawer.js +5 -1
  111. package/lib/renderers/Drawer.js.map +2 -2
  112. package/lib/renderers/Form/InputDate.d.ts +2 -2
  113. package/lib/renderers/Form/InputDate.js.map +2 -2
  114. package/lib/renderers/Form/JSONSchema.d.ts +23 -0
  115. package/lib/renderers/Form/JSONSchema.js +44 -0
  116. package/lib/renderers/Form/JSONSchema.js.map +13 -0
  117. package/lib/renderers/Form/JSONSchemaEditor.d.ts +2 -3
  118. package/lib/renderers/Form/JSONSchemaEditor.js +9 -24
  119. package/lib/renderers/Form/JSONSchemaEditor.js.map +2 -2
  120. package/lib/renderers/Form/Textarea.d.ts +1 -8
  121. package/lib/renderers/Form/Textarea.js +11 -75
  122. package/lib/renderers/Form/Textarea.js.map +2 -2
  123. package/lib/renderers/Form/UserSelect.d.ts +54 -0
  124. package/lib/renderers/Form/UserSelect.js +197 -0
  125. package/lib/renderers/Form/UserSelect.js.map +13 -0
  126. package/lib/renderers/Form/index.d.ts +1 -1
  127. package/lib/renderers/Form/index.js +88 -42
  128. package/lib/renderers/Form/index.js.map +2 -2
  129. package/lib/renderers/Log.d.ts +13 -1
  130. package/lib/renderers/Log.js +82 -16
  131. package/lib/renderers/Log.js.map +2 -2
  132. package/lib/renderers/Page.js +5 -1
  133. package/lib/renderers/Page.js.map +2 -2
  134. package/lib/renderers/Service.js +5 -1
  135. package/lib/renderers/Service.js.map +2 -2
  136. package/lib/renderers/Wizard.js +37 -14
  137. package/lib/renderers/Wizard.js.map +2 -2
  138. package/lib/store/form.js +65 -45
  139. package/lib/store/form.js.map +2 -2
  140. package/lib/themes/ang-ie11.css +561 -21
  141. package/lib/themes/ang.css +538 -9
  142. package/lib/themes/ang.css.map +1 -1
  143. package/lib/themes/antd-ie11.css +561 -21
  144. package/lib/themes/antd.css +538 -9
  145. package/lib/themes/antd.css.map +1 -1
  146. package/lib/themes/cxd-ie11.css +561 -21
  147. package/lib/themes/cxd.css +538 -9
  148. package/lib/themes/cxd.css.map +1 -1
  149. package/lib/themes/dark-ie11.css +561 -21
  150. package/lib/themes/dark.css +538 -9
  151. package/lib/themes/dark.css.map +1 -1
  152. package/lib/themes/default-ie11.css +561 -21
  153. package/lib/themes/default.css +538 -9
  154. package/lib/themes/default.css.map +1 -1
  155. package/lib/utils/api.js +1 -1
  156. package/lib/utils/api.js.map +2 -2
  157. package/lib/utils/renderer-event.js.map +2 -2
  158. package/package.json +2 -1
  159. package/schema.json +539 -3
  160. package/scss/_properties.scss +20 -8
  161. package/scss/components/_input-box.scss +22 -1
  162. package/scss/components/_json-schema.scss +124 -0
  163. package/scss/components/_log.scss +37 -5
  164. package/scss/components/form/_date-range.scss +1 -0
  165. package/scss/components/form/_select.scss +9 -0
  166. package/scss/components/form/_user-select.scss +422 -0
  167. package/scss/themes/_common.scss +2 -0
  168. package/sdk/ang-ie11.css +651 -21
  169. package/sdk/ang.css +628 -9
  170. package/sdk/antd-ie11.css +651 -21
  171. package/sdk/antd.css +628 -9
  172. package/sdk/barcode.js +51 -51
  173. package/sdk/charts.js +14 -14
  174. package/sdk/codemirror.js +7 -7
  175. package/sdk/color-picker.js +65 -65
  176. package/sdk/cropperjs.js +2 -2
  177. package/sdk/cxd-ie11.css +651 -21
  178. package/sdk/cxd.css +628 -9
  179. package/sdk/dark-ie11.css +651 -21
  180. package/sdk/dark.css +628 -9
  181. package/sdk/exceljs.js +1 -1
  182. package/sdk/locale/de-DE.js +11 -1
  183. package/sdk/markdown.js +69 -69
  184. package/sdk/papaparse.js +1 -1
  185. package/sdk/renderers/Form/CityDB.js +1 -1
  186. package/sdk/rest.js +16 -16
  187. package/sdk/rich-text.js +62 -62
  188. package/sdk/sdk-ie11.css +651 -21
  189. package/sdk/sdk.css +628 -9
  190. package/sdk/sdk.js +1655 -1643
  191. package/sdk/thirds/hls.js/hls.js +1 -1
  192. package/sdk/thirds/mpegts.js/mpegts.js +1 -1
  193. package/sdk/tinymce.js +57 -57
  194. package/src/RootRenderer.tsx +27 -15
  195. package/src/Schema.ts +5 -1
  196. package/src/components/Button.tsx +3 -0
  197. package/src/components/Checkbox.tsx +2 -1
  198. package/src/components/ContextMenu.tsx +25 -7
  199. package/src/components/Form.tsx +70 -0
  200. package/src/components/FormField.tsx +127 -0
  201. package/src/components/InputBox.tsx +4 -1
  202. package/src/components/InputBoxWithSuggestion.tsx +113 -0
  203. package/src/components/PickerContainer.tsx +20 -5
  204. package/src/components/Select.tsx +18 -10
  205. package/src/components/Textarea.tsx +234 -2
  206. package/src/components/Toast.tsx +19 -18
  207. package/src/components/UserSelect.tsx +850 -0
  208. package/src/components/UserTabSelect.tsx +261 -0
  209. package/src/components/WithRemoteConfig.tsx +22 -7
  210. package/src/components/calendar/DaysView.tsx +53 -16
  211. package/src/components/calendar/TimeView.tsx +10 -5
  212. package/src/components/icons.tsx +17 -1
  213. package/src/components/index.tsx +3 -1
  214. package/src/components/json-schema/Array.tsx +216 -0
  215. package/src/components/json-schema/Item.tsx +47 -0
  216. package/src/components/json-schema/Object.tsx +339 -0
  217. package/src/components/json-schema/index.tsx +44 -0
  218. package/src/components/schema-editor/Array.tsx +3 -1
  219. package/src/components/schema-editor/Common.tsx +61 -4
  220. package/src/components/schema-editor/Object.tsx +3 -1
  221. package/src/components/schema-editor/index.tsx +12 -5
  222. package/src/hooks/use-validation-resolver.ts +45 -0
  223. package/src/icons/department.svg +17 -0
  224. package/src/icons/menu.svg +2 -0
  225. package/src/icons/post.svg +15 -0
  226. package/src/icons/role.svg +14 -0
  227. package/src/icons/user-remove.svg +12 -0
  228. package/src/index.tsx +2 -0
  229. package/src/locale/de-DE.ts +11 -1
  230. package/src/locale/en-US.ts +12 -1
  231. package/src/locale/zh-CN.ts +14 -3
  232. package/src/renderers/Action.tsx +10 -9
  233. package/src/renderers/CRUD.tsx +5 -1
  234. package/src/renderers/Dialog.tsx +9 -3
  235. package/src/renderers/Drawer.tsx +5 -1
  236. package/src/renderers/Form/InputDate.tsx +9 -4
  237. package/src/renderers/Form/JSONSchema.tsx +56 -0
  238. package/src/renderers/Form/JSONSchemaEditor.tsx +8 -27
  239. package/src/renderers/Form/Textarea.tsx +7 -117
  240. package/src/renderers/Form/UserSelect.tsx +263 -0
  241. package/src/renderers/Form/index.tsx +28 -18
  242. package/src/renderers/Log.tsx +148 -13
  243. package/src/renderers/Page.tsx +6 -1
  244. package/src/renderers/Service.tsx +5 -1
  245. package/src/renderers/Wizard.tsx +24 -10
  246. package/src/store/form.ts +24 -17
  247. package/src/utils/api.ts +1 -1
  248. package/src/utils/renderer-event.ts +0 -2
@@ -3,11 +3,22 @@
3
3
  */
4
4
  import React from 'react';
5
5
  import {Renderer, RendererProps} from '../factory';
6
- import {BaseSchema, SchemaTpl} from '../Schema';
6
+ import {BaseSchema} from '../Schema';
7
7
  import Ansi from 'ansi-to-react';
8
- import {filter} from '../utils/tpl';
9
8
  import {buildApi, isApiOutdated} from '../utils/api';
10
9
  import VirtualList from '../components/virtual-list';
10
+ import Button from '../components/Button';
11
+ import {
12
+ InputClearIcon,
13
+ LeftArrowIcon,
14
+ MinusIcon,
15
+ PauseIcon,
16
+ PlusIcon,
17
+ ReloadIcon,
18
+ RightArrowIcon
19
+ } from '../components/icons';
20
+
21
+ export type LogOperation = 'stop' | 'restart' | 'showLineNumber' | 'clear';
11
22
 
12
23
  /**
13
24
  * 日志展示组件
@@ -58,6 +69,11 @@ export interface LogSchema extends BaseSchema {
58
69
  * 关闭 ANSI 颜色支持
59
70
  */
60
71
  disableColor?: boolean;
72
+
73
+ /**
74
+ * 一些可操作选项
75
+ */
76
+ operation?: Array<LogOperation>;
61
77
  }
62
78
 
63
79
  export interface LogProps
@@ -67,6 +83,9 @@ export interface LogProps
67
83
  export interface LogState {
68
84
  lastLine: string;
69
85
  logs: string[];
86
+ refresh: boolean;
87
+ showLineNumber: boolean;
88
+ showOperation: boolean;
70
89
  }
71
90
 
72
91
  export class Log extends React.Component<LogProps, LogState> {
@@ -85,7 +104,10 @@ export class Log extends React.Component<LogProps, LogState> {
85
104
 
86
105
  state: LogState = {
87
106
  lastLine: '',
88
- logs: []
107
+ logs: [],
108
+ refresh: true,
109
+ showLineNumber: false,
110
+ showOperation: false
89
111
  };
90
112
 
91
113
  constructor(props: LogProps) {
@@ -140,6 +162,36 @@ export class Log extends React.Component<LogProps, LogState> {
140
162
  }
141
163
  }
142
164
 
165
+ refresh = () => {
166
+ let origin = this.state.refresh;
167
+ this.setState({
168
+ refresh: !origin
169
+ });
170
+ if (!origin) {
171
+ this.clear();
172
+ this.loadLogs();
173
+ }
174
+ };
175
+
176
+ clear = () => {
177
+ this.setState({
178
+ logs: [],
179
+ lastLine: ''
180
+ });
181
+ };
182
+
183
+ changeShowLineNumber = () => {
184
+ this.setState({
185
+ showLineNumber: !this.state.showLineNumber
186
+ });
187
+ };
188
+
189
+ changeShowOperation = () => {
190
+ this.setState({
191
+ showOperation: !this.state.showOperation
192
+ });
193
+ };
194
+
143
195
  async loadLogs() {
144
196
  const {source, data, env, translate: __, encoding, maxLength} = this.props;
145
197
  // 因为这里返回结果是流式的,和普通 api 请求不一样,如果直接用 fetcher 经过 responseAdaptor 可能会导致出错,所以就直接 fetch 了
@@ -162,6 +214,12 @@ export class Log extends React.Component<LogProps, LogState> {
162
214
  let lastline = '';
163
215
  let logs: string[] = [];
164
216
  for (;;) {
217
+ if (!this.state.refresh) {
218
+ await reader.cancel('click cancel button').then(() => {
219
+ this.props.env.notify('success', '日志已经停止刷新');
220
+ return;
221
+ });
222
+ }
165
223
  let {done, value} = await reader.read();
166
224
  if (value) {
167
225
  let text = new TextDecoder(encoding).decode(value, {stream: true});
@@ -180,7 +238,7 @@ export class Log extends React.Component<LogProps, LogState> {
180
238
  lastline = lines.pop() || '';
181
239
  if (maxLength) {
182
240
  if (logs.length + lines.length > maxLength) {
183
- logs.splice(0, lines.length);
241
+ logs.splice(0, logs.length + lines.length - maxLength);
184
242
  }
185
243
  }
186
244
  logs = logs.concat(lines);
@@ -204,10 +262,13 @@ export class Log extends React.Component<LogProps, LogState> {
204
262
  /**
205
263
  * 渲染某一行
206
264
  */
207
- renderLine(index: number, line: string) {
265
+ renderLine(index: number, line: string, showLineNumber: boolean) {
208
266
  const {classnames: cx, disableColor} = this.props;
209
267
  return (
210
268
  <div className={cx('Log-line')} key={index}>
269
+ {showLineNumber && (
270
+ <span className={cx('Log-line-number')}>{index + 1} </span>
271
+ )}
211
272
  {disableColor ? line : <Ansi useClasses>{line}</Ansi>}
212
273
  </div>
213
274
  );
@@ -222,9 +283,13 @@ export class Log extends React.Component<LogProps, LogState> {
222
283
  height,
223
284
  rowHeight,
224
285
  disableColor,
225
- translate: __
286
+ translate: __,
287
+ operation,
288
+ env
226
289
  } = this.props;
227
290
 
291
+ const {refresh, showLineNumber, showOperation} = this.state;
292
+
228
293
  let loading = __(placeholder);
229
294
 
230
295
  if (!source) {
@@ -251,6 +316,9 @@ export class Log extends React.Component<LogProps, LogState> {
251
316
  key={index}
252
317
  style={{...style, whiteSpace: 'nowrap'}}
253
318
  >
319
+ {showLineNumber && (
320
+ <span className={cx('Log-line-number')}>{index + 1} </span>
321
+ )}
254
322
  {disableColor ? (
255
323
  logs[index]
256
324
  ) : (
@@ -262,17 +330,84 @@ export class Log extends React.Component<LogProps, LogState> {
262
330
  );
263
331
  } else {
264
332
  lines = logs.map((line, index) => {
265
- return this.renderLine(index, line);
333
+ return this.renderLine(index, line, showLineNumber);
266
334
  });
267
335
  }
268
336
 
269
337
  return (
270
- <div
271
- ref={this.logRef}
272
- className={cx('Log', className)}
273
- style={{height: useVirtualRender ? 'auto' : height}}
274
- >
275
- {useVirtualRender ? lines : lines.length ? lines : loading}
338
+ <div className={cx('Log', className)}>
339
+ <div
340
+ ref={this.logRef}
341
+ className={cx('Log-body')}
342
+ style={{height: useVirtualRender ? 'auto' : height}}
343
+ >
344
+ {useVirtualRender ? lines : lines.length ? lines : loading}
345
+ </div>
346
+ <div className={cx('Log-operation')}>
347
+ {operation &&
348
+ operation?.length > 0 &&
349
+ (showOperation ? (
350
+ <>
351
+ {operation.includes('stop') && (
352
+ <Button
353
+ size="sm"
354
+ title="__('stop')"
355
+ disabled={!refresh}
356
+ onClick={this.refresh}
357
+ >
358
+ <PauseIcon />
359
+ </Button>
360
+ )}
361
+
362
+ {operation.includes('restart') && (
363
+ <Button
364
+ size="sm"
365
+ title={__('reload')}
366
+ disabled={refresh}
367
+ onClick={this.refresh}
368
+ >
369
+ <ReloadIcon />
370
+ </Button>
371
+ )}
372
+
373
+ {operation.includes('showLineNumber') && (
374
+ <Button
375
+ size="sm"
376
+ title={
377
+ showLineNumber
378
+ ? __('Log.notShowLineNumber')
379
+ : __('Log.showLineNumber')
380
+ }
381
+ onClick={this.changeShowLineNumber}
382
+ >
383
+ {showLineNumber ? <MinusIcon /> : <PlusIcon />}
384
+ </Button>
385
+ )}
386
+
387
+ {operation.includes('clear') && (
388
+ <Button size="sm" title={__('clear')} onClick={this.clear}>
389
+ <InputClearIcon />
390
+ </Button>
391
+ )}
392
+
393
+ <Button
394
+ size="sm"
395
+ title={__('Log.collapse')}
396
+ onClick={this.changeShowOperation}
397
+ >
398
+ <LeftArrowIcon />
399
+ </Button>
400
+ </>
401
+ ) : (
402
+ <div
403
+ title={__('Log.expand')}
404
+ className={cx('Log-operation-hidden')}
405
+ onClick={this.changeShowOperation}
406
+ >
407
+ <RightArrowIcon />
408
+ </div>
409
+ ))}
410
+ </div>
276
411
  </div>
277
412
  );
278
413
  }
@@ -467,6 +467,7 @@ export default class Page extends React.Component<PageProps> {
467
467
  store.openDrawer(ctx);
468
468
  } else if (action.actionType === 'ajax') {
469
469
  store.setCurrentAction(action);
470
+
470
471
  return store
471
472
  .saveRemote(action.api as string, ctx, {
472
473
  successMessage:
@@ -486,7 +487,11 @@ export default class Page extends React.Component<PageProps> {
486
487
  redirect && env.jumpTo(redirect, action);
487
488
  action.reload && this.reloadTarget(action.reload, store.data);
488
489
  })
489
- .catch(() => {});
490
+ .catch((e) => {
491
+ if (throwErrors || action.countDown) {
492
+ throw e;
493
+ }
494
+ });
490
495
  } else {
491
496
  return onAction(e, action, ctx, throwErrors, delegate || this.context);
492
497
  }
@@ -523,7 +523,11 @@ export default class Service extends React.Component<ServiceProps> {
523
523
  redirect && env.jumpTo(redirect, action);
524
524
  action.reload && this.reloadTarget(action.reload, store.data);
525
525
  })
526
- .catch(() => {});
526
+ .catch((e) => {
527
+ if (throwErrors || action.countDown) {
528
+ throw e;
529
+ }
530
+ });
527
531
  } else {
528
532
  onAction(e, action, data, throwErrors, delegate || this.context);
529
533
  }
@@ -718,23 +718,41 @@ export default class Wizard extends React.Component<WizardProps, WizardState> {
718
718
 
719
719
  formStore
720
720
  .saveRemote(action.api || step.api || api!, store.data, {
721
- onSuccess: () => {
722
- this.dispatchEvent('submitSucc', store.data);
721
+ onSuccess: async (result: any) => {
722
+ const dispatcher = await this.dispatchEvent(
723
+ 'submitSucc',
724
+ createObject(this.props.data, {result})
725
+ );
723
726
 
724
727
  if (
725
728
  !isEffectiveApi(finnalAsyncApi, store.data) ||
726
729
  store.data[finishedField || 'finished']
727
730
  ) {
728
- return;
731
+ return {
732
+ cbResult: null,
733
+ dispatcher
734
+ };
729
735
  }
730
736
 
731
- return until(
737
+ const cbResult = until(
732
738
  () => store.checkRemote(finnalAsyncApi as Api, store.data),
733
739
  (ret: any) => ret && ret[finishedField || 'finished'],
734
740
  cancel => (this.asyncCancel = cancel)
735
741
  );
742
+ return {
743
+ cbResult,
744
+ dispatcher
745
+ };
736
746
  },
737
- onFailed: error => this.dispatchEvent('submitFail', {error})
747
+ onFailed: async (error: any) => {
748
+ const dispatcher = await this.dispatchEvent(
749
+ 'submitFail',
750
+ createObject(this.props.data, {error})
751
+ );
752
+ return {
753
+ dispatcher
754
+ };
755
+ }
738
756
  })
739
757
  .then(async value => {
740
758
  const feedback = action.feedback;
@@ -778,11 +796,7 @@ export default class Wizard extends React.Component<WizardProps, WizardState> {
778
796
 
779
797
  return value;
780
798
  })
781
- .catch(error => {
782
- this.dispatchEvent('submitFail', {error});
783
- store.markSaving(false);
784
- console.error(error);
785
- });
799
+ .catch(error => {});
786
800
  } else {
787
801
  onFinished && onFinished(store.data, action);
788
802
  this.setState({completeStep: steps.length});
package/src/store/form.ts CHANGED
@@ -326,10 +326,7 @@ export const FormStore = ServiceStore.named('FormStore')
326
326
  }
327
327
 
328
328
  if (!json.ok) {
329
- // 验证错误
330
- if (options && options.onFailed) {
331
- options.onFailed(json);
332
- }
329
+
333
330
  if (json.status === 422 && json.errors) {
334
331
  setFormItemErrors(json.errors);
335
332
 
@@ -349,18 +346,19 @@ export const FormStore = ServiceStore.named('FormStore')
349
346
  throw new ServerError(self.msg, json);
350
347
  } else {
351
348
  updateSavedData();
352
- if (options && options.onSuccess) {
353
- const ret = options.onSuccess(json);
354
-
355
- if (ret && ret.then) {
356
- yield ret;
357
- }
349
+ let ret = options && options.onSuccess && options.onSuccess(json);
350
+ if (ret?.then) {
351
+ ret = yield ret;
352
+ }
353
+ if (ret?.cbResult?.then) {
354
+ yield ret.cbResult;
358
355
  }
359
356
  self.markSaving(false);
360
357
  self.updateMessage(
361
358
  json.msg ?? self.__(options && options.successMessage)
362
359
  );
363
- self.msg &&
360
+ if (!ret?.dispatcher?.prevented) {
361
+ self.msg &&
364
362
  getEnv(self).notify(
365
363
  'success',
366
364
  self.msg,
@@ -371,15 +369,21 @@ export const FormStore = ServiceStore.named('FormStore')
371
369
  }
372
370
  : undefined
373
371
  );
372
+ }
374
373
  return json.data;
375
374
  }
376
375
  } catch (e) {
377
376
  self.markSaving(false);
378
-
377
+ let ret = options && options.onFailed && options.onFailed(e.response || {});
378
+ if (ret?.then) {
379
+ ret = yield ret;
380
+ }
379
381
  if (!isAlive(self) || self.disposed) {
380
382
  return;
381
383
  }
382
-
384
+ if (ret?.dispatcher?.prevented) {
385
+ return;
386
+ }
383
387
  if (e.type === 'ServerError') {
384
388
  const result = (e as ServerError).response;
385
389
  getEnv(self).notify(
@@ -395,7 +399,6 @@ export const FormStore = ServiceStore.named('FormStore')
395
399
  } else {
396
400
  getEnv(self).notify('error', e.message);
397
401
  }
398
-
399
402
  throw e;
400
403
  }
401
404
  });
@@ -479,9 +482,13 @@ export const FormStore = ServiceStore.named('FormStore')
479
482
  ) {
480
483
  let msg = failedMessage ?? self.__('Form.validateFailed');
481
484
  const env = getEnv(self);
482
-
483
- msg && env.notify('error', msg);
484
- validateErrCb && validateErrCb();
485
+ let dispatcher: any = validateErrCb && validateErrCb();
486
+ if (dispatcher?.then) {
487
+ dispatcher = yield dispatcher;
488
+ }
489
+ if (!dispatcher?.prevented){
490
+ msg && env.notify('error', msg);
491
+ }
485
492
  throw new Error(msg);
486
493
  }
487
494
 
package/src/utils/api.ts CHANGED
@@ -307,7 +307,7 @@ export function responseAdaptor(ret: fetcherResult, api: ApiObject) {
307
307
  if (data.hasOwnProperty('errorCode')) {
308
308
  // 阿里 Java 规范
309
309
  data.status = data.errorCode;
310
- data.msg = data.errorMessage;
310
+ data.msg = data.errorMessage || data.errorMsg;
311
311
  } else if (data.hasOwnProperty('errno')) {
312
312
  data.status = data.errno;
313
313
  data.msg = data.errmsg || data.errstr || data.msg;
@@ -138,7 +138,6 @@ export async function dispatchEvent(
138
138
 
139
139
  unbindEvent = bindEvent(renderer);
140
140
  }
141
-
142
141
  // 没有可处理的监听
143
142
  if (!rendererEventListeners.length) {
144
143
  return Promise.resolve();
@@ -152,7 +151,6 @@ export async function dispatchEvent(
152
151
  data,
153
152
  scoped
154
153
  });
155
-
156
154
  // 过滤&排序
157
155
  const listeners = rendererEventListeners
158
156
  .filter(