riku
2026-01-19 068be2757aa2d51e3f6604dae54287683160ad0e
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
const moment = require('../utils/moment.min');
const app = getApp();
 
function name(params) {
  const DEADLINEDAY = app.globalData.userSetting.ledgerDeadline;
  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 = [];
  var tSelf = [];
  var pSelf = [];
  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 };
}
 
/**
 * 对台账或自巡查进行统计,类型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.ledgerFinished) {
  //   s.badge = {
  //     color: 'yellow',
  //     count: '!',
  //   };
  //   s.opacity = 1;
  // }
  if (!s.needUpdate) {
    s.badge = {
      color: '#00500079',
      count: '选填',
      shape: 'bubble',
    };
    s.opacity = 1;
  } else {
    s.badge = {
      color: 'ff00005d',
      count: '必填',
      shape: 'bubble',
    };
    s.opacity = 1;
  }
  if (s.upLoad) {
    s.badge.color = 'gray';
    // s.badge.count += '✓';
    s.opacity = 0.4;
  }
}
 
export { parseLedgerStat, parseSelfPatrol, refreshLedgerStatus };