@arim-aisdc/public-components 2.3.40 → 2.3.42

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.
@@ -12,7 +12,7 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
12
12
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
13
13
  import { useDeepCompareEffect, useUpdateLayoutEffect } from 'ahooks';
14
14
  import { Splitter } from 'antd';
15
- import React, { useCallback, useLayoutEffect, useState } from 'react';
15
+ import React, { useCallback, useEffect, useLayoutEffect, useState } from 'react';
16
16
  import { useConfig } from "../ConfigProvider";
17
17
  import { SplitTypeEnums } from "./config";
18
18
  import { getCurrentRouterName } from "../..";
@@ -60,6 +60,51 @@ var SplitterPane = function SplitterPane(_ref) {
60
60
  useDeepCompareEffect(function () {
61
61
  localStorage.setItem(_cacheKeyKey, JSON.stringify(sizes));
62
62
  }, [sizes]);
63
+
64
+ // 监听窗口缩放变化,重新计算 sizes
65
+ useEffect(function () {
66
+ var handleResize = function handleResize() {
67
+ // 当窗口大小变化时,重新计算面板尺寸
68
+ if (sizes.length > 0) {
69
+ // 检查 sizes 数组中的值是否都是 number 且都有值
70
+ var isValidSizes = sizes.every(function (size) {
71
+ return typeof size === 'number' && size > 0;
72
+ });
73
+ if (isValidSizes) {
74
+ // 计算当前 sizes 的总和
75
+ var totalSize = sizes.reduce(function (sum, size) {
76
+ return sum + size;
77
+ }, 0);
78
+
79
+ // 按比例重新分配为百分比
80
+ if (typeof totalSize === 'number' && totalSize > 0) {
81
+ var newSizes = sizes.map(function (size) {
82
+ return "".concat(Math.round(size / totalSize * 100), "%");
83
+ });
84
+
85
+ // 使用 requestAnimationFrame 确保在下一帧更新
86
+ requestAnimationFrame(function () {
87
+ setSizes(newSizes);
88
+ });
89
+ }
90
+ }
91
+ }
92
+ };
93
+
94
+ // 使用防抖处理,避免频繁触发
95
+ var timeoutId = null;
96
+ var debouncedResize = function debouncedResize() {
97
+ clearTimeout(timeoutId);
98
+ timeoutId = setTimeout(handleResize, 100);
99
+ };
100
+
101
+ // 监听窗口大小变化
102
+ window.addEventListener('resize', debouncedResize);
103
+ return function () {
104
+ window.removeEventListener('resize', debouncedResize);
105
+ clearTimeout(timeoutId);
106
+ };
107
+ }, [sizes]);
63
108
  var handlePaneResize = useCallback(function (newSizes) {
64
109
  setSizes(newSizes);
65
110
  onResize === null || onResize === void 0 || onResize(newSizes);
@@ -11,7 +11,7 @@ var getOffsetLeft = function getOffsetLeft(list, column, visibleColumnSizesMap)
11
11
  };
12
12
  var getOffsetRight = function getOffsetRight(list, column, visibleColumnSizesMap) {
13
13
  var x = 0;
14
- console.log(list, 'list');
14
+ // console.log(list, 'list')
15
15
  for (var i = list.length - 1; i > 0; i--) {
16
16
  var curr = list[i];
17
17
  if (curr === column.id) {
@@ -54,7 +54,7 @@ export var getPinningStyle = function getPinningStyle(header, table, isHeader) {
54
54
  {
55
55
  var offsetRight = 0;
56
56
  offsetRight += getOffsetRight(columnPinning.right, column, visibleColumnSizesMap);
57
- console.log(offsetRight, 'offsetRight');
57
+ // console.log(offsetRight, 'offsetRight')
58
58
  return {
59
59
  position: 'sticky',
60
60
  right: offsetRight - 0.5,
@@ -39,6 +39,7 @@ import { useColumnWidth } from "./hooks/useColumnWidth";
39
39
  import "./tableMax.less";
40
40
  import { downloadExcel, getFormatFilters, getFormatFiltersV2, getFormatSorting, operationColumnNoTooltips } from "./utils";
41
41
  import { useTableScrollShadow } from "./hooks/useTableScrollShadow";
42
+ import { ExportTableData } from "./components/Export";
42
43
  import { jsx as _jsx } from "react/jsx-runtime";
43
44
  import { jsxs as _jsxs } from "react/jsx-runtime";
44
45
  export var ColumnType = /*#__PURE__*/function (ColumnType) {
@@ -106,6 +107,8 @@ var TableMax = function TableMax(_ref) {
106
107
  canSetting = _ref$canSetting === void 0 ? true : _ref$canSetting,
107
108
  _ref$canFilter = _ref.canFilter,
108
109
  canFilter = _ref$canFilter === void 0 ? true : _ref$canFilter,
110
+ _ref$canExport = _ref.canExport,
111
+ canExport = _ref$canExport === void 0 ? false : _ref$canExport,
109
112
  _ref$defaultEnableFil = _ref.defaultEnableFilters,
110
113
  defaultEnableFilters = _ref$defaultEnableFil === void 0 ? false : _ref$defaultEnableFil,
111
114
  _ref$defaultHeaderRow = _ref.defaultHeaderRowNum,
@@ -196,7 +199,8 @@ var TableMax = function TableMax(_ref) {
196
199
  totalDatas = _ref.totalDatas,
197
200
  pageSizeOptions = _ref.pageSizeOptions,
198
201
  openMemo = _ref.openMemo,
199
- getDynamicFilterOptionsFn = _ref.getDynamicFilterOptionsFn;
202
+ getDynamicFilterOptionsFn = _ref.getDynamicFilterOptionsFn,
203
+ exportConfig = _ref.exportConfig;
200
204
  var tableMaxRef = useRef(null);
201
205
  // 表格元素
202
206
  var tableContentRef = useRef(null);
@@ -556,9 +560,7 @@ var TableMax = function TableMax(_ref) {
556
560
  }) === -1) {
557
561
  extraColumns.unshift({
558
562
  id: ColumnType.Expander,
559
- header: function header() {
560
- return null;
561
- },
563
+ header: ColumnType.Expander,
562
564
  size: 40,
563
565
  tooltip: false,
564
566
  enableResizing: false,
@@ -1169,6 +1171,14 @@ var TableMax = function TableMax(_ref) {
1169
1171
  setColumnFilters(defaultColumnFilters);
1170
1172
  }
1171
1173
  })
1174
+ }), /*#__PURE__*/_jsx(ExportTableData, {
1175
+ tableTitle: tableTitle,
1176
+ canExport: canExport,
1177
+ hasTotalRow: hasTotalRow,
1178
+ totalDatas: totalDatas,
1179
+ columns: tableColumns,
1180
+ datas: datas,
1181
+ exportConfig: exportConfig
1172
1182
  }), canCompact && /*#__PURE__*/_jsx(Tooltip, {
1173
1183
  placement: "top",
1174
1184
  title: compactMode ? '标准模式' : '紧凑模式',
@@ -0,0 +1,10 @@
1
+ import { ColumnFiltersState } from "@tanstack/react-table";
2
+ import React, { Dispatch, SetStateAction } from "react";
3
+ type ResetFilterProps = {
4
+ canFilter: boolean;
5
+ defaultColumnFilters: ColumnFiltersState;
6
+ columnFilters: ColumnFiltersState;
7
+ setColumnFilters: Dispatch<SetStateAction<ColumnFiltersState>>;
8
+ };
9
+ export declare const ResetFilter: React.NamedExoticComponent<ResetFilterProps>;
10
+ export {};
@@ -0,0 +1,30 @@
1
+ import { Badge, Tooltip } from "antd";
2
+ import React from "react";
3
+ import { jsx as _jsx } from "react/jsx-runtime";
4
+ import { Fragment as _Fragment } from "react/jsx-runtime";
5
+ var ResetFilterComp = function ResetFilterComp(_ref) {
6
+ var canFilter = _ref.canFilter,
7
+ defaultColumnFilters = _ref.defaultColumnFilters,
8
+ columnFilters = _ref.columnFilters,
9
+ setColumnFilters = _ref.setColumnFilters;
10
+ return /*#__PURE__*/_jsx(_Fragment, {
11
+ children: canFilter && /*#__PURE__*/_jsx(Tooltip, {
12
+ placement: "top",
13
+ title: '重置筛选',
14
+ children: /*#__PURE__*/_jsx(Badge, {
15
+ count: 5,
16
+ children: /*#__PURE__*/_jsx("i", {
17
+ className: "iconfont-table icon-table-refresh handleRightItem",
18
+ style: {
19
+ fontSize: '16px',
20
+ marginRight: 0
21
+ },
22
+ onClick: function onClick() {
23
+ setColumnFilters(defaultColumnFilters);
24
+ }
25
+ })
26
+ })
27
+ })
28
+ });
29
+ };
30
+ export var ResetFilter = /*#__PURE__*/React.memo(ResetFilterComp);
@@ -1,13 +1,13 @@
1
1
  import { TableMaxColumnType } from "../../type";
2
- export declare const numberSortFn: (rowA: any, rowB: any, columnId: string) => 0 | 1 | -1;
3
- export declare const stringSortFn: (rowA: any, rowB: any, columnId: string) => 0 | 1 | -1;
4
- export declare const numberOrStringSortFn: (rowA: any, rowB: any, columnId: string) => 0 | 1 | -1;
5
- export declare const timeSortFn: (rowA: any, rowB: any, columnId: string) => 0 | 1 | -1;
2
+ export declare const numberSortFn: (rowA: any, rowB: any, columnId: string) => 1 | 0 | -1;
3
+ export declare const stringSortFn: (rowA: any, rowB: any, columnId: string) => 1 | 0 | -1;
4
+ export declare const numberOrStringSortFn: (rowA: any, rowB: any, columnId: string) => 1 | 0 | -1;
5
+ export declare const timeSortFn: (rowA: any, rowB: any, columnId: string) => 1 | 0 | -1;
6
6
  declare const customSortFns: {
7
- numberSortFn: (rowA: any, rowB: any, columnId: string) => 0 | 1 | -1;
8
- stringSortFn: (rowA: any, rowB: any, columnId: string) => 0 | 1 | -1;
9
- timeSortFn: (rowA: any, rowB: any, columnId: string) => 0 | 1 | -1;
10
- numberOrStringSortFn: (rowA: any, rowB: any, columnId: string) => 0 | 1 | -1;
7
+ numberSortFn: (rowA: any, rowB: any, columnId: string) => 1 | 0 | -1;
8
+ stringSortFn: (rowA: any, rowB: any, columnId: string) => 1 | 0 | -1;
9
+ timeSortFn: (rowA: any, rowB: any, columnId: string) => 1 | 0 | -1;
10
+ numberOrStringSortFn: (rowA: any, rowB: any, columnId: string) => 1 | 0 | -1;
11
11
  };
12
12
  export default customSortFns;
13
13
  export type SortFnType = keyof typeof customSortFns | undefined;
@@ -0,0 +1,14 @@
1
+ import React from "react";
2
+ import { ExportOptions } from "./useTableExport";
3
+ import { TableMaxColumnType } from "../../type";
4
+ type ExportProps = {
5
+ tableTitle?: string;
6
+ canExport: boolean;
7
+ columns: TableMaxColumnType[];
8
+ datas: any[];
9
+ exportConfig?: ExportOptions;
10
+ hasTotalRow?: boolean;
11
+ totalDatas?: any[];
12
+ };
13
+ export declare const ExportTableData: React.NamedExoticComponent<ExportProps>;
14
+ export {};
@@ -0,0 +1,56 @@
1
+ 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); }
2
+ 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; }
3
+ 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; }
4
+ 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; }
5
+ 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; }
6
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
7
+ 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); }
8
+ 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); } }
9
+ 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); }); }; }
10
+ import { Spin, Tooltip } from "antd";
11
+ import React, { useCallback } from "react";
12
+ import { useTableExport } from "./useTableExport";
13
+ import { jsx as _jsx } from "react/jsx-runtime";
14
+ import { Fragment as _Fragment } from "react/jsx-runtime";
15
+ var ExportComp = function ExportComp(_ref) {
16
+ var tableTitle = _ref.tableTitle,
17
+ canExport = _ref.canExport,
18
+ columns = _ref.columns,
19
+ datas = _ref.datas,
20
+ exportConfig = _ref.exportConfig,
21
+ hasTotalRow = _ref.hasTotalRow,
22
+ totalDatas = _ref.totalDatas;
23
+ var _useTableExport = useTableExport(columns, hasTotalRow, totalDatas),
24
+ exporting = _useTableExport.exporting,
25
+ exportTableData = _useTableExport.exportTableData;
26
+ var handleExport = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
27
+ var _ref3, _exportConfig$fileNam;
28
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
29
+ while (1) switch (_context.prev = _context.next) {
30
+ case 0:
31
+ _context.next = 2;
32
+ return exportTableData(datas, _objectSpread(_objectSpread({}, exportConfig), {}, {
33
+ fileName: (_ref3 = (_exportConfig$fileNam = exportConfig.fileName) !== null && _exportConfig$fileNam !== void 0 ? _exportConfig$fileNam : tableTitle) !== null && _ref3 !== void 0 ? _ref3 : '数据导出'
34
+ }));
35
+ case 2:
36
+ case "end":
37
+ return _context.stop();
38
+ }
39
+ }, _callee);
40
+ })), [datas, tableTitle, exportConfig]);
41
+ return /*#__PURE__*/_jsx(_Fragment, {
42
+ children: canExport && /*#__PURE__*/_jsx(Tooltip, {
43
+ placement: "top",
44
+ title: '导出',
45
+ children: exporting ? /*#__PURE__*/_jsx(Spin, {}) : /*#__PURE__*/_jsx("i", {
46
+ className: "iconfont-table icon-table-download handleRightItem",
47
+ style: {
48
+ fontSize: '16px',
49
+ marginRight: 0
50
+ },
51
+ onClick: handleExport
52
+ })
53
+ })
54
+ });
55
+ };
56
+ export var ExportTableData = /*#__PURE__*/React.memo(ExportComp);
@@ -0,0 +1,30 @@
1
+ import { TableMaxColumnType } from '../../type';
2
+ interface TableColumnType {
3
+ header: string;
4
+ id: string;
5
+ accessorKey: string;
6
+ filterType?: any;
7
+ cell?: any;
8
+ accessorFn?: (originalRow: any) => any;
9
+ filterOptions?: Array<{
10
+ label: string;
11
+ value: any;
12
+ }>;
13
+ unitsChangeFn?: (value: number) => number;
14
+ }
15
+ export interface ExportOptions {
16
+ fileName?: string;
17
+ sheetName?: string;
18
+ applyCellLogic?: (value: any, columnId: string, originalRow: any, column: TableColumnType) => any;
19
+ /**是否导出合计行 */
20
+ isIncludeTotalRow?: boolean;
21
+ getExportDataList?: (params?: any) => Promise<any[]>;
22
+ }
23
+ /**
24
+ * 表格导出Hook - 专门适配你的列配置结构
25
+ */
26
+ export declare const useTableExport: (columns: TableMaxColumnType[], hasTotalRow?: boolean, totalDatas?: any[], options?: ExportOptions) => {
27
+ exporting: boolean;
28
+ exportTableData: (data: any[], customOptions: ExportOptions) => Promise<void>;
29
+ };
30
+ export {};
@@ -0,0 +1,202 @@
1
+ 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); }
2
+ 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; }
3
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
4
+ 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 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; }
6
+ 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; }
7
+ 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; }
8
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
9
+ 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); }
10
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
11
+ 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."); }
12
+ 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); }
13
+ 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; }
14
+ 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; } }
15
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
16
+ // hooks/useTableExport.ts
17
+ import { useCallback, useState } from 'react';
18
+ import * as XLSX from 'xlsx';
19
+ import { message } from 'antd';
20
+ import { ColumnType } from "../../TableMax";
21
+
22
+ // 类型定义
23
+
24
+ /**
25
+ * 表格导出Hook - 专门适配你的列配置结构
26
+ */
27
+ export var useTableExport = function useTableExport(columns, hasTotalRow, totalDatas) {
28
+ var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
29
+ var EnableExportColumnTypeList = [ColumnType.Selection, ColumnType.Darg, ColumnType.PlaceHolder, ColumnType.Expander];
30
+ var _useState = useState(false),
31
+ _useState2 = _slicedToArray(_useState, 2),
32
+ exporting = _useState2[0],
33
+ setExporting = _useState2[1];
34
+ var defaultOptions = _objectSpread({
35
+ fileName: '表格数据导出',
36
+ sheetName: 'Sheet1'
37
+ }, options);
38
+
39
+ /**
40
+ * 根据列配置处理数据
41
+ */
42
+ var processDataWithColumns = useCallback(function (data, includeTotal, applyCellLogic) {
43
+ if (!data || !Array.isArray(data)) return [];
44
+ return data.map(function (item, dataIndex) {
45
+ var processedItem = {};
46
+ var isTotalData = dataIndex === (data === null || data === void 0 ? void 0 : data.length) - 1 && includeTotal;
47
+ columns.filter(function (col) {
48
+ return !EnableExportColumnTypeList.includes(col === null || col === void 0 ? void 0 : col.id) && !(col !== null && col !== void 0 && col.disabledExport);
49
+ }).forEach(function (column, index) {
50
+ var header = column.header,
51
+ id = column.id,
52
+ accessorKey = column.accessorKey,
53
+ accessorFn = column.accessorFn,
54
+ cell = column.cell,
55
+ unitsChangeFn = column.unitsChangeFn;
56
+ var value;
57
+
58
+ // 1. 优先使用 accessorFn 获取值
59
+ if (!isTotalData && accessorFn) {
60
+ value = accessorFn(item, index);
61
+ }
62
+ // 2. 使用 accessorKey 获取值
63
+ else if (accessorKey) {
64
+ value = item[accessorKey];
65
+ }
66
+ // 3. 使用 id 获取值
67
+ else {
68
+ value = item[id];
69
+ }
70
+
71
+ // 4. 应用单元格渲染逻辑(转换为文本)
72
+ value = applyCellLogic ? applyCellLogic(value, id, item, column) : value;
73
+ processedItem[typeof header === "string" ? header : accessorKey !== null && accessorKey !== void 0 ? accessorKey : id] = value;
74
+ });
75
+ return processedItem;
76
+ });
77
+ }, [columns]);
78
+
79
+ /**
80
+ * 设置列宽
81
+ */
82
+ var setColumnWidths = useCallback(function (worksheet) {
83
+ if (!worksheet['!cols']) worksheet['!cols'] = [];
84
+ columns.forEach(function (column, index) {
85
+ var width = calculateColumnWidth(typeof column.header === 'string' ? column.header : '表格列宽');
86
+ worksheet['!cols'][index] = {
87
+ width: width
88
+ };
89
+ });
90
+ }, [columns]);
91
+
92
+ /**
93
+ * 计算列宽
94
+ */
95
+ var calculateColumnWidth = function calculateColumnWidth(header) {
96
+ var chineseCharCount = (header.match(/[^\x00-\xff]/g) || []).length;
97
+ var otherCharCount = header.length - chineseCharCount;
98
+ var width = chineseCharCount * 2 + otherCharCount * 1.1 + 4;
99
+ return Math.min(Math.max(width, 8), 50);
100
+ };
101
+
102
+ /**
103
+ * 主导出函数
104
+ */
105
+ var exportTableData = useCallback( /*#__PURE__*/function () {
106
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(data, customOptions) {
107
+ var _customOptions$isIncl, isIncludeTotalRow, exportData, finalOptions, processedData, workbook, worksheet, timestamp, exportFilename;
108
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
109
+ while (1) switch (_context.prev = _context.next) {
110
+ case 0:
111
+ _customOptions$isIncl = customOptions.isIncludeTotalRow, isIncludeTotalRow = _customOptions$isIncl === void 0 ? true : _customOptions$isIncl;
112
+ exportData = data;
113
+ if (!exporting) {
114
+ _context.next = 5;
115
+ break;
116
+ }
117
+ message.warning('已有导出任务在进行中');
118
+ return _context.abrupt("return");
119
+ case 5:
120
+ setExporting(true);
121
+ if (!customOptions.getExportDataList) {
122
+ _context.next = 10;
123
+ break;
124
+ }
125
+ _context.next = 9;
126
+ return customOptions.getExportDataList();
127
+ case 9:
128
+ exportData = _context.sent;
129
+ case 10:
130
+ if (isIncludeTotalRow && hasTotalRow) {
131
+ exportData.push(totalDatas);
132
+ }
133
+ try {
134
+ finalOptions = _objectSpread({}, customOptions); // 处理数据
135
+ processedData = processDataWithColumns(exportData, isIncludeTotalRow && hasTotalRow, customOptions === null || customOptions === void 0 ? void 0 : customOptions.applyCellLogic);
136
+ console.log(processedData, 'processedData');
137
+
138
+ // 创建工作簿
139
+ workbook = XLSX.utils.book_new();
140
+ worksheet = XLSX.utils.json_to_sheet(processedData); // 设置列宽
141
+ setColumnWidths(worksheet);
142
+
143
+ // 添加到工作簿
144
+ XLSX.utils.book_append_sheet(workbook, worksheet, finalOptions.sheetName);
145
+
146
+ // 生成文件名
147
+ timestamp = new Date().toISOString().slice(0, 10).replace(/-/g, '');
148
+ exportFilename = "".concat(finalOptions.fileName, "_").concat(timestamp, ".xlsx"); // 导出文件
149
+ XLSX.writeFile(workbook, exportFilename);
150
+ message.success("\u5BFC\u51FA\u6210\u529F: ".concat(exportFilename));
151
+ } catch (error) {
152
+ console.error('导出失败:', error);
153
+ message.error('导出失败,请重试');
154
+ } finally {
155
+ setExporting(false);
156
+ }
157
+ case 12:
158
+ case "end":
159
+ return _context.stop();
160
+ }
161
+ }, _callee);
162
+ }));
163
+ return function (_x, _x2) {
164
+ return _ref.apply(this, arguments);
165
+ };
166
+ }(), [exporting, processDataWithColumns, setColumnWidths, defaultOptions, hasTotalRow, totalDatas]);
167
+ return {
168
+ exporting: exporting,
169
+ exportTableData: exportTableData
170
+ };
171
+ };
172
+
173
+ // /**
174
+ // * 应用单元格逻辑转换为导出文本
175
+ // */
176
+ // const applyCellLogic = (value: any, columnId: string, originalRow: any, column: TableColumnType) => {
177
+ // switch (columnId) {
178
+ // case 'status':
179
+ // // 状态列:将状态码转换为文本
180
+ // const statusValue = originalRow.status as keyof typeof statusMap;
181
+ // return statusMap[statusValue]?.label || value;
182
+
183
+ // case 'ingot':
184
+ // // 吨位列:应用单位转换
185
+ // if (value === null || value === undefined) return '-';
186
+ // return convertUnitUp(value);
187
+
188
+ // case 'onlineTime':
189
+ // case 'setupTime':
190
+ // // 时间列:格式化日期
191
+ // return formatDate(value);
192
+
193
+ // case 'usageCount':
194
+ // case 'currentUsageCount':
195
+ // // 使用次数列:确保显示数字
196
+ // return value ?? 0;
197
+
198
+ // default:
199
+ // // 其他列:直接返回值或空字符串
200
+ // return value ?? '';
201
+ // }
202
+ // };
@@ -4,6 +4,7 @@ import { Dispatch, ReactNode, SetStateAction } from 'react';
4
4
  import { InputType } from './components/ColumnEdit';
