$(function()
{
    $('#menu .nav > li').removeClass('active').find('[href*=' + v.mode + ']').parent().addClass('active');

    $('.main-table').table(
    {
        statisticCreator: function(table)
        {
            var $checkedRows = table.getTable().find('tbody>tr.checked');
            var checkedTotal = $checkedRows.length;
            if(!checkedTotal) return;

            var checkedPlanList = [];
            var checkedRealList = [];
            $checkedRows.each(function()
            {
                var $row = $(this);
                var data = $row.data();

                var currency = data.currency;
                var plan     = data.plan;
                var real     = data.real;
                if(currency && checkedPlanList[currency] == undefined) checkedPlanList[currency] = 0;
                if(currency && checkedRealList[currency] == undefined) checkedRealList[currency] = 0;

                checkedPlanList[currency] += Number(data.plan);
                checkedRealList[currency] += Number(data.real);
            });

            var planList = [];
            var realList = [];
            for(let currency in checkedPlanList) planList.push(v.currencySign[currency] + checkedPlanList[currency].toFixed(2));
            for(let currency in checkedRealList) realList.push(v.currencySign[currency] + checkedRealList[currency].toFixed(2));

            return v.checkedSummary.replace('%total%', checkedTotal).replace('%plan%', planList.join('，')).replace('%real%', realList.join( '，'));
        }
    });
});
