@ccs-ui/rc-pro 2.3.6-beta-25 → 2.3.6-beta-27

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.
@@ -53,8 +53,30 @@ type FnContextType<T = Store> = {
53
53
  close: () => void;
54
54
  };
55
55
  type CcsFieldNamesType = {
56
+ /** 数据源 */
56
57
  dataSource?: string[];
58
+ /** 数据总条数 */
57
59
  total?: string[];
60
+ /** 自定义接口请求属性对象,
61
+ * 默认配置
62
+ * { pageNo:['pageNo'],
63
+ * pageSize: ['pageSize'],
64
+ * filters':['filters'],
65
+ * orderProps: ['orderProps'],
66
+ * query: ['query'] }
67
+ * */
68
+ requestParam?: {
69
+ /** 页码 */
70
+ pageNo: string[];
71
+ /** 页记录数 */
72
+ pageSize: string[];
73
+ /** 查询条件 */
74
+ query?: string[];
75
+ /** 排序 */
76
+ orderProps?: string[];
77
+ /** 列过滤条件 */
78
+ filters?: string[];
79
+ };
58
80
  };
59
81
  type CcsDialogFieldNames = {
60
82
  /** 成功标识字段 */
@@ -16,7 +16,7 @@ export type DialogButtonsProps<T> = Pick<CcsDialogModalProps, 'okText' | 'onClos
16
16
  export type DialogButtonRef = {
17
17
  onSetButtons: (e: React.ReactElement) => void;
18
18
  };
19
- export declare const DialogButtonHolder: <TParams, TData>({ auth, extraBtn, formRef, request, onOk, onClose, buttonRef, requestFieldNames, formInitialValues, preventRequestHandle, }: Pick<CcsDialogModalProps<TParams, TData>, "onOk" | "onClose" | "auth" | "extraBtn" | "request" | "requestFieldNames" | "preventRequestHandle"> & {
19
+ export declare const DialogButtonHolder: <TParams, TData>({ auth, extraBtn, formRef, request, onOk, onClose, buttonRef, requestFieldNames, formInitialValues, preventRequestHandle, }: Pick<CcsDialogModalProps<TParams, TData>, "auth" | "request" | "onClose" | "onOk" | "extraBtn" | "requestFieldNames" | "preventRequestHandle"> & {
20
20
  formRef: React.RefObject<DialogFormRef<TParams>>;
21
21
  formInitialValues: FormProps['initialValues'];
22
22
  buttonRef: RefObject<DialogButtonRef>;
@@ -6,6 +6,13 @@ declare const useAppConfig: () => import("../context").CssAppConfigType;
6
6
  export declare const useProTableFields: () => {
7
7
  dataSource: string[];
8
8
  total: string[];
9
+ requestParam: {
10
+ pageNo: string[];
11
+ pageSize: string[];
12
+ query?: string[] | undefined;
13
+ orderProps?: string[] | undefined;
14
+ filters?: string[] | undefined;
15
+ };
9
16
  };
10
17
  export declare const useProTableTreeFields: () => {
11
18
  dataSource: string[];
@@ -23,9 +23,14 @@ export var useProTableFields = function useProTableFields() {
23
23
  var context = useContext(AppConfigContext) || {};
24
24
  return _objectSpread({
25
25
  dataSource: ['data', 'result'],
26
- // current: ['data', 'pageNo'],
27
- // pageSize: ['data', 'pageSize'],
28
- total: ['data', 'totalNum']
26
+ total: ['data', 'totalNum'],
27
+ requestParam: {
28
+ pageNo: ['pageNo'],
29
+ pageSize: ['pageSize'],
30
+ filters: ['filters'],
31
+ orderProps: ['orderProps'],
32
+ query: ['query']
33
+ }
29
34
  }, context === null || context === void 0 || (_context$fieldNames = context.fieldNames) === null || _context$fieldNames === void 0 ? void 0 : _context$fieldNames.proTable);
30
35
  };
31
36
  export var useProTableTreeFields = function useProTableTreeFields() {
@@ -1,16 +1,17 @@
1
- import { FormInstance } from 'antd/lib/form';
2
- import { ReactElement } from 'react';
1
+ import { FormInstance } from 'antd';
2
+ import React, { ReactElement } from 'react';
3
3
  import { PropsWithElementChildren } from '../ccs';
4
4
  import { CcsProTableProps } from './table';
5
5
  type PropsType<T> = Pick<CcsProTableProps<T>, 'toolbar' | 'formItems' | 'formInitValues' | 'expandForm' | 'title' | 'formItemLabelWidth'> & PropsWithElementChildren & {
6
6
  /** 更多查询条件 */
7
7
  hasMore?: boolean;
8
- form: FormInstance<any>;
9
8
  /** table 操作栏 */
10
9
  tableOperation: ReactElement;
11
10
  /** 查询 */
12
11
  onSearch: () => void;
12
+ /** form */
13
+ formRef: React.RefObject<FormInstance<any>>;
13
14
  };
14
15
  /** 操作按钮、查询,重置、列筛选、 */
15
- declare function HeadComponent<T>({ form, title, toolbar, children, expandForm, formItems, formInitValues, formItemLabelWidth, tableOperation, onSearch, }: PropsType<T>): import("react/jsx-runtime").JSX.Element;
16
+ declare function HeadComponent<T>({ title, toolbar, expandForm, formItems, formInitValues, formItemLabelWidth, tableOperation, formRef, onSearch, }: PropsType<T>): import("react/jsx-runtime").JSX.Element;
16
17
  export default HeadComponent;
@@ -8,7 +8,7 @@ import { DownOutlined, UpOutlined } from '@ant-design/icons';
8
8
  import { useUpdateEffect } from 'ahooks';
9
9
  import { Button, Card, Form, theme } from 'antd';
10
10
  import _debounce from 'lodash.debounce';
11
- import React, { useEffect, useMemo, useRef, useState } from 'react';
11
+ import React, { useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
12
12
  import { CcsResizeObserver } from '..';
13
13
  import { getShowDpends } from "./_utils";
14
14
  import HeadFormItem from "./form-item";
@@ -17,10 +17,8 @@ import { jsxs as _jsxs } from "react/jsx-runtime";
17
17
  import { Fragment as _Fragment } from "react/jsx-runtime";
18
18
  /** 操作按钮、查询,重置、列筛选、 */
19
19
  function HeadComponent(_ref) {
20
- var form = _ref.form,
21
- title = _ref.title,
20
+ var title = _ref.title,
22
21
  toolbar = _ref.toolbar,
23
- children = _ref.children,
24
22
  _ref$expandForm = _ref.expandForm,
25
23
  expandForm = _ref$expandForm === void 0 ? false : _ref$expandForm,
26
24
  _ref$formItems = _ref.formItems,
@@ -28,7 +26,11 @@ function HeadComponent(_ref) {
28
26
  formInitValues = _ref.formInitValues,
29
27
  formItemLabelWidth = _ref.formItemLabelWidth,
30
28
  tableOperation = _ref.tableOperation,
29
+ formRef = _ref.formRef,
31
30
  onSearch = _ref.onSearch;
31
+ var _Form$useForm = Form.useForm(),
32
+ _Form$useForm2 = _slicedToArray(_Form$useForm, 1),
33
+ form = _Form$useForm2[0];
32
34
  var formItemsRef = useRef(null);
33
35
 
34
36
  // 根据位置判断是否换行ref
@@ -46,6 +48,9 @@ function HeadComponent(_ref) {
46
48
  useUpdateEffect(function () {
47
49
  setIsExpand(expandForm);
48
50
  }, [expandForm]);
51
+ useImperativeHandle(formRef, function () {
52
+ return form;
53
+ });
49
54
 
50
55
  // 处理form item 依赖
51
56
  var allFormItems = useMemo(function () {
@@ -99,9 +104,6 @@ function HeadComponent(_ref) {
99
104
  onClick: function onClick() {
100
105
  return form.submit();
101
106
  },
102
- style: {
103
- marginLeft: !hasMore ? 10 : undefined
104
- },
105
107
  children: "\u67E5\u8BE2"
106
108
  }), toolbar ? null : tableOperation]
107
109
  });
@@ -168,8 +170,8 @@ function HeadComponent(_ref) {
168
170
  var token = theme.useToken().token;
169
171
  var controlHeight = token.rootValue ? "".concat((token.controlHeight / token.rootValue).toFixed(3), "rem") : token.controlHeight;
170
172
  var adaptationRef = useRef(null);
171
- return /*#__PURE__*/_jsxs(_Fragment, {
172
- children: [allFormItems.length > 0 && /*#__PURE__*/_jsxs(_Fragment, {
173
+ return /*#__PURE__*/_jsx(_Fragment, {
174
+ children: allFormItems.length > 0 && /*#__PURE__*/_jsxs(_Fragment, {
173
175
  children: [/*#__PURE__*/_jsx(CcsResizeObserver.Target, {
174
176
  targetRef: formItemsRef,
175
177
  onResize: onResize
@@ -210,37 +212,7 @@ function HeadComponent(_ref) {
210
212
  })]
211
213
  })
212
214
  })]
213
- }), toolbar && /*#__PURE__*/_jsxs(Card, {
214
- styles: {
215
- cover: {
216
- borderRadius: 0
217
- },
218
- body: {
219
- display: 'flex',
220
- justifyContent: 'space-between',
221
- width: '100%',
222
- padding: '12px 16px',
223
- alignContent: 'center'
224
- }
225
- },
226
- style: {
227
- borderRadius: 0,
228
- borderLeft: 0,
229
- borderBottom: 0,
230
- borderRight: 0
231
- },
232
- children: [/*#__PURE__*/_jsx("div", {
233
- style: {
234
- flex: '1 1 auto'
235
- },
236
- children: toolbar
237
- }), /*#__PURE__*/_jsx("div", {
238
- style: {
239
- flex: '0 0 auto'
240
- },
241
- children: tableOperation
242
- })]
243
- }), children]
215
+ })
244
216
  });
245
217
  }
246
218
  export default HeadComponent;
@@ -109,5 +109,5 @@ export declare const TableSelectionContext: React.Context<{
109
109
  * @param ref
110
110
  * @returns
111
111
  */
112
- declare const InternalProTable: <RecordType extends object = any>(props: CcsProTableProps<RecordType>) => import("react/jsx-runtime").JSX.Element;
112
+ declare const InternalProTable: <RecordType_1 extends object = any>(props: CcsProTableProps<RecordType_1>) => import("react/jsx-runtime").JSX.Element;
113
113
  export default InternalProTable;
@@ -3,13 +3,13 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
3
3
  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; }
4
4
  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); }
5
5
  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; }
6
- 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); } }
7
- 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); }); }; }
8
6
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
9
7
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
10
8
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
11
9
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
12
10
  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); }
