@fle-ui/plus-table 1.2.28-beta.1 → 1.2.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/es/{FormSearch → components/FormSearch}/FormRender.d.ts +1 -1
  2. package/es/{FormSearch → components/FormSearch}/FormRender.js +1 -2
  3. package/es/{FormSearch → components/FormSearch}/index.js +0 -8
  4. package/es/{FormSearch → components/FormSearch}/index.less +0 -3
  5. package/es/index.d.ts +4 -3
  6. package/es/index.js +425 -345
  7. package/es/mock/list.json +720 -0
  8. package/es/utils/common.d.ts +0 -10
  9. package/es/utils/common.js +0 -5
  10. package/lib/{FormSearch → components/FormSearch}/FormRender.d.ts +1 -1
  11. package/lib/{FormSearch → components/FormSearch}/FormRender.js +3 -4
  12. package/lib/{FormSearch → components/FormSearch}/index.js +0 -8
  13. package/lib/{FormSearch → components/FormSearch}/index.less +0 -3
  14. package/lib/index.d.ts +4 -3
  15. package/lib/index.js +422 -344
  16. package/lib/mock/list.json +720 -0
  17. package/lib/utils/common.d.ts +0 -10
  18. package/lib/utils/common.js +1 -7
  19. package/package.json +6 -6
  20. package/es/components/icon/index.d.ts +0 -3
  21. package/es/components/icon/index.js +0 -7
  22. package/es/json/columnKeys.d.ts +0 -15
  23. package/es/json/columnKeys.js +0 -182
  24. package/es/json/list.d.ts +0 -1365
  25. package/es/json/list.js +0 -1388
  26. package/lib/components/icon/index.d.ts +0 -3
  27. package/lib/components/icon/index.js +0 -13
  28. package/lib/json/columnKeys.d.ts +0 -15
  29. package/lib/json/columnKeys.js +0 -188
  30. package/lib/json/list.d.ts +0 -1365
  31. package/lib/json/list.js +0 -1394
  32. /package/es/{FormSearch → components/FormSearch}/index.d.ts +0 -0
  33. /package/lib/{FormSearch → components/FormSearch}/index.d.ts +0 -0
package/es/index.js CHANGED
@@ -1,10 +1,12 @@
1
+ import "antd/es/config-provider/style";
2
+ import _ConfigProvider from "antd/es/config-provider";
1
3
  import "antd/es/drawer/style";
2
4
  import _Drawer from "antd/es/drawer";
3
5
  import "antd/es/checkbox/style";
4
6
  import _Checkbox from "antd/es/checkbox";
5
7
  import "antd/es/button/style";
6
8
  import _Button from "antd/es/button";
7
- var _excluded = ["columns", "hasShowFull", "request", "pagination", "formRef", "actionRef", "defaultColumnsState", "options", "action", "showDefaultSetting"];
9
+ var _excluded = ["columns", "hasShowFull", "request", "pagination", "formRef", "actionRef", "defaultColumnsState", "options", "action", "search", "showDefaultSetting"];
8
10
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
9
11
  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); }
10
12
  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 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 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 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; }
@@ -23,14 +25,28 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
23
25
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
24
26
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
25
27
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } } return target; }
26
- import React, { useEffect, useRef, useState, useImperativeHandle } from 'react';
28
+ import React, { useEffect, useRef, useState, useImperativeHandle, useCallback, useMemo } from 'react';
27
29
  import { ProTable } from '@ant-design/pro-components';
28
- import FormRender from './FormSearch/index';
30
+ import FormRender from './components/FormSearch/index';
29
31
  import { BarsOutlined } from '@ant-design/icons';
30
32
  import { simulateClick } from './utils/common';
