@arim-aisdc/public-components 2.3.92 → 2.3.95
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.
- package/dist/components/TableMax/components/ColumnSort/customSortFns.d.ts +8 -8
- package/dist/components/TableMax/components/Export/index.d.ts +37 -3
- package/dist/components/TableMax/components/Export/index.js +768 -23
- package/dist/components/TableMax/components/Export/useTableExport.d.ts +9 -11
- package/dist/components/TableMax/components/Export/useTableExport.js +438 -127
- package/dist/components/TableMax/type.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1,35 +1,29 @@
|
|
|
1
|
-
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; }
|
|
2
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
-
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; }
|
|
5
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
|
-
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); }
|
|
7
1
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
8
2
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
9
3
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
10
4
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
11
|
-
function
|
|
12
|
-
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
|
+
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; }
|
|
13
6
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
14
7
|
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."); }
|
|
15
8
|
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); }
|
|
16
9
|
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; }
|
|
17
10
|
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; } }
|
|
18
11
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
12
|
+
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); } }
|
|
13
|
+
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); }); }; }
|
|
19
14
|
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); }
|
|
20
15
|
// hooks/useTableExport.ts
|
|
21
|
-
import { useCallback, useState } from 'react';
|
|
16
|
+
import { useCallback, useState, useRef } from 'react';
|
|
22
17
|
import * as XLSX from 'xlsx';
|
|
23
18
|
import { message } from 'antd';
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
*/
|
|
19
|
+
var ColumnType = /*#__PURE__*/function (ColumnType) {
|
|
20
|
+
ColumnType["Selection"] = "selection-column";
|
|
21
|
+
ColumnType["Drag"] = "darg-column";
|
|
22
|
+
ColumnType["PlaceHolder"] = "placeholder-column";
|
|
23
|
+
ColumnType["Expander"] = "expander";
|
|
24
|
+
ColumnType["Index"] = "inner-index";
|
|
25
|
+
return ColumnType;
|
|
26
|
+
}(ColumnType || {});
|
|
33
27
|
var defaultApplyCellLogic = function defaultApplyCellLogic(value, columnId, originalRow, column) {
|
|
34
28
|
var cell = column.cell,
|
|
35
29
|
accessorKey = column.accessorKey,
|
|
@@ -38,8 +32,6 @@ var defaultApplyCellLogic = function defaultApplyCellLogic(value, columnId, orig
|
|
|
38
32
|
if (exportValueFormat) {
|
|
39
33
|
return exportValueFormat(originalRow);
|
|
40
34
|
}
|
|
41
|
-
|
|
42
|
-
// 如果有自定义的cell渲染函数,需要执行它来获取显示值
|
|
43
35
|
if (cell) {
|
|
44
36
|
try {
|
|
45
37
|
var cellInfo = {
|
|
@@ -54,13 +46,11 @@ var defaultApplyCellLogic = function defaultApplyCellLogic(value, columnId, orig
|
|
|
54
46
|
}
|
|
55
47
|
};
|
|
56
48
|
var cellResult = cell(cellInfo);
|
|
57
|
-
// cellResult === false 兼容 cell: (info: any) => typeof info.getValue() === 'number' && convertNumber(convertUnitUp(info.getValue()) as number)
|
|
58
49
|
if (cellResult === null || cellResult === undefined || cellResult === false) {
|
|
59
50
|
return '';
|
|
60
51
|
}
|
|
61
52
|
if (cellResult && _typeof(cellResult) === 'object' && cellResult !== null && cellResult !== void 0 && cellResult.props) {
|
|
62
53
|
var _cellResult$props;
|
|
63
|
-
// 处理 BadgeComponent
|
|
64
54
|
if ((_cellResult$props = cellResult.props) !== null && _cellResult$props !== void 0 && _cellResult$props.label) {
|
|
65
55
|
var _cellResult$props2;
|
|
66
56
|
return (_cellResult$props2 = cellResult.props) === null || _cellResult$props2 === void 0 ? void 0 : _cellResult$props2.label;
|
|
@@ -75,151 +65,472 @@ var defaultApplyCellLogic = function defaultApplyCellLogic(value, columnId, orig
|
|
|
75
65
|
}
|
|
76
66
|
return value !== null && value !== void 0 ? value : '';
|
|
77
67
|
};
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
68
|
+
var EnableExportColumnTypeList = [ColumnType.Selection, ColumnType.Drag, ColumnType.PlaceHolder, ColumnType.Expander, ColumnType.Index];
|
|
69
|
+
function fetchWithRetry(_x) {
|
|
70
|
+
return _fetchWithRetry.apply(this, arguments);
|
|
71
|
+
}
|
|
72
|
+
function _fetchWithRetry() {
|
|
73
|
+
_fetchWithRetry = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(fn) {
|
|
74
|
+
var retryCount,
|
|
75
|
+
lastError,
|
|
76
|
+
_loop,
|
|
77
|
+
_ret,
|
|
78
|
+
attempt,
|
|
79
|
+
_args6 = arguments;
|
|
80
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context6) {
|
|
81
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
82
|
+
case 0:
|
|
83
|
+
retryCount = _args6.length > 1 && _args6[1] !== undefined ? _args6[1] : 2;
|
|
84
|
+
lastError = null;
|
|
85
|
+
_loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop() {
|
|
86
|
+
var delay;
|
|
87
|
+
return _regeneratorRuntime().wrap(function _loop$(_context5) {
|
|
88
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
89
|
+
case 0:
|
|
90
|
+
_context5.prev = 0;
|
|
91
|
+
_context5.next = 3;
|
|
92
|
+
return fn();
|
|
93
|
+
case 3:
|
|
94
|
+
_context5.t0 = _context5.sent;
|
|
95
|
+
return _context5.abrupt("return", {
|
|
96
|
+
v: _context5.t0
|
|
97
|
+
});
|
|
98
|
+
case 7:
|
|
99
|
+
_context5.prev = 7;
|
|
100
|
+
_context5.t1 = _context5["catch"](0);
|
|
101
|
+
lastError = _context5.t1;
|
|
102
|
+
if (!(attempt < retryCount)) {
|
|
103
|
+
_context5.next = 14;
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
delay = Math.pow(2, attempt) * 1000;
|
|
107
|
+
_context5.next = 14;
|
|
108
|
+
return new Promise(function (resolve) {
|
|
109
|
+
return setTimeout(resolve, delay);
|
|
110
|
+
});
|
|
111
|
+
case 14:
|
|
112
|
+
case "end":
|
|
113
|
+
return _context5.stop();
|
|
114
|
+
}
|
|
115
|
+
}, _loop, null, [[0, 7]]);
|
|
116
|
+
});
|
|
117
|
+
attempt = 0;
|
|
118
|
+
case 4:
|
|
119
|
+
if (!(attempt <= retryCount)) {
|
|
120
|
+
_context6.next = 12;
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
123
|
+
return _context6.delegateYield(_loop(), "t0", 6);
|
|
124
|
+
case 6:
|
|
125
|
+
_ret = _context6.t0;
|
|
126
|
+
if (!_ret) {
|
|
127
|
+
_context6.next = 9;
|
|
128
|
+
break;
|
|
129
|
+
}
|
|
130
|
+
return _context6.abrupt("return", _ret.v);
|
|
131
|
+
case 9:
|
|
132
|
+
attempt++;
|
|
133
|
+
_context6.next = 4;
|
|
134
|
+
break;
|
|
135
|
+
case 12:
|
|
136
|
+
throw lastError;
|
|
137
|
+
case 13:
|
|
138
|
+
case "end":
|
|
139
|
+
return _context6.stop();
|
|
140
|
+
}
|
|
141
|
+
}, _callee5);
|
|
142
|
+
}));
|
|
143
|
+
return _fetchWithRetry.apply(this, arguments);
|
|
144
|
+
}
|
|
145
|
+
export var useTableExport = function useTableExport() {
|
|
89
146
|
var _useState = useState(false),
|
|
90
147
|
_useState2 = _slicedToArray(_useState, 2),
|
|
91
148
|
exporting = _useState2[0],
|
|
92
149
|
setExporting = _useState2[1];
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
var _item$accessorKey;
|
|
115
|
-
value = value = (_item$accessorKey = item[accessorKey]) !== null && _item$accessorKey !== void 0 ? _item$accessorKey : item[id];
|
|
150
|
+
var exportingRef = useRef(false);
|
|
151
|
+
var abortControllerRef = useRef(null);
|
|
152
|
+
var processRowData = useCallback(function (item, columns) {
|
|
153
|
+
var isTotalRow = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
154
|
+
var processedItem = {};
|
|
155
|
+
columns.filter(function (col) {
|
|
156
|
+
return !EnableExportColumnTypeList.includes(col === null || col === void 0 ? void 0 : col.id) && !(col !== null && col !== void 0 && col.disabledExport);
|
|
157
|
+
}).forEach(function (column) {
|
|
158
|
+
var header = column.header,
|
|
159
|
+
id = column.id,
|
|
160
|
+
accessorKey = column.accessorKey,
|
|
161
|
+
accessorFn = column.accessorFn;
|
|
162
|
+
var value;
|
|
163
|
+
if (isTotalRow) {
|
|
164
|
+
var _item$accessorKey;
|
|
165
|
+
value = (_item$accessorKey = item[accessorKey]) !== null && _item$accessorKey !== void 0 ? _item$accessorKey : item[id];
|
|
166
|
+
} else {
|
|
167
|
+
if (accessorFn) {
|
|
168
|
+
value = accessorFn(item, 0);
|
|
169
|
+
} else if (accessorKey) {
|
|
170
|
+
value = item[accessorKey];
|
|
116
171
|
} else {
|
|
117
|
-
|
|
118
|
-
value = accessorFn(item, index);
|
|
119
|
-
}
|
|
120
|
-
// 2. 使用 accessorKey 获取值
|
|
121
|
-
else if (accessorKey) {
|
|
122
|
-
value = item[accessorKey];
|
|
123
|
-
}
|
|
124
|
-
// 3. 使用 id 获取值
|
|
125
|
-
else {
|
|
126
|
-
value = item[id];
|
|
127
|
-
}
|
|
128
|
-
// 4. 应用单元格渲染逻辑(转换为文本)
|
|
129
|
-
var finalApplyCellLogic = defaultApplyCellLogic;
|
|
130
|
-
value = finalApplyCellLogic(value, id, item, column);
|
|
172
|
+
value = item[id];
|
|
131
173
|
}
|
|
132
|
-
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
});
|
|
136
|
-
}, []);
|
|
137
|
-
/**
|
|
138
|
-
* 设置列宽
|
|
139
|
-
*/
|
|
140
|
-
var setColumnWidths = useCallback(function (columns, worksheet) {
|
|
141
|
-
if (!worksheet['!cols']) worksheet['!cols'] = [];
|
|
142
|
-
columns.forEach(function (column, index) {
|
|
143
|
-
var width = calculateColumnWidth(typeof column.header === 'string' ? column.header : '表格列宽');
|
|
144
|
-
worksheet['!cols'][index] = {
|
|
145
|
-
width: width
|
|
146
|
-
};
|
|
174
|
+
value = defaultApplyCellLogic(value, id, item, column);
|
|
175
|
+
}
|
|
176
|
+
processedItem[typeof header === "string" ? header : accessorKey !== null && accessorKey !== void 0 ? accessorKey : id] = value;
|
|
147
177
|
});
|
|
178
|
+
return processedItem;
|
|
148
179
|
}, []);
|
|
149
|
-
/**
|
|
150
|
-
* 计算列宽
|
|
151
|
-
*/
|
|
152
180
|
var calculateColumnWidth = function calculateColumnWidth(header) {
|
|
181
|
+
if (!header) return 12;
|
|
153
182
|
var chineseCharCount = (header.match(/[^\x00-\xff]/g) || []).length;
|
|
154
183
|
var otherCharCount = header.length - chineseCharCount;
|
|
155
184
|
var width = chineseCharCount * 2 + otherCharCount * 1.1 + 4;
|
|
156
185
|
return Math.min(Math.max(width, 12), 50);
|
|
157
186
|
};
|
|
187
|
+
var getHeaders = useCallback(function (columns) {
|
|
188
|
+
return columns.filter(function (col) {
|
|
189
|
+
return !EnableExportColumnTypeList.includes(col === null || col === void 0 ? void 0 : col.id) && !(col !== null && col !== void 0 && col.disabledExport);
|
|
190
|
+
}).map(function (col) {
|
|
191
|
+
var _col$accessorKey;
|
|
192
|
+
return typeof col.header === 'string' ? col.header : (_col$accessorKey = col.accessorKey) !== null && _col$accessorKey !== void 0 ? _col$accessorKey : col.id;
|
|
193
|
+
});
|
|
194
|
+
}, []);
|
|
195
|
+
|
|
158
196
|
/**
|
|
159
|
-
*
|
|
197
|
+
* 流式导出 - 并发获取,分批写入,及时释放内存
|
|
160
198
|
*/
|
|
161
|
-
var
|
|
162
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
163
|
-
var
|
|
164
|
-
|
|
165
|
-
|
|
199
|
+
var streamExport = useCallback( /*#__PURE__*/function () {
|
|
200
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(getBatchData, totalCount, columns, options, hasTotalRow, totalDatas) {
|
|
201
|
+
var retryCount,
|
|
202
|
+
_options$fileName,
|
|
203
|
+
fileName,
|
|
204
|
+
_options$sheetName,
|
|
205
|
+
sheetName,
|
|
206
|
+
_options$maxConcurren,
|
|
207
|
+
maxConcurrent,
|
|
208
|
+
_options$batchSize,
|
|
209
|
+
batchSize,
|
|
210
|
+
onProgress,
|
|
211
|
+
onBatchComplete,
|
|
212
|
+
workbook,
|
|
213
|
+
headers,
|
|
214
|
+
worksheet,
|
|
215
|
+
colWidths,
|
|
216
|
+
_totalBatches,
|
|
217
|
+
writtenRowCount,
|
|
218
|
+
loadedCount,
|
|
219
|
+
nextBatchToWrite,
|
|
220
|
+
pendingResults,
|
|
221
|
+
batches,
|
|
222
|
+
currentIndex,
|
|
223
|
+
activeCount,
|
|
224
|
+
writeBatch,
|
|
225
|
+
tryWritePendingBatches,
|
|
226
|
+
executeNext,
|
|
227
|
+
i,
|
|
228
|
+
totalRow,
|
|
229
|
+
totalSheetRow,
|
|
230
|
+
timestamp,
|
|
231
|
+
exportFilename,
|
|
232
|
+
_args3 = arguments;
|
|
233
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
234
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
166
235
|
case 0:
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
if (!
|
|
170
|
-
|
|
236
|
+
retryCount = _args3.length > 6 && _args3[6] !== undefined ? _args3[6] : 2;
|
|
237
|
+
_options$fileName = options.fileName, fileName = _options$fileName === void 0 ? 'export' : _options$fileName, _options$sheetName = options.sheetName, sheetName = _options$sheetName === void 0 ? 'Sheet1' : _options$sheetName, _options$maxConcurren = options.maxConcurrent, maxConcurrent = _options$maxConcurren === void 0 ? 3 : _options$maxConcurren, _options$batchSize = options.batchSize, batchSize = _options$batchSize === void 0 ? 1000 : _options$batchSize, onProgress = options.onProgress, onBatchComplete = options.onBatchComplete;
|
|
238
|
+
if (!exportingRef.current) {
|
|
239
|
+
_context3.next = 5;
|
|
171
240
|
break;
|
|
172
241
|
}
|
|
173
242
|
message.warning('已有导出任务在进行中');
|
|
174
|
-
return
|
|
243
|
+
return _context3.abrupt("return");
|
|
175
244
|
case 5:
|
|
245
|
+
exportingRef.current = true;
|
|
176
246
|
setExporting(true);
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
247
|
+
abortControllerRef.current = new AbortController();
|
|
248
|
+
_context3.prev = 8;
|
|
249
|
+
// 创建工作簿和工作表
|
|
250
|
+
workbook = XLSX.utils.book_new();
|
|
251
|
+
headers = getHeaders(columns);
|
|
252
|
+
worksheet = XLSX.utils.aoa_to_sheet([headers]); // 设置列宽
|
|
253
|
+
colWidths = columns.filter(function (col) {
|
|
254
|
+
return !EnableExportColumnTypeList.includes(col === null || col === void 0 ? void 0 : col.id) && !(col !== null && col !== void 0 && col.disabledExport);
|
|
255
|
+
}).map(function (col) {
|
|
256
|
+
return {
|
|
257
|
+
wch: calculateColumnWidth(typeof col.header === 'string' ? col.header : undefined)
|
|
258
|
+
};
|
|
259
|
+
});
|
|
260
|
+
worksheet['!cols'] = colWidths;
|
|
261
|
+
_totalBatches = Math.ceil(totalCount / batchSize);
|
|
262
|
+
writtenRowCount = 0;
|
|
263
|
+
loadedCount = 0; // 用于存储并发请求的结果(滑动窗口)
|
|
264
|
+
nextBatchToWrite = 0;
|
|
265
|
+
pendingResults = new Map(); // 创建所有批次的任务
|
|
266
|
+
batches = Array.from({
|
|
267
|
+
length: _totalBatches
|
|
268
|
+
}, function (_, i) {
|
|
269
|
+
return {
|
|
270
|
+
batchIndex: i,
|
|
271
|
+
skipCount: i * batchSize,
|
|
272
|
+
size: Math.min(batchSize, totalCount - i * batchSize)
|
|
273
|
+
};
|
|
274
|
+
}); // 并发控制
|
|
275
|
+
currentIndex = 0;
|
|
276
|
+
activeCount = 0; // 写入批次到工作表
|
|
277
|
+
writeBatch = function writeBatch(batchIndex, data) {
|
|
278
|
+
var rows = data.map(function (item) {
|
|
279
|
+
return processRowData(item, columns, false);
|
|
280
|
+
});
|
|
281
|
+
var sheetRows = rows.map(function (row) {
|
|
282
|
+
return headers.map(function (header) {
|
|
283
|
+
var _row$header;
|
|
284
|
+
return (_row$header = row[header]) !== null && _row$header !== void 0 ? _row$header : '';
|
|
285
|
+
});
|
|
286
|
+
});
|
|
287
|
+
if (sheetRows.length > 0) {
|
|
288
|
+
var startRow = 1 + writtenRowCount;
|
|
289
|
+
XLSX.utils.sheet_add_aoa(worksheet, sheetRows, {
|
|
290
|
+
origin: "A".concat(startRow + 1)
|
|
291
|
+
});
|
|
292
|
+
writtenRowCount += sheetRows.length;
|
|
293
|
+
}
|
|
294
|
+
onBatchComplete === null || onBatchComplete === void 0 || onBatchComplete(batchIndex + 1, _totalBatches);
|
|
295
|
+
|
|
296
|
+
// 释放数据引用
|
|
297
|
+
data.length = 0;
|
|
298
|
+
}; // 尝试写入所有可写入的批次
|
|
299
|
+
tryWritePendingBatches = function tryWritePendingBatches() {
|
|
300
|
+
while (pendingResults.has(nextBatchToWrite)) {
|
|
301
|
+
var data = pendingResults.get(nextBatchToWrite);
|
|
302
|
+
writeBatch(nextBatchToWrite, data);
|
|
303
|
+
pendingResults.delete(nextBatchToWrite);
|
|
304
|
+
nextBatchToWrite++;
|
|
305
|
+
}
|
|
306
|
+
}; // 执行并发请求
|
|
307
|
+
executeNext = /*#__PURE__*/function () {
|
|
308
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
309
|
+
var _abortControllerRef$c;
|
|
310
|
+
var batch;
|
|
311
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
312
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
313
|
+
case 0:
|
|
314
|
+
if (!((_abortControllerRef$c = abortControllerRef.current) !== null && _abortControllerRef$c !== void 0 && _abortControllerRef$c.signal.aborted)) {
|
|
315
|
+
_context2.next = 2;
|
|
316
|
+
break;
|
|
317
|
+
}
|
|
318
|
+
return _context2.abrupt("return");
|
|
319
|
+
case 2:
|
|
320
|
+
if (!(currentIndex >= batches.length && activeCount === 0)) {
|
|
321
|
+
_context2.next = 5;
|
|
322
|
+
break;
|
|
323
|
+
}
|
|
324
|
+
// 所有请求完成,等待写入完成
|
|
325
|
+
tryWritePendingBatches();
|
|
326
|
+
return _context2.abrupt("return");
|
|
327
|
+
case 5:
|
|
328
|
+
if (currentIndex < batches.length && activeCount < maxConcurrent) {
|
|
329
|
+
batch = batches[currentIndex];
|
|
330
|
+
currentIndex++;
|
|
331
|
+
activeCount++;
|
|
332
|
+
|
|
333
|
+
// 发起请求
|
|
334
|
+
_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
335
|
+
var _abortControllerRef$c2, data, _percent;
|
|
336
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
337
|
+
while (1) switch (_context.prev = _context.next) {
|
|
338
|
+
case 0:
|
|
339
|
+
_context.prev = 0;
|
|
340
|
+
_context.next = 3;
|
|
341
|
+
return fetchWithRetry(function () {
|
|
342
|
+
return getBatchData(batch.skipCount, batch.size);
|
|
343
|
+
}, retryCount);
|
|
344
|
+
case 3:
|
|
345
|
+
data = _context.sent;
|
|
346
|
+
if (!((_abortControllerRef$c2 = abortControllerRef.current) !== null && _abortControllerRef$c2 !== void 0 && _abortControllerRef$c2.signal.aborted)) {
|
|
347
|
+
_context.next = 6;
|
|
348
|
+
break;
|
|
349
|
+
}
|
|
350
|
+
return _context.abrupt("return");
|
|
351
|
+
case 6:
|
|
352
|
+
loadedCount += data.length;
|
|
353
|
+
_percent = Math.floor(loadedCount / totalCount * 100);
|
|
354
|
+
onProgress === null || onProgress === void 0 || onProgress(loadedCount, totalCount, _percent);
|
|
355
|
+
|
|
356
|
+
// 存储结果
|
|
357
|
+
pendingResults.set(batch.batchIndex, data);
|
|
358
|
+
|
|
359
|
+
// 尝试按顺序写入
|
|
360
|
+
tryWritePendingBatches();
|
|
361
|
+
_context.next = 17;
|
|
362
|
+
break;
|
|
363
|
+
case 13:
|
|
364
|
+
_context.prev = 13;
|
|
365
|
+
_context.t0 = _context["catch"](0);
|
|
366
|
+
console.error("\u83B7\u53D6\u7B2C ".concat(batch.batchIndex + 1, " \u6279\u6570\u636E\u5931\u8D25:"), _context.t0);
|
|
367
|
+
message.error("\u83B7\u53D6\u6570\u636E\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5");
|
|
368
|
+
case 17:
|
|
369
|
+
_context.prev = 17;
|
|
370
|
+
activeCount--;
|
|
371
|
+
executeNext();
|
|
372
|
+
return _context.finish(17);
|
|
373
|
+
case 21:
|
|
374
|
+
case "end":
|
|
375
|
+
return _context.stop();
|
|
376
|
+
}
|
|
377
|
+
}, _callee, null, [[0, 13, 17, 21]]);
|
|
378
|
+
}))();
|
|
379
|
+
|
|
380
|
+
// 继续发起下一个请求
|
|
381
|
+
executeNext();
|
|
382
|
+
}
|
|
383
|
+
case 6:
|
|
384
|
+
case "end":
|
|
385
|
+
return _context2.stop();
|
|
386
|
+
}
|
|
387
|
+
}, _callee2);
|
|
388
|
+
}));
|
|
389
|
+
return function executeNext() {
|
|
390
|
+
return _ref2.apply(this, arguments);
|
|
391
|
+
};
|
|
392
|
+
}(); // 启动并发请求
|
|
393
|
+
for (i = 0; i < Math.min(maxConcurrent, batches.length); i++) {
|
|
394
|
+
executeNext();
|
|
180
395
|
}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
396
|
+
|
|
397
|
+
// 等待所有请求完成
|
|
398
|
+
_context3.next = 28;
|
|
399
|
+
return new Promise(function (resolve) {
|
|
400
|
+
var checkComplete = function checkComplete() {
|
|
401
|
+
if (currentIndex >= batches.length && activeCount === 0 && nextBatchToWrite === batches.length) {
|
|
402
|
+
resolve();
|
|
403
|
+
} else {
|
|
404
|
+
setTimeout(checkComplete, 100);
|
|
405
|
+
}
|
|
406
|
+
};
|
|
407
|
+
checkComplete();
|
|
408
|
+
});
|
|
409
|
+
case 28:
|
|
410
|
+
// 添加合计行
|
|
411
|
+
if (hasTotalRow && totalDatas) {
|
|
412
|
+
totalRow = processRowData(totalDatas, columns, true);
|
|
413
|
+
totalSheetRow = [headers.map(function (header) {
|
|
414
|
+
var _totalRow$header;
|
|
415
|
+
return (_totalRow$header = totalRow[header]) !== null && _totalRow$header !== void 0 ? _totalRow$header : '';
|
|
416
|
+
})];
|
|
417
|
+
XLSX.utils.sheet_add_aoa(worksheet, totalSheetRow, {
|
|
418
|
+
origin: "A".concat(1 + writtenRowCount + 1)
|
|
419
|
+
});
|
|
187
420
|
}
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
421
|
+
|
|
422
|
+
// 添加工作表到工作簿
|
|
423
|
+
XLSX.utils.book_append_sheet(workbook, worksheet, sheetName);
|
|
424
|
+
|
|
425
|
+
// 写入文件
|
|
426
|
+
timestamp = new Date().toISOString().slice(0, 19).replace(/:/g, '-');
|
|
427
|
+
exportFilename = "".concat(fileName, "_").concat(timestamp, ".xlsx");
|
|
428
|
+
_context3.next = 34;
|
|
429
|
+
return new Promise(function (resolve) {
|
|
430
|
+
setTimeout(function () {
|
|
431
|
+
XLSX.writeFile(workbook, exportFilename);
|
|
432
|
+
resolve();
|
|
433
|
+
}, 100);
|
|
434
|
+
});
|
|
435
|
+
case 34:
|
|
436
|
+
message.success("\u5BFC\u51FA\u6210\u529F: ".concat(exportFilename, " (\u5171 ").concat(loadedCount, " \u6761\u6570\u636E)"));
|
|
437
|
+
_context3.next = 41;
|
|
438
|
+
break;
|
|
439
|
+
case 37:
|
|
440
|
+
_context3.prev = 37;
|
|
441
|
+
_context3.t0 = _context3["catch"](8);
|
|
442
|
+
console.error('导出失败:', _context3.t0);
|
|
443
|
+
message.error('导出失败,请重试');
|
|
444
|
+
case 41:
|
|
445
|
+
_context3.prev = 41;
|
|
446
|
+
exportingRef.current = false;
|
|
447
|
+
setExporting(false);
|
|
448
|
+
abortControllerRef.current = null;
|
|
449
|
+
return _context3.finish(41);
|
|
450
|
+
case 46:
|
|
451
|
+
case "end":
|
|
452
|
+
return _context3.stop();
|
|
453
|
+
}
|
|
454
|
+
}, _callee3, null, [[8, 37, 41, 46]]);
|
|
455
|
+
}));
|
|
456
|
+
return function (_x2, _x3, _x4, _x5, _x6, _x7) {
|
|
457
|
+
return _ref.apply(this, arguments);
|
|
458
|
+
};
|
|
459
|
+
}(), [getHeaders, processRowData]);
|
|
460
|
+
|
|
461
|
+
/**
|
|
462
|
+
* 常规导出(小数据量)
|
|
463
|
+
*/
|
|
464
|
+
var exportTableData = useCallback( /*#__PURE__*/function () {
|
|
465
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(data, columns, hasTotalRow, totalDatas, customOptions) {
|
|
466
|
+
var _customOptions$isIncl, isIncludeTotalRow, _customOptions$fileNa, fileName, _customOptions$sheetN, sheetName, exportData, processedData, workbook, _worksheet, colWidths, timestamp, exportFilename;
|
|
467
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
468
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
469
|
+
case 0:
|
|
470
|
+
if (!exportingRef.current) {
|
|
471
|
+
_context4.next = 3;
|
|
472
|
+
break;
|
|
191
473
|
}
|
|
474
|
+
message.warning('已有导出任务在进行中');
|
|
475
|
+
return _context4.abrupt("return");
|
|
476
|
+
case 3:
|
|
477
|
+
exportingRef.current = true;
|
|
478
|
+
setExporting(true);
|
|
192
479
|
try {
|
|
193
|
-
|
|
194
|
-
|
|
480
|
+
_customOptions$isIncl = customOptions.isIncludeTotalRow, isIncludeTotalRow = _customOptions$isIncl === void 0 ? true : _customOptions$isIncl, _customOptions$fileNa = customOptions.fileName, fileName = _customOptions$fileNa === void 0 ? 'export' : _customOptions$fileNa, _customOptions$sheetN = customOptions.sheetName, sheetName = _customOptions$sheetN === void 0 ? 'Sheet1' : _customOptions$sheetN;
|
|
481
|
+
exportData = _toConsumableArray(data);
|
|
482
|
+
if (isIncludeTotalRow && hasTotalRow && totalDatas) {
|
|
483
|
+
exportData.push(totalDatas);
|
|
484
|
+
}
|
|
485
|
+
processedData = exportData.map(function (item, index) {
|
|
486
|
+
var isTotalRow = isIncludeTotalRow && hasTotalRow && index === exportData.length - 1;
|
|
487
|
+
return processRowData(item, columns, isTotalRow);
|
|
488
|
+
});
|
|
195
489
|
workbook = XLSX.utils.book_new();
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
490
|
+
_worksheet = XLSX.utils.json_to_sheet(processedData);
|
|
491
|
+
colWidths = columns.filter(function (col) {
|
|
492
|
+
return !EnableExportColumnTypeList.includes(col === null || col === void 0 ? void 0 : col.id) && !(col !== null && col !== void 0 && col.disabledExport);
|
|
493
|
+
}).map(function (col) {
|
|
494
|
+
return {
|
|
495
|
+
wch: calculateColumnWidth(typeof col.header === 'string' ? col.header : undefined)
|
|
496
|
+
};
|
|
497
|
+
});
|
|
498
|
+
_worksheet['!cols'] = colWidths;
|
|
499
|
+
XLSX.utils.book_append_sheet(workbook, _worksheet, sheetName);
|
|
500
|
+
timestamp = new Date().toISOString().slice(0, 19).replace(/:/g, '-');
|
|
501
|
+
exportFilename = "".concat(fileName, "_").concat(timestamp, ".xlsx");
|
|
203
502
|
XLSX.writeFile(workbook, exportFilename);
|
|
204
503
|
message.success("\u5BFC\u51FA\u6210\u529F: ".concat(exportFilename));
|
|
205
504
|
} catch (error) {
|
|
206
505
|
console.error('导出失败:', error);
|
|
207
506
|
message.error('导出失败,请重试');
|
|
208
507
|
} finally {
|
|
508
|
+
exportingRef.current = false;
|
|
209
509
|
setExporting(false);
|
|
210
510
|
}
|
|
211
|
-
case
|
|
511
|
+
case 6:
|
|
212
512
|
case "end":
|
|
213
|
-
return
|
|
513
|
+
return _context4.stop();
|
|
214
514
|
}
|
|
215
|
-
},
|
|
515
|
+
}, _callee4);
|
|
216
516
|
}));
|
|
217
|
-
return function (
|
|
218
|
-
return
|
|
517
|
+
return function (_x8, _x9, _x10, _x11, _x12) {
|
|
518
|
+
return _ref4.apply(this, arguments);
|
|
219
519
|
};
|
|
220
|
-
}(), [
|
|
520
|
+
}(), [processRowData]);
|
|
521
|
+
|
|
522
|
+
/**
|
|
523
|
+
* 取消导出
|
|
524
|
+
*/
|
|
525
|
+
var cancelExport = useCallback(function () {
|
|
526
|
+
if (abortControllerRef.current) {
|
|
527
|
+
abortControllerRef.current.abort();
|
|
528
|
+
}
|
|
529
|
+
}, []);
|
|
221
530
|
return {
|
|
222
531
|
exporting: exporting,
|
|
223
|
-
exportTableData: exportTableData
|
|
532
|
+
exportTableData: exportTableData,
|
|
533
|
+
streamExport: streamExport,
|
|
534
|
+
cancelExport: cancelExport
|
|
224
535
|
};
|
|
225
536
|
};
|