riku
2025-04-27 f46786f11c5c08ead7501a82e5a71430ad69b782
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
import { fetchProblemsStatistic } from '../../../services/inspection/fetchInspection';
 
export const useStatistic = Behavior({
  data: {
    statistic: {
      proNum: 0,
      changeNum: 0,
    },
  },
  methods: {
    fetchProblems(params, page) {
      return fetchProblemsStatistic(params).then(res => {
        let proNum = 0,
          changeNum = 0,
          changePer = 0;
        res.data.forEach(r => {
          proNum += r.count;
          changeNum += r.changeCount;
        });
        if (proNum > 0) {
          changePer = Math.round((changeNum / proNum) * 1000) / 10;
          changePer += '%';
        }
        this.setData({
          statistic: { proNum, changeNum, changePer },
        });
        return res.head;
      });
    },
  },
});