@fle-ui/plus-table 1.2.28 → 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.less +0 -3
  4. package/es/index.d.ts +3 -3
  5. package/es/index.js +425 -337
  6. package/es/mock/list.json +720 -0
  7. package/es/utils/common.d.ts +0 -10
  8. package/es/utils/common.js +0 -5
  9. package/lib/{FormSearch → components/FormSearch}/FormRender.d.ts +1 -1
  10. package/lib/{FormSearch → components/FormSearch}/FormRender.js +3 -4
  11. package/lib/{FormSearch → components/FormSearch}/index.less +0 -3
  12. package/lib/index.d.ts +3 -3
  13. package/lib/index.js +422 -336
  14. package/lib/mock/list.json +720 -0
  15. package/lib/utils/common.d.ts +0 -10
  16. package/lib/utils/common.js +1 -7
  17. package/package.json +6 -6
  18. package/es/components/icon/index.d.ts +0 -3
  19. package/es/components/icon/index.js +0 -7
  20. package/es/json/columnKeys.d.ts +0 -15
  21. package/es/json/columnKeys.js +0 -182
  22. package/es/json/list.d.ts +0 -1365
  23. package/es/json/list.js +0 -1388
  24. package/lib/components/icon/index.d.ts +0 -3
  25. package/lib/components/icon/index.js +0 -13
  26. package/lib/json/columnKeys.d.ts +0 -15
  27. package/lib/json/columnKeys.js +0 -188
  28. package/lib/json/list.d.ts +0 -1365
  29. package/lib/json/list.js +0 -1394
  30. /package/es/{FormSearch → components/FormSearch}/index.d.ts +0 -0
  31. /package/es/{FormSearch → components/FormSearch}/index.js +0 -0
  32. /package/lib/{FormSearch → components/FormSearch}/index.d.ts +0 -0
  33. /package/lib/{FormSearch → components/FormSearch}/index.js +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);
@@ -59,296 +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 _searchRef$current4;
223
- searchRef === null || searchRef === void 0 ? void 0 : (_searchRef$current4 = searchRef.current) === null || _searchRef$current4 === void 0 ? void 0 : _searchRef$current4.setFieldsValue(drawFormRef.current.getFieldsValue());
224
- };
225
- var handleSearchAll = /*#__PURE__*/function () {
226
- var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(searchConfig) {
227
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
228
- 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) {
229
265
  case 0:
230
- searchConfig.form.submit();
266
+ try {
267
+ searchConfig.form.submit();
268
+ } catch (error) {
269
+ console.error('搜索失败:', error);
270
+ }
231
271
  case 1:
232
272
  case "end":
233
- return _context7.stop();
273
+ return _context6.stop();
234
274
  }
235
- }, _callee7);
275
+ }, _callee6);
236
276
  }));
237
- return function handleSearchAll(_x4) {
238
- return _ref4.apply(this, arguments);
277
+ return function (_x4) {
278
+ return _ref6.apply(this, arguments);
239
279
  };
240
- }();
241
- useEffect(function () {
242
- 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
+ });
288
+ }, []);
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
+ }
243
328
  }, []);
244
- var dealFetchParams = function dealFetchParams(params) {
245
- // 处理transform中的函数处理
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) {
246
342
  var fetchParams = {};
247
343
  columns.forEach(function (item) {
248
- var _item$search;
249
- 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]) {
250
- 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
+ }
251
350
  } else {
252
- fetchParams = _objectSpread(_objectSpread({}, fetchParams), {}, _defineProperty({}, item.dataIndex, params[item.dataIndex]));
351
+ fetchParams[dataIndex] = params[dataIndex];
253
352
  }
254
353
  });
255
354
  return fetchParams;
