'use strict';
/**
*
*
* @author Mai
* @date
* @version
*/
const tenderListOrder = (function () {
let orderSetting = getLocalCache('zh-calc-tender-list-order');
if (!orderSetting) orderSetting = 'name|up';
function reOrderTenders (orderStr) {
if (orderStr) {
orderSetting = orderStr;
setLocalCache('zh-calc-tender-list-order', orderStr);
}
const orders = orderSetting.split('|');
if (orders[0] === 'name') {
tenders.sort(function (a, b) {
return orders[1] === 'up'
? a[orders[0]].localeCompare(b[orders[0]], 'zh-CN')
: -a[orders[0]].localeCompare(b[orders[0]], 'zh-CN')
});
} else if (orders[0] === 'create_time') {
tenders.sort(function (a, b){
return orders[1] === 'up'
? Date.parse(a[orders[0]]) - Date.parse(b[orders[0]])
: Date.parse(b[orders[0]]) - Date.parse(a[orders[0]]);
})
}
initTenderTree();
$('.c-body').html(getTenderTreeHtml());
localHideList();
}
function getOrderButton(field) {
const orders = orderSetting.split('|');
const button = field === orders[0]
? (orders[1] === 'up'
? ''
: '')
: '';
return '' + button + '';
}
return { reOrderTenders, getOrderButton }
})();