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.
Files changed (55) hide show
  1. package/dist/fan-standard-comp.min.css +1 -1
  2. package/dist/fan-standard-comp.min.js +1 -1
  3. package/es/CompositeTable/index.d.ts +0 -0
  4. package/es/CompositeTable/index.js +211 -0
  5. package/es/CompositeTable/index.style.d.ts +5 -0
  6. package/es/CompositeTable/index.style.js +27 -0
  7. package/es/FormComp/FieldComponent/index.js +2 -6
  8. package/es/StandardContent/ContentHeader.js +17 -25
  9. package/es/StandardContent/SubfieldContent.js +12 -9
  10. package/es/StandardContent/WrapperContent.js +9 -8
  11. package/es/StandardContent/styles/Subfield.js +18 -5
  12. package/es/StandardContent/styles/Wrapper.js +13 -2
  13. package/es/StandardContent/styles/index.less +8 -2
  14. package/es/StandardFilter/index.js +26 -12
  15. package/es/StandardFilter/style/FilterStyle.js +3 -2
  16. package/es/StandardFilter/style/index.less +7 -0
  17. package/es/StandardTable/index.d.ts +3 -3
  18. package/es/StandardTable/index.js +9 -3
  19. package/es/StandardTablePro/index.d.ts +2 -12
  20. package/es/StandardTablePro/index.js +216 -31
  21. package/es/StandardTablePro/types.d.ts +29 -0
  22. package/es/StandardTablePro/types.js +1 -0
  23. package/es/StandardTablePro/useFetchData.d.ts +0 -0
  24. package/es/StandardTablePro/useFetchData.js +275 -0
  25. package/es/StandardTablePro/utils.d.ts +3 -0
  26. package/es/StandardTablePro/utils.js +49 -0
  27. package/es/utils/ValueFormat.js +1 -0
  28. package/es/utils/getParentNodes.js +1 -1
  29. package/lib/CompositeTable/index.d.ts +0 -0
  30. package/lib/CompositeTable/index.js +212 -0
  31. package/lib/CompositeTable/index.style.d.ts +5 -0
  32. package/lib/CompositeTable/index.style.js +33 -0
  33. package/lib/FormComp/FieldComponent/index.js +2 -6
  34. package/lib/StandardContent/ContentHeader.js +16 -24
  35. package/lib/StandardContent/SubfieldContent.js +12 -9
  36. package/lib/StandardContent/WrapperContent.js +9 -8
  37. package/lib/StandardContent/styles/Subfield.js +18 -5
  38. package/lib/StandardContent/styles/Wrapper.js +13 -2
  39. package/lib/StandardContent/styles/index.less +8 -2
  40. package/lib/StandardFilter/index.js +26 -12
  41. package/lib/StandardFilter/style/FilterStyle.js +3 -2
  42. package/lib/StandardFilter/style/index.less +7 -0
  43. package/lib/StandardTable/index.d.ts +3 -3
  44. package/lib/StandardTable/index.js +8 -2
  45. package/lib/StandardTablePro/index.d.ts +2 -12
  46. package/lib/StandardTablePro/index.js +214 -29
  47. package/lib/StandardTablePro/types.d.ts +29 -0
  48. package/lib/StandardTablePro/types.js +5 -1
  49. package/lib/StandardTablePro/useFetchData.d.ts +0 -0
  50. package/lib/StandardTablePro/useFetchData.js +276 -0
  51. package/lib/StandardTablePro/utils.d.ts +3 -0
  52. package/lib/StandardTablePro/utils.js +55 -0
  53. package/lib/utils/ValueFormat.js +1 -0
  54. package/lib/utils/getParentNodes.js +1 -1
  55. package/package.json +2 -2
@@ -14,7 +14,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
14
14
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
15
15
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
16
16
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
17
- import React, { useContext } from 'react';
17
+ import React, { useContext, memo } from 'react';
18
18
  import classNames from 'classnames';
19
19
  import { Table, Card } from 'antd';
20
20
  import ButtonGroup from "../ButtonGroup/index";
@@ -232,7 +232,13 @@ var StandardTable = function StandardTable(props) {
232
232
  });
233
233
  rest === null || rest === void 0 || (_rest$onChange = rest.onChange) === null || _rest$onChange === void 0 || _rest$onChange.call(rest, _objectSpread(_objectSpread({}, pagination), {}, {
234
234
  size: pagination.pageSize,
235
- // orders, // 对象
235
+ orders: sorters.map(function (item) {
236
+ return {
237
+ column: item.columnKey,
238
+ asc: item.order == 'ascend'
239
+ };
240
+ }),
241
+ // 对象
236
242
  sorters: sorters,
237
243
  // 数组
238
244
  sorterParams: sorterParams // 对象
@@ -240,4 +246,4 @@ var StandardTable = function StandardTable(props) {
240
246
  }
241
247
  }))));
