@fle-ui/plus-table 1.2.28 → 1.2.30-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/{FormSearch → components/FormSearch}/FormRender.d.ts +1 -1
- package/es/{FormSearch → components/FormSearch}/FormRender.js +1 -2
- package/es/{FormSearch → components/FormSearch}/index.less +5 -3
- package/es/index.d.ts +3 -3
- package/es/index.js +420 -336
- package/es/mock/list.json +720 -0
- package/es/utils/common.d.ts +0 -10
- package/es/utils/common.js +0 -5
- package/lib/{FormSearch → components/FormSearch}/FormRender.d.ts +1 -1
- package/lib/{FormSearch → components/FormSearch}/FormRender.js +3 -4
- package/lib/{FormSearch → components/FormSearch}/index.less +5 -3
- package/lib/index.d.ts +3 -3
- package/lib/index.js +419 -335
- package/lib/mock/list.json +720 -0
- package/lib/utils/common.d.ts +0 -10
- package/lib/utils/common.js +1 -7
- package/package.json +6 -6
- package/es/components/icon/index.d.ts +0 -3
- package/es/components/icon/index.js +0 -7
- package/es/json/columnKeys.d.ts +0 -15
- package/es/json/columnKeys.js +0 -182
- package/es/json/list.d.ts +0 -1365
- package/es/json/list.js +0 -1388
- package/lib/components/icon/index.d.ts +0 -3
- package/lib/components/icon/index.js +0 -13
- package/lib/json/columnKeys.d.ts +0 -15
- package/lib/json/columnKeys.js +0 -188
- package/lib/json/list.d.ts +0 -1365
- package/lib/json/list.js +0 -1394
- /package/es/{FormSearch → components/FormSearch}/index.d.ts +0 -0
- /package/es/{FormSearch → components/FormSearch}/index.js +0 -0
- /package/lib/{FormSearch → components/FormSearch}/index.d.ts +0 -0
- /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,401 @@ 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
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
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
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
return _regeneratorRuntime().wrap(function
|
|
157
|
-
while (1) switch (
|
|
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
|
-
|
|
160
|
-
|
|
161
|
-
|
|
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
|
-
|
|
167
|
-
|
|
168
|
-
case
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
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
|
|
132
|
+
return _context2.stop();
|
|
189
133
|
}
|
|
190
|
-
},
|
|
134
|
+
}, _callee2, null, [[0, 5]]);
|
|
191
135
|
}));
|
|
192
|
-
return function
|
|
136
|
+
return function (_x) {
|
|
193
137
|
return _ref2.apply(this, arguments);
|
|
194
138
|
};
|
|
195
|
-
}();
|
|
196
|
-
var
|
|
197
|
-
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
198
|
-
var
|
|
199
|
-
return _regeneratorRuntime().wrap(function
|
|
200
|
-
while (1) switch (
|
|
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
|
-
|
|
203
|
-
|
|
204
|
-
|
|
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
|
-
|
|
210
|
-
|
|
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
|
|
158
|
+
return _context3.stop();
|
|
214
159
|
}
|
|
215
|
-
},
|
|
160
|
+
}, _callee3, null, [[0, 5]]);
|
|
216
161
|
}));
|
|
217
|
-
return function
|
|
162
|
+
return function (_x2, _x3) {
|
|
218
163
|
return _ref3.apply(this, arguments);
|
|
219
164
|
};
|
|
220
|
-
}();
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
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, fetchRes;
|
|
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) && props.fetchSetting)) {
|
|
226
|
+
_context5.next = 9;
|
|
227
|
+
break;
|
|
228
|
+
}
|
|
229
|
+
_context5.next = 7;
|
|
230
|
+
return props.fetchSetting();
|
|
231
|
+
case 7:
|
|
232
|
+
fetchRes = _context5.sent;
|
|
233
|
+
setColumnsStateMap(fetchRes);
|
|
234
|
+
case 9:
|
|
235
|
+
_context5.next = 14;
|
|
236
|
+
break;
|
|
237
|
+
case 11:
|
|
238
|
+
_context5.prev = 11;
|
|
239
|
+
_context5.t0 = _context5["catch"](0);
|
|
240
|
+
console.error('重置列设置失败:', _context5.t0);
|
|
241
|
+
case 14:
|
|
242
|
+
case "end":
|
|
243
|
+
return _context5.stop();
|
|
244
|
+
}
|
|
245
|
+
}, _callee5, null, [[0, 11]]);
|
|
246
|
+
})), [props.resetSetting, props.fetchSetting]);
|
|
247
|
+
var onValuesChange = useCallback(function (changeValue, allValue) {
|
|
248
|
+
try {
|
|
249
|
+
var _drawFormRef$current4;
|
|
250
|
+
var currentValues = (_drawFormRef$current4 = drawFormRef.current) === null || _drawFormRef$current4 === void 0 ? void 0 : _drawFormRef$current4.getFieldsValue();
|
|
251
|
+
if (currentValues) {
|
|
252
|
+
var _searchRef$current4;
|
|
253
|
+
searchRef === null || searchRef === void 0 ? void 0 : (_searchRef$current4 = searchRef.current) === null || _searchRef$current4 === void 0 ? void 0 : _searchRef$current4.setFieldsValue(currentValues);
|
|
254
|
+
}
|
|
255
|
+
} catch (error) {
|
|
256
|
+
console.error('同步表单值失败:', error);
|
|
257
|
+
}
|
|
258
|
+
}, []);
|
|
259
|
+
var handleSearchAll = useCallback( /*#__PURE__*/function () {
|
|
260
|
+
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(searchConfig) {
|
|
261
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
262
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
229
263
|
case 0:
|
|
230
|
-
|
|
264
|
+
try {
|
|
265
|
+
searchConfig.form.submit();
|
|
266
|
+
} catch (error) {
|
|
267
|
+
console.error('搜索失败:', error);
|
|
268
|
+
}
|
|
231
269
|
case 1:
|
|
232
270
|
case "end":
|
|
233
|
-
return
|
|
271
|
+
return _context6.stop();
|
|
234
272
|
}
|
|
235
|
-
},
|
|
273
|
+
}, _callee6);
|
|
236
274
|
}));
|
|
237
|
-
return function
|
|
238
|
-
return
|
|
275
|
+
return function (_x4) {
|
|
276
|
+
return _ref6.apply(this, arguments);
|
|
239
277
|
};
|
|
240
|
-
}();
|
|
241
|
-
|
|
242
|
-
|
|
278
|
+
}(), []);
|
|
279
|
+
var handleShowFullChange = useCallback(function (e) {
|
|
280
|
+
setShowFull(e.target.checked);
|
|
281
|
+
// 优化:使用 requestAnimationFrame 替代 setTimeout
|
|
282
|
+
requestAnimationFrame(function () {
|
|
283
|
+
var _actionRef$current, _actionRef$current$re;
|
|
284
|
+
(_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);
|
|
285
|
+
});
|
|
286
|
+
}, []);
|
|
287
|
+
var handleAdvancedFilterClick = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
|
|
288
|
+
var newDrawerState, _searchRef$current5, _drawFormRef$current5, fieldsValue;
|
|
289
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
290
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
291
|
+
case 0:
|
|
292
|
+
_context7.prev = 0;
|
|
293
|
+
newDrawerState = !searchDrawer;
|
|
294
|
+
setSearchDrawer(newDrawerState);
|
|
295
|
+
if (!newDrawerState) {
|
|
296
|
+
_context7.next = 8;
|
|
297
|
+
break;
|
|
298
|
+
}
|
|
299
|
+
_context7.next = 6;
|
|
300
|
+
return searchRef === null || searchRef === void 0 ? void 0 : (_searchRef$current5 = searchRef.current) === null || _searchRef$current5 === void 0 ? void 0 : _searchRef$current5.getFieldsValue();
|
|
301
|
+
case 6:
|
|
302
|
+
fieldsValue = _context7.sent;
|
|
303
|
+
drawFormRef === null || drawFormRef === void 0 ? void 0 : (_drawFormRef$current5 = drawFormRef.current) === null || _drawFormRef$current5 === void 0 ? void 0 : _drawFormRef$current5.setFieldsValue(fieldsValue);
|
|
304
|
+
case 8:
|
|
305
|
+
_context7.next = 13;
|
|
306
|
+
break;
|
|
307
|
+
case 10:
|
|
308
|
+
_context7.prev = 10;
|
|
309
|
+
_context7.t0 = _context7["catch"](0);
|
|
310
|
+
console.error('切换高级筛选失败:', _context7.t0);
|
|
311
|
+
case 13:
|
|
312
|
+
case "end":
|
|
313
|
+
return _context7.stop();
|
|
314
|
+
}
|
|
315
|
+
}, _callee7, null, [[0, 10]]);
|
|
316
|
+
})), [searchDrawer]);
|
|
317
|
+
var handleResetForm = useCallback(function () {
|
|
318
|
+
try {
|
|
319
|
+
var _drawFormRef$current6, _actionRef$current2, _actionRef$current2$r, _actionRef$current3, _actionRef$current3$r;
|
|
320
|
+
drawFormRef === null || drawFormRef === void 0 ? void 0 : (_drawFormRef$current6 = drawFormRef.current) === null || _drawFormRef$current6 === void 0 ? void 0 : _drawFormRef$current6.resetFields();
|
|
321
|
+
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);
|
|
322
|
+
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);
|
|
323
|
+
} catch (error) {
|
|
324
|
+
console.error('重置表单失败:', error);
|
|
325
|
+
}
|
|
243
326
|
}, []);
|
|
244
|
-
|
|
245
|
-
|
|
327
|
+
// 修复死循环:只在组件挂载时执行一次,不依赖 init 函数
|
|
328
|
+
useEffect(function () {
|
|
329
|
+
// 组件挂载时执行一次初始化
|
|
330
|
+
if (props.fetchSetting) {
|
|
331
|
+
props.fetchSetting().then(function (res) {
|
|
332
|
+
setColumnsStateMap(res);
|
|
333
|
+
}).catch(function (error) {
|
|
334
|
+
console.error('获取列设置失败:', error);
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
}, []); // 空依赖数组,只在挂载时执行一次
|
|
338
|
+
// 优化:使用 useMemo 缓存计算结果
|
|
339
|
+
var dealFetchParams = useCallback(function (params) {
|
|
246
340
|
var fetchParams = {};
|
|
247
341
|
columns.forEach(function (item) {
|
|
248
|
-
var
|
|
249
|
-
if ((item === null || item === void 0 ? void 0 :
|
|
250
|
-
|
|
342
|
+
var dataIndex = item.dataIndex;
|
|
343
|
+
if ((item === null || item === void 0 ? void 0 : item.search) && _typeof(item.search) === 'object' && item.search.transform && params[dataIndex]) {
|
|
344
|
+
var transformResult = item.search.transform(params[dataIndex], dataIndex, params);
|
|
345
|
+
if (transformResult && _typeof(transformResult) === 'object') {
|
|
346
|
+
Object.assign(fetchParams, transformResult);
|
|
347
|
+
}
|
|
251
348
|
} else {
|
|
252
|
-
fetchParams =
|
|
349
|
+
fetchParams[dataIndex] = params[dataIndex];
|
|
253
350
|
}
|
|
254
351
|
});
|
|
255
352
|
return fetchParams;
|
|
256
|
-
};
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
353
|
+
}, [columns]);
|
|
354
|
+
// 优化:使用 useMemo 缓存列状态配置
|
|
355
|
+
var columnsState = useMemo(function () {
|
|
356
|
+
return {
|
|
357
|
+
defaultValue: defaultColumnsState,
|
|
358
|
+
value: columnsStateMap,
|
|
359
|
+
onChange: handleOnChangeColumn
|
|
360
|
+
};
|
|
361
|
+
}, [defaultColumnsState, columnsStateMap, handleOnChangeColumn]);
|
|
362
|
+
// 优化:使用 useCallback 缓存请求函数
|
|
363
|
+
var propsRequest = useCallback( /*#__PURE__*/function () {
|
|
364
|
+
var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(params, sort, filter) {
|
|
365
|
+
var _searchRef$current6, _drawFormRef$current7, res1, res2;
|
|
267
366
|
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
268
367
|
while (1) switch (_context8.prev = _context8.next) {
|
|
269
368
|
case 0:
|
|
270
|
-
_context8.
|
|
271
|
-
|
|
272
|
-
|
|
369
|
+
_context8.prev = 0;
|
|
370
|
+
_context8.next = 3;
|
|
371
|
+
return searchRef === null || searchRef === void 0 ? void 0 : (_searchRef$current6 = searchRef.current) === null || _searchRef$current6 === void 0 ? void 0 : _searchRef$current6.getFieldsValue();
|
|
372
|
+
case 3:
|
|
273
373
|
res1 = _context8.sent;
|
|
274
|
-
_context8.next =
|
|
275
|
-
return drawFormRef === null || drawFormRef === void 0 ? void 0 : (_drawFormRef$
|
|
276
|
-
case
|
|
374
|
+
_context8.next = 6;
|
|
375
|
+
return drawFormRef === null || drawFormRef === void 0 ? void 0 : (_drawFormRef$current7 = drawFormRef.current) === null || _drawFormRef$current7 === void 0 ? void 0 : _drawFormRef$current7.getFieldsValue();
|
|
376
|
+
case 6:
|
|
277
377
|
res2 = _context8.sent;
|
|
278
|
-
if (
|
|
279
|
-
_context8.next =
|
|
378
|
+
if (request) {
|
|
379
|
+
_context8.next = 9;
|
|
280
380
|
break;
|
|
281
381
|
}
|
|
282
|
-
_context8.
|
|
382
|
+
return _context8.abrupt("return", {});
|
|
383
|
+
case 9:
|
|
384
|
+
_context8.next = 11;
|
|
283
385
|
return request(_objectSpread(_objectSpread(_objectSpread({}, params), dealFetchParams(_objectSpread(_objectSpread(_objectSpread({}, res1), res2), params))), {}, {
|
|
284
386
|
showFull: showFull
|
|
285
387
|
}), sort, filter);
|
|
286
|
-
case
|
|
287
|
-
_context8.
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
_context8.t0
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
return _context8.abrupt("return", res);
|
|
295
|
-
case 15:
|
|
388
|
+
case 11:
|
|
389
|
+
return _context8.abrupt("return", _context8.sent);
|
|
390
|
+
case 14:
|
|
391
|
+
_context8.prev = 14;
|
|
392
|
+
_context8.t0 = _context8["catch"](0);
|
|
393
|
+
console.error('请求数据失败:', _context8.t0);
|
|
394
|
+
return _context8.abrupt("return", {});
|
|
395
|
+
case 18:
|
|
296
396
|
case "end":
|
|
297
397
|
return _context8.stop();
|
|
298
398
|
}
|
|
299
|
-
}, _callee8);
|
|
399
|
+
}, _callee8, null, [[0, 14]]);
|
|
300
400
|
}));
|
|
301
|
-
return function
|
|
302
|
-
return
|
|
401
|
+
return function (_x5, _x6, _x7) {
|
|
402
|
+
return _ref8.apply(this, arguments);
|
|
303
403
|
};
|
|
304
|
-
}();
|
|
305
|
-
|
|
306
|
-
var __options = (
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
404
|
+
}(), [request, dealFetchParams, showFull]);
|
|
405
|
+
// 优化:使用 useMemo 缓存选项配置
|
|
406
|
+
var __options = useMemo(function () {
|
|
407
|
+
var optionsSetting = _typeof(options) === 'object' && _typeof(options.setting) === 'object' ? options.setting : {};
|
|
408
|
+
console.log(action === null || action === void 0 ? void 0 : action.includes('columnSetting'), showDefaultSetting !== true);
|
|
409
|
+
if ((action === null || action === void 0 ? void 0 : action.includes('columnSetting')) && showDefaultSetting !== true) {
|
|
410
|
+
return _objectSpread(_objectSpread({}, options), {}, {
|
|
411
|
+
setting: _objectSpread(_objectSpread({}, optionsSetting), {}, {
|
|
412
|
+
checkedReset: false,
|
|
413
|
+
showListItemOption: true,
|
|
414
|
+
extra: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("a", {
|
|
415
|
+
onClick: handleSave,
|
|
416
|
+
style: {
|
|
417
|
+
cursor: isLoading ? 'not-allowed' : 'pointer',
|
|
418
|
+
opacity: isLoading ? 0.6 : 1,
|
|
419
|
+
pointerEvents: isLoading ? 'none' : 'auto'
|
|
420
|
+
}
|
|
421
|
+
}, isLoading ? '保存中...' : '保存'), /*#__PURE__*/React.createElement("a", {
|
|
422
|
+
style: {
|
|
423
|
+
color: '#333'
|
|
424
|
+
},
|
|
425
|
+
onClick: handleReset
|
|
426
|
+
}, "\u91CD\u7F6E"))
|
|
427
|
+
})
|
|
428
|
+
});
|
|
329
429
|
}
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
430
|
+
return options;
|
|
431
|
+
}, [options, action, showDefaultSetting, handleSave, handleReset, isLoading]);
|
|
432
|
+
// 优化:使用 useMemo 缓存列配置
|
|
433
|
+
var processedColumns = useMemo(function () {
|
|
434
|
+
if (!(action === null || action === void 0 ? void 0 : action.includes('advancedFilter'))) {
|
|
435
|
+
return columns;
|
|
436
|
+
}
|
|
437
|
+
return columns.map(function (item) {
|
|
438
|
+
if (item.baseSearch) {
|
|
439
|
+
return _objectSpread(_objectSpread({}, item), {}, {
|
|
440
|
+
search: item.search,
|
|
441
|
+
fieldProps: _objectSpread({
|
|
442
|
+
onChange: function onChange(e) {
|
|
443
|
+
try {
|
|
444
|
+
if (e) {
|
|
445
|
+
var _drawFormRef$current8;
|
|
446
|
+
var value = e.target ? e.target.value : e;
|
|
447
|
+
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));
|
|
448
|
+
} else {
|
|
449
|
+
var _drawFormRef$current10;
|
|
450
|
+
drawFormRef === null || drawFormRef === void 0 ? void 0 : (_drawFormRef$current10 = drawFormRef.current) === null || _drawFormRef$current10 === void 0 ? void 0 : _drawFormRef$current10.resetFields([item.dataIndex]);
|
|
451
|
+
}
|
|
452
|
+
} catch (error) {
|
|
453
|
+
console.error('字段值变更处理失败:', error);
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
}, item.fieldProps)
|
|
457
|
+
});
|
|
458
|
+
}
|
|
459
|
+
return _objectSpread(_objectSpread({}, item), {}, {
|
|
460
|
+
search: false
|
|
461
|
+
});
|
|
462
|
+
});
|
|
463
|
+
}, [columns, action]);
|
|
464
|
+
// 优化:使用 useMemo 缓存搜索配置
|
|
465
|
+
var searchConfig = useMemo(function () {
|
|
466
|
+
if (!(action === null || action === void 0 ? void 0 : action.includes('advancedFilter'))) {
|
|
467
|
+
return props.search;
|
|
468
|
+
}
|
|
469
|
+
return _objectSpread(_objectSpread({}, search), {}, {
|
|
470
|
+
span: CONSTANTS.SEARCH_SPAN,
|
|
471
|
+
labelWidth: CONSTANTS.LABEL_WIDTH,
|
|
352
472
|
collapseRender: function collapseRender() {
|
|
353
473
|
return null;
|
|
354
474
|
},
|
|
@@ -358,17 +478,12 @@ function PlusTable(props, ref) {
|
|
|
358
478
|
size: "middle",
|
|
359
479
|
type: "primary",
|
|
360
480
|
onClick: function onClick() {
|
|
361
|
-
handleSearchAll(searchConfig);
|
|
481
|
+
return handleSearchAll(searchConfig);
|
|
362
482
|
}
|
|
363
483
|
}, "\u67E5\u8BE2"), /*#__PURE__*/React.createElement(_Button, {
|
|
364
484
|
key: "2",
|
|
365
485
|
type: "default",
|
|
366
|
-
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
|
-
},
|
|
486
|
+
onClick: handleResetForm,
|
|
372
487
|
size: "middle"
|
|
373
488
|
}, "\u91CD\u7F6E"), /*#__PURE__*/React.createElement("a", {
|
|
374
489
|
key: "3",
|
|
@@ -376,75 +491,61 @@ function PlusTable(props, ref) {
|
|
|
376
491
|
wordBreak: 'break-word',
|
|
377
492
|
whiteSpace: 'nowrap'
|
|
378
493
|
},
|
|
379
|
-
onClick:
|
|
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
|
-
}))
|
|
494
|
+
onClick: handleAdvancedFilterClick
|
|
395
495
|
}, /*#__PURE__*/React.createElement(BarsOutlined, null), "\u9AD8\u7EA7\u7B5B\u9009")];
|
|
396
496
|
}
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
|
|
497
|
+
});
|
|
498
|
+
}, [action, props.search, handleSearchAll, handleResetForm, handleAdvancedFilterClick]);
|
|
499
|
+
// 优化:使用 useMemo 缓存工具栏渲染
|
|
500
|
+
var toolBarRender = useCallback(function (searchConfig, rows) {
|
|
501
|
+
return [(action === null || action === void 0 ? void 0 : action.includes('viewInvisibleData')) ? /*#__PURE__*/React.createElement(_Checkbox, {
|
|
502
|
+
defaultChecked: showFull,
|
|
503
|
+
onChange: handleShowFullChange
|
|
504
|
+
}, "\u663E\u793A\u6240\u6709\u6570\u636E") : null, typeof otherProps.toolBarRender === 'function' && otherProps.toolBarRender(searchConfig, rows)];
|
|
505
|
+
}, [action, showFull, handleShowFullChange, otherProps.toolBarRender]);
|
|
506
|
+
// 优化:使用 useMemo 缓存抽屉样式
|
|
507
|
+
var drawerStyle = useMemo(function () {
|
|
508
|
+
return {
|
|
509
|
+
position: 'fixed',
|
|
510
|
+
top: props.top || CONSTANTS.DEFAULT_TOP
|
|
511
|
+
};
|
|
512
|
+
}, [props.top]);
|
|
513
|
+
// 优化:使用 useMemo 缓存抽屉底部按钮样式
|
|
514
|
+
var bottomButtonStyle = useMemo(function () {
|
|
515
|
+
return {
|
|
516
|
+
position: 'fixed',
|
|
517
|
+
bottom: 0,
|
|
518
|
+
background: 'white',
|
|
519
|
+
display: 'flex',
|
|
520
|
+
width: "".concat(CONSTANTS.DRAWER_WIDTH, "px"),
|
|
521
|
+
borderTop: '1px solid #f0f0f0',
|
|
522
|
+
right: '0',
|
|
523
|
+
justifyContent: 'space-around',
|
|
524
|
+
padding: '16px',
|
|
525
|
+
boxSizing: 'border-box'
|
|
526
|
+
};
|
|
527
|
+
}, []);
|
|
528
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
529
|
+
className: "page_plustable__body"
|
|
530
|
+
}, /*#__PURE__*/React.createElement(ProTable, _extends({
|
|
531
|
+
pagination: _objectSpread({
|
|
532
|
+
size: 'default'
|
|
533
|
+
}, pagination),
|
|
534
|
+
actionRef: actionRef,
|
|
535
|
+
formRef: searchRef,
|
|
536
|
+
search: searchConfig,
|
|
400
537
|
columnsState: (action === null || action === void 0 ? void 0 : action.includes('columnSetting')) ? columnsState : props.columnsState,
|
|
401
|
-
request: request ? propsRequest : undefined
|
|
402
|
-
|
|
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
|
-
},
|
|
538
|
+
request: request ? propsRequest : undefined,
|
|
539
|
+
columns: processedColumns,
|
|
540
|
+
toolBarRender: toolBarRender,
|
|
437
541
|
options: __options
|
|
438
542
|
}, otherProps)), /*#__PURE__*/React.createElement(_Drawer, {
|
|
439
543
|
onClose: function onClose() {
|
|
440
544
|
return setSearchDrawer(false);
|
|
441
545
|
},
|
|
442
|
-
title:
|
|
443
|
-
width:
|
|
444
|
-
rootStyle:
|
|
445
|
-
position: 'fixed',
|
|
446
|
-
top: props.top || 92
|
|
447
|
-
},
|
|
546
|
+
title: "\u9AD8\u7EA7\u7B5B\u9009",
|
|
547
|
+
width: CONSTANTS.DRAWER_WIDTH,
|
|
548
|
+
rootStyle: drawerStyle,
|
|
448
549
|
getContainer: (otherProps === null || otherProps === void 0 ? void 0 : otherProps.getContainer) || document.getElementsByTagName('body')[0],
|
|
449
550
|
className: "search-drawer",
|
|
450
551
|
open: searchDrawer,
|
|
@@ -453,9 +554,7 @@ function PlusTable(props, ref) {
|
|
|
453
554
|
}, /*#__PURE__*/React.createElement(FormRender, {
|
|
454
555
|
columns: columns,
|
|
455
556
|
loading: false,
|
|
456
|
-
changeValue:
|
|
457
|
-
return onValuesChange(_changeValue, allValue);
|
|
458
|
-
},
|
|
557
|
+
changeValue: onValuesChange,
|
|
459
558
|
onFormSearchSubmit: function onFormSearchSubmit() {
|
|
460
559
|
var _searchRef$current7;
|
|
461
560
|
searchRef === null || searchRef === void 0 ? void 0 : (_searchRef$current7 = searchRef.current) === null || _searchRef$current7 === void 0 ? void 0 : _searchRef$current7.submit();
|
|
@@ -470,32 +569,17 @@ function PlusTable(props, ref) {
|
|
|
470
569
|
search: {
|
|
471
570
|
optionRender: function optionRender(searchConfig) {
|
|
472
571
|
return [/*#__PURE__*/React.createElement("div", {
|
|
473
|
-
|
|
474
|
-
|
|
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
|
-
}
|
|
572
|
+
key: "bottom-buttons",
|
|
573
|
+
style: bottomButtonStyle
|
|
485
574
|
}, /*#__PURE__*/React.createElement(_Button, {
|
|
486
575
|
size: "middle",
|
|
487
576
|
type: "primary",
|
|
488
577
|
onClick: function onClick() {
|
|
489
|
-
handleSearchAll(searchConfig);
|
|
578
|
+
return handleSearchAll(searchConfig);
|
|
490
579
|
}
|
|
491
580
|
}, "\u67E5\u8BE2"), /*#__PURE__*/React.createElement(_Button, {
|
|
492
581
|
type: "default",
|
|
493
|
-
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
|
-
},
|
|
582
|
+
onClick: handleResetForm,
|
|
499
583
|
size: "middle"
|
|
500
584
|
}, "\u91CD\u7F6E"))];
|
|
501
585
|
},
|