riku
2023-03-06 e902f689c542971a5bbf43c3b68d88d34c32ed8b
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
import { $fysp } from "@/api/index";
 
//问题状态
function calProStatus(proList) {
  const status = {
    //问题数量
    proNum: proList.length,
    //整改数量
    changeNum: 0,
    //待审核数量
    uncheckNum: 0,
    //已审核通过数量
    passNum: 0,
    //未通过数量
    unpassNum: 0,
    //整改率
    changePer: "0%",
    //通过率
    passPer: "0%",
    //审核率
    checkPer: "0%",
  };
 
  proList.forEach((p) => {
    if (p.ischanged) status.changeNum++;
 
    if (p.extension3 == "fail" || p.extension3 == "change_fail")
      status.unpassNum++;
    else if (
      p.extension3 == "unCheck" ||
      p.extension3 == "change_unCheck" ||
      (p.extension3 == "pass" && p.ischanged)
    )
      status.uncheckNum++;
    else status.passNum++;
 
    status.changePer =
      String(
        (status.changeNum / status.proNum) * 100
          ? ((status.changeNum / status.proNum) * 100).toFixed(1)
          : 0
      ) + "%";
    status.passPer =
      String(
        (status.passNum / status.proNum) * 100
          ? ((status.passNum / status.proNum) * 100).toFixed(1)
          : 0
      ) + "%";
    status.checkPer =
      String(
        ((status.passNum + status.unpassNum) / status.proNum) * 100
          ? (
              ((status.passNum + status.unpassNum) / status.proNum) *
              100
            ).toFixed(1)
          : 0
      ) + "%";
  });
 
  return status;
}
 
//问题状态数组
function proStatusArray(proList) {
  const status = calProStatus(proList);
  return [
    { name: "问题数", value: status.proNum },
    { name: "整改数", value: status.changeNum },
    { name: "待审核", value: status.uncheckNum },
    { name: "已审核", value: status.passNum },
    { name: "未通过", value: status.unpassNum },
    { name: "整改率", value: status.changePer },
    { name: "通过率", value: status.passPer },
    { name: "审核率", value: status.checkPer },
  ];
}
 
//问题图片和整改图片
function proPics(pro) {
  const pics = [
    {
      title: "问题图片",
      path: [],
    },
    {
      title: "整改图片",
      path: [],
    },
  ];
  if (pro.mediafileList) {
    pro.mediafileList.forEach((m) => {
      pics[m.ischanged ? 1 : 0].path.push(
        `${$fysp.imgUrl}${m.extension1}${m.guid}.jpg`
      );
    });
  }
 
  return pics;
}
 
//问题审核状态转换中文
function proStatusMap(p) {
  switch (p) {
    case "unCheck":
      return { name: '问题未审核', type: 'warning'}
    case "pass":
      return { name: '问题通过', type: 'success'}
    case "fail":
      return { name: '问题不通过', type: 'danger'}
    case "change_unCheck":
      return { name: '整改未审核', type: 'warning'}
    case "change_fail":
      return { name: '整改不通过', type: 'danger'}
    case "change_pass":
      return { name: '整改通过', type: 'success'}
    default:
      return { name: '问题未审核', type: 'warning'}
  }
}
 
export { calProStatus, proStatusArray, proPics, proStatusMap };