31
- import './FormSearch/index.less';
33
+ import './components/FormSearch/index.less';
34
+ // 常量定义
35
+ var CONSTANTS = {
36
+ DRAWER_WIDTH: 380,
37
+ DEFAULT_TOP: 92,
38
+ RELOAD_DELAY: 100,
39
+ SEARCH_SPAN: {
40
+ xs: 12,
41
+ sm: 12,
42
+ md: 12,
43
+ lg: 12,
44
+ xl: 8,
45
+ xxl: 6
46
+ },
47
+ LABEL_WIDTH: 80
48
+ };
32
49
  function PlusTable(props, ref) {
33
- var _otherProps$scroll;
34
50
  var columns = props.columns,
35
51
  _props$hasShowFull = props.hasShowFull,
36
52
  hasShowFull = _props$hasShowFull === void 0 ? true : _props$hasShowFull,
@@ -42,6 +58,7 @@ function PlusTable(props, ref) {
42
58
  _props$options = props.options,
43
59
  options = _props$options === void 0 ? {} : _props$options,
44
60
  action = props.action,
61
+ search = props.search,
45
62
  _props$showDefaultSet = props.showDefaultSetting,
46
63
  showDefaultSetting = _props$showDefaultSet === void 0 ? true : _props$showDefaultSet,
47
64
  otherProps = _objectWithoutProperties(props, _excluded);
@@ -50,7 +67,7 @@ function PlusTable(props, ref) {
50
67
  _useState2 = _slicedToArray(_useState, 2),
51
68
  searchDrawer = _useState2[0],
52
69
  setSearchDrawer = _useState2[1];
53
- var _useState3 = useState(false),
70
+ var _useState3 = useState(props.defaultShowFull || false),
54
71
  _useState4 = _slicedToArray(_useState3, 2),
55
72
  showFull = _useState4[0],
56
73
  setShowFull = _useState4[1];
@@ -59,305 +76,401 @@ function PlusTable(props, ref) {
59
76
  _useState6 = _slicedToArray(_useState5, 2),
60
77
  columnsStateMap = _useState6[0],
61
78
  setColumnsStateMap = _useState6[1];
79
+ var _useState7 = useState(false),
80
+ _useState8 = _slicedToArray(_useState7, 2),
81
+ isLoading = _useState8[0],
82
+ setIsLoading = _useState8[1];
62
83
  var actionRef = useRef();
63
84
  useImperativeHandle(propsActionRef, function () {
64
85
  return actionRef.current;
65
86
  });
66
- useImperativeHandle(ref, function () {
67
- return {
68
- getFieldsValue: function () {
69
- var _getFieldsValue = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
70
- var _searchRef$current, _drawFormRef$current;
71
- var res1, res2, res;
72
- return _regeneratorRuntime().wrap(function _callee$(_context) {
73
- while (1) switch (_context.prev = _context.next) {
74
- case 0:
75
- _context.next = 2;
76
- return searchRef === null || searchRef === void 0 ? void 0 : (_searchRef$current = searchRef.current) === null || _searchRef$current === void 0 ? void 0 : _searchRef$current.getFieldsValue();
77
- case 2:
78
- res1 = _context.sent;
79
- _context.next = 5;
80
- return drawFormRef === null || drawFormRef === void 0 ? void 0 : (_drawFormRef$current = drawFormRef.current) === null || _drawFormRef$current === void 0 ? void 0 : _drawFormRef$current.getFieldsValue();
81
- case 5:
82
- res2 = _context.sent;
83
- res = _objectSpread(_objectSpread({}, dealFetchParams(_objectSpread(_objectSpread({}, res1), res2))), {}, {
84
- showFull: showFull
85
- });
86
- return _context.abrupt("return", res);
87
- case 8:
88
- case "end":
89
- return _context.stop();
90
- }
91
- }, _callee);
92
- }));
93
- function getFieldsValue() {
94
- return _getFieldsValue.apply(this, arguments);
95
- }
96
- return getFieldsValue;
97
- }(),
98
- setFiledsValue: function () {
99
- var _setFiledsValue = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(params) {
100
- var _searchRef$current2, _drawFormRef$current2;
101
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
102
- while (1) switch (_context2.prev = _context2.next) {
103
- case 0:
104
- _context2.next = 2;
105
- return searchRef === null || searchRef === void 0 ? void 0 : (_searchRef$current2 = searchRef.current) === null || _searchRef$current2 === void 0 ? void 0 : _searchRef$current2.setFieldsValue(params);
106
- case 2:
107
- _context2.next = 4;
108
- return drawFormRef === null || drawFormRef === void 0 ? void 0 : (_drawFormRef$current2 = drawFormRef.current) === null || _drawFormRef$current2 === void 0 ? void 0 : _drawFormRef$current2.setFieldsValue(params);
109
- case 4:
110
- case "end":
111
- return _context2.stop();
112
- }
113
- }, _callee2);
114
- }));
115
- function setFiledsValue(_x) {
116
- return _setFiledsValue.apply(this, arguments);
117
- }
118
- return setFiledsValue;
119
- }(),
120
- setFiledValue: function () {
121
- var _setFiledValue = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(key, value) {
122
- var _searchRef$current3, _drawFormRef$current3;
123
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
124
- while (1) switch (_context3.prev = _context3.next) {
125
- case 0:
126
- _context3.next = 2;
127
- return searchRef === null || searchRef === void 0 ? void 0 : (_searchRef$current3 = searchRef.current) === null || _searchRef$current3 === void 0 ? void 0 : _searchRef$current3.setFieldValue(key, value);
128
- case 2:
129
- _context3.next = 4;
130
- return drawFormRef === null || drawFormRef === void 0 ? void 0 : (_drawFormRef$current3 = drawFormRef.current) === null || _drawFormRef$current3 === void 0 ? void 0 : _drawFormRef$current3.setFieldValue(key, value);
131
- case 4:
132
- case "end":
133
- return _context3.stop();
134
- }
135
- }, _callee3);
136
- }));
137
- function setFiledValue(_x2, _x3) {
138
- return _setFiledValue.apply(this, arguments);
139
- }
140
- return setFiledValue;
141
- }()
142
- };
143
- });
144
- var handleOnChangeColumn = function handleOnChangeColumn(map) {
145
- // 列设置更新
146
- setColumnsStateMap(function (columnsStateMap) {
147
- var newObj = {};
148
- for (var key in map) {
149
- newObj[key] = _objectSpread(_objectSpread({}, columnsStateMap[key]), map[key]);
87
+ // 优化:使用 useCallback 避免重复创建函数
88
+ var getFieldsValue = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
89
+ var _searchRef$current, _drawFormRef$current, res1, res2;
90
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
91
+ while (1) switch (_context.prev = _context.next) {
92
+ case 0:
93
+ _context.prev = 0;
94
+ _context.next = 3;
95
+ return searchRef === null || searchRef === void 0 ? void 0 : (_searchRef$current = searchRef.current) === null || _searchRef$current === void 0 ? void 0 : _searchRef$current.getFieldsValue();
96
+ case 3:
97
+ res1 = _context.sent;
98
+ _context.next = 6;
99
+ return drawFormRef === null || drawFormRef === void 0 ? void 0 : (_drawFormRef$current = drawFormRef.current) === null || _drawFormRef$current === void 0 ? void 0 : _drawFormRef$current.getFieldsValue();
100
+ case 6:
101
+ res2 = _context.sent;
102
+ return _context.abrupt("return", _objectSpread(_objectSpread({}, dealFetchParams(_objectSpread(_objectSpread({}, res1), res2))), {}, {
103
+ showFull: showFull
104
+ }));
105
+ case 10:
106
+ _context.prev = 10;
107
+ _context.t0 = _context["catch"](0);
108
+ console.error('获取字段值失败:', _context.t0);
109
+ return _context.abrupt("return", {});
110
+ case 14:
111
+ case "end":
112
+ return _context.stop();
150
113
  }
151
- return newObj;
152
- });
153
- };
154
- var handleSave = /*#__PURE__*/function () {
155
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
156
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
157
- while (1) switch (_context4.prev = _context4.next) {
114
+ }, _callee, null, [[0, 10]]);
115
+ })), [showFull]);
116
+ var setFiledsValue = useCallback( /*#__PURE__*/function () {
117
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(params) {
118
+ var _searchRef$current2, _drawFormRef$current2;
119
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
120
+ while (1) switch (_context2.prev = _context2.next) {
158
121
  case 0:
159
- if (!props.updateSetting) {
160
- _context4.next = 4;
161
- break;
162
- }
163
- _context4.next = 3;
164
- return props.updateSetting(columnsStateMap);
122
+ _context2.prev = 0;
123
+ _context2.next = 3;
124
+ return Promise.all([searchRef === null || searchRef === void 0 ? void 0 : (_searchRef$current2 = searchRef.current) === null || _searchRef$current2 === void 0 ? void 0 : _searchRef$current2.setFieldsValue(params), drawFormRef === null || drawFormRef === void 0 ? void 0 : (_drawFormRef$current2 = drawFormRef.current) === null || _drawFormRef$current2 === void 0 ? void 0 : _drawFormRef$current2.setFieldsValue(params)]);
165
125
  case 3:
166
- simulateClick();
167
- case 4:
168
- case "end":
169
- return _context4.stop();
170
- }
171
- }, _callee4);
172
- }));
173
- return function handleSave() {
174
- return _ref.apply(this, arguments);
175
- };
176
- }();
177
- var handleReset = /*#__PURE__*/function () {
178
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
179
- var _props$resetSetting;
180
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
181
- while (1) switch (_context5.prev = _context5.next) {
182
- case 0:
183
- return _context5.abrupt("return", (_props$resetSetting = props.resetSetting) === null || _props$resetSetting === void 0 ? void 0 : _props$resetSetting.call(props).then(function (res) {
184
- res.success && init();
185
- }));
186
- case 1:
126
+ _context2.next = 8;
127
+ break;
128
+ case 5:
129
+ _context2.prev = 5;
130
+ _context2.t0 = _context2["catch"](0);
131
+ console.error('设置字段值失败:', _context2.t0);
132
+ case 8:
187
133
  case "end":
188
- return _context5.stop();
134
+ return _context2.stop();
189
135
  }
190
- }, _callee5);
136
+ }, _callee2, null, [[0, 5]]);
191
137
  }));
