const moment = require('../utils/moment.min'); // 统计台账上传情况 function parseLedgerStat(subtypes, lastMonth) { const DEADLINEDAY = 10; let monthInfo = { totalMust: 0, finishedMust: 0, totalSelf: 0, finishedSelf: 0, totalSelect: 0, finishedSelect: 0, status: '', overtime: '', suggestion: '', }; let map = new Map(); subtypes.forEach(s => { //月度统计 if (s.ledgerTypeId == -1) { monthInfo.totalSelf++; if (s.upLoad) { monthInfo.finishedSelf++; } } else { if (s.needUpdate) { monthInfo.totalMust++; if (s.upLoad) { monthInfo.finishedMust++; } } else { monthInfo.totalSelect++; if (s.upLoad) { monthInfo.finishedSelect++; } } } refreshLedgerStatus(s); if (!map.has(s.ledgerType)) { map.set(s.ledgerType, []); } map.get(s.ledgerType).push(s); }); // if (monthInfo.finishedMust + monthInfo.finishedSelf == 0) { monthInfo.status = '未提交'; if (lastMonth) { monthInfo.suggestion = '建议:当期台账完全未提交,严重影响评估结果,后续请注意'; } else { monthInfo.suggestion = '建议:请尽快提交台账'; } } else if ( monthInfo.finishedMust + monthInfo.finishedSelf < monthInfo.totalMust + monthInfo.totalSelf ) { monthInfo.status = '部分提交'; if (lastMonth) { monthInfo.suggestion = '建议:当期台账部分未提交,会影响评估结果,后续请尽量提交所有台账'; } else { monthInfo.suggestion = '建议:当前已提交部分台账,请补全剩余台账'; } } else { monthInfo.status = '已提交'; if (lastMonth) { monthInfo.suggestion = '当期台账已全部提交,请保持'; } else { monthInfo.suggestion = '本期台账已全部提交'; } } monthInfo.overtime = moment().date() - DEADLINEDAY; monthInfo.percent = monthInfo.totalMust == 0 ? 0 : Math.round((monthInfo.finishedMust / monthInfo.totalMust) * 100); monthInfo.percent2 = monthInfo.totalSelf == 0 ? 0 : Math.round((monthInfo.finishedSelf / monthInfo.totalSelf) * 100); //选项卡 var t = []; var p = []; for (let item of map) { let notUpload = 0; item[1].forEach(l => { if (l.needUpdate && !l.upLoad) { notUpload++; } }); t.push({ name: item[0], tag: notUpload, total: item[1].length, }); p.push(item[1]); } return [t, p, monthInfo]; } function refreshLedgerStatus(s) { if (s.upLoad) { s.badge = { color: 'green', count: '✓', }; s.opacity = 0.7; } else if (s.ledgerFinished) { s.badge = { color: 'yellow', count: '!', }; s.opacity = 1; } else if (!s.needUpdate) { s.badge = { color: 'green', count: '选填', }; s.opacity = 0.8; } else { s.badge = { color: 'red', count: '!', }; s.opacity = 1; } } export { parseLedgerStat, refreshLedgerStatus };