@nokecy/qc-ui 1.1.63 → 1.1.65

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.
@@ -3,7 +3,7 @@ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyri
3
3
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
4
4
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
5
5
  import React, { useMemo } from 'react';
6
- import { Space, Button } from 'antd';
6
+ import { Space, Button, Tooltip } from 'antd';
7
7
  import { EditOutlined, DeleteOutlined } from '@ant-design/icons';
8
8
  import AccessWrapper from "./_utils/AccessWrapper";
9
9
  import { defaultHandleDelete } from "./_utils/defaultHandlers";
@@ -24,10 +24,12 @@ var OptionsColumn = function OptionsColumn(props) {
24
24
  formDialog = props.formDialog,
25
25
  deleteApi = props.deleteApi,
26
26
  _props$useErrorHandle = props.useErrorHandler,
27
- useErrorHandler = _props$useErrorHandle === void 0 ? true : _props$useErrorHandle;
27
+ useErrorHandler = _props$useErrorHandle === void 0 ? true : _props$useErrorHandle,
28
+ access = props.access,
29
+ deleteConfirm = props.deleteConfirm;
28
30
 
29
31
  // 使用权限检查 Hook
30
- var _usePermissionCheck = usePermissionCheck(permissions),
32
+ var _usePermissionCheck = usePermissionCheck(permissions, access),
31
33
  canUpdate = _usePermissionCheck.canUpdate,
32
34
  canDelete = _usePermissionCheck.canDelete,
33
35
  hasPermission = _usePermissionCheck.hasPermission;
@@ -50,13 +52,15 @@ var OptionsColumn = function OptionsColumn(props) {
50
52
  _context.next = 6;
51
53
  return defaultHandleDelete(deleteApi, id, refresh);
52
54
  case 6:
53
- _context.next = 11;
55
+ _context.next = 12;
54
56
  break;
55
57
  case 8:
56
58
  _context.prev = 8;
57
59
  _context.t0 = _context["catch"](3);
58
60
  console.error('删除失败:', _context.t0);
59
- case 11:
61
+ // 让确认框结束加载并保留失败状态,避免失败被当作成功关闭。@author nokecy
62
+ throw _context.t0;
63
+ case 12:
60
64
  case "end":
61
65
  return _context.stop();
62
66
  }
@@ -80,13 +84,24 @@ var OptionsColumn = function OptionsColumn(props) {
80
84
  return null;
81
85
  }
82
86
  var FormDialogComponent = formDialog === null || formDialog === void 0 ? void 0 : formDialog.component;
87
+
88
+ // 确认框要说清删的是哪一条:页面没给标题时取该行的名称或编码。@author nokecy
89
+ var record = data;
90
+ var recordLabel = (record === null || record === void 0 ? void 0 : record.name) || (record === null || record === void 0 ? void 0 : record.displayName) || (record === null || record === void 0 ? void 0 : record.code);
91
+ var resolveText = function resolveText(value, fallback) {
92
+ return typeof value === 'function' ? value(data) : value !== null && value !== void 0 ? value : fallback;
93
+ };
94
+ var deleteTitle = resolveText(deleteConfirm === null || deleteConfirm === void 0 ? void 0 : deleteConfirm.title, recordLabel ? "\u786E\u5B9A\u5220\u9664\u300C".concat(recordLabel, "\u300D\uFF1F") : '确定删除?');
95
+ var deleteContent = resolveText(deleteConfirm === null || deleteConfirm === void 0 ? void 0 : deleteConfirm.content, '删除后无法恢复。');
83
96
  return /*#__PURE__*/React.createElement(Space, {
84
97
  onClick: function onClick(event) {
85
98
  event.stopPropagation();
86
99
  }
87
100
  }, showEditButton && FormDialogComponent && /*#__PURE__*/React.createElement(Access, {
88
101
  accessible: canUpdate
89
- }, /*#__PURE__*/React.createElement(FormDialogComponent, {
102
+ }, /*#__PURE__*/React.createElement(Tooltip, {
103
+ title: "\u7F16\u8F91"
104
+ }, /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement(FormDialogComponent, {
90
105
  buttonProps: {
91
106
  size: "small",
92
107
  type: "link",
@@ -94,17 +109,19 @@ var OptionsColumn = function OptionsColumn(props) {
94
109
  style: {
95
110
  fontSize: 14
96
111
  }
97
- })
112
+ }),
113
+ 'aria-label': '编辑'
98
114
  },
99
115
  key: data.id,
100
116
  title: formDialog.editTitle || '编辑',
101
117
  entityId: data.id,
102
118
  onAfterSubmit: refresh
103
- })), showDeleteButton && /*#__PURE__*/React.createElement(Access, {
119
+ })))), showDeleteButton && /*#__PURE__*/React.createElement(Access, {
104
120
  accessible: canDelete
105
121
  }, /*#__PURE__*/React.createElement(DeleteConfirm, {
106
- title: "\u786E\u5B9A\u5220\u9664?",
107
- content: "\u6B64\u64CD\u4F5C\u5C06\u6C38\u4E45\u5220\u9664\u8BE5\u6570\u636E\uFF0C\u4E14\u65E0\u6CD5\u6062\u590D",
122
+ title: deleteTitle,
123
+ content: deleteContent,
124
+ okText: "\u5220\u9664",
108
125
  onConfirm: /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
109
126
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
110
127
  while (1) switch (_context2.prev = _context2.next) {
@@ -117,11 +134,13 @@ var OptionsColumn = function OptionsColumn(props) {
117
134
  }
118
135
  }, _callee2);
119
136
  }))