11
+ 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); } }
12
+ 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); }); }; }
13
13
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
14
14
  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."); }
15
15
  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); }
@@ -18,7 +18,7 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
18
18
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
19
19
  import CcsUtils from '@ccs-ui/utils';
20
20
  import { useUpdateEffect } from 'ahooks';
21
- import { theme as antTheme, Empty, Form } from 'antd';
21
+ import { theme as antTheme, Card, Empty } from 'antd';
22
22
  import classNames from 'classnames';
23
23
  import _debounce from 'lodash.debounce';
24
24
  import React, { useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
@@ -31,11 +31,23 @@ import HeadComponent from "./head";
31
31
  import "./index.less";
32
32
  import TableOperation from "./operation";
33
33
  import TableTree from "./tree";
34
-
35
- /** 请求参数类型 */
36
34
  import { jsx as _jsx } from "react/jsx-runtime";
37
35
  import { Fragment as _Fragment } from "react/jsx-runtime";
38
36
  import { jsxs as _jsxs } from "react/jsx-runtime";
37
+ function onSetObj(target, paths, value) {
38
+ while (paths.length > 0) {
39
+ var path = paths.shift();
40
+ if (paths.length > 0) {
41
+ if (!target[path]) target[path] = {};
42
+ onSetObj(target[path], paths, value);
43
+ } else {
44
+ target[path] = value;
45
+ }
46
+ }
47
+ }
48
+
49
+ /** 请求参数类型 */
50
+
39
51
  export var classPrefix = 'ccs-pl';
40
52
  export var TableSelectionContext = /*#__PURE__*/React.createContext({
41
53
  selectedRows: undefined
@@ -48,7 +60,7 @@ export var TableSelectionContext = /*#__PURE__*/React.createContext({
48
60
  * @returns
49
61
  */
50
62
  var InternalProTable = function InternalProTable(props) {
51
- var _props$table, _table$scroll2, _table$scroll3;
63
+ var _table$scroll2, _table$scroll3;
52
64
  var init = props.init,
53
65
  auth = props.auth,
54
66
  table = props.table,
@@ -110,9 +122,7 @@ var InternalProTable = function InternalProTable(props) {
110
122
  // table ref
111
123
  var tableRef = useRef();
112
124
  // 查询form
113
- var _Form$useForm = Form.useForm(),
114
- _Form$useForm2 = _slicedToArray(_Form$useForm, 1),
115
- form = _Form$useForm2[0];
125
+ var formRef = useRef(null);
116
126
  // table data
117
127
  var _useState = useState({
118
128
  total: 0,
@@ -137,8 +147,6 @@ var InternalProTable = function InternalProTable(props) {
137
147
  theme = _useAppConfig.theme;
138
148
  // 接口字段指定全局配置
139
149
  var globalFieldNames = useProTableFields();
140
- // 接口字段指定
141
- var fieldNames = _objectSpread(_objectSpread({}, globalFieldNames), (_props$table = props.table) === null || _props$table === void 0 ? void 0 : _props$table.fieldNames);
142
150
 
143
151
  // 暗黑模式
144
152
  var isDark = theme === 'dark';
@@ -156,146 +164,150 @@ var InternalProTable = function InternalProTable(props) {
156
164
 
157
165
  // 获取数据
158
166
  var onRequest = /*#__PURE__*/function () {
159
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(eventType) {
167
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(eventType) {
168
+ var _formRef$current, _props$table;
160
169
  var pageNo,
161
170
  pageSize,
162
171
  record,
163
- _args2 = arguments;
164
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
165
- while (1) switch (_context2.prev = _context2.next) {
172
+ formValues,
173
+ fieldNames,
174
+ _fieldNames$requestPa,
175
+ _fieldNames$requestPa2,
176
+ fsFilters,
177
+ _fieldNames$requestPa3,
178
+ fsPageNo,
179
+ _fieldNames$requestPa4,
180
+ fsPageSize,
181
+ _fieldNames$requestPa5,
182
+ fsOrderProps,
183
+ fsQuery,
184
+ params,
185
+ _filtersRef$current,
186
+ filters,
187
+ orderProps,
188
+ _treeRef$current,
189
+ requestResult,
190
+ dataSource,
191
+ total,
192
+ _args = arguments;
193
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
194
+ while (1) switch (_context.prev = _context.next) {
166
195
  case 0:
167
- pageNo = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : 1;
168
- pageSize = _args2.length > 2 && _args2[2] !== undefined ? _args2[2] : (pagination ? pagination.defaultPageSize : 10) || 10;
169
- record = _args2.length > 3 ? _args2[3] : undefined;
196
+ pageNo = _args.length > 1 && _args[1] !== undefined ? _args[1] : 1;
197
+ pageSize = _args.length > 2 && _args[2] !== undefined ? _args[2] : (pagination ? pagination.defaultPageSize : 10) || 10;
198
+ record = _args.length > 3 ? _args[3] : undefined;
170
199
  if (!(!isAuth || !httpRequest)) {
171
- _context2.next = 5;
200
+ _context.next = 5;
172
201
  break;
173
202
  }
174
- return _context2.abrupt("return");
203
+ return _context.abrupt("return");
175
204
  case 5:
176
- // 构建查询条件:表单数据、请求额外参数、分页参数、其他参数
177
- form.validateFields().then( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
178
- var formValues,
179
- pageValue,
180
- params,
181
- _filtersRef$current,
182
- filters,
183
- orderProps,
184
- _treeRef$current,
185
- requestResult,
186
- dataSource,
187
- total,
188
- _args = arguments;
189
- return _regeneratorRuntime().wrap(function _callee$(_context) {
190
- while (1) switch (_context.prev = _context.next) {
191
- case 0:
192
- formValues = _args.length > 0 && _args[0] !== undefined ? _args[0] : {};
193
- // 格式化条件
194
- if (formatFormItems.length) {
195
- Object.keys(formValues).forEach(function (k) {
196
- if (formValues[k] !== undefined) {
197
- var s = formatFormItems.find(function (f) {
198
- return f.name === k;
199
- });
200
- if (s) formValues[k] = s.onFormat && s.onFormat(formValues[k]);
201
- }
202
- });
203
- }
205
+ _context.next = 7;
206
+ return (_formRef$current = formRef.current) === null || _formRef$current === void 0 ? void 0 : _formRef$current.validateFields();
207
+ case 7:
208
+ formValues = _context.sent;
209
+ // 接口字段指定
210
+ fieldNames = _objectSpread(_objectSpread({}, globalFieldNames), (_props$table = props.table) === null || _props$table === void 0 ? void 0 : _props$table.fieldNames); // 格式化条件
211
+ if (formatFormItems.length) {
212
+ Object.keys(formValues).forEach(function (k) {
213
+ if (formValues[k] !== undefined) {
214
+ var s = formatFormItems.find(function (f) {
215
+ return f.name === k;
216
+ });
217
+ if (s) formValues[k] = s.onFormat && s.onFormat(formValues[k]);
218
+ }
219
+ });
220
+ }
221
+
222
+ // 请求字段
223
+ _fieldNames$requestPa = fieldNames.requestParam, _fieldNames$requestPa2 = _fieldNames$requestPa.filters, fsFilters = _fieldNames$requestPa2 === void 0 ? ['filters'] : _fieldNames$requestPa2, _fieldNames$requestPa3 = _fieldNames$requestPa.pageNo, fsPageNo = _fieldNames$requestPa3 === void 0 ? ['pageNo'] : _fieldNames$requestPa3, _fieldNames$requestPa4 = _fieldNames$requestPa.pageSize, fsPageSize = _fieldNames$requestPa4 === void 0 ? ['pageSize'] : _fieldNames$requestPa4, _fieldNames$requestPa5 = _fieldNames$requestPa.orderProps, fsOrderProps = _fieldNames$requestPa5 === void 0 ? ['orderProps'] : _fieldNames$requestPa5, fsQuery = _fieldNames$requestPa.query; // 构建请求参数
224
+ params = {
225
+ eventType: eventType
226
+ };
227
+ if (fsQuery && fsQuery.length > 0) {
228
+ onSetObj(params, fsQuery, _objectSpread(_objectSpread(_objectSpread({}, requestParam), formInitValues), formValues));
229
+ } else {
230
+ params = _objectSpread(_objectSpread({}, requestParam), formValues);
231
+ }
204
232
 
205
- // 构建请求参数
206
- pageValue = pagination === false ? {} : {
207
- pageNo: pageNo,
208
- pageSize: pageSize
209
- };
210
- params = _objectSpread(_objectSpread({
211
- query: _objectSpread(_objectSpread({}, requestParam), formValues)
212
- }, pageValue), {}, {
213
- eventType: eventType
214
- }); // 列过滤或排序参数
215
- _filtersRef$current = filtersRef.current, filters = _filtersRef$current.filters, orderProps = _filtersRef$current.orderProps;
216
- if (Object.keys(filters).length > 0) {
217
- params.filters = filters;
218
- }
219
- if (orderProps.length > 0) {
220
- params.orderProps = orderProps;
221
- }
233
+ // 分页
234
+ if (pagination !== false) {
235
+ onSetObj(params, fsPageNo, pageNo);
236
+ onSetObj(params, fsPageSize, pageSize);
237
+ }
222
238
 
223
- // 异步树
224
- if (!parentFieldName) {
225
- _context.next = 10;
226
- break;
227
- }
228
- (_treeRef$current = treeRef.current) === null || _treeRef$current === void 0 || _treeRef$current.onRequestTree(params.query, record);
229
- return _context.abrupt("return");
230
- case 10:
231
- // 发起请求
232
- setData(function (d) {
233
- return _objectSpread(_objectSpread({}, d), {}, {
234
- loading: true
235
- });
236
- });
237
- _context.next = 13;
238
- return httpRequest(params);
239
- case 13:
240
- requestResult = _context.sent;
241
- if (!requestResult) {
242
- _context.next = 23;
243
- break;
244
- }
245
- // 获取table数据
246
- dataSource = getDataFromFields(requestResult, fieldNames.dataSource); // const pageSize = getDataFromFields(
247
- // requestResult,
248
- // fieldNames.pageSize,
249
- // );
250
- // const current = getDataFromFields(requestResult, fieldNames.current);
251
- total = getDataFromFields(requestResult, fieldNames.total);
252
- if (!(total === undefined ||
253
- // pageSize === undefined ||
254
- // current === undefined ||
255
- dataSource === undefined)) {
256
- _context.next = 20;
257
- break;
258
- }
259
- setData({
260
- dataSource: dataSource,
261
- pageSize: pageSize,
262
- current: pageNo,
263
- total: total,
264
- loading: false
265
- });
266
- return _context.abrupt("return");
267
- case 20:
268
- // 当前页无数据,返回上一页
269
- if (!dataSource.length && pageNo !== 1) {
270
- onRequest('reload', pageNo - 1);
271
- } else {
272
- setData({
273
- current: pageNo,
274
- pageSize: pageSize,
275
- loading: false,
276
- dataSource: dataSource,
277
- total: total || 0
278
- });
279
- }
280
- _context.next = 24;
281
- break;
282
- case 23:
283
- setData(function (d) {
284
- return _objectSpread(_objectSpread({}, d), {}, {
285
- loading: false
286
- });
287
- });
288
- case 24:
289
- case "end":
290
- return _context.stop();
291
- }
292
- }, _callee);
293
- }))).catch(function () {});
294
- case 6:
239
+ // 列过滤或排序参数
240
+ _filtersRef$current = filtersRef.current, filters = _filtersRef$current.filters, orderProps = _filtersRef$current.orderProps;
241
+ if (Object.keys(filters).length > 0) {
242
+ onSetObj(params, fsFilters, filters);
243
+ }
244
+ if (orderProps.length > 0) {
245
+ onSetObj(params, fsOrderProps, orderProps);
246
+ }
247
+
248
+ // 异步树
249
+ if (!parentFieldName) {
250
+ _context.next = 20;
251
+ break;
252
+ }
253
+ (_treeRef$current = treeRef.current) === null || _treeRef$current === void 0 || _treeRef$current.onRequestTree(params.query, record);
254
+ return _context.abrupt("return");
255
+ case 20:
256
+ // 发起请求
257
+ setData(function (d) {
258
+ return _objectSpread(_objectSpread({}, d), {}, {
259
+ loading: true
260
+ });
261
+ });
262
+ _context.next = 23;
263
+ return httpRequest(params);
264
+ case 23:
265
+ requestResult = _context.sent;
266
+ if (!requestResult) {
267
+ _context.next = 33;
268
+ break;
269
+ }
270
+ // 获取table数据
271
+ dataSource = getDataFromFields(requestResult, fieldNames.dataSource);
272
+ total = getDataFromFields(requestResult, fieldNames.total);
273
+ if (!(total === undefined || dataSource === undefined)) {
274
+ _context.next = 30;
275
+ break;
276
+ }
277
+ setData({
278
+ dataSource: dataSource,
279
+ pageSize: pageSize,
280
+ current: pageNo,
281
+ total: total,
282
+ loading: false
283
+ });
284
+ return _context.abrupt("return");
285
+ case 30:
286
+ // 当前页无数据,返回上一页
287
+ if (!dataSource.length && pageNo !== 1) {
288
+ onRequest('reload', pageNo - 1);
289
+ } else {
290
+ setData({
291
+ current: pageNo,
292
+ pageSize: pageSize,
293
+ loading: false,
294
+ dataSource: dataSource,
295
+ total: total || 0
296
+ });
297
+ }
298
+ _context.next = 34;
299
+ break;
300
+ case 33:
301
+ setData(function (d) {
302
+ return _objectSpread(_objectSpread({}, d), {}, {
303
+ loading: false
304
+ });
305
+ });
306
+ case 34:
295
307
  case "end":
296
- return _context2.stop();
308
+ return _context.stop();
297
309
  }
298
- }, _callee2);
310
+ }, _callee);
299
311
  }));
300
312
  return function onRequest(_x) {
301
313
  return _ref2.apply(this, arguments);
@@ -355,8 +367,9 @@ var InternalProTable = function InternalProTable(props) {
355
367
 
356
368
  // 重置
357
369
  var _onReset = function onReset() {
370
+ var _formRef$current2;
358
371
  if (selectedRows.length > 0) setSelectedRows([]);
359
- form === null || form === void 0 || form.resetFields();
372
+ (_formRef$current2 = formRef.current) === null || _formRef$current2 === void 0 || _formRef$current2.resetFields();
360
373
  // 清空columns显示filter和sort值
361
374
  columns === null || columns === void 0 || columns.forEach(function (c) {
362
375
  if (c.filterDropdown || c.filters) {
@@ -379,10 +392,11 @@ var InternalProTable = function InternalProTable(props) {
379
392
 
380
393
  // form 数据 查询,重载,重置方法
381
394
  useImperativeHandle(proRef, function () {
395
+ var _formRef$current3;
382
396
  return {
383
397
  data: data,
384
398
  selectedRows: selectedRows,
385
- formValues: _objectSpread(_objectSpread({}, form.getFieldsValue()), filtersRef.current),
399
+ formValues: _objectSpread(_objectSpread({}, (_formRef$current3 = formRef.current) === null || _formRef$current3 === void 0 ? void 0 : _formRef$current3.getFieldsValue()), filtersRef.current),
386
400
  onSearch: function onSearch() {
387
401
  _onSearch();
388
402
  },
@@ -486,10 +500,10 @@ var InternalProTable = function InternalProTable(props) {
486
500
  }
487
501
 
488
502
  // 选择,只传入一个type参数或不传,封装选择行为
489
- var _ref4 = table.rowSelection || {},
490
- _ref4$type = _ref4.type,
491
- type = _ref4$type === void 0 ? 'checkbox' : _ref4$type,
492
- restSelection = _objectWithoutProperties(_ref4, _excluded);
503
+ var _ref3 = table.rowSelection || {},
504
+ _ref3$type = _ref3.type,
505
+ type = _ref3$type === void 0 ? 'checkbox' : _ref3$type,
506
+ restSelection = _objectWithoutProperties(_ref3, _excluded);
493
507
  var hasSelection = table.rowSelection && CcsUtils.isEmpty(restSelection);
494
508
  var rowSelection = hasSelection ? {
495
509
  type: type,
@@ -550,18 +564,6 @@ var InternalProTable = function InternalProTable(props) {
550
564
  } : undefined
551
565
  }));
552
566
  };
553
- var newToolbar = toolbar && /*#__PURE__*/_jsx(TableSelectionContext.Provider, {
554
- value: {
555
- selectedRows: selectedRows
556
- },
557
- children: toolbar
558
- });
559
- var newToolbarExtra = /*#__PURE__*/_jsx(TableSelectionContext.Provider, {
560
- value: {
561
- selectedRows: selectedRows
562
- },
563
- children: toolbarExtra
564
- });
565
567
  var _antTheme$useToken = antTheme.useToken(),
566
568
  token = _antTheme$useToken.token;
567
569
  var rootStyle = styles.root || {};
@@ -572,9 +574,9 @@ var InternalProTable = function InternalProTable(props) {
572
574
  }, rootStyle);
573
575
  }
574
576
  var onFullScreen = function onFullScreen(isFull) {
575
- var _ref5 = containerRef.current || {},
576
- classList = _ref5.classList,
577
- style = _ref5.style;
577
+ var _ref4 = containerRef.current || {},
578
+ classList = _ref4.classList,
579
+ style = _ref4.style;
578
580
  if (isFull) {
579
581
  classList === null || classList === void 0 || classList.add('css-table-full');
580
582
  style.backgroundColor = token.colorBgContainer;
@@ -595,6 +597,18 @@ var InternalProTable = function InternalProTable(props) {
595
597
 
596
598
  // 监听容器尺寸变化
597
599
  var onResize = _debounce(resizeFn, 500);
600
+
601
+ // table 操作按钮
602
+ var renderTableOperation = (table === null || table === void 0 ? void 0 : table.hideOperation) !== true ? /*#__PURE__*/_jsx(TableOperation, {
603
+ onChangeRowSize: function onChangeRowSize(e) {
604
+ return setTableRowSize(e);
605
+ },
606
+ tableRowSize: tableRowSize,
607
+ onReset: _onReset,
608
+ columns: columns,
609
+ tableRef: tableRef,
610
+ onFullScreen: onFullScreen
611
+ }) : /*#__PURE__*/_jsx(_Fragment, {});
598
612
  return /*#__PURE__*/_jsxs(_Fragment, {
599
613
  children: [/*#__PURE__*/_jsx(CcsResizeObserver.Target, {
600
614
  targetRef: tableContentRef,
@@ -605,26 +619,52 @@ var InternalProTable = function InternalProTable(props) {
605
619
  overflow: (table === null || table === void 0 || (_table$scroll2 = table.scroll) === null || _table$scroll2 === void 0 ? void 0 : _table$scroll2.y) === 'auto' ? 'hidden' : 'unset'
606
620
  }),
607
621
  ref: containerRef,
608
- children: [!(!formItems.length && !toolbar) && isAuth && /*#__PURE__*/_jsx(HeadComponent, {
609
- form: form,
610
- toolbar: newToolbar,
611
- formItems: formItems,
612
- expandForm: expandForm,
613
- formInitValues: formInitValues,
614
- formItemLabelWidth: props.formItemLabelWidth,
615
- onSearch: _onSearch,
616
- title: props.title,
617
- tableOperation: (table === null || table === void 0 ? void 0 : table.hideOperation) !== true ? /*#__PURE__*/_jsx(TableOperation, {
618
- onChangeRowSize: function onChangeRowSize(e) {
619
- return setTableRowSize(e);
622
+ children: [!(!formItems.length && !toolbar) && isAuth && /*#__PURE__*/_jsxs(TableSelectionContext.Provider, {
623
+ value: {
624
+ selectedRows: selectedRows
625
+ },
626
+ children: [/*#__PURE__*/_jsx(HeadComponent, {
627
+ formRef: formRef,
628
+ toolbar: toolbar,
629
+ formItems: formItems,
630
+ expandForm: expandForm,
631
+ formInitValues: formInitValues,
632
+ formItemLabelWidth: props.formItemLabelWidth,
633
+ onSearch: _onSearch,
634
+ title: props.title,
635
+ tableOperation: renderTableOperation,
636
+ children: toolbarExtra
637
+ }), toolbar && /*#__PURE__*/_jsxs(Card, {
638
+ styles: {
639
+ cover: {
640
+ borderRadius: 0
641
+ },
642
+ body: {
643
+ display: 'flex',
644
+ justifyContent: 'space-between',
645
+ width: '100%',
646
+ padding: '12px 16px',
647
+ alignContent: 'center'
648
+ }
649
+ },
650
+ style: {
651
+ borderRadius: 0,
652
+ borderLeft: 0,
653
+ borderBottom: 0,
654
+ borderRight: 0
620
655
  },
621
- tableRowSize: tableRowSize,
622
- onReset: _onReset,
623
- columns: columns,
624
- tableRef: tableRef,
625
- onFullScreen: onFullScreen
626
- }) : /*#__PURE__*/_jsx(_Fragment, {}),
627
- children: newToolbarExtra
656
+ children: [/*#__PURE__*/_jsx("div", {
657
+ style: {
658
+ flex: '1 1 auto'
659
+ },
660
+ children: toolbar
661
+ }), /*#__PURE__*/_jsx("div", {
662
+ style: {
663
+ flex: '0 0 auto'
664
+ },
665
+ children: renderTableOperation
666
+ })]
667
+ }), children]
628
668
  }), /*#__PURE__*/_jsxs("div", {
629
669
  className: "".concat(classPrefix, "-table-content"),
630
670
  style: _objectSpread(_objectSpread({}, styles === null || styles === void 0 ? void 0 : styles.table), {}, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ccs-ui/rc-pro",
3
- "version": "2.3.6-beta-25",
3
+ "version": "2.3.6-beta-27",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "author": {