256
- };
257
- var columnsState = {
258
- //列设置
259
- defaultValue: defaultColumnsState,
260
- value: columnsStateMap,
261
- onChange: handleOnChangeColumn //列状态的值发生改变之后触发
262
- };
263
- var propsRequest = /*#__PURE__*/function () {
264
- var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(params, sort, filter) {
265
- var _searchRef$current5, _drawFormRef$current4;
266
- var res1, res2, 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;
267
368
  return _regeneratorRuntime().wrap(function _callee8$(_context8) {
268
369
  while (1) switch (_context8.prev = _context8.next) {
269
370
  case 0:
270
- _context8.next = 2;
271
- return searchRef === null || searchRef === void 0 ? void 0 : (_searchRef$current5 = searchRef.current) === null || _searchRef$current5 === void 0 ? void 0 : _searchRef$current5.getFieldsValue();
272
- 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:
273
375
  res1 = _context8.sent;
274
- _context8.next = 5;
275
- return drawFormRef === null || drawFormRef === void 0 ? void 0 : (_drawFormRef$current4 = drawFormRef.current) === null || _drawFormRef$current4 === void 0 ? void 0 : _drawFormRef$current4.getFieldsValue();
276
- 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:
277
379
  res2 = _context8.sent;
278
- if (!request) {
279
- _context8.next = 12;
380
+ if (request) {
381
+ _context8.next = 9;
280
382
  break;
281
383
  }
282
- _context8.next = 9;
384
+ return _context8.abrupt("return", {});
385
+ case 9:
386
+ _context8.next = 11;
283
387
  return request(_objectSpread(_objectSpread(_objectSpread({}, params), dealFetchParams(_objectSpread(_objectSpread(_objectSpread({}, res1), res2), params))), {}, {
284
388
  showFull: showFull
285
389
  }), sort, filter);
286
- case 9:
287
- _context8.t0 = _context8.sent;
288
- _context8.next = 13;
289
- break;
290
- case 12:
291
- _context8.t0 = {};
292
- case 13:
293
- res = _context8.t0;
294
- return _context8.abrupt("return", res);
295
- case 15:
390
+ case 11:
391
+ return _context8.abrupt("return", _context8.sent);
392
+ case 14:
393
+ _context8.prev = 14;
394
+ _context8.t0 = _context8["catch"](0);
395
+ console.error('请求数据失败:', _context8.t0);
396
+ return _context8.abrupt("return", {});
397
+ case 18:
296
398
  case "end":
297
399
  return _context8.stop();
298
400
  }
299
- }, _callee8);
401
+ }, _callee8, null, [[0, 14]]);
300
402
  }));
