fix: 多排序字段处理

This commit is contained in:
Gaox2025f 2021-01-07 19:48:19 +08:00
parent 464cc6fccf
commit a19770beee
7 changed files with 3496 additions and 2804 deletions

View File

@ -56,7 +56,13 @@ const columns13 = [
key: "e",
width: 200,
sumCol: true,
sorter: (pre, after) => pre.e - after.e,
sorter: (pre, after) => pre.e.value - after.e.value,
getMultiSorterValue: data => {
return data.value
},
render: (text, data) => {
return text.value
}
},
{
title: "供应商",
@ -67,14 +73,13 @@ const columns13 = [
];
const data13 = [
{ a: "NU0391001", b: 675, c: 30, d: "xx供应商",e:100, key: "2" },
{ a: "NU0391002", b: 43, c: 41, d: "yy供应商",e:90, key: "1" },
{ a: "NU0391003", b: 43, c: 81, d: "zz供应商", e:120,key: "4" },
{ a: "NU0391004", b: 43, c: 81, d: "aa供应商", e:130,key: "5" },
{ a: "NU0391005", b: 153, c: 25, d: "bb供应商",e:90, key: "3" }
{ a: "NU0391001", b: 675, c: 30, d: "xx供应商",e:{value: 120}, key: "2" },
{ a: "NU0391002", b: 43, c: 41, d: "yy供应商",e:{value: 90}, key: "1" },
{ a: "NU0391003", b: 43, c: 81, d: "zz供应商", e:{value: 120},key: "4" },
{ a: "NU0391004", b: 43, c: 81, d: "aa供应商", e:{value: 110},key: "5" },
{ a: "NU0391005", b: 153, c: 25, d: "bb供应商",e:{value: 90}, key: "3" }
];
//拼接成复杂功能的table组件不能在render中定义需要像此例子声明在组件的外侧不然操作state会导致功能出现异常
let ComplexTable = multiSelect(sort(sum(Table, Icon)), Checkbox);

File diff suppressed because one or more lines are too long

2
dist/demo.css.map vendored

File diff suppressed because one or more lines are too long

5094
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

@ -139,8 +139,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;