fan-standard-comp 4.1.3 → 4.1.4
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/dist/fan-standard-comp.min.css +1 -1
- package/dist/fan-standard-comp.min.js +1 -1
- package/es/CompositeTable/index.d.ts +0 -0
- package/es/CompositeTable/index.js +211 -0
- package/es/CompositeTable/index.style.d.ts +5 -0
- package/es/CompositeTable/index.style.js +27 -0
- package/es/FormComp/FieldComponent/index.js +2 -6
- package/es/StandardContent/ContentHeader.js +17 -25
- package/es/StandardContent/SubfieldContent.js +12 -9
- package/es/StandardContent/WrapperContent.js +9 -8
- package/es/StandardContent/styles/Subfield.js +18 -5
- package/es/StandardContent/styles/Wrapper.js +13 -2
- package/es/StandardContent/styles/index.less +8 -2
- package/es/StandardFilter/index.js +26 -12
- package/es/StandardFilter/style/FilterStyle.js +3 -2
- package/es/StandardFilter/style/index.less +7 -0
- package/es/StandardTable/index.d.ts +3 -3
- package/es/StandardTable/index.js +9 -3
- package/es/StandardTablePro/index.d.ts +2 -12
- package/es/StandardTablePro/index.js +216 -31
- package/es/StandardTablePro/types.d.ts +29 -0
- package/es/StandardTablePro/types.js +1 -0
- package/es/StandardTablePro/useFetchData.d.ts +0 -0
- package/es/StandardTablePro/useFetchData.js +275 -0
- package/es/StandardTablePro/utils.d.ts +3 -0
- package/es/StandardTablePro/utils.js +49 -0
- package/es/utils/ValueFormat.js +1 -0
- package/es/utils/getParentNodes.js +1 -1
- package/lib/CompositeTable/index.d.ts +0 -0
- package/lib/CompositeTable/index.js +212 -0
- package/lib/CompositeTable/index.style.d.ts +5 -0
- package/lib/CompositeTable/index.style.js +33 -0
- package/lib/FormComp/FieldComponent/index.js +2 -6
- package/lib/StandardContent/ContentHeader.js +16 -24
- package/lib/StandardContent/SubfieldContent.js +12 -9
- package/lib/StandardContent/WrapperContent.js +9 -8
- package/lib/StandardContent/styles/Subfield.js +18 -5
- package/lib/StandardContent/styles/Wrapper.js +13 -2
- package/lib/StandardContent/styles/index.less +8 -2
- package/lib/StandardFilter/index.js +26 -12
- package/lib/StandardFilter/style/FilterStyle.js +3 -2
- package/lib/StandardFilter/style/index.less +7 -0
- package/lib/StandardTable/index.d.ts +3 -3
- package/lib/StandardTable/index.js +8 -2
- package/lib/StandardTablePro/index.d.ts +2 -12
- package/lib/StandardTablePro/index.js +214 -29
- package/lib/StandardTablePro/types.d.ts +29 -0
- package/lib/StandardTablePro/types.js +5 -1
- package/lib/StandardTablePro/useFetchData.d.ts +0 -0
- package/lib/StandardTablePro/useFetchData.js +276 -0
- package/lib/StandardTablePro/utils.d.ts +3 -0
- package/lib/StandardTablePro/utils.js +55 -0
- package/lib/utils/ValueFormat.js +1 -0
- package/lib/utils/getParentNodes.js +1 -1
- package/package.json +2 -2
|
@@ -9,13 +9,17 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
9
9
|
var _ConfigContext = require("../ConfigContext");
|
|
10
10
|
var _StandardFilter = _interopRequireDefault(require("../StandardFilter"));
|
|
11
11
|
var _StandardTable = _interopRequireDefault(require("../StandardTable"));
|
|
12
|
+
var _utils = require("./utils");
|
|
12
13
|
var _index = _interopRequireDefault(require("./style/index"));
|
|
13
14
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
14
|
-
var _excluded = ["proClassname", "filter", "formConfig", "codes", "permissionCodes", "onSubmit", "onReset", "onChange", "children", "className", "columns", "
|
|
15
|
+
var _excluded = ["proClassname", "filter", "formConfig", "codes", "permissionCodes", "onSubmit", "onReset", "onChange", "children", "className", "columns", "defaultParams", "acceptType", "data", "fetchData", "fetchOptionName", "onAction", "tableActionRef", "filterFormRef", "getDataSource", "localPageInfo"];
|
|
15
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
17
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
17
18
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
18
19
|
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); }
|
|
20
|
+
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 new 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 new 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 new 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; }
|
|
21
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
22
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
19
23
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
20
24
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
21
25
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
@@ -47,7 +51,28 @@ var StandardTablePro = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref)
|
|
|
47
51
|
children = _providerConfig$props.children,
|
|
48
52
|
className = _providerConfig$props.className,
|
|
49
53
|
columns = _providerConfig$props.columns,
|
|
50
|
-
|
|
54
|
+
defaultParams = _providerConfig$props.defaultParams,
|
|
55
|
+
_providerConfig$props2 = _providerConfig$props.acceptType,
|
|
56
|
+
acceptType = _providerConfig$props2 === void 0 ? 'data' : _providerConfig$props2,
|
|
57
|
+
data = _providerConfig$props.data,
|
|
58
|
+
fetchData = _providerConfig$props.fetchData,
|
|
59
|
+
_providerConfig$props3 = _providerConfig$props.fetchOptionName,
|
|
60
|
+
fetchOptionName = _providerConfig$props3 === void 0 ? {
|
|
61
|
+
dataKey: 'data',
|
|
62
|
+
listKey: 'records',
|
|
63
|
+
totalKey: 'total',
|
|
64
|
+
currentKey: 'current',
|
|
65
|
+
sizeKey: 'size'
|
|
66
|
+
} : _providerConfig$props3,
|
|
67
|
+
onAction = _providerConfig$props.onAction,
|
|
68
|
+
propsActionRef = _providerConfig$props.tableActionRef,
|
|
69
|
+
defaultFormRef = _providerConfig$props.filterFormRef,
|
|
70
|
+
getDataSource = _providerConfig$props.getDataSource,
|
|
71
|
+
_providerConfig$props4 = _providerConfig$props.localPageInfo,
|
|
72
|
+
localPageInfo = _providerConfig$props4 === void 0 ? {
|
|
73
|
+
current: 1,
|
|
74
|
+
size: 10
|
|
75
|
+
} : _providerConfig$props4,
|
|
51
76
|
others = _objectWithoutProperties(_providerConfig$props, _excluded);
|
|
52
77
|
var commonConfig = {
|
|
53
78
|
codes: codes,
|
|
@@ -58,6 +83,27 @@ var StandardTablePro = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref)
|
|
|
58
83
|
_useStyle2 = _slicedToArray(_useStyle, 2),
|
|
59
84
|
wrapSSR = _useStyle2[0],
|
|
60
85
|
hashId = _useStyle2[1];
|
|
86
|
+
// data.list, data.pagination
|
|
87
|
+
var _useState = (0, _react.useState)({
|
|
88
|
+
list: [],
|
|
89
|
+
pagination: {},
|
|
90
|
+
keywords: {}
|
|
91
|
+
}),
|
|
92
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
93
|
+
resDataSource = _useState2[0],
|
|
94
|
+
setResDataSource = _useState2[1];
|
|
95
|
+
var _useState3 = (0, _react.useState)(false),
|
|
96
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
97
|
+
queryLoading = _useState4[0],
|
|
98
|
+
setQueryLoading = _useState4[1];
|
|
99
|
+
var _useState5 = (0, _react.useState)(false),
|
|
100
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
101
|
+
searchLoading = _useState6[0],
|
|
102
|
+
setSearchLoading = _useState6[1];
|
|
103
|
+
var _useState7 = (0, _react.useState)(),
|
|
104
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
105
|
+
sorterParams = _useState8[0],
|
|
106
|
+
setSorterParams = _useState8[1];
|
|
61
107
|
var handleChange = function handleChange(targetKey, data, defaultParam) {
|
|
62
108
|
if (targetKey === 'filterSearch') {
|
|
63
109
|
onSubmit === null || onSubmit === void 0 || onSubmit(data);
|
|
@@ -65,11 +111,8 @@ var StandardTablePro = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref)
|
|
|
65
111
|
if (targetKey === 'filterReset') {
|
|
66
112
|
onReset === null || onReset === void 0 || onReset();
|
|
67
113
|
}
|
|
68
|
-
// if (targetKey === 'tableChange') {
|
|
69
|
-
// onChange && onChange(data, defaultParam)
|
|
70
|
-
// }
|
|
71
114
|
};
|
|
72
|
-
var
|
|
115
|
+
var formItemGroupConcat = (0, _react.useMemo)(function () {
|
|
73
116
|
var itemGroupFromColumns = (columns || []).filter(function (item) {
|
|
74
117
|
return item.formItem && JSON.stringify(item.formItem) !== '{}';
|
|
75
118
|
}).map(function (fItem) {
|
|
@@ -80,51 +123,193 @@ var StandardTablePro = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref)
|
|
|
80
123
|
});
|
|
81
124
|
return ((filter === null || filter === void 0 ? void 0 : filter.formItemGroup) || []).concat(itemGroupFromColumns);
|
|
82
125
|
}, [columns, filter === null || filter === void 0 ? void 0 : filter.formItemGroup]);
|
|
83
|
-
|
|
126
|
+
var _useState9 = (0, _react.useState)({}),
|
|
127
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
128
|
+
filterInstance = _useState10[0],
|
|
129
|
+
setFilterFormInstance = _useState10[1];
|
|
130
|
+
// const [filterInitialValues, setFilterInitialValues] = useState({})
|
|
84
131
|
// const [filterFields, setFilterFormFields] = useState({})
|
|
85
|
-
var _useState = (0, _react.useState)({}),
|
|
86
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
87
|
-
filterInstance = _useState2[0],
|
|
88
|
-
setFilterFormInstance = _useState2[1];
|
|
89
132
|
// const [filterValues, setFilterValues] = useState<any>({})
|
|
133
|
+
|
|
134
|
+
var action = {
|
|
135
|
+
pagination: (resDataSource === null || resDataSource === void 0 ? void 0 : resDataSource.pagination) || localPageInfo,
|
|
136
|
+
dataSource: resDataSource === null || resDataSource === void 0 ? void 0 : resDataSource.list,
|
|
137
|
+
keywords: resDataSource === null || resDataSource === void 0 ? void 0 : resDataSource.keywords,
|
|
138
|
+
loading: queryLoading,
|
|
139
|
+
reload: function reload(filter) {
|
|
140
|
+
return loadData('reload', _objectSpread({}, localPageInfo), _objectSpread({}, filter));
|
|
141
|
+
},
|
|
142
|
+
// 更新列表
|
|
143
|
+
refresh: function refresh(filter) {
|
|
144
|
+
return loadData('refresh', _objectSpread({}, resDataSource.pagination), _objectSpread({}, filter));
|
|
145
|
+
} // 更新列表
|
|
146
|
+
};
|
|
147
|
+
/** 通用的来操作子节点的工具类 */
|
|
148
|
+
var actionRef = (0, _react.useRef)();
|
|
149
|
+
(0, _react.useImperativeHandle)(propsActionRef, function () {
|
|
150
|
+
return actionRef.current;
|
|
151
|
+
});
|
|
152
|
+
(0, _react.useImperativeHandle)(defaultFormRef, function () {
|
|
153
|
+
return filterInstance === null || filterInstance === void 0 ? void 0 : filterInstance.current;
|
|
154
|
+
});
|
|
90
155
|
// ref 的转发
|
|
91
156
|
(0, _react.useImperativeHandle)(ref, function () {
|
|
92
157
|
return {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
filterInstance: filterInstance === null || filterInstance === void 0 ? void 0 : filterInstance.current
|
|
96
|
-
// dataSource: resDataSource,
|
|
97
|
-
// setDataSource: setResDataSource,
|
|
98
|
-
// reload: (filter) => loadData('refresh', {}, filter) // 更新列表
|
|
158
|
+
filterInstance: filterInstance === null || filterInstance === void 0 ? void 0 : filterInstance.current,
|
|
159
|
+
tableInstance: actionRef.current
|
|
99
160
|
};
|
|
100
|
-
}, [filterInstance]);
|
|
101
|
-
|
|
102
|
-
|
|
161
|
+
}, [filterInstance, actionRef]);
|
|
162
|
+
|
|
163
|
+
/** 绑定 action current */
|
|
164
|
+
(0, _utils.useActionType)(actionRef, action);
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* 加载数据方法
|
|
168
|
+
* @param {string} updateKey 触发位置
|
|
169
|
+
* @param {Object} pagination 分页选项
|
|
170
|
+
* @param {Object} filter 筛选条件或表格排序条件
|
|
171
|
+
* @param {Object} tableChangeParams (表格默认参数){pagination, filter, sorter, extra}
|
|
172
|
+
*/
|
|
173
|
+
var loadData = (0, _react.useCallback)( /*#__PURE__*/function () {
|
|
174
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(updateKey, pagination, filters, tableChangeParams) {
|
|
175
|
+
var parameter, response, responseData;
|
|
176
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
177
|
+
while (1) switch (_context.prev = _context.next) {
|
|
178
|
+
case 0:
|
|
179
|
+
if (updateKey !== 'init' && updateKey !== 'reload' && updateKey !== 'refresh') {
|
|
180
|
+
onAction === null || onAction === void 0 || onAction(updateKey, updateKey === 'reset' ? {} : _objectSpread(_objectSpread({}, pagination), filters));
|
|
181
|
+
}
|
|
182
|
+
if (!(acceptType === 'fetch' && fetchData)) {
|
|
183
|
+
_context.next = 10;
|
|
184
|
+
break;
|
|
185
|
+
}
|
|
186
|
+
setQueryLoading(true);
|
|
187
|
+
parameter = Object.assign(_objectSpread({}, defaultParams),
|
|
188
|
+
// updateKey === 'init' ? { ...params } : {}, // 重置条件下,会清空params
|
|
189
|
+
{
|
|
190
|
+
current: (pagination === null || pagination === void 0 ? void 0 : pagination.current) || localPageInfo.current,
|
|
191
|
+
size: (pagination === null || pagination === void 0 ? void 0 : pagination.size) || localPageInfo.size
|
|
192
|
+
}, _objectSpread({}, filters) // 排序与筛选待定
|
|
193
|
+
// (sorter && sorter.field && {
|
|
194
|
+
// sortField: sorter.field
|
|
195
|
+
// }) || {},
|
|
196
|
+
// (sorter && sorter.order && {
|
|
197
|
+
// sortOrder: sorter.order
|
|
198
|
+
// }) || {},
|
|
199
|
+
);
|
|
200
|
+
_context.next = 6;
|
|
201
|
+
return fetchData(parameter, updateKey, tableChangeParams);
|
|
202
|
+
case 6:
|
|
203
|
+
response = _context.sent;
|
|
204
|
+
setQueryLoading(false);
|
|
205
|
+
setSearchLoading(false);
|
|
206
|
+
// 转换列表数据
|
|
207
|
+
if (response.code == '200') {
|
|
208
|
+
responseData = response[fetchOptionName.dataKey];
|
|
209
|
+
if (Array.isArray(responseData)) {
|
|
210
|
+
// 返回值为数组
|
|
211
|
+
setResDataSource({
|
|
212
|
+
list: responseData,
|
|
213
|
+
pagination: null,
|
|
214
|
+
keywords: parameter || {}
|
|
215
|
+
});
|
|
216
|
+
} else {
|
|
217
|
+
// 返回值为对象
|
|
218
|
+
setResDataSource(Object.assign({
|
|
219
|
+
list: responseData === null || responseData === void 0 ? void 0 : responseData[fetchOptionName.listKey || 'records'],
|
|
220
|
+
pagination: {
|
|
221
|
+
total: (responseData === null || responseData === void 0 ? void 0 : responseData[fetchOptionName.totalKey || 'total']) || 0,
|
|
222
|
+
current: (responseData === null || responseData === void 0 ? void 0 : responseData[fetchOptionName.currentKey || 'current']) | localPageInfo.current,
|
|
223
|
+
size: (responseData === null || responseData === void 0 ? void 0 : responseData[fetchOptionName.sizeKey || 'size']) || localPageInfo.size
|
|
224
|
+
},
|
|
225
|
+
keywords: parameter || {} // 关键字搜索字段
|
|
226
|
+
}));
|
|
227
|
+
}
|
|
228
|
+
} else {
|
|
229
|
+
setResDataSource({
|
|
230
|
+
list: [],
|
|
231
|
+
pagination: {},
|
|
232
|
+
keywords: {}
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
case 10:
|
|
236
|
+
case "end":
|
|
237
|
+
return _context.stop();
|
|
238
|
+
}
|
|
239
|
+
}, _callee);
|
|
240
|
+
}));
|
|
241
|
+
return function (_x, _x2, _x3, _x4) {
|
|
242
|
+
return _ref.apply(this, arguments);
|
|
243
|
+
};
|
|
244
|
+
}(), [acceptType, defaultParams, fetchData]);
|
|
245
|
+
(0, _react.useEffect)(function () {
|
|
246
|
+
if (acceptType === 'data') {
|
|
247
|
+
setResDataSource(data);
|
|
248
|
+
}
|
|
249
|
+
}, [acceptType, data]);
|
|
250
|
+
(0, _react.useEffect)(function () {
|
|
251
|
+
getDataSource && getDataSource(resDataSource);
|
|
252
|
+
}, [resDataSource]);
|
|
253
|
+
(0, _react.useEffect)(function () {
|
|
254
|
+
loadData('init'); // 接口请求调用
|
|
255
|
+
}, []);
|
|
103
256
|
return wrapSSR( /*#__PURE__*/_react.default.createElement("div", {
|
|
104
257
|
className: (0, _classnames.default)(componentName, proClassname, hashId)
|
|
105
|
-
}, /*#__PURE__*/_react.default.createElement(_StandardFilter.default, _extends({}, commonConfig,
|
|
106
|
-
|
|
107
|
-
|
|
258
|
+
}, formItemGroupConcat !== null && formItemGroupConcat !== void 0 && formItemGroupConcat.length ? /*#__PURE__*/_react.default.createElement(_StandardFilter.default, _extends({}, commonConfig, {
|
|
259
|
+
forceListener: false
|
|
260
|
+
}, filter, {
|
|
261
|
+
confirmButtonProps: _objectSpread({
|
|
262
|
+
loading: acceptType === 'fetch' ? searchLoading : false
|
|
263
|
+
}, filter === null || filter === void 0 ? void 0 : filter.confirmButtonProps),
|
|
264
|
+
formItemGroup: formItemGroupConcat,
|
|
108
265
|
getFormFields: function getFormFields(fieldValues, form) {
|
|
109
266
|
var _filter$getFormFields;
|
|
110
267
|
// setFilterFormFields(fieldValues) // 获取表单内部控件值
|
|
111
268
|
setFilterFormInstance(form); // 获取表单实例
|
|
112
269
|
filter === null || filter === void 0 || (_filter$getFormFields = filter.getFormFields) === null || _filter$getFormFields === void 0 || _filter$getFormFields.call(filter, fieldValues, form);
|
|
113
270
|
},
|
|
114
|
-
onFilterSearch: function onFilterSearch(
|
|
115
|
-
|
|
271
|
+
onFilterSearch: function onFilterSearch(fields) {
|
|
272
|
+
if (acceptType === 'fetch') {
|
|
273
|
+
setSearchLoading(true);
|
|
274
|
+
loadData('search', _objectSpread({}, localPageInfo), fields);
|
|
275
|
+
}
|
|
276
|
+
handleChange('filterSearch', fields);
|
|
116
277
|
},
|
|
117
278
|
onFilterReset: function onFilterReset() {
|
|
118
|
-
|
|
279
|
+
if (acceptType === 'fetch') {
|
|
280
|
+
loadData('reset', _objectSpread({}, localPageInfo), {});
|
|
281
|
+
}
|
|
282
|
+
handleChange('filterReset');
|
|
119
283
|
},
|
|
120
284
|
className: (0, _classnames.default)('spec-standard-table-pro-filter', filter === null || filter === void 0 ? void 0 : filter.className)
|
|
121
|
-
})), /*#__PURE__*/_react.default.createElement(_StandardTable.default, _extends({}, commonConfig, others, {
|
|
122
|
-
|
|
285
|
+
})) : null, /*#__PURE__*/_react.default.createElement(_StandardTable.default, _extends({}, commonConfig, others, {
|
|
286
|
+
data: resDataSource,
|
|
287
|
+
columns: columns,
|
|
288
|
+
sortOrders: others.sortOrders || sorterParams,
|
|
289
|
+
loading: acceptType === 'fetch' ? queryLoading || (others === null || others === void 0 ? void 0 : others.loading) : others === null || others === void 0 ? void 0 : others.loading
|
|
123
290
|
// @ts-ignore
|
|
124
291
|
,
|
|
125
292
|
onChange: function onChange(pagination, filters, sorter, extra) {
|
|
293
|
+
console.log('pagination', pagination);
|
|
294
|
+
if (acceptType === 'fetch') {
|
|
295
|
+
var _pagination$orders;
|
|
296
|
+
setSorterParams(pagination.sorterParams);
|
|
297
|
+
loadData(extra.action, {
|
|
298
|
+
current: pagination.current,
|
|
299
|
+
size: pagination.size
|
|
300
|
+
}, (_pagination$orders = pagination.orders) !== null && _pagination$orders !== void 0 && _pagination$orders.length ? {
|
|
301
|
+
orders: pagination.orders,
|
|
302
|
+
sorterParams: pagination.sorterParams
|
|
303
|
+
} : {},
|
|
304
|
+
// 有筛选条件才传
|
|
305
|
+
{
|
|
306
|
+
pagination: pagination,
|
|
307
|
+
filters: filters,
|
|
308
|
+
sorter: sorter,
|
|
309
|
+
extra: extra
|
|
310
|
+
});
|
|
311
|
+
}
|
|
126
312
|
_onChange && _onChange(pagination, filters, sorter, extra);
|
|
127
|
-
// handleChange('tableChange', { pagination, filters, sorter, extra, action: extra.action })
|
|
128
313
|
},
|
|
129
314
|
className: (0, _classnames.default)('spec-standard-table-pro-table', className)
|
|
130
315
|
})), children));
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { StandardTableProps } from '../StandardTable/types';
|
|
2
|
+
export interface StandardTableProType extends StandardTableProps {
|
|
3
|
+
proClassname?: string;
|
|
4
|
+
filter?: any;
|
|
5
|
+
formConfig?: any;
|
|
6
|
+
onChange?: (pageParams?: any) => void;
|
|
7
|
+
onSubmit?: (searchParams?: any) => void;
|
|
8
|
+
onReset?: () => void;
|
|
9
|
+
params?: any;
|
|
10
|
+
acceptType?: 'data' | 'fetch' | string;
|
|
11
|
+
fetchData?: () => void;
|
|
12
|
+
parseTransform?: () => void;
|
|
13
|
+
[k: string]: any;
|
|
14
|
+
}
|
|
15
|
+
export type ActionType = {
|
|
16
|
+
reload?: () => void;
|
|
17
|
+
[k: string]: any;
|
|
18
|
+
};
|
|
19
|
+
export type PageInfo = {
|
|
20
|
+
size?: number;
|
|
21
|
+
total?: number;
|
|
22
|
+
current?: number;
|
|
23
|
+
[k: string]: any;
|
|
24
|
+
};
|
|
25
|
+
export type UseFetchDataAction<T = any> = {
|
|
26
|
+
dataSource?: T[];
|
|
27
|
+
pagination?: PageInfo;
|
|
28
|
+
[k: string]: any;
|
|
29
|
+
};
|
|
File without changes
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
// import {
|
|
2
|
+
// runFunction,
|
|
3
|
+
// useDebounceFn,
|
|
4
|
+
// useDeepCompareEffect,
|
|
5
|
+
// useMountMergeState,
|
|
6
|
+
// usePrevious,
|
|
7
|
+
// useRefFunction,
|
|
8
|
+
// } from '@ant-design/pro-utils';
|
|
9
|
+
// import { useEffect, useLayoutEffect, useRef } from 'react';
|
|
10
|
+
// import type { PageInfo, RequestData, UseFetchDataAction, UseFetchProps } from './typing';
|
|
11
|
+
// import { postDataPipeline } from './utils/index';
|
|
12
|
+
//
|
|
13
|
+
// /**
|
|
14
|
+
// * 组合用户的配置和默认值
|
|
15
|
+
// *
|
|
16
|
+
// * @param param0
|
|
17
|
+
// */
|
|
18
|
+
// const mergeOptionAndPageInfo = ({ pageInfo }: UseFetchProps) => {
|
|
19
|
+
// if (pageInfo) {
|
|
20
|
+
// const { current, defaultCurrent, pageSize, defaultPageSize } = pageInfo;
|
|
21
|
+
// return {
|
|
22
|
+
// current: current || defaultCurrent || 1,
|
|
23
|
+
// total: 0,
|
|
24
|
+
// pageSize: pageSize || defaultPageSize || 20,
|
|
25
|
+
// };
|
|
26
|
+
// }
|
|
27
|
+
// return { current: 1, total: 0, pageSize: 20 };
|
|
28
|
+
// };
|
|
29
|
+
//
|
|
30
|
+
// const useFetchData = <T extends RequestData<any>>(
|
|
31
|
+
// getData: undefined | ((params?: { pageSize: number; current: number }) => Promise<T>),
|
|
32
|
+
// defaultData: any[] | undefined,
|
|
33
|
+
// options: UseFetchProps,
|
|
34
|
+
// ): UseFetchDataAction => {
|
|
35
|
+
// const umountRef = useRef<boolean>(false);
|
|
36
|
+
// const { onLoad, manual, polling, onRequestError, debounceTime = 20 } = options || {};
|
|
37
|
+
//
|
|
38
|
+
// /** 是否首次加载的指示器 */
|
|
39
|
+
// const manualRequestRef = useRef<boolean>(manual);
|
|
40
|
+
//
|
|
41
|
+
// /** 轮询的setTime ID 存储 */
|
|
42
|
+
// const pollingSetTimeRef = useRef<any>();
|
|
43
|
+
// const [list, setList] = useMountMergeState<any[] | undefined>(defaultData, {
|
|
44
|
+
// value: options?.dataSource,
|
|
45
|
+
// onChange: options?.onDataSourceChange,
|
|
46
|
+
// });
|
|
47
|
+
//
|
|
48
|
+
// const [tableLoading, setTableLoading] = useMountMergeState<UseFetchDataAction['loading']>(false, {
|
|
49
|
+
// value: options?.loading,
|
|
50
|
+
// onChange: options?.onLoadingChange,
|
|
51
|
+
// });
|
|
52
|
+
//
|
|
53
|
+
// const requesting = useRef(false);
|
|
54
|
+
//
|
|
55
|
+
// const [pageInfo, setPageInfoState] = useMountMergeState<PageInfo>(
|
|
56
|
+
// () => mergeOptionAndPageInfo(options),
|
|
57
|
+
// {
|
|
58
|
+
// onChange: options?.onPageInfoChange,
|
|
59
|
+
// },
|
|
60
|
+
// );
|
|
61
|
+
// const setPageInfo = useRefFunction((changePageInfo: PageInfo) => {
|
|
62
|
+
// if (
|
|
63
|
+
// changePageInfo.current !== pageInfo.current ||
|
|
64
|
+
// changePageInfo.pageSize !== pageInfo.pageSize ||
|
|
65
|
+
// changePageInfo.total !== pageInfo.total
|
|
66
|
+
// ) {
|
|
67
|
+
// setPageInfoState(changePageInfo);
|
|
68
|
+
// }
|
|
69
|
+
// });
|
|
70
|
+
//
|
|
71
|
+
// const [pollingLoading, setPollingLoading] = useMountMergeState(false);
|
|
72
|
+
//
|
|
73
|
+
// // Batching update https://github.com/facebook/react/issues/14259
|
|
74
|
+
// const setDataAndLoading = (newData: T[], dataTotal: number) => {
|
|
75
|
+
// setList(newData);
|
|
76
|
+
//
|
|
77
|
+
// if (pageInfo?.total !== dataTotal) {
|
|
78
|
+
// setPageInfo({
|
|
79
|
+
// ...pageInfo,
|
|
80
|
+
// total: dataTotal || newData.length,
|
|
81
|
+
// });
|
|
82
|
+
// }
|
|
83
|
+
// };
|
|
84
|
+
//
|
|
85
|
+
// // pre state
|
|
86
|
+
// const prePage = usePrevious(pageInfo?.current);
|
|
87
|
+
// const prePageSize = usePrevious(pageInfo?.pageSize);
|
|
88
|
+
// const prePolling = usePrevious(polling);
|
|
89
|
+
//
|
|
90
|
+
// const { effects = [] } = options || {};
|
|
91
|
+
//
|
|
92
|
+
// /**
|
|
93
|
+
// * 不这样做会导致状态不更新
|
|
94
|
+
// *
|
|
95
|
+
// * https://github.com/ant-design/pro-components/issues/4390
|
|
96
|
+
// */
|
|
97
|
+
// const requestFinally = useRefFunction(() => {
|
|
98
|
+
// if (typeof tableLoading === 'object') {
|
|
99
|
+
// setTableLoading({ ...tableLoading, spinning: false });
|
|
100
|
+
// } else {
|
|
101
|
+
// setTableLoading(false);
|
|
102
|
+
// }
|
|
103
|
+
// setPollingLoading(false);
|
|
104
|
+
// });
|
|
105
|
+
// /** 请求数据 */
|
|
106
|
+
// const fetchList = async (isPolling: boolean) => {
|
|
107
|
+
// if ((tableLoading && typeof tableLoading === 'boolean') || requesting.current || !getData) {
|
|
108
|
+
// return [];
|
|
109
|
+
// }
|
|
110
|
+
//
|
|
111
|
+
// // 需要手动触发的首次请求
|
|
112
|
+
// if (manualRequestRef.current) {
|
|
113
|
+
// manualRequestRef.current = false;
|
|
114
|
+
// return [];
|
|
115
|
+
// }
|
|
116
|
+
// if (!isPolling) {
|
|
117
|
+
// if (typeof tableLoading === 'object') {
|
|
118
|
+
// setTableLoading({ ...tableLoading, spinning: true });
|
|
119
|
+
// } else {
|
|
120
|
+
// setTableLoading(true);
|
|
121
|
+
// }
|
|
122
|
+
// } else {
|
|
123
|
+
// setPollingLoading(true);
|
|
124
|
+
// }
|
|
125
|
+
//
|
|
126
|
+
// requesting.current = true;
|
|
127
|
+
// const { pageSize, current } = pageInfo || {};
|
|
128
|
+
// try {
|
|
129
|
+
// const pageParams =
|
|
130
|
+
// options?.pageInfo !== false
|
|
131
|
+
// ? {
|
|
132
|
+
// current,
|
|
133
|
+
// pageSize,
|
|
134
|
+
// }
|
|
135
|
+
// : undefined;
|
|
136
|
+
//
|
|
137
|
+
// const { data = [], success, total = 0, ...rest } = (await getData(pageParams)) || {};
|
|
138
|
+
// // 如果失败了,直接返回,不走剩下的逻辑了
|
|
139
|
+
// if (success === false) return [];
|
|
140
|
+
//
|
|
141
|
+
// const responseData = postDataPipeline<T[]>(
|
|
142
|
+
// data!,
|
|
143
|
+
// [options.postData].filter((item) => item) as any,
|
|
144
|
+
// );
|
|
145
|
+
// setDataAndLoading(responseData, total);
|
|
146
|
+
// onLoad?.(responseData, rest);
|
|
147
|
+
// return responseData;
|
|
148
|
+
// } catch (e) {
|
|
149
|
+
// // 如果没有传递这个方法的话,需要把错误抛出去,以免吞掉错误
|
|
150
|
+
// if (onRequestError === undefined) throw new Error(e as string);
|
|
151
|
+
// if (list === undefined) setList([]);
|
|
152
|
+
// onRequestError(e as Error);
|
|
153
|
+
// } finally {
|
|
154
|
+
// requesting.current = false;
|
|
155
|
+
// requestFinally();
|
|
156
|
+
// }
|
|
157
|
+
//
|
|
158
|
+
// return [];
|
|
159
|
+
// };
|
|
160
|
+
//
|
|
161
|
+
// const fetchListDebounce = useDebounceFn(async (isPolling: boolean) => {
|
|
162
|
+
// if (pollingSetTimeRef.current) {
|
|
163
|
+
// clearTimeout(pollingSetTimeRef.current);
|
|
164
|
+
// }
|
|
165
|
+
// const msg = await fetchList(isPolling);
|
|
166
|
+
//
|
|
167
|
+
// // 把判断要不要轮询的逻辑放到后面来这样可以保证数据是根据当前来
|
|
168
|
+
// // 放到请求前面会导致数据是上一次的
|
|
169
|
+
// const needPolling = runFunction(polling, msg);
|
|
170
|
+
//
|
|
171
|
+
// // 如果需要轮询,搞个一段时间后执行
|
|
172
|
+
// // 如果解除了挂载,删除一下
|
|
173
|
+
// if (needPolling && !umountRef.current) {
|
|
174
|
+
// pollingSetTimeRef.current = setTimeout(() => {
|
|
175
|
+
// fetchListDebounce.run(needPolling);
|
|
176
|
+
// // 这里判断最小要2000ms,不然一直loading
|
|
177
|
+
// }, Math.max(needPolling, 2000));
|
|
178
|
+
// }
|
|
179
|
+
// return msg;
|
|
180
|
+
// }, debounceTime || 10);
|
|
181
|
+
//
|
|
182
|
+
// // 如果轮询结束了,直接销毁定时器
|
|
183
|
+
// useEffect(() => {
|
|
184
|
+
// if (!polling) {
|
|
185
|
+
// clearTimeout(pollingSetTimeRef.current);
|
|
186
|
+
// }
|
|
187
|
+
// if (!prePolling && polling) {
|
|
188
|
+
// fetchListDebounce.run(true);
|
|
189
|
+
// }
|
|
190
|
+
// return () => {
|
|
191
|
+
// clearTimeout(pollingSetTimeRef.current);
|
|
192
|
+
// };
|
|
193
|
+
// // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
194
|
+
// }, [polling]);
|
|
195
|
+
//
|
|
196
|
+
// useLayoutEffect(() => {
|
|
197
|
+
// umountRef.current = false;
|
|
198
|
+
//
|
|
199
|
+
// return () => {
|
|
200
|
+
// umountRef.current = true;
|
|
201
|
+
// };
|
|
202
|
+
// }, []);
|
|
203
|
+
//
|
|
204
|
+
// /** PageIndex 改变的时候自动刷新 */
|
|
205
|
+
// useEffect(() => {
|
|
206
|
+
// const { current, pageSize } = pageInfo || {};
|
|
207
|
+
// // 如果上次的页码为空或者两次页码等于是没必要查询的
|
|
208
|
+
// // 如果 pageSize 发生变化是需要查询的,所以又加了 prePageSize
|
|
209
|
+
// if ((!prePage || prePage === current) && (!prePageSize || prePageSize === pageSize)) {
|
|
210
|
+
// return;
|
|
211
|
+
// }
|
|
212
|
+
//
|
|
213
|
+
// if ((options.pageInfo && list && list?.length > pageSize) || 0) {
|
|
214
|
+
// return;
|
|
215
|
+
// }
|
|
216
|
+
//
|
|
217
|
+
// // 如果 list 的长度大于 pageSize 的长度
|
|
218
|
+
// // 说明是一个假分页
|
|
219
|
+
// // (pageIndex - 1 || 1) 至少要第一页
|
|
220
|
+
// // 在第一页大于 10
|
|
221
|
+
// // 第二页也应该是大于 10
|
|
222
|
+
// if (current !== undefined && list && list.length <= pageSize) {
|
|
223
|
+
// fetchListDebounce.run(false);
|
|
224
|
+
// }
|
|
225
|
+
// // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
226
|
+
// }, [pageInfo?.current]);
|
|
227
|
+
//
|
|
228
|
+
// // pageSize 修改后返回第一页
|
|
229
|
+
// useEffect(() => {
|
|
230
|
+
// if (!prePageSize) {
|
|
231
|
+
// return;
|
|
232
|
+
// }
|
|
233
|
+
// fetchListDebounce.run(false);
|
|
234
|
+
// // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
235
|
+
// }, [pageInfo?.pageSize]);
|
|
236
|
+
//
|
|
237
|
+
// useDeepCompareEffect(() => {
|
|
238
|
+
// fetchListDebounce.run(false);
|
|
239
|
+
// if (!manual) {
|
|
240
|
+
// manualRequestRef.current = false;
|
|
241
|
+
// }
|
|
242
|
+
// return () => {
|
|
243
|
+
// fetchListDebounce.cancel();
|
|
244
|
+
// };
|
|
245
|
+
// }, [...effects, manual]);
|
|
246
|
+
//
|
|
247
|
+
// return {
|
|
248
|
+
// dataSource: list!,
|
|
249
|
+
// setDataSource: setList,
|
|
250
|
+
// loading: tableLoading,
|
|
251
|
+
// reload: async () => {
|
|
252
|
+
// await fetchListDebounce.run(false);
|
|
253
|
+
// },
|
|
254
|
+
// pageInfo,
|
|
255
|
+
// pollingLoading,
|
|
256
|
+
// reset: async () => {
|
|
257
|
+
// const { pageInfo: optionPageInfo } = options || {};
|
|
258
|
+
// const { defaultCurrent = 1, defaultPageSize = 20 } = optionPageInfo || {};
|
|
259
|
+
// const initialPageInfo = {
|
|
260
|
+
// current: defaultCurrent,
|
|
261
|
+
// total: 0,
|
|
262
|
+
// pageSize: defaultPageSize,
|
|
263
|
+
// };
|
|
264
|
+
// setPageInfo(initialPageInfo);
|
|
265
|
+
// },
|
|
266
|
+
// setPageInfo: async (info) => {
|
|
267
|
+
// setPageInfo({
|
|
268
|
+
// ...pageInfo,
|
|
269
|
+
// ...info,
|
|
270
|
+
// });
|
|
271
|
+
// },
|
|
272
|
+
// };
|
|
273
|
+
// };
|
|
274
|
+
//
|
|
275
|
+
// export default useFetchData;
|
|
276
|
+
"use strict";
|