fix: 多列排序时sorter规则优先安置用户传入的sorter方法,如果不传走默认

This commit is contained in:
izbz wh 2019-06-05 14:10:44 +08:00
parent 49aee39c59
commit b90ab5e9b6
7 changed files with 85592 additions and 141721 deletions

View File

@ -19,7 +19,12 @@ const columns13 = [
dataIndex: "a",
key: "a",
className:'dfasd',
width: 200
width: 200,
sorter: (pre, after) => {return pre.a.localeCompare(after.a)},
sorterClick:(data,type)=>{//排序的回调函数
//type value is up or down
console.log("data",data);
}
},
{
title: "金额",
@ -27,7 +32,7 @@ const columns13 = [
key: "b",
width: 200,
sumCol: true,
sorter: (a, b) => a.c - b.c,
sorter: (pre, after) => pre.b - after.b,
sorterClick:(data,type)=>{//排序的回调函数
//type value is up or down
console.log("data",data);
@ -39,7 +44,7 @@ const columns13 = [
key: "c",
width: 200,
sumCol: true,
sorter: (a, b) => a.c - b.c,
sorter: (pre, after) => pre.c - after.c,
sorterClick:(data,type)=>{//排序的回调函数
//type value is up or down
console.log("data",data);
@ -51,7 +56,7 @@ const columns13 = [
key: "e",
width: 200,
sumCol: true,
sorter: (a, b) => a.c - b.c,
sorter: (pre, after) => pre.e - after.e,
},
{
title: "供应商",

File diff suppressed because one or more lines are too long

6
dist/demo.css vendored
View File

@ -142,12 +142,6 @@
.u-loading.u-loading-line.u-loading-line-warning > div {
background-color: #ff9800; }
.u-loading.u-loading-custom > div {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%); }
@keyframes line-scale {
0% {
transform: scaley(1); }

2
dist/demo.css.map vendored

File diff suppressed because one or more lines are too long

227271
dist/demo.js vendored

File diff suppressed because one or more lines are too long

2
dist/demo.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -115,15 +115,20 @@ export default function sort(Table, Icon) {
* orderType:升序降序
*/
_sortBy = (pre, after, orderCols, orderColslen, currentIndex) => {
const preKey = pre[orderCols[currentIndex].key];
const afterKey = after[orderCols[currentIndex].key];
const currentCol = orderCols[currentIndex];
const preKey = pre[currentCol.key];
const afterKey = after[currentCol.key];
let colSortFun = currentCol.sorter;
if(typeof colSortFun !== 'function'){
colSortFun = () => preKey - afterKey;
}
if (preKey == afterKey && currentIndex + 1 <= orderColslen) {
return this._sortBy(pre, after, orderCols, orderColslen, currentIndex + 1);
}
if (orderCols[currentIndex].order == "ascend") {
return preKey - afterKey;
} else {
return afterKey - preKey;
if (currentCol.order == "ascend") {
return colSortFun(pre,after);
} else {
return -colSortFun(pre,after);
}
};
/**