5
5
  import { FilterFnType, FilterType } from './components/ColumnFilterV2';
6
6
  import { SortFnType } from './components/ColumnSort/customSortFns';
7
+ import { ExportOptions } from './components/Export/useTableExport';
7
8
  export type PrefixClsType = 'custom-light' | 'custom-dark';
8
9
  export declare enum DropSide {
9
10
  Top = "top",
@@ -158,6 +159,8 @@ export type TableMaxProps = {
158
159
  canSetting?: boolean;
159
160
  /**是否支持表头筛选(是否展示筛选开关),默认不支持 */
160
161
  canFilter?: boolean;
162
+ /**是否导出表格数据 */
163
+ canExport?: boolean;
161
164
  /**默认是否展示筛选组件(筛选开关默认状态), 默认不展示 */
162
165
  defaultEnableFilters?: boolean;
163
166
  /**表头默认展示文字行数,默认1行 */
@@ -325,6 +328,7 @@ export type TableMaxProps = {
325
328
  field: string;
326
329
  opera: any;
327
330
  }, field: string, value: any) => Promise<any>;
331
+ exportConfig?: ExportOptions;
328
332
  };
329
333
  export interface TableMaxColumnType {
330
334
  /**每一列的id是唯一的 */
@@ -415,6 +419,8 @@ export interface TableMaxColumnType {
415
419
  };
416
420
  /** 是否缓存行单元格 */
417
421
  openMemo?: boolean;
422
+ /**禁止导出 */
423
+ disabledExport?: boolean;
418
424
  }
