@fle-ui/plus-table 1.2.28 → 1.2.30-beta.0

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