301
- return function propsRequest(_x5, _x6, _x7) {
302
- return _ref5.apply(this, arguments);
403
+ return function (_x5, _x6, _x7) {
404
+ return _ref8.apply(this, arguments);
303
405
  };
304
- }();
305
- var optionsSetting = _typeof(options) === 'object' && _typeof(options.setting) === 'object' ? options.setting : {};
306
- var __options = (action === null || action === void 0 ? void 0 : action.includes('columnSetting')) && showDefaultSetting !== true ? _objectSpread(_objectSpread({}, options), {}, {
307
- setting: _objectSpread(_objectSpread({}, optionsSetting), {}, {
308
- checkedReset: false,
309
- showListItemOption: true,
310
- extra: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("a", {
311
- onClick: function onClick() {
312
- return handleSave();
313
- }
314
- }, "\u4FDD\u5B58"), /*#__PURE__*/React.createElement("a", {
315
- style: {
316
- color: '#333'
317
- },
318
- onClick: function onClick() {
319
- return handleReset();
320
- }
321
- }, "\u91CD\u7F6E"))
322
- })
323
- }) : options;
324
- return /*#__PURE__*/React.createElement("div", {
325
- className: "page_plustable__body"
326
- }, /*#__PURE__*/React.createElement(ProTable, _extends({
327
- scroll: {
328
- 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
+ });
329
431
  }
330
- // 公共配置 大家都有的
331
- ,
332
- pagination: _objectSpread({
333
- size: 'default'
334
- }, pagination),
335
- actionRef: actionRef,
336
- formRef: searchRef
337
- // 根据用户自定义的配置 如果配置了高级筛选就有这个配置
338
- ,
339
- search: (action === null || action === void 0 ? void 0 : action.includes('advancedFilter')) ? {
340
- span: {
341
- xs: 12,
342
- sm: 12,
343
- md: 12,
344
- lg: 12,
345
- xl: 8,
346
- xxl: 6
347
- },
348
- labelWidth: 80,
349
- onCollapse: function onCollapse() {
350
- // 执行展开和关闭动作
351
- },
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,
352
474
  collapseRender: function collapseRender() {
353
475
  return null;
354
476
  },
@@ -358,17 +480,12 @@ function PlusTable(props, ref) {
358
480
  size: "middle",
359
481
  type: "primary",
360
482
  onClick: function onClick() {
361
- handleSearchAll(searchConfig);
483
+ return handleSearchAll(searchConfig);
362
484
  }
363
485
  }, "\u67E5\u8BE2"), /*#__PURE__*/React.createElement(_Button, {
364
486
  key: "2",
365
487
  type: "default",
366
- onClick: function onClick() {
367
- var _drawFormRef$current5, _actionRef$current, _actionRef$current$re, _actionRef$current2, _actionRef$current2$r;
368
- drawFormRef === null || drawFormRef === void 0 ? void 0 : (_drawFormRef$current5 = drawFormRef.current) === null || _drawFormRef$current5 === void 0 ? void 0 : _drawFormRef$current5.resetFields();
369
- 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);
370
- 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);
371
- },
488
+ onClick: handleResetForm,
372
489
  size: "middle"
373
490
  }, "\u91CD\u7F6E"), /*#__PURE__*/React.createElement("a", {
374
491
  key: "3",
@@ -376,75 +493,63 @@ function PlusTable(props, ref) {
376
493
  wordBreak: 'break-word',
377
494
  whiteSpace: 'nowrap'
378
495
  },
379
- onClick: /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
380
- var _drawFormRef$current6, _searchRef$current6;
381
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
382
- while (1) switch (_context9.prev = _context9.next) {
383
- case 0:
384
- _context9.next = 2;
385
- return setSearchDrawer(!searchDrawer);
386
- case 2:
387
- // 没法实时监听数据所以这里要带过来
388
- drawFormRef === null || drawFormRef === void 0 ? void 0 : (_drawFormRef$current6 = drawFormRef.current) === null || _drawFormRef$current6 === void 0 ? void 0 : _drawFormRef$current6.setFieldsValue(searchRef === null || searchRef === void 0 ? void 0 : (_searchRef$current6 = searchRef.current) === null || _searchRef$current6 === void 0 ? void 0 : _searchRef$current6.getFieldsValue());
389
- case 3:
390
- case "end":
391
- return _context9.stop();
392
- }
393
- }, _callee9);
394
- }))
496
+ onClick: handleAdvancedFilterClick
395
497
  }, /*#__PURE__*/React.createElement(BarsOutlined, null), "\u9AD8\u7EA7\u7B5B\u9009")];
396
498
  }
397
- } : props.search
398
- // 根据用户自定义的配置 如果配置了列设置就有这个配置完全受控
399
- ,
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,
400
541
  columnsState: (action === null || action === void 0 ? void 0 : action.includes('columnSetting')) ? columnsState : props.columnsState,
401
- request: request ? propsRequest : undefined
402
- // 同步高筛配置 只有高筛 才有特殊的配置 (baseSearch才会生效)
403
- ,
404
- columns: (action === null || action === void 0 ? void 0 : action.includes('advancedFilter')) ? columns.map(function (item) {
405
- // 只保留基本搜索栏的配置
406
- if (item.baseSearch) {
407
- return _objectSpread(_objectSpread({}, item), {}, {
408
- search: item.search,
409
- fieldProps: _objectSpread({
410
- onChange: function onChange(e) {
411
- if (e) {
412
- var _drawFormRef$current7;
413
- drawFormRef === null || drawFormRef === void 0 ? void 0 : (_drawFormRef$current7 = drawFormRef.current) === null || _drawFormRef$current7 === void 0 ? void 0 : _drawFormRef$current7.setFieldsValue(_defineProperty({}, item.dataIndex, e.target ? e.target.value : e));
414
- } else {
415
- var _drawFormRef$current9;
416
- drawFormRef === null || drawFormRef === void 0 ? void 0 : (_drawFormRef$current9 = drawFormRef.current) === null || _drawFormRef$current9 === void 0 ? void 0 : _drawFormRef$current9.resetFields([item.dataIndex]);
417
- }
418
- }
419
- }, item.fieldProps)
420
- });
421
- }
422
- return _objectSpread(_objectSpread({}, item), {}, {
423
- search: false
424
- });
425
- }) : columns,
426
- toolBarRender: function toolBarRender(searchConfig, rows) {
427
- return [(action === null || action === void 0 ? void 0 : action.includes('viewInvisibleData')) ? /*#__PURE__*/React.createElement(_Checkbox, {
428
- defaultChecked: showFull,
429
- onChange: function onChange(e) {
430
- setShowFull(e.target.checked);
431
- setTimeout(function () {
432
- searchConfig === null || searchConfig === void 0 ? void 0 : searchConfig.reload();
433
- }, 100);
434
- }
435
- }, "\u663E\u793A\u6240\u6709\u6570\u636E") : null, typeof otherProps.toolBarRender === 'function' && otherProps.toolBarRender(searchConfig, rows)];
436
- },
542
+ request: request ? propsRequest : undefined,
543
+ columns: processedColumns,
544
+ toolBarRender: toolBarRender,
437
545
  options: __options
