riku
2023-11-29 9b09d13712c0c005891450a3bf4b6d848ec0ff37
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
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 };