137
+ }, /*#__PURE__*/React.createElement(Tooltip, {
138
+ title: "\u5220\u9664"
120
139
  }, /*#__PURE__*/React.createElement(Button, {
121
140
  size: "small",
122
141
  icon: /*#__PURE__*/React.createElement(DeleteOutlined, null),
123
142
  type: "link",
124
- title: "\u5220\u9664"
125
- }))));
143
+ "aria-label": "\u5220\u9664"
144
+ })))));
126
145
  };
127
146
  export default OptionsColumn;
@@ -12,7 +12,7 @@ export { default } from './GeneratedListPage';
12
12
  export { default as GeneratedListPage } from './GeneratedListPage';
13
13
  export { default as ConfigurableToolbar } from './ConfigurableToolbar';
14
14
  export { default as OptionsColumn } from './OptionsColumn';
15
- export type { GeneratedListPageConfig, PermissionConfig, ApiConfig, ListParams, PagedResult, DeleteParams, ExportParams, ToolbarActionConfig, FormDialogConfig, TreeDataConfig, OptionsComponentProps } from './types';
15
+ export type { GeneratedListPageConfig, PermissionConfig, ApiConfig, ListParams, PagedResult, DeleteParams, ExportParams, ToolbarActionConfig, FormDialogConfig, TreeDataConfig, OptionsComponentProps, DeleteConfirmConfig } from './types';
16
16
  export { usePermissionCheck, PermissionChecker } from './usePermissionCheck';
17
17
  export { usePerformanceMonitor, PerformanceDevTools } from './PerformanceMonitor';
18
18
  export { useRequestManager } from './useRequestManager';
@@ -1,7 +1,7 @@
1
- /// <reference types="react" />
2
1
  import { GridRef } from "../ag-grid-plus/interface";
3
2
  import { ColDef } from "ag-grid-community";
4
3
  import { ButtonProps } from "antd";
4
+ import { ReactNode } from "react";
5
5
  import { PagedApiAdapter } from '../adapters';
6
6
  /**
7
7
  * 权限配置接口
@@ -203,6 +203,27 @@ export interface GeneratedListPageConfig<T = any> {
203
203
  onRefresh?: () => void;
204
204
  /** 分页 API 适配器(默认 ABP);非 ABP 后端可注入。@author nokecy */
205
205
  pagedApiAdapter?: PagedApiAdapter;
206
+ /**
207
+ * 表格组件,默认用包内 AgGridPlus。
208
+ * 宿主可注入自己的表格基座(属性与 AgGridPlus 相同),让序号、默认复选、编码列收起、
209
+ * 内部字段隐藏等列表规范在通用列表页上同样生效。@author nokecy
210
+ */
211
+ gridComponent?: React.ComponentType<any>;
212
+ /**
213
+ * 当前用户已授予的权限(权限名 → 是否授予),通常传 umi 的 useAccess()。
214
+ * 不传时工具栏与操作列不做权限过滤——没有权限的人也会看到新建、编辑、删除,点了才报 403。@author nokecy
215
+ */
216
+ access?: Record<string, boolean>;
217
+ /** 删除确认框;title、content 可按行生成 */
218
+ deleteConfirm?: DeleteConfirmConfig<T>;
219
+ }
220
+ /**
221
+ * 删除确认框配置。
222
+ * 不传 title 时标题带上该行的名称或编码,让用户看清删的是哪一条;不传 content 时说明删除后无法恢复。@author nokecy
223
+ */
224
+ export interface DeleteConfirmConfig<T = any> {
225
+ title?: ReactNode | ((record: T) => ReactNode);
226
+ content?: ReactNode | ((record: T) => ReactNode);
206
227
  }
