@nokecy/qc-ui 1.1.75 → 1.1.78

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/dist/cjs/exportButton/exportAction.d.ts +74 -0
  2. package/dist/cjs/exportButton/exportAction.js +199 -0
  3. package/dist/cjs/exportButton/index.d.ts +39 -0
  4. package/dist/cjs/exportButton/index.js +295 -0
  5. package/dist/cjs/importModal/index.d.ts +9 -0
  6. package/dist/cjs/importModal/index.js +46 -8
  7. package/dist/cjs/index.d.ts +4 -0
  8. package/dist/cjs/index.js +66 -0
  9. package/dist/cjs/standardList/StandardAgGridPlus.d.ts +58 -0
  10. package/dist/cjs/standardList/StandardAgGridPlus.js +698 -0
  11. package/dist/cjs/standardList/dateFormat.d.ts +16 -0
  12. package/dist/cjs/standardList/dateFormat.js +56 -0
  13. package/dist/cjs/standardList/emptyState.d.ts +36 -0
  14. package/dist/cjs/standardList/emptyState.js +89 -0
  15. package/dist/cjs/standardList/enumColumns.d.ts +31 -0
  16. package/dist/cjs/standardList/enumColumns.js +87 -0
  17. package/dist/cjs/standardList/gridColumnDefs.d.ts +33 -0
  18. package/dist/cjs/standardList/gridColumnDefs.js +61 -0
  19. package/dist/cjs/standardList/groupedHeaders.d.ts +28 -0
  20. package/dist/cjs/standardList/groupedHeaders.js +84 -0
  21. package/dist/cjs/standardList/groupedHeaders.less +29 -0
  22. package/dist/cjs/standardList/index.d.ts +20 -0
  23. package/dist/cjs/standardList/index.js +176 -0
  24. package/dist/cjs/standardList/listDateDisplay.d.ts +9 -0
  25. package/dist/cjs/standardList/listDateDisplay.js +64 -0
  26. package/dist/cjs/standardList/listDefaultSort.d.ts +38 -0
  27. package/dist/cjs/standardList/listDefaultSort.js +139 -0
  28. package/dist/cjs/standardList/listRefresh.d.ts +25 -0
  29. package/dist/cjs/standardList/listRefresh.js +53 -0
  30. package/dist/cjs/utils/download.d.ts +6 -0
  31. package/dist/cjs/utils/download.js +23 -0
  32. package/dist/esm/exportButton/exportAction.d.ts +74 -0
  33. package/dist/esm/exportButton/exportAction.js +193 -0
  34. package/dist/esm/exportButton/index.d.ts +39 -0
  35. package/dist/esm/exportButton/index.js +259 -0
  36. package/dist/esm/importModal/index.d.ts +9 -0
  37. package/dist/esm/importModal/index.js +46 -8
  38. package/dist/esm/index.d.ts +4 -0
  39. package/dist/esm/index.js +3 -0
  40. package/dist/esm/standardList/StandardAgGridPlus.d.ts +58 -0
  41. package/dist/esm/standardList/StandardAgGridPlus.js +691 -0
  42. package/dist/esm/standardList/dateFormat.d.ts +16 -0
  43. package/dist/esm/standardList/dateFormat.js +50 -0
  44. package/dist/esm/standardList/emptyState.d.ts +36 -0
  45. package/dist/esm/standardList/emptyState.js +83 -0
  46. package/dist/esm/standardList/enumColumns.d.ts +31 -0
  47. package/dist/esm/standardList/enumColumns.js +82 -0
  48. package/dist/esm/standardList/gridColumnDefs.d.ts +33 -0
  49. package/dist/esm/standardList/gridColumnDefs.js +55 -0
  50. package/dist/esm/standardList/groupedHeaders.d.ts +28 -0
  51. package/dist/esm/standardList/groupedHeaders.js +78 -0
  52. package/dist/esm/standardList/groupedHeaders.less +29 -0
  53. package/dist/esm/standardList/index.d.ts +20 -0
  54. package/dist/esm/standardList/index.js +15 -0
  55. package/dist/esm/standardList/listDateDisplay.d.ts +9 -0
  56. package/dist/esm/standardList/listDateDisplay.js +58 -0
  57. package/dist/esm/standardList/listDefaultSort.d.ts +38 -0
  58. package/dist/esm/standardList/listDefaultSort.js +133 -0
  59. package/dist/esm/standardList/listRefresh.d.ts +25 -0
  60. package/dist/esm/standardList/listRefresh.js +47 -0
  61. package/dist/esm/utils/download.d.ts +6 -0
  62. package/dist/esm/utils/download.js +17 -0
  63. package/dist/umd/qc-ui.min.css +1 -1
  64. package/dist/umd/qc-ui.min.js +1 -1
  65. package/package.json +1 -1