192
- return function handleReset() {
138
+ return function (_x) {
193
139
  return _ref2.apply(this, arguments);
194
140
  };
195
- }();
196
- var init = /*#__PURE__*/function () {
197
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
198
- var _props$fetchSetting, res;
199
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
200
- while (1) switch (_context6.prev = _context6.next) {
141
+ }(), []);
142
+ var setFiledValue = useCallback( /*#__PURE__*/function () {
143
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(key, value) {
144
+ var _searchRef$current3, _drawFormRef$current3;
145
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
146
+ while (1) switch (_context3.prev = _context3.next) {
201
147
  case 0:
202
- if (!props.fetchSetting) {
203
- _context6.next = 5;
204
- break;
205
- }
206
- _context6.next = 3;
207
- return (_props$fetchSetting = props.fetchSetting) === null || _props$fetchSetting === void 0 ? void 0 : _props$fetchSetting.call(props);
148
+ _context3.prev = 0;
149
+ _context3.next = 3;
150
+ return Promise.all([searchRef === null || searchRef === void 0 ? void 0 : (_searchRef$current3 = searchRef.current) === null || _searchRef$current3 === void 0 ? void 0 : _searchRef$current3.setFieldValue(key, value), drawFormRef === null || drawFormRef === void 0 ? void 0 : (_drawFormRef$current3 = drawFormRef.current) === null || _drawFormRef$current3 === void 0 ? void 0 : _drawFormRef$current3.setFieldValue(key, value)]);
208
151
  case 3:
209
- res = _context6.sent;
210
- setColumnsStateMap(res);
152
+ _context3.next = 8;
153
+ break;
211
154
  case 5:
155
+ _context3.prev = 5;
156
+ _context3.t0 = _context3["catch"](0);
157
+ console.error('设置字段值失败:', _context3.t0);
158
+ case 8:
212
159
  case "end":
213
- return _context6.stop();
160
+ return _context3.stop();
214
161
  }
215
- }, _callee6);
162
+ }, _callee3, null, [[0, 5]]);
216
163
  }));
