代码记录
商圈监控页面右下表格代码 ChartTable.js
this.sort = (a, b, type) => {
// let newA;
// let newB;
// newA = a.sortFixed || b.sortFixed || a[type] === '-' ? this.state.sortedInfo.order === 'descend' ? -100000 : 100000 : a[type];
// newB = a.sortFixed || b.sortFixed || b[type] === '-' ? this.state.sortedInfo.order === 'descend' ? -100000 : 100000 : b[type];
// return newA - newB;
const IS_ASC = this.state.sortedInfo.order === 'ascend';
const infinity = 1/0;
let valA = a[type];
let valB = b[type];
if (a.sortFixed) {
valA = IS_ASC ? -infinity : infinity;
}
if (a[type] === '-' || !a[type]) {
valA = IS_ASC ? (infinity) : (-infinity);
}
if (b.sortFixed) {
valB = IS_ASC ? -infinity : infinity;
}
if (b[type] === '-' || !b[type]) {
valB = IS_ASC ? (infinity) : (-infinity);
}
return valA - valB;
};
this.initData = (v) => {
let res = [];
let sortFixed = false;
for (let i of Object.keys(v)) {
if (i + '' === '0') {
sortFixed = true;
} else {
sortFixed = false;
}
res.push(
{
...v[i].table,
key: i,
aoiname: v[i].aoiname,
sortFixed: sortFixed
}
);
}
return res;
};

浙公网安备 33010602011771号