242
248
  };
243
- export default StandardTable;
249
+ export default /*#__PURE__*/memo(StandardTable);
@@ -1,17 +1,7 @@
1
1
  import React from 'react';
2
- import type { StandardTableProps } from '../StandardTable/types';
3
- interface StandardTableProType extends StandardTableProps {
4
- proClassname?: string;
5
- filter?: any;
6
- formConfig?: any;
7
- onChange?: (pageParams?: any) => void;
8
- onSubmit?: (searchParams?: any) => void;
9
- onReset?: () => void;
10
- params?: any;
11
- [k: string]: any;
12
- }
2
+ import { StandardTableProType } from './types';
13
3
  /**
14
4
  * 复合表格:筛选+表格列表
15
5
  * */
16
- declare const StandardTablePro: React.ForwardRefExoticComponent<React.RefAttributes<StandardTableProType>>;
6
+ declare const StandardTablePro: React.ForwardRefExoticComponent<Omit<StandardTableProType, "ref"> & React.RefAttributes<HTMLDivElement>>;
17
7
  export default StandardTablePro;
@@ -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", "filter", "formConfig", "codes", "permissionCodes", "onSubmit", "onReset", "onChange", "children", "className", "columns", "params"];
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,13 +17,14 @@ 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, useMemo } from 'react';
18
- // import { FanContext, StandardFilter, StandardTable } from "fan-standard-comp";
20
+ import React, { useContext, useImperativeHandle, forwardRef, useState, useMemo, useCallback, useEffect, useRef } from 'react';
19
21
  import { FanContext } from "../ConfigContext";
20
22
  import StandardFilter from "../StandardFilter";
21
23
  import StandardTable from "../StandardTable";
24
+ import { useActionType } from "./utils";
22
25
  import useStyle from "./style/index";
23
26
  import classNames from "classnames";
27
+
24
28
  /**
25
29
  * 复合表格:筛选+表格列表
26
30
  * */
