@nokecy/qc-ui 1.1.68 → 1.1.70

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 (32) hide show
  1. package/dist/cjs/ag-grid-plus/ag-gridPlus.js +1 -16
  2. package/dist/cjs/ag-grid-plus/setting/ColumnConfigForm.js +3 -1
  3. package/dist/cjs/ag-grid-plus/setting/ColumnConfigTable.js +7 -3
  4. package/dist/cjs/ag-grid-plus/setting/ColumnNameCellRenderer.js +9 -6
  5. package/dist/cjs/ag-grid-plus/setting/ColumnSetting.js +4 -2
  6. package/dist/cjs/ag-grid-plus/setting/MoveNodeModal.js +3 -1
  7. package/dist/cjs/ag-grid-plus/setting/NameColumnRenderer.js +6 -4
  8. package/dist/cjs/ag-grid-plus/setting/QuerySchemeManager.js +10 -8
  9. package/dist/cjs/ag-grid-plus/utils/columnProcessors.js +6 -3
  10. package/dist/cjs/array-table/readOnlyFormatters.d.ts +8 -0
  11. package/dist/cjs/array-table/readOnlyFormatters.js +23 -1
  12. package/dist/cjs/array-table/utils.js +49 -12
  13. package/dist/cjs/generatedListPage/_utils/defaultHandlers.d.ts +1 -1
  14. package/dist/cjs/generatedListPage/_utils/defaultHandlers.js +130 -42
  15. package/dist/cjs/generatedListPage/types.d.ts +2 -2
  16. package/dist/esm/ag-grid-plus/ag-gridPlus.js +3 -18
  17. package/dist/esm/ag-grid-plus/setting/ColumnConfigForm.js +4 -2
  18. package/dist/esm/ag-grid-plus/setting/ColumnConfigTable.js +8 -4
  19. package/dist/esm/ag-grid-plus/setting/ColumnNameCellRenderer.js +10 -7
  20. package/dist/esm/ag-grid-plus/setting/ColumnSetting.js +5 -3
  21. package/dist/esm/ag-grid-plus/setting/MoveNodeModal.js +4 -2
  22. package/dist/esm/ag-grid-plus/setting/NameColumnRenderer.js +7 -5
  23. package/dist/esm/ag-grid-plus/setting/QuerySchemeManager.js +11 -9
  24. package/dist/esm/ag-grid-plus/utils/columnProcessors.js +6 -3
  25. package/dist/esm/array-table/readOnlyFormatters.d.ts +8 -0
  26. package/dist/esm/array-table/readOnlyFormatters.js +22 -0
  27. package/dist/esm/array-table/utils.js +50 -13
  28. package/dist/esm/generatedListPage/_utils/defaultHandlers.d.ts +1 -1
  29. package/dist/esm/generatedListPage/_utils/defaultHandlers.js +130 -42
  30. package/dist/esm/generatedListPage/types.d.ts +2 -2
  31. package/dist/umd/qc-ui.min.js +1 -1
  32. package/package.json +1 -1
@@ -207,6 +207,8 @@ export function processEllipsisColumn(col) {
207
207
  return col;
208
208
  }