207
228
  /**
208
229
  * 操作列组件属性接口
@@ -221,4 +242,8 @@ export interface OptionsComponentProps<T = any> {
221
242
  deleteApi?: (params: DeleteParams) => Promise<void>;
222
243
  /** 是否使用统一错误处理 */
223
244
  useErrorHandler?: boolean;
245
+ /** 当前用户已授予的权限,见 GeneratedListPageConfig.access */
246
+ access?: Record<string, boolean>;
247
+ /** 删除确认框配置 */
248
+ deleteConfirm?: DeleteConfirmConfig<T>;
224
249
  }
@@ -18,18 +18,12 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
18
18
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
19
19
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
20
20
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
21
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
22
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
23
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
24
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
25
- function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
26
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
27
- import React, { useState, useCallback, useMemo, useRef, useEffect } from 'react';
21
+ import React, { useCallback, useMemo, useRef, useEffect } from 'react';
28
22
  import { FormDialog, FormLayout, FormItem, FormGrid, Input, Select, DatePicker, NumberPicker, Switch } from '@formily/antd-v5';
29
- import { onFormInit, onFormValidateFailed } from '@formily/core';
30
- import { Button, message, Spin } from 'antd';
23
+ import { onFormInit, onFormValidateFailed, onFormSubmitEnd } from '@formily/core';
24
+ import { Button, ConfigProvider, message, Spin } from 'antd';
31
25
  import portalManager from "./PortalManager";
32
- import { createSchemaField } from '@formily/react';
26
+ import { createSchemaField, Observer } from '@formily/react';
33
27
 
34
28
  // 创建默认的 SchemaField,包含基本组件和装饰器
