fix: 支持传多排序判断的方法

This commit is contained in:
gx2025f 2021-01-11 18:28:49 +08:00
parent fb7446d973
commit 30f6fb90f9
2 changed files with 8 additions and 2 deletions

View File

@ -121,6 +121,7 @@ import 'bee-table/build/Table.css';
|width|宽度的特定比例根据列的宽度计算|String/Number|-|
|fixed| 当表水平滚动时此列将被固定true或'left'或'right'| true/'left'/'right'|-|
|sorter|前端列排序方法,只要列上有此属性就说明这列可排序。**注:默认是前端排序,排序方法书写时注意有些字段的值可能是undefined的情况需要转换成0**| function|-|
|getMultiSorterValue| 多列排序的时候,可以使用此方法得到单元格中显示的值,用来进行排序中的判断|Function(row)|-|
|sorterClick|排序的回调函数|function|-|
|render|cell的render函数有三个参数这个单元格的文本这行的记录这行的索引它返回一个对象{childrenvalueprops{colSpan1rowSpan1}} ==>'children'是这个单元格的文本props是这个单元格的一些设置可以设置单元格行/列合并。2.2.48及以后版本新增第四个参数options为column设置的属性|-|
|onCellClick|单击列的单元格时调用|Function(row, event)|-|

View File

@ -116,8 +116,13 @@ export default function sort(Table, Icon) {
*/
_sortBy = (pre, after, orderCols, orderColslen, currentIndex) => {
const currentCol = orderCols[currentIndex];
const preKey = pre[currentCol.key];
const afterKey = after[currentCol.key];
const getMultiSorterValueFunc = currentCol.getMultiSorterValue
let preKey = pre[currentCol.key];
let afterKey = after[currentCol.key];
if (getMultiSorterValueFunc) {
preKey = getMultiSorterValueFunc(preKey)
afterKey = getMultiSorterValueFunc(afterKey)
}
let colSortFun = currentCol.sorter;
if(typeof colSortFun !== 'function'){
colSortFun = () => preKey - afterKey;