@@ -39,7 +43,28 @@ var StandardTablePro = /*#__PURE__*/forwardRef(function (props, ref) {
39
43
  children = _providerConfig$props.children,
40
44
  className = _providerConfig$props.className,
41
45
  columns = _providerConfig$props.columns,
42
- params = _providerConfig$props.params,
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,
43
68
  others = _objectWithoutProperties(_providerConfig$props, _excluded);
44
69
  var commonConfig = {
45
70
  codes: codes,
@@ -50,6 +75,27 @@ var StandardTablePro = /*#__PURE__*/forwardRef(function (props, ref) {
50
75
  _useStyle2 = _slicedToArray(_useStyle, 2),
51
76
  wrapSSR = _useStyle2[0],
52
77
  hashId = _useStyle2[1];
78
+ // data.list, data.pagination
79
+ var _useState = useState({
80
+ list: [],
81
+ pagination: {},
82
+ keywords: {}
83
+ }),
84
+ _useState2 = _slicedToArray(_useState, 2),
85
+ resDataSource = _useState2[0],
86
+ setResDataSource = _useState2[1];
87
+ var _useState3 = useState(false),
88
+ _useState4 = _slicedToArray(_useState3, 2),
89
+ queryLoading = _useState4[0],
90
+ setQueryLoading = _useState4[1];
91
+ var _useState5 = useState(false),
92
+ _useState6 = _slicedToArray(_useState5, 2),
93
+ searchLoading = _useState6[0],
94
+ setSearchLoading = _useState6[1];
95
+ var _useState7 = useState(),
96
+ _useState8 = _slicedToArray(_useState7, 2),
97
+ sorterParams = _useState8[0],
98
+ setSorterParams = _useState8[1];
53
99
  var handleChange = function handleChange(targetKey, data, defaultParam) {
54
100
  if (targetKey === 'filterSearch') {
55
101
  onSubmit === null || onSubmit === void 0 || onSubmit(data);
@@ -57,11 +103,8 @@ var StandardTablePro = /*#__PURE__*/forwardRef(function (props, ref) {
57
103
  if (targetKey === 'filterReset') {
58
104
  onReset === null || onReset === void 0 || onReset();
59
105
  }
60
- // if (targetKey === 'tableChange') {
61
- // onChange && onChange(data, defaultParam)
62
- // }
63
106
  };
64
- var formItemGroup = useMemo(function () {
107
+ var formItemGroupConcat = useMemo(function () {
65
108
  var itemGroupFromColumns = (columns || []).filter(function (item) {
66
109
  return item.formItem && JSON.stringify(item.formItem) !== '{}';
67
110
  }).map(function (fItem) {
@@ -72,51 +115,193 @@ var StandardTablePro = /*#__PURE__*/forwardRef(function (props, ref) {
72
115
  });
73
116
  return ((filter === null || filter === void 0 ? void 0 : filter.formItemGroup) || []).concat(itemGroupFromColumns);
74
117
  }, [columns, filter === null || filter === void 0 ? void 0 : filter.formItemGroup]);
75
-
118
+ var _useState9 = useState({}),
119
+ _useState10 = _slicedToArray(_useState9, 2),
120
+ filterInstance = _useState10[0],
121
+ setFilterFormInstance = _useState10[1];
122
+ // const [filterInitialValues, setFilterInitialValues] = useState({})
76
123
  // const [filterFields, setFilterFormFields] = useState({})
77
- var _useState = useState({}),
78
- _useState2 = _slicedToArray(_useState, 2),
79
- filterInstance = _useState2[0],
80
- setFilterFormInstance = _useState2[1];
81
124
  // const [filterValues, setFilterValues] = useState<any>({})
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
+ });
82
147
  // ref 的转发
83
148
  useImperativeHandle(ref, function () {
84
149
  return {
85
- // ...filter,
86
- // filterFields, // 值不会更新,不传给ref
87
- filterInstance: filterInstance === null || filterInstance === void 0 ? void 0 : filterInstance.current
88
- // dataSource: resDataSource,
89
- // setDataSource: setResDataSource,
90
- // reload: (filter) => loadData('refresh', {}, filter) // 更新列表
150
+ filterInstance: filterInstance === null || filterInstance === void 0 ? void 0 : filterInstance.current,
151
+ tableInstance: actionRef.current
91
152
  };
92
- }, [filterInstance]);
93
- // sortOrder: sortedInfo.columnKey === 'name' ? sortedInfo.order : null,
94
- // columns 里面需要把sort添加上去
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
+ }, []);
95
248
  return wrapSSR( /*#__PURE__*/React.createElement("div", {
96
249
  className: classNames(componentName, proClassname, hashId)
97
- }, /*#__PURE__*/React.createElement(StandardFilter, _extends({}, commonConfig, filter, {
98
- // initialValue={filterValues}
99
- formItemGroup: formItemGroup,
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,
100
257
  getFormFields: function getFormFields(fieldValues, form) {
101
258
  var _filter$getFormFields;
102
259
  // setFilterFormFields(fieldValues) // 获取表单内部控件值
103
260
  setFilterFormInstance(form); // 获取表单实例
104
261
  filter === null || filter === void 0 || (_filter$getFormFields = filter.getFormFields) === null || _filter$getFormFields === void 0 || _filter$getFormFields.call(filter, fieldValues, form);
105
262
  },
106
- onFilterSearch: function onFilterSearch(values) {
107
- return handleChange('filterSearch', values);
263
+ onFilterSearch: function onFilterSearch(fields) {
264
+ if (acceptType === 'fetch') {
265
+ setSearchLoading(true);
266
+ loadData('search', _objectSpread({}, localPageInfo), fields);
267
+ }
268
+ handleChange('filterSearch', fields);
108
269
  },
109
270
  onFilterReset: function onFilterReset() {
110
- return handleChange('filterReset');
271
+ if (acceptType === 'fetch') {
272
+ loadData('reset', _objectSpread({}, localPageInfo), {});
273
+ }
274
+ handleChange('filterReset');
111
275
  },
112
276
  className: classNames('spec-standard-table-pro-filter', filter === null || filter === void 0 ? void 0 : filter.className)
113
- })), /*#__PURE__*/React.createElement(StandardTable, _extends({}, commonConfig, others, {
114
- columns: columns
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
115
282
  // @ts-ignore
116
283
  ,
117
284
  onChange: function onChange(pagination, filters, sorter, extra) {
285
+ console.log('pagination', pagination);
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
302
+ });
303
+ }
118
304
  _onChange && _onChange(pagination, filters, sorter, extra);
119
- // handleChange('tableChange', { pagination, filters, sorter, extra, action: extra.action })
120
305
  },
121
306
  className: classNames('spec-standard-table-pro-table', className)
122
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