209
209
  return _objectSpread(_objectSpread({}, col), {}, {
210
+ // 块级占满单元格,对齐继承单元格的 text-align(列方案的左/中/右对齐、数字列右对齐);
211
+ // 以前写死 flex 居中,列方案选左对齐也居中,且 flex 容器里省略号不截断。@author nokecy
210
212
  cellRenderer: function cellRenderer(_ref) {
211
213
  var value = _ref.value;
212
214
  return /*#__PURE__*/React.createElement(Text, {
@@ -214,9 +216,10 @@ export function processEllipsisColumn(col) {
214
216
  tooltip: value
215
217
  },
216
218
  style: {
217
- display: 'flex',
218
- justifyContent: 'center',
219
- alignItems: 'center'
219
+ display: 'block',
220
+ width: '100%',
221
+ color: 'inherit',
222
+ lineHeight: 'inherit'
220
223
  }
221
224
  }, value);
222
225
  }
@@ -5,6 +5,14 @@ export type ReadOnlyFormatterCtx = {
5
5
  fieldSchema: any;
6
6
  };
7
7
  export type ReadOnlyFormatter = (value: any, ctx: ReadOnlyFormatterCtx) => string;
8
+ /**
9
+ * 兜底格式化器:注册表里没有的组件(业务自定义的选择器、输入框等),可编辑列按它出懒挂载文本。
10
+ *
11
+ * 显示与控件失焦时看到的一致:原始值原样显示;labelInValue 对象 / 解构字段({value,label})显示 label,
12
+ * 没有 label 才显示 value;数组逐个显示后逗号拼接。显示需要按编码查名称等特殊逻辑的组件,
13
+ * 消费方用 registerReadOnlyFormatter 注册专用格式化器覆盖。@author nokecy
14
+ */
15
+ export declare const fallbackFormatter: ReadOnlyFormatter;
8
16
  /** 消费方扩展自定义只读列的显示逻辑 */
9
17
  export declare const registerReadOnlyFormatter: (component: string, formatter: ReadOnlyFormatter) => void;
10
18
  /**
@@ -94,6 +94,28 @@ var registry = {
94
94
  Checkbox: booleanFormatter
95
95
  };
96
96
 
97
+ /**
98
+ * 兜底格式化器:注册表里没有的组件(业务自定义的选择器、输入框等),可编辑列按它出懒挂载文本。
99
+ *
100
+ * 显示与控件失焦时看到的一致:原始值原样显示;labelInValue 对象 / 解构字段({value,label})显示 label,
101
+ * 没有 label 才显示 value;数组逐个显示后逗号拼接。显示需要按编码查名称等特殊逻辑的组件,
102
+ * 消费方用 registerReadOnlyFormatter 注册专用格式化器覆盖。@author nokecy
103
+ */
104
+ export var fallbackFormatter = function fallbackFormatter(value, ctx) {
105
+ if (value == null || value === '') return '';
106
+ if (Array.isArray(value)) return value.map(function (v) {
107
+ return fallbackFormatter(v, ctx);
108
+ }).filter(Boolean).join(', ');
109
+ if (typeof value === 'boolean') return booleanFormatter(value, ctx);
110
+ if (_typeof(value) === 'object') {
111
+ var _value$label2;
112
+ if (typeof value.format === 'function') return dateFormatter(value, ctx);
113
+ var shown = (_value$label2 = value.label) !== null && _value$label2 !== void 0 ? _value$label2 : value.value;
114
+ return shown == null ? '' : String(shown);
115
+ }
116
+ return String(value);
117
+ };
118
+
97
119
  /** 消费方扩展自定义只读列的显示逻辑 */
98
120
  export var registerReadOnlyFormatter = function registerReadOnlyFormatter(component, formatter) {
99
121
  registry[component] = formatter;
@@ -9,20 +9,20 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
9
9
  function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
10
10
  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); } }
11
11
  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); }); }; }
12
+ 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); }
12
13
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
13
14
  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."); }
14
15
  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); }
15
16
  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; }
16
17
  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; } }
17
18
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
18
- 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); }
19
19
  import React, { useReducer, useRef } from 'react';
20
20
  import { theme } from 'antd';
21
21
  import { useField, useFieldSchema, RecursionField, Observer, useExpressionScope } from '@formily/react';
22
22
  import { isArr, lazyMerge } from '@formily/shared';
23
23
  import { Schema } from '@formily/json-schema';
24
24
  import ArrayBase from "./arrayBase";
25
- import { getReadOnlyFormatter } from "./readOnlyFormatters";
25
+ import { fallbackFormatter, getReadOnlyFormatter } from "./readOnlyFormatters";
26
26
  import { markHeaderGroup } from "./columnGroup";
27
27
  import { CellFocusScope } from "./cellFocusScope";