35
29
  var SchemaFieldComponents = createSchemaField({
@@ -73,6 +67,7 @@ var defaultUseSchemaField = function defaultUseSchemaField(config) {
73
67
  * - 灵活的Schema支持
74
68
  * - 性能优化和加载状态管理
75
69
  *
70
+ * @author nokecy
76
71
  * @param props 组件属性
77
72
  */
78
73
  var StandardFormDialog = function StandardFormDialog(props) {
@@ -102,15 +97,11 @@ var StandardFormDialog = function StandardFormDialog(props) {
102
97
  _props$useSchemaField = props.useSchemaField,
103
98
  useSchemaFieldHook = _props$useSchemaField === void 0 ? defaultUseSchemaField : _props$useSchemaField;
104
99
 
105
- // 组件状态
106
- var _useState = useState(false),
107
- _useState2 = _slicedToArray(_useState, 2),
108
- loading = _useState2[0],
109
- setLoading = _useState2[1];
110
- var _useState3 = useState(false),
111
- _useState4 = _slicedToArray(_useState3, 2),
112
- submitting = _useState4[0],
113
- setSubmitting = _useState4[1];
100
+ // 直接观察弹窗表单,避免打开时的 React 状态快照覆盖实时状态。
101
+ // @author nokecy
102
+ var formRef = useRef();
103
+ var confirmingRef = useRef(false);
104
+ var loadingRef = useRef(false);
114
105
 
115
106
  // 组件挂载状态追踪 - 防止内存泄漏
116
107
  var isMountedRef = useRef(true);
@@ -162,78 +153,81 @@ var StandardFormDialog = function StandardFormDialog(props) {
162
153
  return _regeneratorRuntime().wrap(function _callee$(_context) {
163
154
  while (1) switch (_context.prev = _context.next) {
164
155
  case 0:
165
- if (!entityId) {
166
- _context.next = 30;
156
+ formRef.current = form;
157
+ if (!(entityId !== undefined && entityId !== null)) {
158
+ _context.next = 32;
167
159
  break;
168
160
  }
169
161
  // 创建新的 AbortController
170
162
  controller = new AbortController();
171
163
  abortControllerRef.current = controller;
172
164
  if (isMountedRef.current) {
173
- _context.next = 5;
165
+ _context.next = 6;
174
166
  break;
175
167
  }
176
168
  return _context.abrupt("return");
177
- case 5:
178
- setLoading(true);
179
- _context.prev = 6;
169
+ case 6:
170
+ loadingRef.current = true;
171
+ form.setLoading(true);
172
+ _context.prev = 8;
180
173
  if (!customInitializer) {
181
- _context.next = 12;
174
+ _context.next = 14;
182
175
  break;
183
176
  }
184
- _context.next = 10;
177
+ _context.next = 12;
185
178
  return customInitializer(form, entityId);
186
- case 10:
187
- _context.next = 20;
188
- break;
189
179
  case 12:
180
+ _context.next = 22;
181
+ break;
182
+ case 14:
190
183
  if (!apiConfig.get) {
191
- _context.next = 19;
184
+ _context.next = 21;
192
185
  break;
193
186
  }
194
- _context.next = 15;
187
+ _context.next = 17;
195
188
  return apiConfig.get({
196
189
  id: entityId
197
190
  });
198
- case 15:
191
+ case 17:
199
192
  data = _context.sent;
200
193
  // 检查组件是否已卸载或请求是否已取消
201
194
  if (!controller.signal.aborted && isMountedRef.current) {
202
195
  form.setInitialValues(data);
203
196
  }
204
- _context.next = 20;
197
+ _context.next = 22;
205
198
  break;
206
- case 19:
199
+ case 21:
207
200
  console.warn('编辑模式但未提供get API或自定义初始化函数');
208
- case 20:
209
- _context.next = 27;
210
- break;
211
201
  case 22:
212
- _context.prev = 22;
213
- _context.t0 = _context["catch"](6);
202
+ _context.next = 29;
203
+ break;
204
+ case 24:
205
+ _context.prev = 24;
206
+ _context.t0 = _context["catch"](8);
214
207
  if (!controller.signal.aborted) {
215
- _context.next = 26;
208
+ _context.next = 28;
216
209
  break;
217
210
  }
218
211
  return _context.abrupt("return");
219
- case 26:
212
+ case 28:
220
213
  if (isMountedRef.current) {
221
214
  console.error('加载数据失败:', _context.t0);
222
215
  errorMessage = ((_error$response = _context.t0.response) === null || _error$response === void 0 || (_error$response = _error$response.data) === null || _error$response === void 0 || (_error$response = _error$response.error) === null || _error$response === void 0 ? void 0 : _error$response.message) || _context.t0.message || '加载数据失败';
223
216
  message.error(errorMessage);
224
217
  }
225
- case 27:
226
- _context.prev = 27;
218
+ case 29:
219
+ _context.prev = 29;
227
220
  // 只在组件仍挂载且请求未取消时更新状态
228
221
  if (!controller.signal.aborted && isMountedRef.current) {
229
- setLoading(false);
222
+ loadingRef.current = false;
223
+ form.setLoading(false);
230
224
  }
231
- return _context.finish(27);
232
- case 30:
225
+ return _context.finish(29);
226
+ case 32:
233
227
  case "end":
234
228
  return _context.stop();
235
229
  }
236
- }, _callee, null, [[6, 22, 27, 30]]);
230
+ }, _callee, null, [[8, 24, 29, 32]]);
237
231
  }));
238
232
  return function (_x) {
239
233
  return _ref.apply(this, arguments);
@@ -280,7 +274,13 @@ var StandardFormDialog = function StandardFormDialog(props) {
280
274
  return {
281
275
  effects: function effects() {
282
276
  onFormInit(initializeForm);
283
- onFormValidateFailed(handleValidationFailed);
277
+ onFormValidateFailed(function (form) {
278
+ confirmingRef.current = false;
279
+ handleValidationFailed(form);
280
+ });
281
+ onFormSubmitEnd(function () {
282
+ confirmingRef.current = false;
283
+ });
284
284
  }
285
285
  };
286
286
  }, [initializeForm, handleValidationFailed]);
@@ -288,7 +288,7 @@ var StandardFormDialog = function StandardFormDialog(props) {
288
288
  // 提交处理函数
289
289
  var handleSubmit = useCallback( /*#__PURE__*/function () {
290
290
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(payload, next) {
291
- var values, isEdit, _error$response2, errorMessage;
291
+ var values, isEdit, _values$id, _error$response2, errorMessage;
292
292
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
293
293
  while (1) switch (_context2.prev = _context2.next) {
294
294
  case 0:
@@ -298,79 +298,82 @@ var StandardFormDialog = function StandardFormDialog(props) {
298
298
  }
299
299
  return _context2.abrupt("return");
300
300
  case 2:
301
- setSubmitting(true);
302
- _context2.prev = 3;
301
+ _context2.prev = 2;
303
302
  values = payload.values;
304
- isEdit = !!values.id || !!entityId; // FormDialog已经在内部处理了验证,无需手动调用validate
303
+ isEdit = values.id != null || entityId != null; // FormDialog已经在内部处理了验证,无需手动调用validate
305
304
  // Formily的FormDialog.forConfirm会自动验证表单
306
305
  if (!customSubmitHandler) {
307
- _context2.next = 11;
306
+ _context2.next = 10;
308
307
  break;
309
308
  }
310
- _context2.next = 9;
309
+ _context2.next = 8;
311
310
  return customSubmitHandler(values, isEdit);
312
- case 9:
313
- _context2.next = 24;
311
+ case 8:
312
+ _context2.next = 23;
314
313
  break;
315
- case 11:
314
+ case 10:
316
315
  if (!isEdit) {
317
- _context2.next = 19;
316
+ _context2.next = 18;
318
317
  break;
319
318
  }
320
319
  if (apiConfig.update) {
321
- _context2.next = 14;
320
+ _context2.next = 13;
322
321
  break;
323
322
  }
324
323
  throw new Error('更新API未配置');
325
- case 14:
326
- _context2.next = 16;
324
+ case 13:
325
+ _context2.next = 15;
327
326
  return apiConfig.update({
328
- id: values.id || entityId
327
+ id: (_values$id = values.id) !== null && _values$id !== void 0 ? _values$id : entityId
329
328
  }, values);
330
- case 16:
329
+ case 15:
331
330
  // 只在组件仍挂载时显示消息
332
331
  if (isMountedRef.current) {
333
332
  message.success('更新成功');
334
333
  }
335
- _context2.next = 24;
334
+ _context2.next = 23;
336
335
  break;
337
- case 19:
336
+ case 18:
338
337
  if (apiConfig.create) {
339
- _context2.next = 21;
338
+ _context2.next = 20;
340
339
  break;
341
340
  }
342
341
  throw new Error('创建API未配置');
343
- case 21:
344
- _context2.next = 23;
342
+ case 20:
343
+ _context2.next = 22;
345
344
  return apiConfig.create(values);
346
- case 23:
345
+ case 22:
347
346
  // 只在组件仍挂载时显示消息
348
347
  if (isMountedRef.current) {
349
348
  message.success('创建成功');
350
349
  }
351
- case 24:
350
+ case 23:
352
351
  // 调用成功回调
353
352
  if (isMountedRef.current && onAfterSubmit) {
354
353
  onAfterSubmit();
355
354
  }
356
355
 
357
356
  // 关闭对话框
358
- if (isMountedRef.current) {
359
- // 标记 Portal 为已关闭
360
- portalManager.markAsClosed(portalId);
361
- next(payload);
357
+ if (!isMountedRef.current) {
358
+ _context2.next = 28;
359
+ break;
362
360
  }
363
- _context2.next = 34;
364
- break;
361
+ // 标记 Portal 为已关闭
362
+ portalManager.markAsClosed(portalId);
363
+ _context2.next = 28;
364
+ return next(payload);
365
365
  case 28:
366
- _context2.prev = 28;
367
- _context2.t0 = _context2["catch"](3);
366
+ _context2.next = 37;
367
+ break;
368
+ case 30:
369
+ _context2.prev = 30;
370
+ _context2.t0 = _context2["catch"](2);
368
371
  if (isMountedRef.current) {
369
- _context2.next = 32;
372
+ _context2.next = 34;
370
373
  break;
371
374
  }
372
375
  return _context2.abrupt("return");
373
- case 32:
376
+ case 34:
374
377
  console.error('提交失败:', _context2.t0);
375
378
  if (useUnifiedErrorHandling) {
376
379
  // 使用统一错误处理
@@ -381,24 +384,19 @@ var StandardFormDialog = function StandardFormDialog(props) {
381
384
  message.error('操作失败:' + (_context2.t0.message || '未知错误'));
382
385
  }
383
386
 
384
- // 不调用 next,阻止对话框关闭
385
- case 34:
386
- _context2.prev = 34;
387
- // 只在组件仍挂载时更新状态
388
- if (isMountedRef.current) {
389
- setSubmitting(false);
390
- }
391
- return _context2.finish(34);
387
+ // 拒绝中间件链,让 Formily 结束提交状态并保留弹窗供重试。
388
+ // @author nokecy
389
+ throw _context2.t0;
392
390
  case 37:
393
391
  case "end":
394
392
  return _context2.stop();
395
393
  }
396
- }, _callee2, null, [[3, 28, 34, 37]]);
394
+ }, _callee2, null, [[2, 30]]);
397
395
  }));
398
396
  return function (_x2, _x3) {
399
397
  return _ref2.apply(this, arguments);
400
398
  };
401
- }(), [entityId, customSubmitHandler, apiConfig, onAfterSubmit, useUnifiedErrorHandling]);
399
+ }(), [entityId, customSubmitHandler, apiConfig, onAfterSubmit, useUnifiedErrorHandling, portalId]);
402
400
 
