| | |
| | | const moment = require('../utils/moment.min'); |
| | | const app = getApp(); |
| | | |
| | | // 统计台账上传情况 |
| | | function parseLedgerStat(subtypes, lastMonth) { |
| | | const DEADLINEDAY = 10; |
| | | function name(params) { |
| | | const DEADLINEDAY = app.globalData.userSetting.ledgerDeadline; |
| | | let monthInfo = { |
| | | totalMust: 0, |
| | | finishedMust: 0, |
| | |
| | | //选项卡 |
| | | var t = []; |
| | | var p = []; |
| | | var tSelf = []; |
| | | var pSelf = []; |
| | | for (let item of map) { |
| | | let notUpload = 0; |
| | | item[1].forEach(l => { |
| | |
| | | p.push(item[1]); |
| | | } |
| | | |
| | | return [t, p, monthInfo]; |
| | | return { types: t, items: p, monthInfo }; |
| | | } |
| | | |
| | | /** |
| | | * 对台账或自巡查进行统计,类型ledgerTypeId为-1的是自巡查,其余为台账 |
| | | * @param {Array} subtypes 台账记录 |
| | | * @param {Boolean} isSelfPatrol 是否统计自巡查类型 |
| | | */ |
| | | function _parse(subtypes, isSelfPatrol) { |
| | | const DEADLINEDAY = 10; |
| | | // 月度统计 |
| | | let monthInfo = { |
| | | // 全部必填数 |
| | | totalMust: 0, |
| | | // 完成必填数 |
| | | finishedMust: 0, |
| | | // 必填完成百分比 |
| | | percent: 0, |
| | | // 全部选填数 |
| | | totalSelect: 0, |
| | | // 完成选填数 |
| | | finishedSelect: 0, |
| | | // 提交状态:未提交 | 部分提交 | 已提交 |
| | | status: '', |
| | | // 逾期天数 |
| | | overtime: '', |
| | | // 建议 |
| | | suggestion: '', |
| | | }; |
| | | let map = new Map(); |
| | | for (let i = 0; i < subtypes.length; i++) { |
| | | const s = subtypes[i]; |
| | | // 统计自巡查时,过滤普通台账 |
| | | if (isSelfPatrol && s.ledgerTypeId != -1) continue; |
| | | // 统计台账时,过滤自巡查 |
| | | if (!isSelfPatrol && s.ledgerTypeId == -1) continue; |
| | | // 分别统计必填和选填的完成情况 |
| | | 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 = '未提交'; |
| | | monthInfo.suggestion = '台账完全未提交,将严重影响评估结果'; |
| | | } else if (monthInfo.finishedMust < monthInfo.totalMust) { |
| | | monthInfo.status = '部分提交'; |
| | | monthInfo.suggestion = '台账部分未提交,会影响评估结果'; |
| | | } else { |
| | | monthInfo.status = '已提交'; |
| | | monthInfo.suggestion = '台账已全部提交'; |
| | | } |
| | | monthInfo.overtime = moment().date() - DEADLINEDAY; |
| | | monthInfo.percent = |
| | | monthInfo.totalMust == 0 |
| | | ? 0 |
| | | : Math.round((monthInfo.finishedMust / monthInfo.totalMust) * 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 { types: t, items: p, monthInfo }; |
| | | } |
| | | // 统计台账上传情况 |
| | | function parseLedgerStat(subtypes) { |
| | | return _parse(subtypes); |
| | | } |
| | | |
| | | // 统计自巡查上传情况 |
| | | function parseSelfPatrol(subtypes) { |
| | | return _parse(subtypes, true); |
| | | } |
| | | |
| | | function refreshLedgerStatus(s) { |
| | | if (s.upLoad) { |
| | | // if (s.ledgerFinished) { |
| | | // s.badge = { |
| | | // color: 'yellow', |
| | | // count: '!', |
| | | // }; |
| | | // s.opacity = 1; |
| | | // } |
| | | if (!s.needUpdate) { |
| | | s.badge = { |
| | | color: 'green', |
| | | count: '✓', |
| | | }; |
| | | s.opacity = 0.7; |
| | | } else if (s.ledgerFinished) { |
| | | s.badge = { |
| | | color: 'yellow', |
| | | count: '!', |
| | | color: '#00500079', |
| | | count: '选填', |
| | | shape: 'bubble', |
| | | }; |
| | | s.opacity = 1; |
| | | } else if (!s.needUpdate) { |
| | | s.badge = { |
| | | color: 'green', |
| | | count: '选填', |
| | | }; |
| | | s.opacity = 0.8; |
| | | } else { |
| | | s.badge = { |
| | | color: 'red', |
| | | count: '!', |
| | | color: 'ff00005d', |
| | | count: '必填', |
| | | shape: 'bubble', |
| | | }; |
| | | s.opacity = 1; |
| | | } |
| | | if (s.upLoad) { |
| | | s.badge.color = 'gray'; |
| | | // s.badge.count += '✓'; |
| | | s.opacity = 0.4; |
| | | } |
| | | } |
| | | |
| | | export { parseLedgerStat, refreshLedgerStatus }; |
| | | export { parseLedgerStat, parseSelfPatrol, refreshLedgerStatus }; |