28
28
  var isColumnComponent = function isColumnComponent(schema) {
@@ -159,6 +159,32 @@ var isSimpleFieldPath = function isSimpleFieldPath(name) {
159
159
  return !!name && /^[^.{}[\]*]+(\.[^.{}[\]*]+)*$/.test(name);
160
160
  };
161
161
 
162
+ /**
163
+ * 解析对象解构字段名 `{value:code,label:name}`(选择器 labelInValue 常用),返回 [对象键, 数据路径] 列表;
164
+ * 不是对象解构、或成员路径不是简单点号路径时返回 null(调用方回退 AgField 全树)。
165
+ * 成员可简写成 `{code}`,等同 `{code:code}`。@author nokecy
166
+ */
167
+ var parseObjectDestructure = function parseObjectDestructure(name) {
168
+ var matched = name && /^\{([^{}]+)\}$/.exec(name.trim());
169
+ if (!matched) return null;
170
+ var members = matched[1].split(',').map(function (part) {
171
+ return part.split(':').map(function (x) {
172
+ return x.trim();
173
+ });
174
+ });
175
+ if (members.some(function (m) {
176
+ return m.length > 2 || !m[0] || !isSimpleFieldPath(m[m.length - 1]);
177
+ })) return null;
178
+ return members.map(function (m) {
179
+ return [m[0], m[m.length - 1]];
180
+ });
181
+ };
182
+
183
+ /** 快路径(只读文本/懒挂载)能自己解析取值的字段名:简单点号路径或对象解构 @author nokecy */
184
+ var isFastPathFieldName = function isFastPathFieldName(name) {
185
+ return isSimpleFieldPath(name) || !!parseObjectDestructure(name);
186
+ };
187
+
162
188
  /**
163
189
  * 按 Formily 字段名从行数据取值。
164
190
  *
@@ -169,6 +195,14 @@ var isSimpleFieldPath = function isSimpleFieldPath(name) {
169
195
  */
170
196
  var readByFieldPath = function readByFieldPath(record, path) {
171
197
  if (record == null) return undefined;
198
+ // 对象解构:与 Formily 一致,按成员路径分别取值拼回 {value, label} 对象 @author nokecy
199
+ var destructure = path.startsWith('{') ? parseObjectDestructure(path) : null;
200
+ if (destructure) return Object.fromEntries(destructure.map(function (_ref3) {
201
+ var _ref4 = _slicedToArray(_ref3, 2),
202
+ key = _ref4[0],
203
+ memberPath = _ref4[1];
204
+ return [key, readByFieldPath(record, memberPath)];
205
+ }));
172
206
  if (path.indexOf('.') < 0) return record[path];
173
207
  return path.split('.').reduce(function (acc, key) {
174
208
  return acc == null ? undefined : acc[key];
@@ -328,7 +362,7 @@ var LazyAgField = function LazyAgField(params) {
328
362
 
329
363
  /** 焦点离开本格:校验通过才卸回懒挂载文本。isStale 为真说明校验期间焦点又回来了或格子已销毁 */
330
364
  var handleLeave = /*#__PURE__*/function () {
331
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(isStale) {
365
+ var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(isStale) {
332
366
  var _field$value$indexOf3, _field$value3, _field$value3$indexOf, _field$form;
333
367
  var index, cellField;
334
368
  return _regeneratorRuntime().wrap(function _callee$(_context) {
@@ -372,7 +406,7 @@ var LazyAgField = function LazyAgField(params) {
372
406
  }, _callee, null, [[3, 8]]);
373
407
  }));
374
408
  return function handleLeave(_x) {
375
- return _ref3.apply(this, arguments);
409
+ return _ref5.apply(this, arguments);
376
410
  };
377
411
  }();
378
412
 
@@ -542,11 +576,12 @@ var applyNumberInputDefaults = function applyNumberInputDefaults(dataField) {
542
576
  // 重命名自 useArrayTableColumns:内部无任何 Hook 调用,use 前缀违反 Hook 命名约定且曾在 useMemo 内被调用 @author nokecy
543
577
  var buildArrayTableColumns = function buildArrayTableColumns(dataSource, field, sources) {
544
578
  var arrayPattern = field === null || field === void 0 ? void 0 : field.pattern;
545
- return sources.reduce(function (buf, _ref4, key) {
546
- var name = _ref4.name,
547
- columnProps = _ref4.columnProps,
548
- schema = _ref4.schema,
549
- display = _ref4.display;
579
+ return sources.reduce(function (buf, _ref6, key) {
580
+ var _getReadOnlyFormatter;
581
+ var name = _ref6.name,
582
+ columnProps = _ref6.columnProps,
583
+ schema = _ref6.schema,
584
+ display = _ref6.display;
550
585
  if (display && display !== 'visible') return buf;
551
586
  if (!isColumnComponent(schema)) return buf;
552
587
 
@@ -585,8 +620,10 @@ var buildArrayTableColumns = function buildArrayTableColumns(dataSource, field,
585
620
  // ③ 兜底全树:其余(无格式化器/带 reactions/forceAgField/复杂字段名/只读但无格式化器) -> AgField。
586
621
  var dataField = findDataFieldSchema(schema, name);
587
622
  var component = dataField === null || dataField === void 0 ? void 0 : dataField['x-component'];
588
- var formatter = getReadOnlyFormatter(component);
589
623
  var readOnly = isColumnReadOnlyEligible(arrayPattern, dataField, columnProps);
624
+ // 可编辑的数据字段(非 void 操作按钮)即使是业务自定义组件,也按兜底格式化器出懒挂载文本,默认阅读态;
625
+ // 只读列不兜底:自定义只读组件常显示别的字段(如 SiblingText),按自身值出文本会错。@author nokecy
626
+ var formatter = (_getReadOnlyFormatter = getReadOnlyFormatter(component)) !== null && _getReadOnlyFormatter !== void 0 ? _getReadOnlyFormatter : !readOnly && component && (dataField === null || dataField === void 0 ? void 0 : dataField.type) !== 'void' ? fallbackFormatter : null;
590
627
  var hasReactions = !!(dataField && dataField['x-reactions']);
591
628
  if (!readOnly) applyNumberInputDefaults(dataField);
592
629
  var forceEager = (columnProps === null || columnProps === void 0 ? void 0 : columnProps.forceAgField) === true;
@@ -603,9 +640,9 @@ var buildArrayTableColumns = function buildArrayTableColumns(dataSource, field,
603
640
  var valueGetter = dataFieldName && dataFieldName !== name ? function (params) {
604
641
  return readByFieldPath(params === null || params === void 0 ? void 0 : params.data, dataFieldName);
605
642
  } : undefined;
606
- // 字段名是路径:`item.qty` 的值在 record.item.qty。快路径自己解析,只认点号分段;
607
- // 解构(`{value:a,label:b}`)/数组下标等复杂语法解析不了,回退全树交给 Formily。@author nokecy
608
- var canFastPath = !dataFieldName || isSimpleFieldPath(dataFieldName);
643
+ // 字段名是路径:`item.qty` 的值在 record.item.qty。快路径自己解析点号分段与对象解构(`{value:a,label:b}`);
644
+ // 数组解构/下标等其余语法解析不了,回退全树交给 Formily。@author nokecy
645
+ var canFastPath = !dataFieldName || isFastPathFieldName(dataFieldName);
609
646
 
610
647
  // ① 只读纯文本
611
648
  if (readOnly && formatter && canFastPath) {
@@ -4,7 +4,7 @@
4
4
  * @param params 导出参数
5
5
  * @param fileName 文件名
6
6
  */
7
- export declare const defaultHandleExport: (exportApi: (params: any) => Promise<Blob>, params: any, fileName: string) => Promise<void>;
7
+ export declare const defaultHandleExport: (exportApi: (params: any, options?: Record<string, any>) => Promise<Blob>, params: any, fileName: string) => Promise<void>;
8
8
  /**
9
9
  * 默认的删除处理器
10
10
  * @param deleteApi 删除API函数
@@ -4,6 +4,68 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try
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 { message } from 'antd';
6
6
 
7
+ /**
8
+ * 按 blob 收的请求,后端的 JSON 错误体(无权限、业务校验等)也是 Blob,要读出来才能给出原因。@author nokecy
9
+ */
10
+ var readBlobErrorMessage = /*#__PURE__*/function () {
11
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(data) {
12
+ var _JSON$parse;
13
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
14
+ while (1) switch (_context.prev = _context.next) {
15
+ case 0:
16
+ if (data instanceof Blob) {
17
+ _context.next = 2;
18
+ break;
19
+ }
20
+ return _context.abrupt("return", undefined);
21
+ case 2:
22
+ _context.prev = 2;
23
+ _context.t2 = JSON;
24
+ _context.next = 6;
25
+ return data.text();
26
+ case 6:
27
+ _context.t3 = _context.sent;
28
+ _context.t4 = _JSON$parse = _context.t2.parse.call(_context.t2, _context.t3);
29
+ _context.t1 = _context.t4 === null;
30
+ if (_context.t1) {
31
+ _context.next = 11;
32
+ break;
33
+ }
34
+ _context.t1 = _JSON$parse === void 0;
35
+ case 11:
36
+ _context.t0 = _context.t1;
37
+ if (_context.t0) {
38
+ _context.next = 14;
39
+ break;
40
+ }
41
+ _context.t0 = (_JSON$parse = _JSON$parse.error) === null || _JSON$parse === void 0;
42
+ case 14:
43
+ if (!_context.t0) {
44
+ _context.next = 18;
45
+ break;
46
+ }
47
+ _context.t5 = void 0;
48
+ _context.next = 19;
49
+ break;
50
+ case 18:
51
+ _context.t5 = _JSON$parse.message;
52
+ case 19:
53
+ return _context.abrupt("return", _context.t5);
54
+ case 22:
55
+ _context.prev = 22;
56
+ _context.t6 = _context["catch"](2);
57
+ return _context.abrupt("return", undefined);
58
+ case 25:
59
+ case "end":
60
+ return _context.stop();
61
+ }
62
+ }, _callee, null, [[2, 22]]);
63
+ }));
64
+ return function readBlobErrorMessage(_x) {
65
+ return _ref.apply(this, arguments);
66
+ };
67
+ }();
68
+
7
69
  /**
8
70
  * 默认的导出处理器
9
71
  * @param exportApi 导出API函数
@@ -11,26 +73,28 @@ import { message } from 'antd';
11
73
  * @param fileName 文件名
12
74
  */
13
75
  export var defaultHandleExport = /*#__PURE__*/function () {
14
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(exportApi, params, fileName) {
15
- var hide, response, url, link, _error$response, errorMessage;
16
- return _regeneratorRuntime().wrap(function _callee$(_context) {
17
- while (1) switch (_context.prev = _context.next) {
76
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(exportApi, params, fileName) {
77
+ var hide, response, url, link, _error$response, _error$response2, errorMessage;
78
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
79
+ while (1) switch (_context2.prev = _context2.next) {
18
80
  case 0:
19
81
  hide = message.loading('正在导出,请稍后', 0);
20
- _context.prev = 1;
21
- _context.next = 4;
22
- return exportApi(params);
82
+ _context2.prev = 1;
83
+ _context2.next = 4;
84
+ return exportApi(params, {
85
+ responseType: 'blob'
86
+ });
23
87
  case 4:
24
- response = _context.sent;
88
+ response = _context2.sent;
25
89
  if (response instanceof Blob) {
26
- _context.next = 8;
90
+ _context2.next = 8;
27
91
  break;
28
92
  }
29
93
  console.error('导出API返回的不是Blob对象:', response);
30
94
  throw new Error('导出数据格式错误,请检查API配置');
31
95
  case 8:
32
96
  if (!(response.size === 0)) {
33
- _context.next = 10;
97
+ _context2.next = 10;
34
98
  break;
35
99
  }
36
100
  throw new Error('导出的文件为空');
@@ -47,27 +111,51 @@ export var defaultHandleExport = /*#__PURE__*/function () {
47
111
  document.body.removeChild(link);
48
112
  window.URL.revokeObjectURL(url);
49
113
  message.success('导出成功');
50
- _context.next = 27;
114
+ _context2.next = 38;
51
115
  break;
52
116
  case 21:
53
- _context.prev = 21;
54
- _context.t0 = _context["catch"](1);
55
- console.error('导出失败:', _context.t0);
56
- 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 || '导出失败';
117
+ _context2.prev = 21;
118
+ _context2.t0 = _context2["catch"](1);
119
+ console.error('导出失败:', _context2.t0);
120
+ _context2.next = 26;
121
+ return readBlobErrorMessage((_error$response = _context2.t0.response) === null || _error$response === void 0 ? void 0 : _error$response.data);
122
+ case 26:
123
+ _context2.t3 = _context2.sent;
124
+ if (_context2.t3) {
125
+ _context2.next = 29;
126
+ break;
127
+ }
128
+ _context2.t3 = (_error$response2 = _context2.t0.response) === null || _error$response2 === void 0 || (_error$response2 = _error$response2.data) === null || _error$response2 === void 0 || (_error$response2 = _error$response2.error) === null || _error$response2 === void 0 ? void 0 : _error$response2.message;
129
+ case 29:
130
+ _context2.t2 = _context2.t3;
131
+ if (_context2.t2) {
132
+ _context2.next = 32;
133
+ break;
134
+ }
135
+ _context2.t2 = _context2.t0.message;
136
+ case 32:
137
+ _context2.t1 = _context2.t2;
138
+ if (_context2.t1) {
139
+ _context2.next = 35;
140
+ break;
141
+ }
142
+ _context2.t1 = '导出失败';
143
+ case 35:
144
+ errorMessage = _context2.t1;
57
145
  message.error("\u5BFC\u51FA\u5931\u8D25\uFF1A".concat(errorMessage));
58
- throw _context.t0;
59
- case 27:
60
- _context.prev = 27;
146
+ throw _context2.t0;
147
+ case 38:
148
+ _context2.prev = 38;
61
149
  hide();
62
- return _context.finish(27);
63
- case 30:
150
+ return _context2.finish(38);
151
+ case 41:
64
152
  case "end":
65
- return _context.stop();
153
+ return _context2.stop();
66
154
  }
67
- }, _callee, null, [[1, 21, 27, 30]]);
155
+ }, _callee2, null, [[1, 21, 38, 41]]);
68
156
  }));
69
- return function defaultHandleExport(_x, _x2, _x3) {
70
- return _ref.apply(this, arguments);
157
+ return function defaultHandleExport(_x2, _x3, _x4) {
158
+ return _ref2.apply(this, arguments);
71
159
  };
72
160
  }();
73
161
 
@@ -78,14 +166,14 @@ export var defaultHandleExport = /*#__PURE__*/function () {
78
166
  * @param onSuccess 成功回调
79
167
  */
80
168
  export var defaultHandleDelete = /*#__PURE__*/function () {
81
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(deleteApi, id, onSuccess) {
82
- var hide, _error$response2, errorMessage;
83
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
84
- while (1) switch (_context2.prev = _context2.next) {
169
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(deleteApi, id, onSuccess) {
170
+ var hide, _error$response3, errorMessage;
171
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
172
+ while (1) switch (_context3.prev = _context3.next) {
85
173
  case 0:
86
174
  hide = message.loading('正在删除,请稍后', 0);
87
- _context2.prev = 1;
88
- _context2.next = 4;
175
+ _context3.prev = 1;
176
+ _context3.next = 4;
89
177
  return deleteApi({
90
178
  id: id
91
179
  });
@@ -94,27 +182,27 @@ export var defaultHandleDelete = /*#__PURE__*/function () {
94
182
  if (onSuccess) {
95
183
  onSuccess();
96
184
  }
97
- _context2.next = 14;
185
+ _context3.next = 14;
98
186
  break;
99
187
  case 8:
100
- _context2.prev = 8;
101
- _context2.t0 = _context2["catch"](1);
102
- console.error('删除失败:', _context2.t0);
103
- errorMessage = ((_error$response2 = _context2.t0.response) === null || _error$response2 === void 0 || (_error$response2 = _error$response2.data) === null || _error$response2 === void 0 || (_error$response2 = _error$response2.error) === null || _error$response2 === void 0 ? void 0 : _error$response2.message) || _context2.t0.message || '删除失败';
188
+ _context3.prev = 8;
189
+ _context3.t0 = _context3["catch"](1);
190
+ console.error('删除失败:', _context3.t0);
191
+ errorMessage = ((_error$response3 = _context3.t0.response) === null || _error$response3 === void 0 || (_error$response3 = _error$response3.data) === null || _error$response3 === void 0 || (_error$response3 = _error$response3.error) === null || _error$response3 === void 0 ? void 0 : _error$response3.message) || _context3.t0.message || '删除失败';
104
192
  message.error("\u5220\u9664\u5931\u8D25\uFF1A".concat(errorMessage));
105
- throw _context2.t0;
193
+ throw _context3.t0;
106
194
  case 14:
107
- _context2.prev = 14;
195
+ _context3.prev = 14;
108
196
  hide();
109
- return _context2.finish(14);
197
+ return _context3.finish(14);
110
198
  case 17:
111
199
  case "end":
112
- return _context2.stop();
200
+ return _context3.stop();
113
201
  }
114
- }, _callee2, null, [[1, 8, 14, 17]]);
202
+ }, _callee3, null, [[1, 8, 14, 17]]);
115
203
  }));
116
- return function defaultHandleDelete(_x4, _x5, _x6) {
117
- return _ref2.apply(this, arguments);
204
+ return function defaultHandleDelete(_x5, _x6, _x7) {
205
+ return _ref3.apply(this, arguments);
118
206
  };
119
207
  }();
120
208
 
@@ -77,8 +77,8 @@ export interface ApiConfig<T = any> {
77
77
  list: (params: ListParams) => Promise<PagedResult<T>>;
78
78
  /** 删除API */
79
79
  delete?: (params: DeleteParams) => Promise<void>;
80
- /** 导出API */
81
- export?: (params: ExportParams) => Promise<Blob>;
80
+ /** 导出API;第二参会传 `{ responseType: 'blob' }`,openapi 生成的函数直接透传给请求 */
81
+ export?: (params: ExportParams, options?: Record<string, any>) => Promise<Blob>;
82
82
  /** 获取导入模板API */
83
83
  getImportTemplate?: () => Promise<Blob>;
84
84
  /** 导入API */