@ccs-ui/rc-pro 2.3.6-alpha-3 → 2.3.6-alpha-5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/ccs.d.ts +0 -4
- package/es/date-picker/index.js +20 -0
- package/es/ellipsis/index.js +4 -2
- package/es/hooks/use-selection.js +4 -3
- package/es/pro-table/table.d.ts +2 -15
- package/es/pro-table/table.js +13 -182
- package/package.json +1 -1
package/es/ccs.d.ts
CHANGED
|
@@ -52,8 +52,6 @@ type TableInstance<T = any> = {
|
|
|
52
52
|
searchParam: Record<string, any>;
|
|
53
53
|
/** 获取当前表单数据 */
|
|
54
54
|
data: TableData<T>;
|
|
55
|
-
/** 获取当前选中的数据 */
|
|
56
|
-
selectedRows: T[];
|
|
57
55
|
/** 查询数据,根据条件,从第一页开始显示 */
|
|
58
56
|
onSearch: () => void;
|
|
59
57
|
/** 刷新数据、根据条件,当前页 */
|
|
@@ -64,8 +62,6 @@ type TableInstance<T = any> = {
|
|
|
64
62
|
onReset: () => void;
|
|
65
63
|
/** 改变data 数据 */
|
|
66
64
|
onChangeData: React.Dispatch<React.SetStateAction<TableDataType<T>>>;
|
|
67
|
-
/** 清空选中的数据 */
|
|
68
|
-
onClearSelected: (key?: React.Key) => void;
|
|
69
65
|
};
|
|
70
66
|
type AuthButtonItem = {
|
|
71
67
|
key: string;
|
package/es/date-picker/index.js
CHANGED
|
@@ -12,6 +12,25 @@ import { DatePicker } from 'antd';
|
|
|
12
12
|
import dayjs from 'dayjs';
|
|
13
13
|
import _isArray from 'lodash.isarray';
|
|
14
14
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
|
+
var rangePresets = [{
|
|
16
|
+
label: '今天',
|
|
17
|
+
value: [dayjs().startOf('day'), dayjs().endOf('day')]
|
|
18
|
+
}, {
|
|
19
|
+
label: '最近3天',
|
|
20
|
+
value: [dayjs().add(-3, 'd'), dayjs()]
|
|
21
|
+
}, {
|
|
22
|
+
label: '最近7天',
|
|
23
|
+
value: [dayjs().add(-7, 'd'), dayjs()]
|
|
24
|
+
}, {
|
|
25
|
+
label: '最近14天',
|
|
26
|
+
value: [dayjs().add(-14, 'd'), dayjs()]
|
|
27
|
+
}, {
|
|
28
|
+
label: '最近30天',
|
|
29
|
+
value: [dayjs().add(-30, 'd'), dayjs()]
|
|
30
|
+
}, {
|
|
31
|
+
label: '最近90天',
|
|
32
|
+
value: [dayjs().add(-90, 'd'), dayjs()]
|
|
33
|
+
}];
|
|
15
34
|
function CcsDatePicker(_ref) {
|
|
16
35
|
var value = _ref.value,
|
|
17
36
|
onChange = _ref.onChange,
|
|
@@ -41,6 +60,7 @@ function RangePicker(_ref2) {
|
|
|
41
60
|
if (onChange) onChange(dateString || undefined);
|
|
42
61
|
};
|
|
43
62
|
return /*#__PURE__*/_jsx(DatePicker.RangePicker, _objectSpread({
|
|
63
|
+
presets: restProps.picker === 'date' || !restProps.picker ? rangePresets : undefined,
|
|
44
64
|
value: getDateValue(),
|
|
45
65
|
onChange: handleOnChange
|
|
46
66
|
}, restProps));
|
package/es/ellipsis/index.js
CHANGED
|
@@ -114,8 +114,10 @@ var Ellipsis = function Ellipsis(p) {
|
|
|
114
114
|
},
|
|
115
115
|
placement: "bottomLeft",
|
|
116
116
|
destroyTooltipOnHide: true,
|
|
117
|
-
|
|
118
|
-
|
|
117
|
+
styles: {
|
|
118
|
+
body: {
|
|
119
|
+
whiteSpace: 'normal'
|
|
120
|
+
}
|
|
119
121
|
},
|
|
120
122
|
children: renderNode
|
|
121
123
|
});
|
|
@@ -128,8 +128,8 @@ export default function useTableSelection(props) {
|
|
|
128
128
|
// 未传入key,删除全部
|
|
129
129
|
if (!key) {
|
|
130
130
|
selectionRef.current = {
|
|
131
|
-
selectedRowKeys:
|
|
132
|
-
selectedRows:
|
|
131
|
+
selectedRowKeys: [],
|
|
132
|
+
selectedRows: [],
|
|
133
133
|
info: {
|
|
134
134
|
type: 'none'
|
|
135
135
|
}
|
|
@@ -160,6 +160,7 @@ export default function useTableSelection(props) {
|
|
|
160
160
|
return _objectSpread(_objectSpread({}, selectionRef.current), {}, {
|
|
161
161
|
onChange: onChange,
|
|
162
162
|
onClear: onClear,
|
|
163
|
-
type: type
|
|
163
|
+
type: type,
|
|
164
|
+
preserveSelectedRowKeys: true
|
|
164
165
|
});
|
|
165
166
|
}
|
package/es/pro-table/table.d.ts
CHANGED
|
@@ -29,18 +29,7 @@ export type TableColumn<RecordType = any> = (Omit<ColumnGroupType<RecordType>, '
|
|
|
29
29
|
/** 省略显示行数,最大支持10行 */
|
|
30
30
|
ellipsis?: Omit<EllipsisProps, 'content'> | boolean | number;
|
|
31
31
|
};
|
|
32
|
-
type
|
|
33
|
-
/** 选中Key */
|
|
34
|
-
selectedRowKeys?: React.Key[];
|
|
35
|
-
/** 选中记录 */
|
|
36
|
-
selectedRows?: T[];
|
|
37
|
-
/** table datasource */
|
|
38
|
-
data: T[];
|
|
39
|
-
/** 清空选择,传入key取消指定选中,否清空所有 */
|
|
40
|
-
onClear: (key?: React.Key) => void;
|
|
41
|
-
};
|
|
42
|
-
export type TableExtraNode<T> = ReactNode | (({ selectedRowKeys, selectedRows, data, onClear, }: TableTitleType<T>) => ReactNode);
|
|
43
|
-
export type CcsTableProps<T> = Omit<TableProps<T>, 'columns' | 'title' | 'summary'> & {
|
|
32
|
+
export type CcsTableProps<T> = Omit<TableProps<T>, 'columns' | 'summary'> & {
|
|
44
33
|
data?: CCS.TableData<T>;
|
|
45
34
|
/** 为空时,默认一条数据 */
|
|
46
35
|
emptyDefaultOne?: boolean;
|
|
@@ -58,8 +47,6 @@ export type CcsTableProps<T> = Omit<TableProps<T>, 'columns' | 'title' | 'summar
|
|
|
58
47
|
hideOperation?: boolean;
|
|
59
48
|
/** 列配置 */
|
|
60
49
|
columns?: TableColumns<T>;
|
|
61
|
-
/** table title */
|
|
62
|
-
title?: TableExtraNode<T>;
|
|
63
50
|
/** table summary */
|
|
64
51
|
summary?: (data: readonly T[], columns: TableColumn<T>[]) => React.ReactNode;
|
|
65
52
|
};
|
|
@@ -78,7 +65,7 @@ export type CcsProTableProps<RecordType = any> = Pick<PropsWithCss, 'className'>
|
|
|
78
65
|
/** 查询form 初始值 */
|
|
79
66
|
formInitValues?: ParamType;
|
|
80
67
|
/** 按钮 操作部分 */
|
|
81
|
-
toolbar?:
|
|
68
|
+
toolbar?: ReactNode;
|
|
82
69
|
/** 边框 */
|
|
83
70
|
bordered?: boolean;
|
|
84
71
|
/** 展开查询条件,默认false */
|
package/es/pro-table/table.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
var _excluded = ["selectedRowKeys", "onChange"];
|
|
2
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); }
|
|
3
|
-
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; }
|
|
4
|
-
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; }
|
|
5
2
|
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
3
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
7
4
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
@@ -20,7 +17,6 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
20
17
|
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; }
|
|
21
18
|
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; } }
|
|
22
19
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
23
|
-
import CcsUtils from '@ccs-ui/utils';
|
|
24
20
|
import { useUpdateEffect } from 'ahooks';
|
|
25
21
|
import { theme as antTheme, Card, Empty } from 'antd';
|
|
26
22
|
import classNames from 'classnames';
|
|
@@ -97,8 +93,7 @@ var InternalProTable = function InternalProTable(props) {
|
|
|
97
93
|
requestParam = _ref$requestParam === void 0 ? {} : _ref$requestParam,
|
|
98
94
|
columns = _ref.columns,
|
|
99
95
|
rowKey = _ref.rowKey,
|
|
100
|
-
httpRequest = _ref.request
|
|
101
|
-
rowSelection = _ref.rowSelection;
|
|
96
|
+
httpRequest = _ref.request;
|
|
102
97
|
// table sticky
|
|
103
98
|
var stickyRef = useRef(false);
|
|
104
99
|
|
|
@@ -148,18 +143,10 @@ var InternalProTable = function InternalProTable(props) {
|
|
|
148
143
|
data = _useState2[0],
|
|
149
144
|
setData = _useState2[1];
|
|
150
145
|
var treeRef = useRef(null);
|
|
151
|
-
|
|
152
|
-
// table?.rowSelection?.defaultSelectedRowKeys || [],
|
|
153
|
-
// );
|
|
154
|
-
var _useState3 = useState({}),
|
|
146
|
+
var _useState3 = useState((table === null || table === void 0 ? void 0 : table.size) || 'middle'),
|
|
155
147
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
// const selectedRowsRef = useRef<RecordType[]>([]);
|
|
159
|
-
var _useState5 = useState((table === null || table === void 0 ? void 0 : table.size) || 'middle'),
|
|
160
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
161
|
-
tableRowSize = _useState6[0],
|
|
162
|
-
setTableRowSize = _useState6[1];
|
|
148
|
+
tableRowSize = _useState4[0],
|
|
149
|
+
setTableRowSize = _useState4[1];
|
|
163
150
|
// 上下文配置
|
|
164
151
|
var _useAppConfig = useAppConfig(),
|
|
165
152
|
theme = _useAppConfig.theme;
|
|
@@ -393,147 +380,14 @@ var InternalProTable = function InternalProTable(props) {
|
|
|
393
380
|
}
|
|
394
381
|
}, [Object.keys(requestParam || {}).toString(), Object.values(requestParam || {}).toString()]);
|
|
395
382
|
|
|
396
|
-
// 初始状态,记录选中key和选中记录,用作选中数据回显
|
|
397
|
-
// useEffect(() => {
|
|
398
|
-
// if (!rowSelectionDefaultRows) return;
|
|
399
|
-
|
|
400
|
-
// const { selectedRowKeys } = table?.rowSelection || {};
|
|
401
|
-
// if (
|
|
402
|
-
// selectedRowKeys &&
|
|
403
|
-
// selectedRowKeys.length > 0 &&
|
|
404
|
-
// !rowSelectionRef.current.selectedRowKeys &&
|
|
405
|
-
// rowSelectionDefaultRows.length > 0
|
|
406
|
-
// ) {
|
|
407
|
-
// rowSelectionRef.current = {
|
|
408
|
-
// selectedRowKeys,
|
|
409
|
-
// selectedRows: rowSelectionDefaultRows,
|
|
410
|
-
// };
|
|
411
|
-
// update({});
|
|
412
|
-
// }
|
|
413
|
-
// }, [rowSelectionDefaultRows]);
|
|
414
|
-
|
|
415
383
|
// 查询按钮
|
|
416
384
|
var onSearch = function onSearch() {
|
|
417
385
|
onRequest(TableEvent.Search);
|
|
418
386
|
};
|
|
419
387
|
|
|
420
|
-
// ==================== 封装table行选中逻辑 start====================
|
|
421
|
-
var _ref3 = rowSelection || {},
|
|
422
|
-
selectedRowKeys = _ref3.selectedRowKeys,
|
|
423
|
-
onRowChange = _ref3.onChange,
|
|
424
|
-
rsProps = _objectWithoutProperties(_ref3, _excluded);
|
|
425
|
-
var _rowSelectionRef$curr = rowSelectionRef.current.selectedRowKeys,
|
|
426
|
-
keys = _rowSelectionRef$curr === void 0 ? [] : _rowSelectionRef$curr;
|
|
427
|
-
|
|
428
|
-
// // 传入了选中的key,生成与之匹配的selectedRows数据
|
|
429
|
-
// if (
|
|
430
|
-
// rowSelection &&
|
|
431
|
-
// 'selectedRowKeys' in rowSelection &&
|
|
432
|
-
// !isEqual(selectedRowKeys, keys)
|
|
433
|
-
// ) {
|
|
434
|
-
// // 初始状态,传入了默认值,根据rowSelectionDefaultRows 生成选中rows
|
|
435
|
-
// if (
|
|
436
|
-
// selectedRowKeys.length > 0 &&
|
|
437
|
-
// keys.length === 0 &&
|
|
438
|
-
// (rowSelectionDefaultRows || []).length > 0
|
|
439
|
-
// ) {
|
|
440
|
-
// rowSelectionRef.current = {
|
|
441
|
-
// selectedRowKeys,
|
|
442
|
-
// selectedRows: rowSelectionDefaultRows,
|
|
443
|
-
// };
|
|
444
|
-
// }
|
|
445
|
-
|
|
446
|
-
// // 选中数据清空了,清空当前rowSelectionRef.current 数据
|
|
447
|
-
// if (selectedRowKeys.length === 0 && keys.length !== 0) {
|
|
448
|
-
// rowSelectionRef.current = { selectedRowKeys: [], selectedRows: [] };
|
|
449
|
-
// }
|
|
450
|
-
// }
|
|
451
|
-
|
|
452
|
-
// 行选择配置
|
|
453
|
-
var newRowSelection = rowSelection ? _objectSpread({
|
|
454
|
-
selectedRowKeys: selectedRowKeys || keys,
|
|
455
|
-
onChange: function onChange(keys, rows, info) {
|
|
456
|
-
onRowChange === null || onRowChange === void 0 || onRowChange(keys, rows, info);
|
|
457
|
-
// // row 中存在undefined记录,由于初始渲染造成无法获取选中记录,需从rowSelectionDefaultRows 中获取
|
|
458
|
-
// rows.forEach((row, index) => {
|
|
459
|
-
// if (!row) {
|
|
460
|
-
// const defaultRow = rowSelectionDefaultRows?.find(
|
|
461
|
-
// (rs: any) => rs[rowKey || 'id'] === keys[index],
|
|
462
|
-
// );
|
|
463
|
-
// CcsUtils.showWarning(
|
|
464
|
-
// !!defaultRow,
|
|
465
|
-
// 'CcsProTable:存在未知选中记录,请使用rowSelectionDefaultRows传入初始选中记录',
|
|
466
|
-
// );
|
|
467
|
-
// rows[index] = defaultRow || ({} as RecordType);
|
|
468
|
-
// }
|
|
469
|
-
// });
|
|
470
|
-
// rowSelectionRef.current = {
|
|
471
|
-
// selectedRowKeys: keys,
|
|
472
|
-
// selectedRows: rows,
|
|
473
|
-
// };
|
|
474
|
-
onEvent === null || onEvent === void 0 || onEvent(TableEvent.SelectedRows, {
|
|
475
|
-
keys: keys,
|
|
476
|
-
rows: rows
|
|
477
|
-
});
|
|
478
|
-
|
|
479
|
-
// 未传入onChange则更新状态
|
|
480
|
-
if (!onRowChange) update({});
|
|
481
|
-
},
|
|
482
|
-
preserveSelectedRowKeys: true
|
|
483
|
-
}, rsProps) : undefined;
|
|
484
|
-
// ==================== 当处于受控状态,处理table选中记录 end====================
|
|
485
|
-
|
|
486
|
-
// 清除选择
|
|
487
|
-
var onClearSelected = function onClearSelected(key, noUpdate) {
|
|
488
|
-
var _rowSelection$onChang2;
|
|
489
|
-
// 指定删除
|
|
490
|
-
if (key !== undefined) {
|
|
491
|
-
var _rowSelectionRef$curr2 = rowSelectionRef.current,
|
|
492
|
-
_rowSelectionRef$curr3 = _rowSelectionRef$curr2.selectedRowKeys,
|
|
493
|
-
_selectedRowKeys = _rowSelectionRef$curr3 === void 0 ? [] : _rowSelectionRef$curr3,
|
|
494
|
-
_rowSelectionRef$curr4 = _rowSelectionRef$curr2.selectedRows,
|
|
495
|
-
selectedRows = _rowSelectionRef$curr4 === void 0 ? [] : _rowSelectionRef$curr4;
|
|
496
|
-
rowSelectionRef.current = {
|
|
497
|
-
selectedRowKeys: _selectedRowKeys.filter(function (r) {
|
|
498
|
-
return r !== key;
|
|
499
|
-
}),
|
|
500
|
-
selectedRows: selectedRows.filter(function (r) {
|
|
501
|
-
return r[rowKey || 'id'] !== key;
|
|
502
|
-
})
|
|
503
|
-
};
|
|
504
|
-
} else {
|
|
505
|
-
// 删除全部
|
|
506
|
-
rowSelectionRef.current = {
|
|
507
|
-
selectedRowKeys: undefined,
|
|
508
|
-
selectedRows: undefined
|
|
509
|
-
};
|
|
510
|
-
}
|
|
511
|
-
var _rowSelectionRef$curr5 = rowSelectionRef.current,
|
|
512
|
-
keys = _rowSelectionRef$curr5.selectedRowKeys,
|
|
513
|
-
_rowSelectionRef$curr6 = _rowSelectionRef$curr5.selectedRows,
|
|
514
|
-
rows = _rowSelectionRef$curr6 === void 0 ? [] : _rowSelectionRef$curr6;
|
|
515
|
-
onEvent === null || onEvent === void 0 || onEvent(TableEvent.SelectedRows, {
|
|
516
|
-
keys: keys,
|
|
517
|
-
rows: rows
|
|
518
|
-
});
|
|
519
|
-
|
|
520
|
-
// 受控状态,需要调用onchange
|
|
521
|
-
if (rowSelection !== null && rowSelection !== void 0 && rowSelection.onChange) {
|
|
522
|
-
var _rowSelection$onChang;
|
|
523
|
-
rowSelection === null || rowSelection === void 0 || (_rowSelection$onChang = rowSelection.onChange) === null || _rowSelection$onChang === void 0 || _rowSelection$onChang.call(rowSelection, keys, rows, {});
|
|
524
|
-
return;
|
|
525
|
-
}
|
|
526
|
-
if (!noUpdate)
|
|
527
|
-
// 需要更新状态
|
|
528
|
-
update({});
|
|
529
|
-
rowSelection === null || rowSelection === void 0 || (_rowSelection$onChang2 = rowSelection.onChange) === null || _rowSelection$onChang2 === void 0 || _rowSelection$onChang2.call(rowSelection, selectedRowKeys, rows, {});
|
|
530
|
-
};
|
|
531
|
-
|
|
532
388
|
// 重置
|
|
533
389
|
var onReset = function onReset() {
|
|
534
390
|
var _formRef$current2;
|
|
535
|
-
// 清空选择
|
|
536
|
-
onClearSelected(undefined, true);
|
|
537
391
|
// 重置表单
|
|
538
392
|
(_formRef$current2 = formRef.current) === null || _formRef$current2 === void 0 || _formRef$current2.resetFields();
|
|
539
393
|
// 清空columns显示filter和sort值
|
|
@@ -552,16 +406,15 @@ var InternalProTable = function InternalProTable(props) {
|
|
|
552
406
|
|
|
553
407
|
// 刷新
|
|
554
408
|
var onReload = function onReload() {
|
|
555
|
-
onClearSelected(undefined, true);
|
|
556
409
|
onRequest(TableEvent.Reload, data.current, data.pageSize);
|
|
557
410
|
};
|
|
558
411
|
|
|
559
412
|
// form 数据 查询,重载,重置方法
|
|
560
413
|
useImperativeHandle(proRef, function () {
|
|
414
|
+
var _formRef$current3;
|
|
561
415
|
return {
|
|
562
416
|
data: data,
|
|
563
|
-
|
|
564
|
-
formValues: searchParamRef.current,
|
|
417
|
+
formValues: (_formRef$current3 = formRef.current) === null || _formRef$current3 === void 0 ? void 0 : _formRef$current3.getFieldsValue(),
|
|
565
418
|
searchParam: searchParamRef.current,
|
|
566
419
|
onSearch: onSearch,
|
|
567
420
|
onReload: onReload,
|
|
@@ -569,8 +422,7 @@ var InternalProTable = function InternalProTable(props) {
|
|
|
569
422
|
_onPartialReload(param);
|
|
570
423
|
},
|
|
571
424
|
onReset: onReset,
|
|
572
|
-
onChangeData: setData
|
|
573
|
-
onClearSelected: onClearSelected
|
|
425
|
+
onChangeData: setData
|
|
574
426
|
};
|
|
575
427
|
});
|
|
576
428
|
|
|
@@ -632,12 +484,6 @@ var InternalProTable = function InternalProTable(props) {
|
|
|
632
484
|
}
|
|
633
485
|
onRequest(TableEvent.ChangePage, paginationTable.current || 0, paginationTable.pageSize || 10);
|
|
634
486
|
};
|
|
635
|
-
|
|
636
|
-
// 扩展组件传递参数
|
|
637
|
-
var extraProps = _objectSpread(_objectSpread({}, rowSelectionRef.current), {}, {
|
|
638
|
-
data: data.dataSource || [],
|
|
639
|
-
onClear: onClearSelected
|
|
640
|
-
});
|
|
641
487
|
var renderTable = function renderTable() {
|
|
642
488
|
if (!table) return null;
|
|
643
489
|
if (!isAuth) {
|
|
@@ -663,19 +509,11 @@ var InternalProTable = function InternalProTable(props) {
|
|
|
663
509
|
}
|
|
664
510
|
}
|
|
665
511
|
|
|
666
|
-
// table title
|
|
667
|
-
var tableTitle = CcsUtils.isFunction(table.title) ? table.title(extraProps) : undefined;
|
|
668
|
-
|
|
669
512
|
// 异步树
|
|
670
513
|
if (parentFieldName) {
|
|
671
514
|
return /*#__PURE__*/_jsx(TableTree, {
|
|
672
515
|
data: data,
|
|
673
|
-
table:
|
|
674
|
-
rowSelection: newRowSelection,
|
|
675
|
-
title: tableTitle ? function () {
|
|
676
|
-
return tableTitle;
|
|
677
|
-
} : undefined
|
|
678
|
-
}),
|
|
516
|
+
table: table,
|
|
679
517
|
leafNode: leafNode,
|
|
680
518
|
treeRef: treeRef,
|
|
681
519
|
tableRef: tableRef,
|
|
@@ -697,12 +535,8 @@ var InternalProTable = function InternalProTable(props) {
|
|
|
697
535
|
size: tableRowSize,
|
|
698
536
|
columns: columns,
|
|
699
537
|
showSorterTooltip: true,
|
|
700
|
-
rowSelection: newRowSelection,
|
|
701
538
|
showNumber: props.showNumber,
|
|
702
539
|
loading: table.loading || data.loading || false,
|
|
703
|
-
title: tableTitle ? function () {
|
|
704
|
-
return tableTitle;
|
|
705
|
-
} : undefined,
|
|
706
540
|
onEvent: onEvent
|
|
707
541
|
}));
|
|
708
542
|
};
|
|
@@ -716,9 +550,9 @@ var InternalProTable = function InternalProTable(props) {
|
|
|
716
550
|
}, rootStyle);
|
|
717
551
|
}
|
|
718
552
|
var onFullScreen = function onFullScreen(isFull) {
|
|
719
|
-
var
|
|
720
|
-
classList =
|
|
721
|
-
style =
|
|
553
|
+
var _ref3 = containerRef.current || {},
|
|
554
|
+
classList = _ref3.classList,
|
|
555
|
+
style = _ref3.style;
|
|
722
556
|
if (isFull) {
|
|
723
557
|
classList === null || classList === void 0 || classList.add('css-table-full');
|
|
724
558
|
style.backgroundColor = token.colorBgContainer;
|
|
@@ -754,9 +588,6 @@ var InternalProTable = function InternalProTable(props) {
|
|
|
754
588
|
|
|
755
589
|
// 有查询条件
|
|
756
590
|
var hasFormItem = formItems.length > 0;
|
|
757
|
-
|
|
758
|
-
// table 按钮区
|
|
759
|
-
var tableToolbar = CcsUtils.isFunction(toolbar) ? toolbar(extraProps) : toolbar;
|
|
760
591
|
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
761
592
|
children: [/*#__PURE__*/_jsx(CcsResizeObserver.Target, {
|
|
762
593
|
targetRef: tableContentRef,
|
|
@@ -781,7 +612,7 @@ var InternalProTable = function InternalProTable(props) {
|
|
|
781
612
|
title: props.title,
|
|
782
613
|
children: hasFormItem && /*#__PURE__*/_jsx(HeadComponent, {
|
|
783
614
|
formRef: formRef,
|
|
784
|
-
toolbar:
|
|
615
|
+
toolbar: toolbar,
|
|
785
616
|
formItems: formItems,
|
|
786
617
|
expandForm: expandForm,
|
|
787
618
|
formInitValues: formInitValues,
|
|
@@ -813,7 +644,7 @@ var InternalProTable = function InternalProTable(props) {
|
|
|
813
644
|
style: {
|
|
814
645
|
flex: '1 1 auto'
|
|
815
646
|
},
|
|
816
|
-
children:
|
|
647
|
+
children: toolbar
|
|
817
648
|
}), /*#__PURE__*/_jsx("div", {
|
|
818
649
|
style: {
|
|
819
650
|
flex: '0 0 auto'
|