217
- return function init() {
164
+ return function (_x2, _x3) {
218
165
  return _ref3.apply(this, arguments);
219
166
  };
220
- }();
221
- var onValuesChange = function onValuesChange(changeValue, allValue) {
222
- var _drawFormRef$current4, _searchRef$current4;
223
- drawFormRef === null || drawFormRef === void 0 ? void 0 : (_drawFormRef$current4 = drawFormRef.current) === null || _drawFormRef$current4 === void 0 ? void 0 : _drawFormRef$current4.setFieldsValue(allValue);
224
- searchRef === null || searchRef === void 0 ? void 0 : (_searchRef$current4 = searchRef.current) === null || _searchRef$current4 === void 0 ? void 0 : _searchRef$current4.setFieldsValue(allValue);
225
- };
226
- var handleSearchAll = /*#__PURE__*/function () {
227
- var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(searchConfig) {
228
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
229
- while (1) switch (_context7.prev = _context7.next) {
167
+ }(), []);
168
+ useImperativeHandle(ref, function () {
169
+ return {
170
+ getFieldsValue: getFieldsValue,
171
+ setFiledsValue: setFiledsValue,
172
+ setFiledValue: setFiledValue
173
+ };
174
+ });
175
+ // 优化:使用 useCallback 避免重复创建函数
176
+ var handleOnChangeColumn = useCallback(function (map) {
177
+ setColumnsStateMap(function (prevState) {
178
+ var newObj = {};
179
+ for (var key in map) {
180
+ if (Object.prototype.hasOwnProperty.call(map, key)) {
181
+ newObj[key] = _objectSpread(_objectSpread({}, prevState[key]), map[key]);
182
+ }
183
+ }
184
+ return newObj;
185
+ });
186
+ }, []);
187
+ var handleSave = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
188
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
189
+ while (1) switch (_context4.prev = _context4.next) {
190
+ case 0:
191
+ if (!props.updateSetting) {
192
+ _context4.next = 14;
193
+ break;
194
+ }
195
+ _context4.prev = 1;
196
+ setIsLoading(true);
197
+ _context4.next = 5;
198
+ return props.updateSetting(columnsStateMap);
199
+ case 5:
200
+ simulateClick();
201
+ _context4.next = 11;
202
+ break;
203
+ case 8:
204
+ _context4.prev = 8;
205
+ _context4.t0 = _context4["catch"](1);
206
+ console.error('保存列设置失败:', _context4.t0);
207
+ case 11:
208
+ _context4.prev = 11;
209
+ setIsLoading(false);
210
+ return _context4.finish(11);
211
+ case 14:
212
+ case "end":
213
+ return _context4.stop();
214
+ }
215
+ }, _callee4, null, [[1, 8, 11, 14]]);
216
+ })), [props.updateSetting, columnsStateMap]);
217
+ var handleReset = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
218
+ var _props$resetSetting, res, fetchRes;
219
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
220
+ while (1) switch (_context5.prev = _context5.next) {
221
+ case 0:
222
+ _context5.prev = 0;
223
+ _context5.next = 3;
224
+ return (_props$resetSetting = props.resetSetting) === null || _props$resetSetting === void 0 ? void 0 : _props$resetSetting.call(props);
225
+ case 3:
226
+ res = _context5.sent;
227
+ if (!((res === null || res === void 0 ? void 0 : res.success) && props.fetchSetting)) {
228
+ _context5.next = 9;
229
+ break;
230
+ }
231
+ _context5.next = 7;
232
+ return props.fetchSetting();
233
+ case 7:
234
+ fetchRes = _context5.sent;
235
+ setColumnsStateMap(fetchRes);
236
+ case 9:
237
+ _context5.next = 14;
238
+ break;
239
+ case 11:
240
+ _context5.prev = 11;
241
+ _context5.t0 = _context5["catch"](0);
242
+ console.error('重置列设置失败:', _context5.t0);
243
+ case 14:
244
+ case "end":
245
+ return _context5.stop();
246
+ }
247
+ }, _callee5, null, [[0, 11]]);
248
+ })), [props.resetSetting, props.fetchSetting]);
249
+ var onValuesChange = useCallback(function (changeValue, allValue) {
250
+ try {
251
+ var _drawFormRef$current4;
252
+ var currentValues = (_drawFormRef$current4 = drawFormRef.current) === null || _drawFormRef$current4 === void 0 ? void 0 : _drawFormRef$current4.getFieldsValue();
253
+ if (currentValues) {
254
+ var _searchRef$current4;
255
+ searchRef === null || searchRef === void 0 ? void 0 : (_searchRef$current4 = searchRef.current) === null || _searchRef$current4 === void 0 ? void 0 : _searchRef$current4.setFieldsValue(currentValues);
256
+ }
257
+ } catch (error) {
258
+ console.error('同步表单值失败:', error);
259
+ }
260
+ }, []);
261
+ var handleSearchAll = useCallback( /*#__PURE__*/function () {
262
+ var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(searchConfig) {
263
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
264
+ while (1) switch (_context6.prev = _context6.next) {
230
265
  case 0:
231
- searchConfig.form.submit();
266
+ try {
267
+ searchConfig.form.submit();
268
+ } catch (error) {
269
+ console.error('搜索失败:', error);
270
+ }
232
271
  case 1:
233
272
  case "end":
234
- return _context7.stop();
273
+ return _context6.stop();
235
274
  }
236
- }, _callee7);
275
+ }, _callee6);
237
276
  }));
238
- return function handleSearchAll(_x4) {
239
- return _ref4.apply(this, arguments);
277
+ return function (_x4) {
278
+ return _ref6.apply(this, arguments);
240
279
  };
241
- }();
242
- useEffect(function () {
243
- init();
280
+ }(), []);
281
+ var handleShowFullChange = useCallback(function (e) {
282
+ setShowFull(e.target.checked);
283
+ // 优化:使用 requestAnimationFrame 替代 setTimeout
284
+ requestAnimationFrame(function () {
285
+ var _actionRef$current, _actionRef$current$re;
286
+ (_actionRef$current = actionRef.current) === null || _actionRef$current === void 0 ? void 0 : (_actionRef$current$re = _actionRef$current.reload) === null || _actionRef$current$re === void 0 ? void 0 : _actionRef$current$re.call(_actionRef$current);
287
+ });
244
288
  }, []);
