fan-standard-comp 4.1.2 → 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/ExtensionField.d.ts +2 -2
- package/es/FormComp/FieldComponent/ExtensionField.js +1 -1
- 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 +52 -28
- package/es/StandardFilter/style/FilterStyle.js +3 -2
- package/es/StandardFilter/style/index.less +7 -0
- package/es/StandardForm/index.js +3 -1
- package/es/StandardTable/index.d.ts +4 -28
- package/es/StandardTable/index.js +65 -5
- package/es/StandardTable/types.d.ts +33 -0
- package/es/StandardTable/types.js +1 -0
- package/es/StandardTablePro/index.d.ts +5 -7
- package/es/StandardTablePro/index.js +246 -84
- 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/index.d.ts +2 -0
- package/es/index.js +3 -0
- package/es/types.d.ts +1 -0
- package/es/types.js +1 -0
- package/es/utils/ValueFormat.d.ts +1 -1
- package/es/utils/ValueFormat.js +42 -27
- package/es/utils/getParentNodes.js +1 -1
- package/es/utils/urlUtils.d.ts +6 -0
- package/es/utils/urlUtils.js +26 -0
- 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/ExtensionField.d.ts +2 -2
- package/lib/FormComp/FieldComponent/ExtensionField.js +1 -1
- 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 +52 -28
- package/lib/StandardFilter/style/FilterStyle.js +3 -2
- package/lib/StandardFilter/style/index.less +7 -0
- package/lib/StandardForm/index.js +3 -1
- package/lib/StandardTable/index.d.ts +4 -28
- package/lib/StandardTable/index.js +64 -4
- package/lib/StandardTable/types.d.ts +33 -0
- package/lib/StandardTable/types.js +5 -0
- package/lib/StandardTablePro/index.d.ts +5 -7
- package/lib/StandardTablePro/index.js +244 -82
- package/lib/StandardTablePro/types.d.ts +29 -0
- package/lib/StandardTablePro/types.js +5 -0
- 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/index.d.ts +2 -0
- package/lib/index.js +20 -0
- package/lib/types.d.ts +1 -0
- package/lib/types.js +16 -0
- package/lib/utils/ValueFormat.d.ts +1 -1
- package/lib/utils/ValueFormat.js +42 -29
- package/lib/utils/getParentNodes.js +1 -1
- package/lib/utils/urlUtils.d.ts +6 -0
- package/lib/utils/urlUtils.js +27 -3
- package/package.json +2 -2
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
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); }
|
|
2
|
-
var _excluded = ["proClassname", "
|
|
2
|
+
var _excluded = ["proClassname", "filter", "formConfig", "codes", "permissionCodes", "onSubmit", "onReset", "onChange", "children", "className", "columns", "defaultParams", "acceptType", "data", "fetchData", "fetchOptionName", "onAction", "tableActionRef", "filterFormRef", "getDataSource", "localPageInfo"];
|
|
3
3
|
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); }
|
|
4
|
+
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; }
|
|
5
|
+
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); } }
|
|
6
|
+
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); }); }; }
|
|
4
7
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
5
8
|
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."); }
|
|
6
9
|
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); }
|
|
@@ -14,26 +17,54 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
14
17
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
15
18
|
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; }
|
|
16
19
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
17
|
-
import React, { useContext, useImperativeHandle, forwardRef, useState } from 'react';
|
|
18
|
-
// import { FanContext } from "fan-standard-comp";
|
|
20
|
+
import React, { useContext, useImperativeHandle, forwardRef, useState, useMemo, useCallback, useEffect, useRef } from 'react';
|
|
19
21
|
import { FanContext } from "../ConfigContext";
|
|
20
|
-
import useStyle from "./style/index";
|
|
21
|
-
import StandardTable from "../StandardTable";
|
|
22
22
|
import StandardFilter from "../StandardFilter";
|
|
23
|
-
import
|
|
23
|
+
import StandardTable from "../StandardTable";
|
|
24
|
+
import { useActionType } from "./utils";
|
|
25
|
+
import useStyle from "./style/index";
|
|
24
26
|
import classNames from "classnames";
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* 复合表格:筛选+表格列表
|
|
30
|
+
* */
|
|
25
31
|
var StandardTablePro = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
26
32
|
var InitFanContext = useContext(FanContext);
|
|
27
33
|
var providerConfig = InitFanContext['StandardTablePro'] || {}; // 使用上下文(全局配置)设置扩展的配置项
|
|
28
34
|
var _providerConfig$props = _objectSpread(_objectSpread({}, providerConfig), props),
|
|
29
35
|
proClassname = _providerConfig$props.proClassname,
|
|
30
|
-
|
|
31
|
-
|
|
36
|
+
filter = _providerConfig$props.filter,
|
|
37
|
+
formConfig = _providerConfig$props.formConfig,
|
|
32
38
|
codes = _providerConfig$props.codes,
|
|
33
39
|
permissionCodes = _providerConfig$props.permissionCodes,
|
|
34
|
-
|
|
40
|
+
onSubmit = _providerConfig$props.onSubmit,
|
|
41
|
+
onReset = _providerConfig$props.onReset,
|
|
42
|
+
_onChange = _providerConfig$props.onChange,
|
|
35
43
|
children = _providerConfig$props.children,
|
|
36
44
|
className = _providerConfig$props.className,
|
|
45
|
+
columns = _providerConfig$props.columns,
|
|
46
|
+
defaultParams = _providerConfig$props.defaultParams,
|
|
47
|
+
_providerConfig$props2 = _providerConfig$props.acceptType,
|
|
48
|
+
acceptType = _providerConfig$props2 === void 0 ? 'data' : _providerConfig$props2,
|
|
49
|
+
data = _providerConfig$props.data,
|
|
50
|
+
fetchData = _providerConfig$props.fetchData,
|
|
51
|
+
_providerConfig$props3 = _providerConfig$props.fetchOptionName,
|
|
52
|
+
fetchOptionName = _providerConfig$props3 === void 0 ? {
|
|
53
|
+
dataKey: 'data',
|
|
54
|
+
listKey: 'records',
|
|
55
|
+
totalKey: 'total',
|
|
56
|
+
currentKey: 'current',
|
|
57
|
+
sizeKey: 'size'
|
|
58
|
+
} : _providerConfig$props3,
|
|
59
|
+
onAction = _providerConfig$props.onAction,
|
|
60
|
+
propsActionRef = _providerConfig$props.tableActionRef,
|
|
61
|
+
defaultFormRef = _providerConfig$props.filterFormRef,
|
|
62
|
+
getDataSource = _providerConfig$props.getDataSource,
|
|
63
|
+
_providerConfig$props4 = _providerConfig$props.localPageInfo,
|
|
64
|
+
localPageInfo = _providerConfig$props4 === void 0 ? {
|
|
65
|
+
current: 1,
|
|
66
|
+
size: 10
|
|
67
|
+
} : _providerConfig$props4,
|
|
37
68
|
others = _objectWithoutProperties(_providerConfig$props, _excluded);
|
|
38
69
|
var commonConfig = {
|
|
39
70
|
codes: codes,
|
|
@@ -44,102 +75,233 @@ var StandardTablePro = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
44
75
|
_useStyle2 = _slicedToArray(_useStyle, 2),
|
|
45
76
|
wrapSSR = _useStyle2[0],
|
|
46
77
|
hashId = _useStyle2[1];
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
78
|
+
// data.list, data.pagination
|
|
79
|
+
var _useState = useState({
|
|
80
|
+
list: [],
|
|
81
|
+
pagination: {},
|
|
82
|
+
keywords: {}
|
|
83
|
+
}),
|
|
51
84
|
_useState2 = _slicedToArray(_useState, 2),
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
var _useState3 = useState(),
|
|
85
|
+
resDataSource = _useState2[0],
|
|
86
|
+
setResDataSource = _useState2[1];
|
|
87
|
+
var _useState3 = useState(false),
|
|
55
88
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
var _useState5 = useState(
|
|
89
|
+
queryLoading = _useState4[0],
|
|
90
|
+
setQueryLoading = _useState4[1];
|
|
91
|
+
var _useState5 = useState(false),
|
|
59
92
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
60
|
-
|
|
61
|
-
|
|
93
|
+
searchLoading = _useState6[0],
|
|
94
|
+
setSearchLoading = _useState6[1];
|
|
62
95
|
var _useState7 = useState(),
|
|
63
96
|
_useState8 = _slicedToArray(_useState7, 2),
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
var
|
|
97
|
+
sorterParams = _useState8[0],
|
|
98
|
+
setSorterParams = _useState8[1];
|
|
99
|
+
var handleChange = function handleChange(targetKey, data, defaultParam) {
|
|
100
|
+
if (targetKey === 'filterSearch') {
|
|
101
|
+
onSubmit === null || onSubmit === void 0 || onSubmit(data);
|
|
102
|
+
}
|
|
103
|
+
if (targetKey === 'filterReset') {
|
|
104
|
+
onReset === null || onReset === void 0 || onReset();
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
var formItemGroupConcat = useMemo(function () {
|
|
108
|
+
var itemGroupFromColumns = (columns || []).filter(function (item) {
|
|
109
|
+
return item.formItem && JSON.stringify(item.formItem) !== '{}';
|
|
110
|
+
}).map(function (fItem) {
|
|
111
|
+
return _objectSpread({
|
|
112
|
+
label: fItem === null || fItem === void 0 ? void 0 : fItem.title,
|
|
113
|
+
fieldName: (fItem === null || fItem === void 0 ? void 0 : fItem.key) || (fItem === null || fItem === void 0 ? void 0 : fItem.dataIndex)
|
|
114
|
+
}, fItem.formItem);
|
|
115
|
+
});
|
|
116
|
+
return ((filter === null || filter === void 0 ? void 0 : filter.formItemGroup) || []).concat(itemGroupFromColumns);
|
|
117
|
+
}, [columns, filter === null || filter === void 0 ? void 0 : filter.formItemGroup]);
|
|
118
|
+
var _useState9 = useState({}),
|
|
67
119
|
_useState10 = _slicedToArray(_useState9, 2),
|
|
68
|
-
|
|
69
|
-
|
|
120
|
+
filterInstance = _useState10[0],
|
|
121
|
+
setFilterFormInstance = _useState10[1];
|
|
122
|
+
// const [filterInitialValues, setFilterInitialValues] = useState({})
|
|
123
|
+
// const [filterFields, setFilterFormFields] = useState({})
|
|
124
|
+
// const [filterValues, setFilterValues] = useState<any>({})
|
|
70
125
|
|
|
126
|
+
var action = {
|
|
127
|
+
pagination: (resDataSource === null || resDataSource === void 0 ? void 0 : resDataSource.pagination) || localPageInfo,
|
|
128
|
+
dataSource: resDataSource === null || resDataSource === void 0 ? void 0 : resDataSource.list,
|
|
129
|
+
keywords: resDataSource === null || resDataSource === void 0 ? void 0 : resDataSource.keywords,
|
|
130
|
+
loading: queryLoading,
|
|
131
|
+
reload: function reload(filter) {
|
|
132
|
+
return loadData('reload', _objectSpread({}, localPageInfo), _objectSpread({}, filter));
|
|
133
|
+
},
|
|
134
|
+
// 更新列表
|
|
135
|
+
refresh: function refresh(filter) {
|
|
136
|
+
return loadData('refresh', _objectSpread({}, resDataSource.pagination), _objectSpread({}, filter));
|
|
137
|
+
} // 更新列表
|
|
138
|
+
};
|
|
139
|
+
/** 通用的来操作子节点的工具类 */
|
|
140
|
+
var actionRef = useRef();
|
|
141
|
+
useImperativeHandle(propsActionRef, function () {
|
|
142
|
+
return actionRef.current;
|
|
143
|
+
});
|
|
144
|
+
useImperativeHandle(defaultFormRef, function () {
|
|
145
|
+
return filterInstance === null || filterInstance === void 0 ? void 0 : filterInstance.current;
|
|
146
|
+
});
|
|
71
147
|
// ref 的转发
|
|
72
148
|
useImperativeHandle(ref, function () {
|
|
73
|
-
return
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
149
|
+
return {
|
|
150
|
+
filterInstance: filterInstance === null || filterInstance === void 0 ? void 0 : filterInstance.current,
|
|
151
|
+
tableInstance: actionRef.current
|
|
152
|
+
};
|
|
153
|
+
}, [filterInstance, actionRef]);
|
|
154
|
+
|
|
155
|
+
/** 绑定 action current */
|
|
156
|
+
useActionType(actionRef, action);
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* 加载数据方法
|
|
160
|
+
* @param {string} updateKey 触发位置
|
|
161
|
+
* @param {Object} pagination 分页选项
|
|
162
|
+
* @param {Object} filter 筛选条件或表格排序条件
|
|
163
|
+
* @param {Object} tableChangeParams (表格默认参数){pagination, filter, sorter, extra}
|
|
164
|
+
*/
|
|
165
|
+
var loadData = useCallback( /*#__PURE__*/function () {
|
|
166
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(updateKey, pagination, filters, tableChangeParams) {
|
|
167
|
+
var parameter, response, responseData;
|
|
168
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
169
|
+
while (1) switch (_context.prev = _context.next) {
|
|
170
|
+
case 0:
|
|
171
|
+
if (updateKey !== 'init' && updateKey !== 'reload' && updateKey !== 'refresh') {
|
|
172
|
+
onAction === null || onAction === void 0 || onAction(updateKey, updateKey === 'reset' ? {} : _objectSpread(_objectSpread({}, pagination), filters));
|
|
173
|
+
}
|
|
174
|
+
if (!(acceptType === 'fetch' && fetchData)) {
|
|
175
|
+
_context.next = 10;
|
|
176
|
+
break;
|
|
177
|
+
}
|
|
178
|
+
setQueryLoading(true);
|
|
179
|
+
parameter = Object.assign(_objectSpread({}, defaultParams),
|
|
180
|
+
// updateKey === 'init' ? { ...params } : {}, // 重置条件下,会清空params
|
|
181
|
+
{
|
|
182
|
+
current: (pagination === null || pagination === void 0 ? void 0 : pagination.current) || localPageInfo.current,
|
|
183
|
+
size: (pagination === null || pagination === void 0 ? void 0 : pagination.size) || localPageInfo.size
|
|
184
|
+
}, _objectSpread({}, filters) // 排序与筛选待定
|
|
185
|
+
// (sorter && sorter.field && {
|
|
186
|
+
// sortField: sorter.field
|
|
187
|
+
// }) || {},
|
|
188
|
+
// (sorter && sorter.order && {
|
|
189
|
+
// sortOrder: sorter.order
|
|
190
|
+
// }) || {},
|
|
191
|
+
);
|
|
192
|
+
_context.next = 6;
|
|
193
|
+
return fetchData(parameter, updateKey, tableChangeParams);
|
|
194
|
+
case 6:
|
|
195
|
+
response = _context.sent;
|
|
196
|
+
setQueryLoading(false);
|
|
197
|
+
setSearchLoading(false);
|
|
198
|
+
// 转换列表数据
|
|
199
|
+
if (response.code == '200') {
|
|
200
|
+
responseData = response[fetchOptionName.dataKey];
|
|
201
|
+
if (Array.isArray(responseData)) {
|
|
202
|
+
// 返回值为数组
|
|
203
|
+
setResDataSource({
|
|
204
|
+
list: responseData,
|
|
205
|
+
pagination: null,
|
|
206
|
+
keywords: parameter || {}
|
|
207
|
+
});
|
|
208
|
+
} else {
|
|
209
|
+
// 返回值为对象
|
|
210
|
+
setResDataSource(Object.assign({
|
|
211
|
+
list: responseData === null || responseData === void 0 ? void 0 : responseData[fetchOptionName.listKey || 'records'],
|
|
212
|
+
pagination: {
|
|
213
|
+
total: (responseData === null || responseData === void 0 ? void 0 : responseData[fetchOptionName.totalKey || 'total']) || 0,
|
|
214
|
+
current: (responseData === null || responseData === void 0 ? void 0 : responseData[fetchOptionName.currentKey || 'current']) | localPageInfo.current,
|
|
215
|
+
size: (responseData === null || responseData === void 0 ? void 0 : responseData[fetchOptionName.sizeKey || 'size']) || localPageInfo.size
|
|
216
|
+
},
|
|
217
|
+
keywords: parameter || {} // 关键字搜索字段
|
|
218
|
+
}));
|
|
219
|
+
}
|
|
220
|
+
} else {
|
|
221
|
+
setResDataSource({
|
|
222
|
+
list: [],
|
|
223
|
+
pagination: {},
|
|
224
|
+
keywords: {}
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
case 10:
|
|
228
|
+
case "end":
|
|
229
|
+
return _context.stop();
|
|
230
|
+
}
|
|
231
|
+
}, _callee);
|
|
232
|
+
}));
|
|
233
|
+
return function (_x, _x2, _x3, _x4) {
|
|
234
|
+
return _ref.apply(this, arguments);
|
|
235
|
+
};
|
|
236
|
+
}(), [acceptType, defaultParams, fetchData]);
|
|
237
|
+
useEffect(function () {
|
|
238
|
+
if (acceptType === 'data') {
|
|
239
|
+
setResDataSource(data);
|
|
240
|
+
}
|
|
241
|
+
}, [acceptType, data]);
|
|
242
|
+
useEffect(function () {
|
|
243
|
+
getDataSource && getDataSource(resDataSource);
|
|
244
|
+
}, [resDataSource]);
|
|
245
|
+
useEffect(function () {
|
|
246
|
+
loadData('init'); // 接口请求调用
|
|
247
|
+
}, []);
|
|
83
248
|
return wrapSSR( /*#__PURE__*/React.createElement("div", {
|
|
84
249
|
className: classNames(componentName, proClassname, hashId)
|
|
85
|
-
}, /*#__PURE__*/React.createElement(StandardFilter, _extends({}, commonConfig,
|
|
250
|
+
}, formItemGroupConcat !== null && formItemGroupConcat !== void 0 && formItemGroupConcat.length ? /*#__PURE__*/React.createElement(StandardFilter, _extends({}, commonConfig, {
|
|
251
|
+
forceListener: false
|
|
252
|
+
}, filter, {
|
|
253
|
+
confirmButtonProps: _objectSpread({
|
|
254
|
+
loading: acceptType === 'fetch' ? searchLoading : false
|
|
255
|
+
}, filter === null || filter === void 0 ? void 0 : filter.confirmButtonProps),
|
|
256
|
+
formItemGroup: formItemGroupConcat,
|
|
86
257
|
getFormFields: function getFormFields(fieldValues, form) {
|
|
87
|
-
|
|
258
|
+
var _filter$getFormFields;
|
|
259
|
+
// setFilterFormFields(fieldValues) // 获取表单内部控件值
|
|
88
260
|
setFilterFormInstance(form); // 获取表单实例
|
|
261
|
+
filter === null || filter === void 0 || (_filter$getFormFields = filter.getFormFields) === null || _filter$getFormFields === void 0 || _filter$getFormFields.call(filter, fieldValues, form);
|
|
89
262
|
},
|
|
90
|
-
onFilterSearch: function onFilterSearch(
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
263
|
+
onFilterSearch: function onFilterSearch(fields) {
|
|
264
|
+
if (acceptType === 'fetch') {
|
|
265
|
+
setSearchLoading(true);
|
|
266
|
+
loadData('search', _objectSpread({}, localPageInfo), fields);
|
|
267
|
+
}
|
|
268
|
+
handleChange('filterSearch', fields);
|
|
95
269
|
},
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
270
|
+
onFilterReset: function onFilterReset() {
|
|
271
|
+
if (acceptType === 'fetch') {
|
|
272
|
+
loadData('reset', _objectSpread({}, localPageInfo), {});
|
|
273
|
+
}
|
|
274
|
+
handleChange('filterReset');
|
|
101
275
|
},
|
|
102
|
-
className: classNames('spec-standard-table-pro-
|
|
103
|
-
})), /*#__PURE__*/React.createElement(StandardTable, _extends({}, commonConfig, others, {
|
|
276
|
+
className: classNames('spec-standard-table-pro-filter', filter === null || filter === void 0 ? void 0 : filter.className)
|
|
277
|
+
})) : null, /*#__PURE__*/React.createElement(StandardTable, _extends({}, commonConfig, others, {
|
|
278
|
+
data: resDataSource,
|
|
279
|
+
columns: columns,
|
|
280
|
+
sortOrders: others.sortOrders || sorterParams,
|
|
281
|
+
loading: acceptType === 'fetch' ? queryLoading || (others === null || others === void 0 ? void 0 : others.loading) : others === null || others === void 0 ? void 0 : others.loading
|
|
104
282
|
// @ts-ignore
|
|
283
|
+
,
|
|
105
284
|
onChange: function onChange(pagination, filters, sorter, extra) {
|
|
106
|
-
console.log('表格筛选条件', pagination, filters, sorter, extra);
|
|
107
|
-
// console.log(' pagination, filters, sorter', pagination, filters, sorter)
|
|
108
|
-
// loadData('table', {
|
|
109
|
-
// page: pagination.current,
|
|
110
|
-
// size: pagination.pageSize
|
|
111
|
-
// }, filters, sorter)
|
|
112
|
-
|
|
113
285
|
console.log('pagination', pagination);
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
orders =
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
asc: sorter.order === 'ascend'
|
|
286
|
+
if (acceptType === 'fetch') {
|
|
287
|
+
var _pagination$orders;
|
|
288
|
+
setSorterParams(pagination.sorterParams);
|
|
289
|
+
loadData(extra.action, {
|
|
290
|
+
current: pagination.current,
|
|
291
|
+
size: pagination.size
|
|
292
|
+
}, (_pagination$orders = pagination.orders) !== null && _pagination$orders !== void 0 && _pagination$orders.length ? {
|
|
293
|
+
orders: pagination.orders,
|
|
294
|
+
sorterParams: pagination.sorterParams
|
|
295
|
+
} : {},
|
|
296
|
+
// 有筛选条件才传
|
|
297
|
+
{
|
|
298
|
+
pagination: pagination,
|
|
299
|
+
filters: filters,
|
|
300
|
+
sorter: sorter,
|
|
301
|
+
extra: extra
|
|
131
302
|
});
|
|
132
303
|
}
|
|
133
|
-
|
|
134
|
-
handleChange('tableChange', {
|
|
135
|
-
page: pagination.current,
|
|
136
|
-
size: pagination.pageSize
|
|
137
|
-
}, {
|
|
138
|
-
pagination: pagination,
|
|
139
|
-
filters: filters,
|
|
140
|
-
sorter: sorter,
|
|
141
|
-
extra: extra
|
|
142
|
-
});
|
|
304
|
+
_onChange && _onChange(pagination, filters, sorter, extra);
|
|
143
305
|
},
|
|
144
306
|
className: classNames('spec-standard-table-pro-table', className)
|
|
145
307
|
})), 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
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
File without changes
|