438
546
  }, otherProps)), /*#__PURE__*/React.createElement(_Drawer, {
439
547
  onClose: function onClose() {
440
548
  return setSearchDrawer(false);
441
549
  },
442
- title: '高级筛选',
443
- width: 380,
444
- rootStyle: {
445
- position: 'fixed',
446
- top: props.top || 92
447
- },
550
+ title: "\u9AD8\u7EA7\u7B5B\u9009",
551
+ width: CONSTANTS.DRAWER_WIDTH,
552
+ rootStyle: drawerStyle,
448
553
  getContainer: (otherProps === null || otherProps === void 0 ? void 0 : otherProps.getContainer) || document.getElementsByTagName('body')[0],
449
554
  className: "search-drawer",
450
555
  open: searchDrawer,
@@ -453,9 +558,7 @@ function PlusTable(props, ref) {
453
558
  }, /*#__PURE__*/React.createElement(FormRender, {
454
559
  columns: columns,
455
560
  loading: false,
456
- changeValue: function changeValue(_changeValue, allValue) {
457
- return onValuesChange(_changeValue, allValue);
458
- },
561
+ changeValue: onValuesChange,
459
562
  onFormSearchSubmit: function onFormSearchSubmit() {
460
563
  var _searchRef$current7;
461
564
  searchRef === null || searchRef === void 0 ? void 0 : (_searchRef$current7 = searchRef.current) === null || _searchRef$current7 === void 0 ? void 0 : _searchRef$current7.submit();
@@ -470,32 +573,17 @@ function PlusTable(props, ref) {
470
573
  search: {
471
574
  optionRender: function optionRender(searchConfig) {
472
575
  return [/*#__PURE__*/React.createElement("div", {
473
- style: {
474
- position: 'fixed',
475
- bottom: 0,
476
- background: 'white',
477
- display: 'flex',
478
- width: '380px',
479
- borderTop: '1px solid #f0f0f0',
480
- right: '0',
481
- justifyContent: 'space-around',
482
- padding: '16px',
483
- boxSizing: 'border-box'
484
- }
576
+ key: "bottom-buttons",
577
+ style: bottomButtonStyle
485
578
  }, /*#__PURE__*/React.createElement(_Button, {
486
579
  size: "middle",
487
580
  type: "primary",
488
581
  onClick: function onClick() {
489
- handleSearchAll(searchConfig);
582
+ return handleSearchAll(searchConfig);
490
583
  }
491
584
  }, "\u67E5\u8BE2"), /*#__PURE__*/React.createElement(_Button, {
492
585
  type: "default",
493
- onClick: function onClick() {
494
- var _drawFormRef$current10, _actionRef$current3, _actionRef$current3$r, _actionRef$current4, _actionRef$current4$r;
495
- drawFormRef === null || drawFormRef === void 0 ? void 0 : (_drawFormRef$current10 = drawFormRef.current) === null || _drawFormRef$current10 === void 0 ? void 0 : _drawFormRef$current10.resetFields();
496
- 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);
497
- 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);
498
- },
586
+ onClick: handleResetForm,
499
587
  size: "middle"
500
588
  }, "\u91CD\u7F6E"))];
501
589
  },
@@ -506,6 +594,6 @@ function PlusTable(props, ref) {
506
594
  },
507
595
  manualRequest: true,
508
596
  action: actionRef
509
- })));
597
+ }))));
510
598
  }
511
599
  export default /*#__PURE__*/React.forwardRef(PlusTable);