245
- var dealFetchParams = function dealFetchParams(params) {
246
- // 处理transform中的函数处理
289
+ var handleAdvancedFilterClick = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
290
+ var newDrawerState, _searchRef$current5, _drawFormRef$current5, fieldsValue;
291
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
292
+ while (1) switch (_context7.prev = _context7.next) {
293
+ case 0:
294
+ _context7.prev = 0;
295
+ newDrawerState = !searchDrawer;
296
+ setSearchDrawer(newDrawerState);
297
+ if (!newDrawerState) {
298
+ _context7.next = 8;
299
+ break;
300
+ }
301
+ _context7.next = 6;
302
+ return searchRef === null || searchRef === void 0 ? void 0 : (_searchRef$current5 = searchRef.current) === null || _searchRef$current5 === void 0 ? void 0 : _searchRef$current5.getFieldsValue();
303
+ case 6:
304
+ fieldsValue = _context7.sent;
305
+ drawFormRef === null || drawFormRef === void 0 ? void 0 : (_drawFormRef$current5 = drawFormRef.current) === null || _drawFormRef$current5 === void 0 ? void 0 : _drawFormRef$current5.setFieldsValue(fieldsValue);
306
+ case 8:
307
+ _context7.next = 13;
308
+ break;
309
+ case 10:
310
+ _context7.prev = 10;
311
+ _context7.t0 = _context7["catch"](0);
312
+ console.error('切换高级筛选失败:', _context7.t0);
313
+ case 13:
314
+ case "end":
315
+ return _context7.stop();
316
+ }
317
+ }, _callee7, null, [[0, 10]]);
318
+ })), [searchDrawer]);
319
+ var handleResetForm = useCallback(function () {
320
+ try {
321
+ var _drawFormRef$current6, _actionRef$current2, _actionRef$current2$r, _actionRef$current3, _actionRef$current3$r;
322
+ drawFormRef === null || drawFormRef === void 0 ? void 0 : (_drawFormRef$current6 = drawFormRef.current) === null || _drawFormRef$current6 === void 0 ? void 0 : _drawFormRef$current6.resetFields();
323
+ actionRef === null || actionRef === void 0 ? void 0 : (_actionRef$current2 = actionRef.current) === null || _actionRef$current2 === void 0 ? void 0 : (_actionRef$current2$r = _actionRef$current2.reset) === null || _actionRef$current2$r === void 0 ? void 0 : _actionRef$current2$r.call(_actionRef$current2);
324
+ actionRef === null || actionRef === void 0 ? void 0 : (_actionRef$current3 = actionRef.current) === null || _actionRef$current3 === void 0 ? void 0 : (_actionRef$current3$r = _actionRef$current3.reload) === null || _actionRef$current3$r === void 0 ? void 0 : _actionRef$current3$r.call(_actionRef$current3);
325
+ } catch (error) {
326
+ console.error('重置表单失败:', error);
327
+ }
328
+ }, []);
329
+ // 修复死循环:只在组件挂载时执行一次,不依赖 init 函数
330
+ useEffect(function () {
331
+ // 组件挂载时执行一次初始化
332
+ if (props.fetchSetting) {
333
+ props.fetchSetting().then(function (res) {
334
+ setColumnsStateMap(res);
335
+ }).catch(function (error) {
336
+ console.error('获取列设置失败:', error);
337
+ });
338
+ }
339
+ }, []); // 空依赖数组,只在挂载时执行一次
340
+ // 优化:使用 useMemo 缓存计算结果
341
+ var dealFetchParams = useCallback(function (params) {
247
342
  var fetchParams = {};
248
343
  columns.forEach(function (item) {
249
- var _item$search;
250
- if ((item === null || item === void 0 ? void 0 : (_item$search = item.search) === null || _item$search === void 0 ? void 0 : _item$search.transform) && params[item.dataIndex]) {
251
- fetchParams = _objectSpread(_objectSpread({}, fetchParams), item.search.transform(params[item.dataIndex]));
344
+ var dataIndex = item.dataIndex;
345
+ if ((item === null || item === void 0 ? void 0 : item.search) && _typeof(item.search) === 'object' && item.search.transform && params[dataIndex]) {
346
+ var transformResult = item.search.transform(params[dataIndex], dataIndex, params);
347
+ if (transformResult && _typeof(transformResult) === 'object') {
348
+ Object.assign(fetchParams, transformResult);
349
+ }
252
350
  } else {
253
- fetchParams = _objectSpread(_objectSpread({}, fetchParams), {}, _defineProperty({}, item.dataIndex, params[item.dataIndex]));
351
+ fetchParams[dataIndex] = params[dataIndex];
254
352
  }
255
353
  });
256
354
  return fetchParams;
257
- };
258
- var columnsState = {
259
- //列设置
260
- defaultValue: defaultColumnsState,
261
- value: columnsStateMap,
262
- onChange: handleOnChangeColumn //列状态的值发生改变之后触发
263
- };
264
- var propsRequest = /*#__PURE__*/function () {
265
- var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(params, sort, filter) {
266
- var _searchRef$current5, _drawFormRef$current5;
267
- var res1, res2, key, res;
355
+ }, [columns]);
356
+ // 优化:使用 useMemo 缓存列状态配置
357
+ var columnsState = useMemo(function () {
358
+ return {
359
+ defaultValue: defaultColumnsState,
360
+ value: columnsStateMap,
361
+ onChange: handleOnChangeColumn
362
+ };
363
+ }, [defaultColumnsState, columnsStateMap, handleOnChangeColumn]);
364
+ // 优化:使用 useCallback 缓存请求函数
365
+ var propsRequest = useCallback( /*#__PURE__*/function () {
366
+ var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(params, sort, filter) {
367
+ var _searchRef$current6, _drawFormRef$current7, res1, res2;
268
368
  return _regeneratorRuntime().wrap(function _callee8$(_context8) {
269
369
  while (1) switch (_context8.prev = _context8.next) {
270
370
  case 0:
271
- _context8.next = 2;
272
- return searchRef === null || searchRef === void 0 ? void 0 : (_searchRef$current5 = searchRef.current) === null || _searchRef$current5 === void 0 ? void 0 : _searchRef$current5.getFieldsValue();
273
- case 2:
371
+ _context8.prev = 0;
372
+ _context8.next = 3;
373
+ return searchRef === null || searchRef === void 0 ? void 0 : (_searchRef$current6 = searchRef.current) === null || _searchRef$current6 === void 0 ? void 0 : _searchRef$current6.getFieldsValue();
374
+ case 3:
274
375
  res1 = _context8.sent;
275
- _context8.next = 5;
276
- return drawFormRef === null || drawFormRef === void 0 ? void 0 : (_drawFormRef$current5 = drawFormRef.current) === null || _drawFormRef$current5 === void 0 ? void 0 : _drawFormRef$current5.getFieldsValue();
277
- case 5:
376
+ _context8.next = 6;
377
+ return drawFormRef === null || drawFormRef === void 0 ? void 0 : (_drawFormRef$current7 = drawFormRef.current) === null || _drawFormRef$current7 === void 0 ? void 0 : _drawFormRef$current7.getFieldsValue();
378
+ case 6:
278
379
  res2 = _context8.sent;
279
- for (key in res2) {
280
- if (Object.hasOwn(res2, key)) {
281
- if (!res2[key]) {
282
- res1[key] = undefined;
283
- params[key] = undefined;
284
- }
285
- }
286
- }
287
- if (!request) {
288
- _context8.next = 13;
380
+ if (request) {
381
+ _context8.next = 9;
289
382
  break;
290
383
  }
291
- _context8.next = 10;
384
+ return _context8.abrupt("return", {});
385
+ case 9:
386
+ _context8.next = 11;
292
387
  return request(_objectSpread(_objectSpread(_objectSpread({}, params), dealFetchParams(_objectSpread(_objectSpread(_objectSpread({}, res1), res2), params))), {}, {
293
388
  showFull: showFull
294
389
  }), sort, filter);
295
- case 10:
296
- _context8.t0 = _context8.sent;
297
- _context8.next = 14;
298
- break;
299
- case 13:
300
- _context8.t0 = {};
390
+ case 11:
391
+ return _context8.abrupt("return", _context8.sent);
301
392
  case 14:
302
- res = _context8.t0;
303
- return _context8.abrupt("return", res);
304
- case 16:
393
+ _context8.prev = 14;
394
+ _context8.t0 = _context8["catch"](0);
395
+ console.error('请求数据失败:', _context8.t0);
396
+ return _context8.abrupt("return", {});
397
+ case 18:
305
398
  case "end":
306
399
  return _context8.stop();
307
400
  }
308
- }, _callee8);
401
+ }, _callee8, null, [[0, 14]]);
309
402
  }));
310
- return function propsRequest(_x5, _x6, _x7) {
311
- return _ref5.apply(this, arguments);
403
+ return function (_x5, _x6, _x7) {
404
+ return _ref8.apply(this, arguments);
312
405
  };
313
- }();
314
- var optionsSetting = _typeof(options) === 'object' && _typeof(options.setting) === 'object' ? options.setting : {};
315
- var __options = (action === null || action === void 0 ? void 0 : action.includes('columnSetting')) && showDefaultSetting !== true ? _objectSpread(_objectSpread({}, options), {}, {
316
- setting: _objectSpread(_objectSpread({}, optionsSetting), {}, {
317
- checkedReset: false,
318
- showListItemOption: true,
319
- extra: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("a", {
320
- onClick: function onClick() {
321
- return handleSave();
322
- }
323
- }, "\u4FDD\u5B58"), /*#__PURE__*/React.createElement("a", {
324
- style: {
325
- color: '#333'
326
- },
327
- onClick: function onClick() {
328
- return handleReset();
329
- }
330
- }, "\u91CD\u7F6E"))
331
- })
332
- }) : options;
333
- return /*#__PURE__*/React.createElement("div", {
334
- className: "page_plustable__body"
335
- }, /*#__PURE__*/React.createElement(ProTable, _extends({
336
- scroll: {
337
- x: (otherProps === null || otherProps === void 0 ? void 0 : (_otherProps$scroll = otherProps.scroll) === null || _otherProps$scroll === void 0 ? void 0 : _otherProps$scroll.x) || 1300
406
+ }(), [request, dealFetchParams, showFull]);
407
+ // 优化:使用 useMemo 缓存选项配置
408
+ var __options = useMemo(function () {
409
+ var optionsSetting = _typeof(options) === 'object' && _typeof(options.setting) === 'object' ? options.setting : {};
410
+ console.log(action === null || action === void 0 ? void 0 : action.includes('columnSetting'), showDefaultSetting !== true);
411
+ if ((action === null || action === void 0 ? void 0 : action.includes('columnSetting')) && showDefaultSetting !== true) {
412
+ return _objectSpread(_objectSpread({}, options), {}, {
413
+ setting: _objectSpread(_objectSpread({}, optionsSetting), {}, {
414
+ checkedReset: false,
415
+ showListItemOption: true,
416
+ extra: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("a", {
417
+ onClick: handleSave,
418
+ style: {
419
+ cursor: isLoading ? 'not-allowed' : 'pointer',
420
+ opacity: isLoading ? 0.6 : 1,
421
+ pointerEvents: isLoading ? 'none' : 'auto'
422
+ }
423
+ }, isLoading ? '保存中...' : '保存'), /*#__PURE__*/React.createElement("a", {
424
+ style: {
425
+ color: '#333'
426
+ },
427
+ onClick: handleReset
428
+ }, "\u91CD\u7F6E"))
429
+ })
430
+ });
338
431
  }
339
- // 公共配置 大家都有的
340
- ,
341
- pagination: _objectSpread({
342
- size: 'default'
343
- }, pagination),
344
- actionRef: actionRef,
345
- formRef: searchRef
346
- // 根据用户自定义的配置 如果配置了高级筛选就有这个配置
347
- ,
348
- search: (action === null || action === void 0 ? void 0 : action.includes('advancedFilter')) ? {
349
- span: {
350
- xs: 12,
351
- sm: 12,
352
- md: 12,
353
- lg: 12,
354
- xl: 8,
355
- xxl: 6
356
- },
357
- labelWidth: 80,
358
- onCollapse: function onCollapse() {
359
- // 执行展开和关闭动作
360
- },
432
+ return options;
433
+ }, [options, action, showDefaultSetting, handleSave, handleReset, isLoading]);
434
+ // 优化:使用 useMemo 缓存列配置
435
+ var processedColumns = useMemo(function () {
436
+ if (!(action === null || action === void 0 ? void 0 : action.includes('advancedFilter'))) {
437
+ return columns;
438
+ }
439
+ return columns.map(function (item) {
440
+ if (item.baseSearch) {
441
+ return _objectSpread(_objectSpread({}, item), {}, {
442
+ search: item.search,
443
+ fieldProps: _objectSpread({
444
+ onChange: function onChange(e) {
445
+ try {
446
+ if (e) {
447
+ var _drawFormRef$current8;
448
+ var value = e.target ? e.target.value : e;
449
+ drawFormRef === null || drawFormRef === void 0 ? void 0 : (_drawFormRef$current8 = drawFormRef.current) === null || _drawFormRef$current8 === void 0 ? void 0 : _drawFormRef$current8.setFieldsValue(_defineProperty({}, item.dataIndex, value));
450
+ } else {
451
+ var _drawFormRef$current10;
452
+ drawFormRef === null || drawFormRef === void 0 ? void 0 : (_drawFormRef$current10 = drawFormRef.current) === null || _drawFormRef$current10 === void 0 ? void 0 : _drawFormRef$current10.resetFields([item.dataIndex]);
453
+ }
454
+ } catch (error) {
455
+ console.error('字段值变更处理失败:', error);
456
+ }
457
+ }
458
+ }, item.fieldProps)
459
+ });
460
+ }
461
+ return _objectSpread(_objectSpread({}, item), {}, {
462
+ search: false
463
+ });
464
+ });
465
+ }, [columns, action]);
466
+ // 优化:使用 useMemo 缓存搜索配置
467
+ var searchConfig = useMemo(function () {
468
+ if (!(action === null || action === void 0 ? void 0 : action.includes('advancedFilter'))) {
469
+ return props.search;
470
+ }
471
+ return _objectSpread(_objectSpread({}, search), {}, {
472
+ span: CONSTANTS.SEARCH_SPAN,
473
+ labelWidth: CONSTANTS.LABEL_WIDTH,
361
474
  collapseRender: function collapseRender() {
362
475
  return null;
363
476
  },
@@ -367,17 +480,12 @@ function PlusTable(props, ref) {
367
480
  size: "middle",
368
481
  type: "primary",
369
482
  onClick: function onClick() {
370
- handleSearchAll(searchConfig);
483
+ return handleSearchAll(searchConfig);
371
484
  }
372
485
  }, "\u67E5\u8BE2"), /*#__PURE__*/React.createElement(_Button, {
373
486
  key: "2",
374
487
  type: "default",
375
- onClick: function onClick() {
376
- var _drawFormRef$current6, _actionRef$current, _actionRef$current$re, _actionRef$current2, _actionRef$current2$r;
377
- drawFormRef === null || drawFormRef === void 0 ? void 0 : (_drawFormRef$current6 = drawFormRef.current) === null || _drawFormRef$current6 === void 0 ? void 0 : _drawFormRef$current6.resetFields();
378
- actionRef === null || actionRef === void 0 ? void 0 : (_actionRef$current = actionRef.current) === null || _actionRef$current === void 0 ? void 0 : (_actionRef$current$re = _actionRef$current.reset) === null || _actionRef$current$re === void 0 ? void 0 : _actionRef$current$re.call(_actionRef$current);
379
- actionRef === null || actionRef === void 0 ? void 0 : (_actionRef$current2 = actionRef.current) === null || _actionRef$current2 === void 0 ? void 0 : (_actionRef$current2$r = _actionRef$current2.reload) === null || _actionRef$current2$r === void 0 ? void 0 : _actionRef$current2$r.call(_actionRef$current2);
380
- },
488
+ onClick: handleResetForm,
381
489
  size: "middle"
382
490
  }, "\u91CD\u7F6E"), /*#__PURE__*/React.createElement("a", {
383
491
  key: "3",
@@ -385,74 +493,63 @@ function PlusTable(props, ref) {
385
493
  wordBreak: 'break-word',
386
494
  whiteSpace: 'nowrap'
387
495
  },
388
- onClick: /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
389
- var _drawFormRef$current7, _searchRef$current6;
390
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
391
- while (1) switch (_context9.prev = _context9.next) {
392
- case 0:
393
- _context9.next = 2;
394
- return setSearchDrawer(!searchDrawer);
395
- case 2:
396
- // 没法实时监听数据所以这里要带过来
397
- drawFormRef === null || drawFormRef === void 0 ? void 0 : (_drawFormRef$current7 = drawFormRef.current) === null || _drawFormRef$current7 === void 0 ? void 0 : _drawFormRef$current7.setFieldsValue(searchRef === null || searchRef === void 0 ? void 0 : (_searchRef$current6 = searchRef.current) === null || _searchRef$current6 === void 0 ? void 0 : _searchRef$current6.getFieldsValue());
398
- case 3:
399
- case "end":
400
- return _context9.stop();
401
- }
402
- }, _callee9);
403
- }))
496
+ onClick: handleAdvancedFilterClick
404
497
  }, /*#__PURE__*/React.createElement(BarsOutlined, null), "\u9AD8\u7EA7\u7B5B\u9009")];