403
401
  // 点击处理函数
404
402
  var handleClick = useCallback(function () {
@@ -407,42 +405,42 @@ var StandardFormDialog = function StandardFormDialog(props) {
407
405
  var formDialog = FormDialog({
408
406
  title: title,
409
407
  width: width,
410
- okButtonProps: {
411
- loading: submitting,
412
- disabled: loading || submitting
408
+ // 不设置静态 loading,使用 FormDialog 自带的 form.submitting。
409
+ // @author nokecy
410
+ maskClosable: false,
411
+ onOk: function onOk() {
412
+ if (confirmingRef.current || loadingRef.current) return false;
413
+ confirmingRef.current = true;
413
414
  },
414
- cancelButtonProps: {
415
- disabled: submitting
415
+ onCancel: function onCancel() {
416
+ return !confirmingRef.current && !loadingRef.current;
416
417
  },
417
- closable: !submitting,
418
- maskClosable: !submitting
419
- }, portalId, function () {
420
- return /*#__PURE__*/React.createElement("div", {
421
- style: {
422
- minHeight: 200,
423
- position: 'relative'
424
- }
425
- }, loading && /*#__PURE__*/React.createElement("div", {
426
- style: {
427
- position: 'absolute',
428
- top: 0,
429
- left: 0,
430
- right: 0,
431
- bottom: 0,
432
- background: 'rgba(255, 255, 255, 0.8)',
433
- display: 'flex',
434
- alignItems: 'center',
435
- justifyContent: 'center',
436
- zIndex: 1000
437
- }
438
- }, /*#__PURE__*/React.createElement(Spin, {
439
- tip: "\u52A0\u8F7D\u6570\u636E\u4E2D..."
440
- })), /*#__PURE__*/React.createElement(FormLayout, schema.form, /*#__PURE__*/React.createElement(SchemaField, {
441
- schema: schema.schema
442
- })));
418
+ footer: function footer(_, _ref3) {
419
+ var OkBtn = _ref3.OkBtn,
420
+ CancelBtn = _ref3.CancelBtn;
421
+ return /*#__PURE__*/React.createElement(Observer, null, function () {
422
+ var _formRef$current, _formRef$current2, _formRef$current3;
423
+ return /*#__PURE__*/React.createElement(ConfigProvider, {
424
+ componentDisabled: ((_formRef$current = formRef.current) === null || _formRef$current === void 0 ? void 0 : _formRef$current.loading) || ((_formRef$current2 = formRef.current) === null || _formRef$current2 === void 0 ? void 0 : _formRef$current2.validating) || ((_formRef$current3 = formRef.current) === null || _formRef$current3 === void 0 ? void 0 : _formRef$current3.submitting)
425
+ }, /*#__PURE__*/React.createElement(CancelBtn, null), /*#__PURE__*/React.createElement(OkBtn, null));
426
+ });
427
+ }
428
+ }, portalId, function (form) {
429
+ return /*#__PURE__*/React.createElement(Observer, null, function () {
430
+ return /*#__PURE__*/React.createElement(Spin, {
431
+ spinning: form.loading,
432
+ tip: "\u52A0\u8F7D\u6570\u636E\u4E2D..."
433
+ }, /*#__PURE__*/React.createElement("div", {
434
+ style: {
435
+ minHeight: 200
436
+ }
437
+ }, /*#__PURE__*/React.createElement(FormLayout, schema.form, /*#__PURE__*/React.createElement(SchemaField, {
438
+ schema: schema.schema
439
+ }))));
440
+ });
443
441
  });
444
442
  formDialog.forConfirm(handleSubmit).open(formProps);
445
- }, [title, width, portalId, schema, formProps, handleSubmit, loading, submitting]);
443
+ }, [title, width, portalId, schema, SchemaField, formProps, handleSubmit]);
446
444
  return /*#__PURE__*/React.createElement(FormDialog.Portal, {
447
445
  id: portalId
448
446
  }, /*#__PURE__*/React.createElement(Button, _extends({