419
425
  export type FormatFilterType = {
420
426
  field: string;
@@ -9,6 +9,8 @@ import { cloneDeep } from 'lodash';
9
9
  // import request from '../../utils/request';
10
10
  import { FilterType, defaultDateFormat } from "./components/ColumnFilterV2";
11
11
  import { FilterOperator } from "./type";
12
+ /**导出xlsx */
13
+
12
14
  export var noValue = function noValue(value) {
13
15
  return value === undefined || value === null || value === '';
14
16
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arim-aisdc/public-components",
3
- "version": "2.3.40",
3
+ "version": "2.3.42",
4
4
  "description": "前端组件库",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -55,6 +55,7 @@
55
55
  "css-vars-ponyfill": "^2.4.8",
56
56
  "dayjs": "^1.11.11",
57
57
  "dumi": "^2.2.13",
58
+ "file-saver": "^2.0.5",
58
59
  "fs": "^0.0.1-security",
59
60
  "immer": "^10.0.3",
60
61
  "jsep": "^1.3.8",
@@ -70,7 +71,8 @@
70
71
  "react-resizable": "^3.0.5",
71
72
  "react-rnd": "^10.5.2",
72
73
  "react-router-dom": "^6.22.3",
73
- "react-split-pane": "^0.1.92"
74
+ "react-split-pane": "^0.1.92",
75
+ "xlsx": "^0.18.5"
74
76
  },
75
77
  "devDependencies": {
76
78
  "@commitlint/cli": "^17.1.2",