@@ -40,7 +40,10 @@ var ImportModal = function ImportModal(props) {
40
40
  _props$downloadBlob = props.downloadBlob,
41
41
  downloadBlob = _props$downloadBlob === void 0 ? defaultDownloadBlob : _props$downloadBlob,
42
42
  serverUrl = props.serverUrl,
43
- buttonProps = props.buttonProps;
43
+ buttonProps = props.buttonProps,
44
+ request = props.request,
45
+ method = props.method,
46
+ onRealSuccess = props.onRealSuccess;
44
47
  var _useBoolean = (0, _ahooks.useBoolean)(false),
45
48
  _useBoolean2 = _slicedToArray(_useBoolean, 2),
46
49
  visible = _useBoolean2[0],
@@ -70,12 +73,46 @@ var ImportModal = function ImportModal(props) {
70
73
  }
71
74
  }, "\u6A21\u7248")),
72
75
  type: "info"
73
- }), /*#__PURE__*/_react.default.createElement(_antd.Upload.Dragger, {
76
+ }), /*#__PURE__*/_react.default.createElement(_antd.Upload.Dragger, _extends({
74
77
  style: {
75
78
  marginTop: 10
76
79
  },
77
80
  multiple: false,
78
- action: getUploadUrl(),
81
+ action: getUploadUrl()
82
+ }, request ? {
83
+ customRequest: function customRequest(_ref) {
84
+ var action = _ref.action,
85
+ file = _ref.file,
86
+ headers = _ref.headers,
87
+ onError = _ref.onError,
88
+ onProgress = _ref.onProgress,
89
+ onSuccess = _ref.onSuccess;
90
+ var formData = new FormData();
91
+ formData.append('file', file);
92
+ request(action, {
93
+ method: method || 'POST',
94
+ data: formData,
95
+ headers: headers,
96
+ // 导入失败要展示行级原因,交给下面的弹窗统一报,不再走全局吐司。
97
+ skipErrorHandler: true,
98
+ onUploadProgress: function onUploadProgress(_ref2) {
99
+ var total = _ref2.total,
100
+ loaded = _ref2.loaded;
101
+ onProgress === null || onProgress === void 0 || onProgress({
102
+ percent: Number((loaded / total * 100).toFixed(2))
103
+ }, file);
104
+ }
105
+ }).then(function (response) {
106
+ onSuccess === null || onSuccess === void 0 || onSuccess(response, file);
107
+ onRealSuccess === null || onRealSuccess === void 0 || onRealSuccess(response);
108
+ })
109
+ // 第二个参数成为 info.file.response,onChange 靠它拿到后端的失败原因,而不是 axios 的英文文案。
110
+ .catch(function (err) {
111
+ var _err$response;
112
+ return onError === null || onError === void 0 ? void 0 : onError(err, err === null || err === void 0 || (_err$response = err.response) === null || _err$response === void 0 ? void 0 : _err$response.data);
113
+ });
114
+ }
115
+ } : {}, {
79
116
  onChange: function onChange(info) {
80
117
  if (info.file.status === 'done') {
81
118
  _antd.message.success('导入成功');
@@ -84,15 +121,16 @@ var ImportModal = function ImportModal(props) {
84
121
  }
85
122
  if (info.file.status === 'error') {
86
123
  var _info$file;
87
- _antd.Modal.info({
88
- title: '导入失败,原因如下:',
124
+ // 没有后端给的原因时也要有提示,不能让失败无声无息。
125
+ _antd.Modal.error({
126
+ title: '导入失败',
89
127
  closable: true,
90
- width: 1000,
91
- content: info === null || info === void 0 || (_info$file = info.file) === null || _info$file === void 0 || (_info$file = _info$file.response) === null || _info$file === void 0 || (_info$file = _info$file.error) === null || _info$file === void 0 ? void 0 : _info$file.message
128
+ width: 800,
129
+ content: (info === null || info === void 0 || (_info$file = info.file) === null || _info$file === void 0 || (_info$file = _info$file.response) === null || _info$file === void 0 || (_info$file = _info$file.error) === null || _info$file === void 0 ? void 0 : _info$file.message) || '文件未能导入。请核对模板格式与必填列后重试;若持续失败请联系技术支持。'
92
130
  });
93
131
  }
94
132
  }
95
- }, /*#__PURE__*/_react.default.createElement("p", {
133
+ }), /*#__PURE__*/_react.default.createElement("p", {
96
134
  className: "ant-upload-drag-icon"
97
135
  }, /*#__PURE__*/_react.default.createElement(_icons.InboxOutlined, null)), /*#__PURE__*/_react.default.createElement("p", {
98
136
  className: "ant-upload-text"
@@ -32,7 +32,11 @@ export type { ColumnConfig } from "./array-table/columnHelper";
32
32
  export type { CentralizedColumnScheme, QueryScheme, SchemeStorageAdapter, SchemeSyncDataDto, CurrentSchemeDto, SchemeStorageConfig, LocalStorageAdapterConfig, BackendApiAdapterConfig, UseSchemeManagerConfig, GridPlusContextValue, GlobalConfigPermissions, } from "./ag-grid-plus";
33
33
  export * from './adapters';
34
34
  export * from "./readPretty";
35
+ export * from "./standardList";
35
36
  export { createEntitySelect } from "./entitySelect";
37
+ export { default as ExportButton, buildExportUrl, DEFAULT_EXPORT_TEMPLATE_API, resolveExportAction, resolveExportError, resolveFileName } from "./exportButton";
38
+ export type { ExportButtonProps, ExportTemplateApi, ExportTemplateOption } from "./exportButton";
39
+ export { saveAs } from "./utils/download";
36
40
  export type { EntitySelectConfig, EntitySelectProps, EntitySelectQuery } from "./entitySelect";
37
41
  export { semanticTextColors, toGridTextColor, gridValueEnum } from "./ag-grid-plus/utils/valueEnumColor";
38
42
  export type { SemanticPreset } from "./ag-grid-plus/utils/valueEnumColor";
package/dist/cjs/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
 
3
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
@@ -48,6 +49,13 @@ var _exportNames = {
48
49
  MatchItem: true,
49
50
  RegexRailroadDiagram: true,
50
51
  createEntitySelect: true,
52
+ ExportButton: true,
53
+ buildExportUrl: true,
54
+ DEFAULT_EXPORT_TEMPLATE_API: true,
55
+ resolveExportAction: true,
56
+ resolveExportError: true,
57
+ resolveFileName: true,
58
+ saveAs: true,
51
59
  semanticTextColors: true,
52
60
  toGridTextColor: true,
53
61
  gridValueEnum: true,
@@ -120,6 +128,12 @@ Object.defineProperty(exports, "ConfirmPro", {
120
128
  return _ConfirmPro.default;
121
129
  }
122
130
  });
131
+ Object.defineProperty(exports, "DEFAULT_EXPORT_TEMPLATE_API", {
132
+ enumerable: true,
133
+ get: function get() {
134
+ return _exportButton.DEFAULT_EXPORT_TEMPLATE_API;
135
+ }
136
+ });
123
137
  Object.defineProperty(exports, "Dashboard", {
124
138
  enumerable: true,
125
139
  get: function get() {
@@ -150,6 +164,12 @@ Object.defineProperty(exports, "Editable", {
150
164
  return _editable.default;
151
165
  }
152
166
  });
167
+ Object.defineProperty(exports, "ExportButton", {
168
+ enumerable: true,
169
+ get: function get() {
170
+ return _exportButton.default;
171
+ }
172
+ });
153
173
  Object.defineProperty(exports, "ExtensibleGrid", {
154
174
  enumerable: true,
155
175
  get: function get() {
@@ -276,6 +296,12 @@ Object.defineProperty(exports, "ToolBar", {
276
296
  return _toolBar.default;
277
297
  }
278
298
  });
299
+ Object.defineProperty(exports, "buildExportUrl", {
300
+ enumerable: true,
301
+ get: function get() {
302
+ return _exportButton.buildExportUrl;
303
+ }
304
+ });
279
305
  Object.defineProperty(exports, "contrastRatio", {
280
306
  enumerable: true,
281
307
  get: function get() {
@@ -360,12 +386,36 @@ Object.defineProperty(exports, "relativeLuminance", {
360
386
  return _contrast.relativeLuminance;
361
387
  }
362
388
  });
389
+ Object.defineProperty(exports, "resolveExportAction", {
390
+ enumerable: true,
391
+ get: function get() {
392
+ return _exportButton.resolveExportAction;
393
+ }
394
+ });
395
+ Object.defineProperty(exports, "resolveExportError", {
396
+ enumerable: true,
397
+ get: function get() {
398
+ return _exportButton.resolveExportError;
399
+ }
400
+ });
401
+ Object.defineProperty(exports, "resolveFileName", {
402
+ enumerable: true,
403
+ get: function get() {
404
+ return _exportButton.resolveFileName;
405
+ }
406
+ });
363
407
  Object.defineProperty(exports, "roundDecimal", {
364
408
  enumerable: true,
365
409
  get: function get() {
366
410
  return _businessDecimal.roundDecimal;
367
411
  }
368
412
  });
413
+ Object.defineProperty(exports, "saveAs", {
414
+ enumerable: true,
415
+ get: function get() {
416
+ return _download.saveAs;
417
+ }
418
+ });
369
419
  Object.defineProperty(exports, "semanticTextColors", {
370
420
  enumerable: true,
371
421
  get: function get() {
@@ -479,8 +529,24 @@ Object.keys(_readPretty).forEach(function (key) {
479
529
  }
480
530
  });
481
531
  });
532
+ var _standardList = require("./standardList");
533
+ Object.keys(_standardList).forEach(function (key) {
534
+ if (key === "default" || key === "__esModule") return;
535
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
536
+ if (key in exports && exports[key] === _standardList[key]) return;
537
+ Object.defineProperty(exports, key, {
538
+ enumerable: true,
539
+ get: function get() {
540
+ return _standardList[key];
541
+ }
542
+ });
543
+ });
482
544
  var _entitySelect = require("./entitySelect");
545
+ var _exportButton = _interopRequireWildcard(require("./exportButton"));
546
+ var _download = require("./utils/download");
483
547
  var _valueEnumColor = require("./ag-grid-plus/utils/valueEnumColor");
484
548
  var _contrast = require("./utils/contrast");
485
549
  var _businessDecimal = require("./utils/businessDecimal");
550
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
551
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
486
552
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -0,0 +1,58 @@
1
+ import React from 'react';
2
+ import type { AgGridColumnPropsClone, GridRef } from '../ag-grid-plus/interface';
3
+ import { type EnumFallbackRenderer } from './enumColumns';
4
+ import './groupedHeaders.less';
5
+ import { type ListSortPolicy } from './listDefaultSort';
6
+ /**
7
+ * 标准列表的宿主口径。
8
+ * - `enumFallbackRenderer`:枚举列未命中时的显示(如「未知(原码)」);不传则显示原码。
9
+ * - `sortPolicy`:默认排序识别的状态字段与记录时间字段。
10
+ */
11
+ export interface StandardListPolicy {
12
+ enumFallbackRenderer?: EnumFallbackRenderer;
13
+ sortPolicy?: ListSortPolicy;
14
+ }
15
+ /**
16
+ * 标准列表列定义:在表格列定义上补 businessKey。
17
+ * businessKey 为 true 表示该列是业务单号(如 mrpID、mpsID),不按「ID 结尾」当内部键隐藏。
18
+ * @author nokecy
19
+ */
20
+ export type AppGridColumn = AgGridColumnPropsClone & {
21
+ businessKey?: boolean;
22
+ };
23
+ /**
24
+ * 标准列表基座:在 AgGridPlus 外面包一层公司列表规范(序号、内部字段隐藏、日期显示、分组表头、空态四分支、
25
+ * 默认排序、枚举回退等)。宿主的页面一律经宿主自己的薄封装导入它,这里加一次,等于所有列表页都有了。
26
+ * 与路由相关的刷新令牌和宿主口径(未知值文案、排序字段)由宿主通过属性传入。
27
+ *
28
+ * 这层目前做三件事:
29
+ *
30
+ * 1. **从表单页保存返回时,把列表刷新一遍**。
31
+ * 起因是 `pubGoBack()` 只 push 回父路径再关掉表单页标签,而列表页在 KeepAlive 缓存里,
32
+ * push 回去是直接复原缓存的那棵树,不会重新请求——用户刚保存的记录不在列表里,
33
+ * 于是以为没存上,再存一遍。全仓 196 处返回都是这个行为。
34
+ * 为什么不直接 `dropByCacheKey(列表路径)` 把缓存丢掉:那样确实会重新加载,
35
+ * 但连筛选条件、滚动位置、分页和列宽一起丢了。用户进表单前设的筛选,回来就没了。
36
+ * 走 URL 上的 refresh 标记只重新取数,页面状态原样保留。
37
+ *
38
+ * 2. **空态四分支(U2)**:无数据 / 筛选无结果 / 无权限(403) / 加载失败。
39
+ * qc-ui 只支持一句空数据文字(overlayNoRowsTemplateText),分不出四种情况。
40
+ * 这里用 AG-Grid 原生的 `noRowsOverlayComponent`(优先级高于 overlayNoRowsTemplate)
41
+ * 挂 `GridEmptyState`,请求成败与是否带筛选经 context 传给 overlay 组件。
42
+ * 业务页可通过 `emptyActions` 注入「无数据」分支的操作(通常是 Access 包裹的新建按钮),
43
+ * 或用自己的 `noRowsOverlayComponent` 整体覆盖。
44
+ *
45
+ * 3. **valueEnum 文字对比度**:qc-ui 把 `valueEnum.color` 当 CSS 文字色,缺 color 时写成
46
+ * `#ffffff`(销售跟踪「类型」列「普通订单」白底白字就是这条)。封装层给 columnDefs
47
+ * 和 AgGridColumn 统一套 `gridValueEnum()`:缺色用 inherit,浅色 / 预设名收成白底 ≥4.5:1。
48
+ *
49
+ * 4. **列定义上的 live `sort`**:AG Grid 把 `ColDef.sort` 当受控属性,每次 columnDefs 引用变化
50
+ * 都会强制写回。送货单点「送货日期」降序后再点单元格,选中态 setState 重建列定义,
51
+ * 默认「单号升序」被重新套上,排序就自己变了。封装层把 `sort` 收成只用于建列的 `initialSort`。
52
+ *
53
+ * @author nokecy
54
+ */
55
+ declare const StandardAgGridColumn: React.FC<any>;
56
+ declare const StandardAgGridPlus: React.FC<any>;
57
+ export { StandardAgGridColumn, StandardAgGridPlus };
58
+ export type { GridRef };