@fle-ui/plus-table 1.2.28-beta.1 → 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.
- 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.js +0 -8
- package/es/{FormSearch → components/FormSearch}/index.less +5 -3
- package/es/index.d.ts +4 -3
- package/es/index.js +437 -344
- 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.js +0 -8
- package/lib/{FormSearch → components/FormSearch}/index.less +5 -3
- package/lib/index.d.ts +4 -3
- package/lib/index.js +436 -343
- 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/lib/{FormSearch → components/FormSearch}/index.d.ts +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);
|
|
@@ -50,7 +65,7 @@ function PlusTable(props, ref) {
|
|
|
50
65
|
_useState2 = _slicedToArray(_useState, 2),
|
|
51
66
|
searchDrawer = _useState2[0],
|
|
52
67
|
setSearchDrawer = _useState2[1];
|
|
53
|
-
var _useState3 = useState(false),
|
|
68
|
+
var _useState3 = useState(props.defaultShowFull || false),
|
|
54
69
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
55
70
|
showFull = _useState4[0],
|
|
56
71
|
setShowFull = _useState4[1];
|
|
@@ -59,305 +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
|
-
|
|
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
|
-
|
|
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) {
|
|
228
286
|
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
229
287
|
while (1) switch (_context7.prev = _context7.next) {
|
|
230
288
|
case 0:
|
|
231
|
-
|
|
289
|
+
try {
|
|
290
|
+
searchConfig.form.submit();
|
|
291
|
+
} catch (error) {
|
|
292
|
+
console.error('搜索失败:', error);
|
|
293
|
+
}
|
|
232
294
|
case 1:
|
|
233
295
|
case "end":
|
|
234
296
|
return _context7.stop();
|
|
235
297
|
}
|
|
236
298
|
}, _callee7);
|
|
237
299
|
}));
|
|
238
|
-
return function
|
|
239
|
-
return
|
|
300
|
+
return function (_x4) {
|
|
301
|
+
return _ref7.apply(this, arguments);
|
|
240
302
|
};
|
|
241
|
-
}();
|
|
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
|
+
}, []);
|
|
242
352
|
useEffect(function () {
|
|
243
353
|
init();
|
|
244
|
-
}, []);
|
|
245
|
-
|
|
246
|
-
|
|
354
|
+
}, [init]);
|
|
355
|
+
// 优化:使用 useMemo 缓存计算结果
|
|
356
|
+
var dealFetchParams = useCallback(function (params) {
|
|
247
357
|
var fetchParams = {};
|
|
248
358
|
columns.forEach(function (item) {
|
|
249
|
-
var
|
|
250
|
-
if ((item === null || item === void 0 ? void 0 :
|
|
251
|
-
|
|
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
|
+
}
|
|
252
365
|
} else {
|
|
253
|
-
fetchParams =
|
|
366
|
+
fetchParams[dataIndex] = params[dataIndex];
|
|
254
367
|
}
|
|
255
368
|
});
|
|
256
369
|
return fetchParams;
|
|
257
|
-
};
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
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) {
|
|
270
385
|
case 0:
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
res1[key] = undefined;
|
|
283
|
-
params[key] = undefined;
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
if (!request) {
|
|
288
|
-
_context8.next = 13;
|
|
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;
|
|
289
397
|
break;
|
|
290
398
|
}
|
|
291
|
-
|
|
399
|
+
return _context9.abrupt("return", {});
|
|
400
|
+
case 9:
|
|
401
|
+
_context9.next = 11;
|
|
292
402
|
return request(_objectSpread(_objectSpread(_objectSpread({}, params), dealFetchParams(_objectSpread(_objectSpread(_objectSpread({}, res1), res2), params))), {}, {
|
|
293
403
|
showFull: showFull
|
|
294
404
|
}), sort, filter);
|
|
295
|
-
case
|
|
296
|
-
|
|
297
|
-
_context8.next = 14;
|
|
298
|
-
break;
|
|
299
|
-
case 13:
|
|
300
|
-
_context8.t0 = {};
|
|
405
|
+
case 11:
|
|
406
|
+
return _context9.abrupt("return", _context9.sent);
|
|
301
407
|
case 14:
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
408
|
+
_context9.prev = 14;
|
|
409
|
+
_context9.t0 = _context9["catch"](0);
|
|
410
|
+
console.error('请求数据失败:', _context9.t0);
|
|
411
|
+
return _context9.abrupt("return", {});
|
|
412
|
+
case 18:
|
|
305
413
|
case "end":
|
|
306
|
-
return
|
|
414
|
+
return _context9.stop();
|
|
307
415
|
}
|
|
308
|
-
},
|
|
416
|
+
}, _callee9, null, [[0, 14]]);
|
|
309
417
|
}));
|
|
310
|
-
return function
|
|
311
|
-
return
|
|
418
|
+
return function (_x5, _x6, _x7) {
|
|
419
|
+
return _ref9.apply(this, arguments);
|
|
312
420
|
};
|
|
313
|
-
}();
|
|
314
|
-
|
|
315
|
-
var __options = (
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
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
|
+
});
|
|
338
445
|
}
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
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,
|
|
361
488
|
collapseRender: function collapseRender() {
|
|
362
489
|
return null;
|
|
363
490
|
},
|
|
@@ -367,17 +494,12 @@ function PlusTable(props, ref) {
|
|
|
367
494
|
size: "middle",
|
|
368
495
|
type: "primary",
|
|
369
496
|
onClick: function onClick() {
|
|
370
|
-
handleSearchAll(searchConfig);
|
|
497
|
+
return handleSearchAll(searchConfig);
|
|
371
498
|
}
|
|
372
499
|
}, "\u67E5\u8BE2"), /*#__PURE__*/React.createElement(_Button, {
|
|
373
500
|
key: "2",
|
|
374
501
|
type: "default",
|
|
375
|
-
onClick:
|
|
376
|
-
var _drawFormRef$current6, _actionRef$current, _actionRef$current$re, _actionRef$current2, _actionRef$current2$r;
|
|
377
|
-
drawFormRef === null || drawFormRef === void 0 ? void 0 : (_drawFormRef$current6 = drawFormRef.current) === null || _drawFormRef$current6 === void 0 ? void 0 : _drawFormRef$current6.resetFields();
|
|
378
|
-
actionRef === null || actionRef === void 0 ? void 0 : (_actionRef$current = actionRef.current) === null || _actionRef$current === void 0 ? void 0 : (_actionRef$current$re = _actionRef$current.reset) === null || _actionRef$current$re === void 0 ? void 0 : _actionRef$current$re.call(_actionRef$current);
|
|
379
|
-
actionRef === null || actionRef === void 0 ? void 0 : (_actionRef$current2 = actionRef.current) === null || _actionRef$current2 === void 0 ? void 0 : (_actionRef$current2$r = _actionRef$current2.reload) === null || _actionRef$current2$r === void 0 ? void 0 : _actionRef$current2$r.call(_actionRef$current2);
|
|
380
|
-
},
|
|
502
|
+
onClick: handleResetForm,
|
|
381
503
|
size: "middle"
|
|
382
504
|
}, "\u91CD\u7F6E"), /*#__PURE__*/React.createElement("a", {
|
|
383
505
|
key: "3",
|
|
@@ -385,74 +507,62 @@ function PlusTable(props, ref) {
|
|
|
385
507
|
wordBreak: 'break-word',
|
|
386
508
|
whiteSpace: 'nowrap'
|
|
387
509
|
},
|
|
388
|
-
onClick:
|
|
389
|
-
var _drawFormRef$current7, _searchRef$current6;
|
|
390
|
-
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
391
|
-
while (1) switch (_context9.prev = _context9.next) {
|
|
392
|
-
case 0:
|
|
393
|
-
_context9.next = 2;
|
|
394
|
-
return setSearchDrawer(!searchDrawer);
|
|
395
|
-
case 2:
|
|
396
|
-
// 没法实时监听数据所以这里要带过来
|
|
397
|
-
drawFormRef === null || drawFormRef === void 0 ? void 0 : (_drawFormRef$current7 = drawFormRef.current) === null || _drawFormRef$current7 === void 0 ? void 0 : _drawFormRef$current7.setFieldsValue(searchRef === null || searchRef === void 0 ? void 0 : (_searchRef$current6 = searchRef.current) === null || _searchRef$current6 === void 0 ? void 0 : _searchRef$current6.getFieldsValue());
|
|
398
|
-
case 3:
|
|
399
|
-
case "end":
|
|
400
|
-
return _context9.stop();
|
|
401
|
-
}
|
|
402
|
-
}, _callee9);
|
|
403
|
-
}))
|
|
510
|
+
onClick: handleAdvancedFilterClick
|
|
404
511
|
}, /*#__PURE__*/React.createElement(BarsOutlined, null), "\u9AD8\u7EA7\u7B5B\u9009")];
|
|
405
512
|
}
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
|
|
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,
|
|
409
554
|
columnsState: (action === null || action === void 0 ? void 0 : action.includes('columnSetting')) ? columnsState : props.columnsState,
|
|
410
|
-
request: request ? propsRequest : undefined
|
|
411
|
-
|
|
412
|
-
,
|
|
413
|
-
columns: (action === null || action === void 0 ? void 0 : action.includes('advancedFilter')) ? columns.map(function (item) {
|
|
414
|
-
// 只保留基本搜索栏的配置
|
|
415
|
-
if (item.baseSearch) {
|
|
416
|
-
return _objectSpread(_objectSpread({}, item), {}, {
|
|
417
|
-
search: item.search,
|
|
418
|
-
fieldProps: _objectSpread({
|
|
419
|
-
onChange: function onChange(e) {
|
|
420
|
-
if (e) {
|
|
421
|
-
var _drawFormRef$current8;
|
|
422
|
-
drawFormRef === null || drawFormRef === void 0 ? void 0 : (_drawFormRef$current8 = drawFormRef.current) === null || _drawFormRef$current8 === void 0 ? void 0 : _drawFormRef$current8.setFieldsValue(_defineProperty({}, item.dataIndex, e.target ? e.target.value : e));
|
|
423
|
-
} else {
|
|
424
|
-
var _drawFormRef$current10;
|
|
425
|
-
drawFormRef === null || drawFormRef === void 0 ? void 0 : (_drawFormRef$current10 = drawFormRef.current) === null || _drawFormRef$current10 === void 0 ? void 0 : _drawFormRef$current10.resetFields([item.dataIndex]);
|
|
426
|
-
}
|
|
427
|
-
}
|
|
428
|
-
}, item.fieldProps)
|
|
429
|
-
});
|
|
430
|
-
}
|
|
431
|
-
return _objectSpread(_objectSpread({}, item), {}, {
|
|
432
|
-
search: false
|
|
433
|
-
});
|
|
434
|
-
}) : columns,
|
|
435
|
-
toolBarRender: function toolBarRender(searchConfig, rows) {
|
|
436
|
-
return [(action === null || action === void 0 ? void 0 : action.includes('viewInvisibleData')) ? /*#__PURE__*/React.createElement(_Checkbox, {
|
|
437
|
-
onChange: function onChange(e) {
|
|
438
|
-
setShowFull(e.target.checked);
|
|
439
|
-
setTimeout(function () {
|
|
440
|
-
searchConfig === null || searchConfig === void 0 ? void 0 : searchConfig.reload();
|
|
441
|
-
}, 100);
|
|
442
|
-
}
|
|
443
|
-
}, "\u663E\u793A\u6240\u6709\u6570\u636E") : null, typeof otherProps.toolBarRender === 'function' && otherProps.toolBarRender(searchConfig, rows)];
|
|
444
|
-
},
|
|
555
|
+
request: request ? propsRequest : undefined,
|
|
556
|
+
columns: processedColumns,
|
|
557
|
+
toolBarRender: toolBarRender,
|
|
445
558
|
options: __options
|
|
446
559
|
}, otherProps)), /*#__PURE__*/React.createElement(_Drawer, {
|
|
447
560
|
onClose: function onClose() {
|
|
448
561
|
return setSearchDrawer(false);
|
|
449
562
|
},
|
|
450
|
-
title:
|
|
451
|
-
width:
|
|
452
|
-
rootStyle:
|
|
453
|
-
position: 'fixed',
|
|
454
|
-
top: props.top || 92
|
|
455
|
-
},
|
|
563
|
+
title: "\u9AD8\u7EA7\u7B5B\u9009",
|
|
564
|
+
width: CONSTANTS.DRAWER_WIDTH,
|
|
565
|
+
rootStyle: drawerStyle,
|
|
456
566
|
getContainer: (otherProps === null || otherProps === void 0 ? void 0 : otherProps.getContainer) || document.getElementsByTagName('body')[0],
|
|
457
567
|
className: "search-drawer",
|
|
458
568
|
open: searchDrawer,
|
|
@@ -461,9 +571,7 @@ function PlusTable(props, ref) {
|
|
|
461
571
|
}, /*#__PURE__*/React.createElement(FormRender, {
|
|
462
572
|
columns: columns,
|
|
463
573
|
loading: false,
|
|
464
|
-
changeValue:
|
|
465
|
-
return onValuesChange(_changeValue, allValue);
|
|
466
|
-
},
|
|
574
|
+
changeValue: onValuesChange,
|
|
467
575
|
onFormSearchSubmit: function onFormSearchSubmit() {
|
|
468
576
|
var _searchRef$current7;
|
|
469
577
|
searchRef === null || searchRef === void 0 ? void 0 : (_searchRef$current7 = searchRef.current) === null || _searchRef$current7 === void 0 ? void 0 : _searchRef$current7.submit();
|
|
@@ -478,32 +586,17 @@ function PlusTable(props, ref) {
|
|
|
478
586
|
search: {
|
|
479
587
|
optionRender: function optionRender(searchConfig) {
|
|
480
588
|
return [/*#__PURE__*/React.createElement("div", {
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
bottom: 0,
|
|
484
|
-
background: 'white',
|
|
485
|
-
display: 'flex',
|
|
486
|
-
width: '380px',
|
|
487
|
-
borderTop: '1px solid #f0f0f0',
|
|
488
|
-
right: '0',
|
|
489
|
-
justifyContent: 'space-around',
|
|
490
|
-
padding: '16px',
|
|
491
|
-
boxSizing: 'border-box'
|
|
492
|
-
}
|
|
589
|
+
key: "bottom-buttons",
|
|
590
|
+
style: bottomButtonStyle
|
|
493
591
|
}, /*#__PURE__*/React.createElement(_Button, {
|
|
494
592
|
size: "middle",
|
|
495
593
|
type: "primary",
|
|
496
594
|
onClick: function onClick() {
|
|
497
|
-
handleSearchAll(searchConfig);
|
|
595
|
+
return handleSearchAll(searchConfig);
|
|
498
596
|
}
|
|
499
597
|
}, "\u67E5\u8BE2"), /*#__PURE__*/React.createElement(_Button, {
|
|
500
598
|
type: "default",
|
|
501
|
-
onClick:
|
|
502
|
-
var _drawFormRef$current11, _actionRef$current3, _actionRef$current3$r, _actionRef$current4, _actionRef$current4$r;
|
|
503
|
-
drawFormRef === null || drawFormRef === void 0 ? void 0 : (_drawFormRef$current11 = drawFormRef.current) === null || _drawFormRef$current11 === void 0 ? void 0 : _drawFormRef$current11.resetFields();
|
|
504
|
-
actionRef === null || actionRef === void 0 ? void 0 : (_actionRef$current3 = actionRef.current) === null || _actionRef$current3 === void 0 ? void 0 : (_actionRef$current3$r = _actionRef$current3.reset) === null || _actionRef$current3$r === void 0 ? void 0 : _actionRef$current3$r.call(_actionRef$current3);
|
|
505
|
-
actionRef === null || actionRef === void 0 ? void 0 : (_actionRef$current4 = actionRef.current) === null || _actionRef$current4 === void 0 ? void 0 : (_actionRef$current4$r = _actionRef$current4.reload) === null || _actionRef$current4$r === void 0 ? void 0 : _actionRef$current4$r.call(_actionRef$current4);
|
|
506
|
-
},
|
|
599
|
+
onClick: handleResetForm,
|
|
507
600
|
size: "middle"
|
|
508
601
|
}, "\u91CD\u7F6E"))];
|
|
509
602
|
},
|