feat: 排序回调新增data参数

This commit is contained in:
liushaozhen 2020-07-08 14:52:57 +08:00
parent ba317900d3
commit 344e948141
3 changed files with 7 additions and 5 deletions

View File

@ -292,7 +292,7 @@ function sort(Table, Icon) {
} else {
data = oldData.concat();
}
typeof sort.sortFun === "function" && sort.sortFun(sortCol, data);
typeof sort.sortFun === "function" && sort.sortFun(sortCol, data, oldData);
}
} else {
seleObj = flatColumns.find(function (da) {
@ -310,7 +310,7 @@ function sort(Table, Icon) {
sort.sortFun(sortCol);
} else {
data = _this3.multiSort(flatColumns);
typeof sort.sortFun === "function" && sort.sortFun(sortCol, data);
typeof sort.sortFun === "function" && sort.sortFun(sortCol, data, oldData);
}
}
_this3.setState({ data: data, oldData: oldData, flatColumns: flatColumns });

View File

@ -25,6 +25,8 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : _defaults(subClass, superClass); }
function sum(Table) {
var precision = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2;
return function (_React$Component) {
_inherits(SumTable, _React$Component);
@ -91,7 +93,7 @@ function sum(Table) {
count += _num;
}
});
sumdata[column.dataIndex] = (0, _utils.DicimalFormater)(count, 2);
sumdata[column.dataIndex] = (0, _utils.DicimalFormater)(count, precision);
}
if (index == 0) {
sumdata[column.dataIndex] = "合计 " + sumdata[column.dataIndex];

View File

@ -195,7 +195,7 @@ export default function sort(Table, Icon) {
} else {
data = oldData.concat();
}
typeof sort.sortFun === "function" && sort.sortFun(sortCol,data);
typeof sort.sortFun === "function" && sort.sortFun(sortCol,data,oldData);
}
} else {
seleObj = flatColumns.find(da => da.key == column.key);
@ -211,7 +211,7 @@ export default function sort(Table, Icon) {
sort.sortFun(sortCol);
} else {
data = this.multiSort(flatColumns);
typeof sort.sortFun === "function" && sort.sortFun(sortCol,data);
typeof sort.sortFun === "function" && sort.sortFun(sortCol,data,oldData);
}
}
this.setState({ data, oldData, flatColumns });