function regionSort(d1, d2) {
var p1 = d1['商机运营认购占比'];
var p2 = d2['商机运营认购占比'];
p1 = p1 == '-' ? -Infinity : Number(p1);
p2 = p2 == '-' ? -Infinity : Number(p2);
return p2 - p1;
}
function processData(columnStr, dataStr, paramStr) {
var datas = JSON.parse(dataStr);
var queryParams = JSON.parse(paramStr);
var orders = JSON.stringify(queryParams['orders']);
var order;
if (orders != undefined) {
orders = JSON.parse(orders);
order = orders.length > 0 ? JSON.parse(JSON.stringify(orders[0])) : undefined;
}
if (order === undefined || (order['direction'] != 'asc' && order['direction'] != 'desc')) {
datas.sort(regionSort);
}
var index = -1;
var indexs = [];
for (var i = 0; i < datas.length; i++) {
var d = datas[i];
// 一个地区或者事业部,只有一个尾盘合计
if (d['项目名称'] == '尾盘合计') {
index = i;
}
var wp = d['is_wp'];
if (wp != '非尾盘' && d['项目名称'] != '尾盘合计') {
indexs.push(i);
}
}
// 存在尾盘将尾盘合计置底
if (datas.length > 0 && index > -1) {
var d = datas[index];
datas.splice(datas.length, 0, d);
datas.splice(index, 1);
}
for (var i = 0; i < indexs.length; i++) {
datas.splice(indexs[i], 1);
}
return JSON.stringify(datas);
}
console