405
498
  }
406
- } : props.search
407
- // 根据用户自定义的配置 如果配置了列设置就有这个配置完全受控
408
- ,
499
+ });
500
+ }, [action, props.search, handleSearchAll, handleResetForm, handleAdvancedFilterClick]);
501
+ // 优化:使用 useMemo 缓存工具栏渲染
502
+ var toolBarRender = useCallback(function (searchConfig, rows) {
503
+ return [(action === null || action === void 0 ? void 0 : action.includes('viewInvisibleData')) ? /*#__PURE__*/React.createElement(_Checkbox, {
504
+ defaultChecked: showFull,
505
+ onChange: handleShowFullChange
506
+ }, "\u663E\u793A\u6240\u6709\u6570\u636E") : null, typeof otherProps.toolBarRender === 'function' && otherProps.toolBarRender(searchConfig, rows)];
507
+ }, [action, showFull, handleShowFullChange, otherProps.toolBarRender]);
508
+ // 优化:使用 useMemo 缓存抽屉样式
509
+ var drawerStyle = useMemo(function () {
510
+ return {
511
+ position: 'fixed',
512
+ top: props.top || CONSTANTS.DEFAULT_TOP
513
+ };
514
+ }, [props.top]);
515
+ // 优化:使用 useMemo 缓存抽屉底部按钮样式
516
+ var bottomButtonStyle = useMemo(function () {
517
+ return {
518
+ position: 'fixed',
519
+ bottom: 0,
520
+ background: 'white',
521
+ display: 'flex',
522
+ width: "".concat(CONSTANTS.DRAWER_WIDTH, "px"),
523
+ borderTop: '1px solid #f0f0f0',
524
+ right: '0',
525
+ justifyContent: 'space-around',
526
+ padding: '16px',
527
+ boxSizing: 'border-box'
528
+ };
529
+ }, []);
530
+ return /*#__PURE__*/React.createElement("div", {
531
+ className: "page_plustable__body"
532
+ }, /*#__PURE__*/React.createElement(_ConfigProvider, {
533
+ prefixCls: "ant"
534
+ }, /*#__PURE__*/React.createElement(ProTable, _extends({
535
+ pagination: _objectSpread({
536
+ size: 'default'
537
+ }, pagination),
538
+ actionRef: actionRef,
539
+ formRef: searchRef,
540
+ search: searchConfig,
409
541
  columnsState: (action === null || action === void 0 ? void 0 : action.includes('columnSetting')) ? columnsState : props.columnsState,
410
- request: request ? propsRequest : undefined
411
- // 同步高筛配置 只有高筛 才有特殊的配置 (baseSearch才会生效)
412
- ,
413
- columns: (action === null || action === void 0 ? void 0 : action.includes('advancedFilter')) ? columns.map(function (item) {
414
- // 只保留基本搜索栏的配置
415
- if (item.baseSearch) {
416
- return _objectSpread(_objectSpread({}, item), {}, {
417
- search: item.search,
418
- fieldProps: _objectSpread({
419
- onChange: function onChange(e) {
420
- if (e) {
421
- var _drawFormRef$current8;
422
- drawFormRef === null || drawFormRef === void 0 ? void 0 : (_drawFormRef$current8 = drawFormRef.current) === null || _drawFormRef$current8 === void 0 ? void 0 : _drawFormRef$current8.setFieldsValue(_defineProperty({}, item.dataIndex, e.target ? e.target.value : e));
423
- } else {
424
- var _drawFormRef$current10;
425
- drawFormRef === null || drawFormRef === void 0 ? void 0 : (_drawFormRef$current10 = drawFormRef.current) === null || _drawFormRef$current10 === void 0 ? void 0 : _drawFormRef$current10.resetFields([item.dataIndex]);
426
- }
427
- }
428
- }, item.fieldProps)
429
- });
430
- }
431
- return _objectSpread(_objectSpread({}, item), {}, {
432
- search: false
433
- });
434
- }) : columns,
435
- toolBarRender: function toolBarRender(searchConfig, rows) {
436
- return [(action === null || action === void 0 ? void 0 : action.includes('viewInvisibleData')) ? /*#__PURE__*/React.createElement(_Checkbox, {
437
- onChange: function onChange(e) {
438
- setShowFull(e.target.checked);
439
- setTimeout(function () {
440
- searchConfig === null || searchConfig === void 0 ? void 0 : searchConfig.reload();
441
- }, 100);
442
- }
443
- }, "\u663E\u793A\u6240\u6709\u6570\u636E") : null, typeof otherProps.toolBarRender === 'function' && otherProps.toolBarRender(searchConfig, rows)];
444
- },
542
+ request: request ? propsRequest : undefined,
543
+ columns: processedColumns,
544
+ toolBarRender: toolBarRender,
445
545
  options: __options
446
546
  }, otherProps)), /*#__PURE__*/React.createElement(_Drawer, {
447
547
  onClose: function onClose() {
448
548
  return setSearchDrawer(false);
449
549
  },
450
- title: '高级筛选',
451
- width: 380,
452
- rootStyle: {
453
- position: 'fixed',
454
- top: props.top || 92
455
- },
550
+ title: "\u9AD8\u7EA7\u7B5B\u9009",
551
+ width: CONSTANTS.DRAWER_WIDTH,
552
+ rootStyle: drawerStyle,
456
553
  getContainer: (otherProps === null || otherProps === void 0 ? void 0 : otherProps.getContainer) || document.getElementsByTagName('body')[0],
457
554
  className: "search-drawer",
458
555
  open: searchDrawer,
@@ -461,9 +558,7 @@ function PlusTable(props, ref) {
461
558
  }, /*#__PURE__*/React.createElement(FormRender, {
462
559
  columns: columns,
463
560
  loading: false,
464
- changeValue: function changeValue(_changeValue, allValue) {
465
- return onValuesChange(_changeValue, allValue);
466
- },
561
+ changeValue: onValuesChange,
467
562
  onFormSearchSubmit: function onFormSearchSubmit() {
468
563
  var _searchRef$current7;
469
564
  searchRef === null || searchRef === void 0 ? void 0 : (_searchRef$current7 = searchRef.current) === null || _searchRef$current7 === void 0 ? void 0 : _searchRef$current7.submit();
@@ -478,32 +573,17 @@ function PlusTable(props, ref) {
478
573
  search: {
479
574
  optionRender: function optionRender(searchConfig) {
480
575
  return [/*#__PURE__*/React.createElement("div", {
481
- style: {
482
- position: 'fixed',
483
- bottom: 0,
484
- background: 'white',
485
- display: 'flex',
486
- width: '380px',
487
- borderTop: '1px solid #f0f0f0',
488
- right: '0',
489
- justifyContent: 'space-around',
490
- padding: '16px',
491
- boxSizing: 'border-box'
492
- }
576
+ key: "bottom-buttons",
577
+ style: bottomButtonStyle
493
578
  }, /*#__PURE__*/React.createElement(_Button, {
494
579
  size: "middle",
495
580
  type: "primary",
496
581
  onClick: function onClick() {
497
- handleSearchAll(searchConfig);
582
+ return handleSearchAll(searchConfig);
498
583
  }
499
584
  }, "\u67E5\u8BE2"), /*#__PURE__*/React.createElement(_Button, {
500
585
  type: "default",
501
- onClick: function onClick() {
502
- var _drawFormRef$current11, _actionRef$current3, _actionRef$current3$r, _actionRef$current4, _actionRef$current4$r;
503
- drawFormRef === null || drawFormRef === void 0 ? void 0 : (_drawFormRef$current11 = drawFormRef.current) === null || _drawFormRef$current11 === void 0 ? void 0 : _drawFormRef$current11.resetFields();
504
- actionRef === null || actionRef === void 0 ? void 0 : (_actionRef$current3 = actionRef.current) === null || _actionRef$current3 === void 0 ? void 0 : (_actionRef$current3$r = _actionRef$current3.reset) === null || _actionRef$current3$r === void 0 ? void 0 : _actionRef$current3$r.call(_actionRef$current3);
505
- actionRef === null || actionRef === void 0 ? void 0 : (_actionRef$current4 = actionRef.current) === null || _actionRef$current4 === void 0 ? void 0 : (_actionRef$current4$r = _actionRef$current4.reload) === null || _actionRef$current4$r === void 0 ? void 0 : _actionRef$current4$r.call(_actionRef$current4);
506
- },
586
+ onClick: handleResetForm,
507
587
  size: "middle"
508
588
  }, "\u91CD\u7F6E"))];
509
589
  },
@@ -514,6 +594,6 @@ function PlusTable(props, ref) {
514
594
  },
515
595
  manualRequest: true,
516
596
  action: actionRef
517
- })));
597
+ }))));
518
598
  }
519
599
  export default /*#__PURE__*/React.forwardRef(PlusTable);