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
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
import { $fysp } from '@/api/index';
 
//问题状态
const proStatus = {
  unCheck: 'unCheck',
  pass: 'pass',
  fail: 'fail',
  change_unCheck: 'change_unCheck',
  change_fail: 'change_fail',
  change_pass: 'change_pass'
};
 
export default {
  //统计问题
  calProStatus(proList) {
    const status = {
      //问题数量
      proNum: proList.length,
      // 问题审核数
      proCheckedNum: 0,
      //整改数量
      changeNum: 0,
      //整改审核数量
      changeCheckedNum: 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++;
 
      if (p.extension3 == proStatus.pass) {
        status.proCheckedNum++;
      }
      if (p.extension3 == proStatus.change_pass) {
        status.changeCheckedNum++;
      }
 
      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;
  },
 
  //统计问题,返回数组形式
  proStatusArray(proList) {
    const status = this.calProStatus(proList);
    return [
      { name: '问题数', value: status.proNum, type: 'info' },
      {
        name: '整改数',
        value: status.changeNum,
        type: status.changeNum < status.proNum ? 'danger' : 'info'
      },
      {
        name: '待审核',
        value: status.uncheckNum,
        type: status.uncheckNum > 0 ? 'danger' : 'info'
      },
      { name: '已审核', value: status.passNum, type: 'info' },
      // {
      //   name: '未通过',
      //   value: status.unpassNum,
      //   type: status.unpassNum > 0 ? 'danger' : 'info'
      // },
      {
        name: '整改率',
        value: status.changePer,
        type:
          status.proNum > 0 && status.changePer != '100.0%'
            ? 'danger'
            : 'success'
      },
      // {
      //   name: '通过率',
      //   value: status.passPer,
      //   type:
      //     status.proNum > 0 && status.passPer != '100.0%' ? 'danger' : 'success'
      // },
      {
        name: '审核率',
        value: status.checkPer,
        type:
          status.proNum > 0 && status.checkPer != '100.0%'
            ? 'danger'
            : 'success'
      }
    ];
  },
 
  //问题图片和整改图片
  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;
  },
 
  //问题审核状态转换中文
  proStatusMap(p) {
    switch (p) {
      case proStatus.unCheck:
        return {
          name: '问题未审核',
          type: 'warning',
          index: 0,
          checkable: true,
          deletable: true,
          changeable: false
        };
      case proStatus.pass:
        return {
          name: '问题通过',
          type: 'success',
          index: 1,
          checkable: false,
          deletable: true,
          changeable: false
        };
      case proStatus.fail:
        return {
          name: '问题不通过',
          type: 'danger',
          index: 1,
          checkable: false,
          deletable: true,
          changeable: false
        };
      case proStatus.change_unCheck:
        return {
          name: '整改未审核',
          type: 'warning',
          index: 2,
          checkable: true,
          deletable: false,
          changeable: true
        };
      case proStatus.change_fail:
        return {
          name: '整改不通过',
          type: 'danger',
          index: 3,
          checkable: false,
          deletable: false,
          changeable: true
        };
      case proStatus.change_pass:
        return {
          name: '整改通过',
          type: 'success',
          index: 3,
          checkable: false,
          deletable: false,
          changeable: true
        };
      default:
        return {
          name: '问题未审核',
          type: 'warning',
          index: 0,
          checkable: true,
          deletable: true
        };
    }
  },
 
  //获取任务问题的审核情况
  getSubtaskType(s) {
    let type = 0;
    // 无问题
    if (s.proNum == 0) {
      type = 0;
    } 
    // 问题未审核
    else if (s.proCheckedNum == 0) {
      type = 1;
    }
    // 问题部分审核
    else if (s.proCheckedNum < s.proNum) {
      type = 2;
    }
    // 未整改 
    else if (s.changeNum < s.proNum) {
      type = 3;
    }
    // 整改未审核
    else if (s.changeCheckedNum == 0) {
      type = 4;
    }
    // 整改部分审核
    else if (s.changeCheckedNum < s.changeNum) {
      type = 5;
    }
    // 完全审核
    else {
      type = 6;
    }
    return type;
  },
 
  /**
   * 问题审核后状态变换
   * @param {String} s 当前问题状态
   * @param {Boolean} isPass 审核通过或驳回
   * @returns 下一个问题状态
   */
  proNextStatus(s, isPass) {
    let status, action;
    switch (s) {
      case proStatus.unCheck:
        status = isPass ? proStatus.pass : proStatus.fail;
        action = isPass ? 0 : 1;
        break;
      case proStatus.change_unCheck:
        status = isPass ? proStatus.change_pass : proStatus.change_fail;
        action = isPass ? 2 : 3;
        break;
    }
    return { status: status, action: action };
  },
 
  /**
   * 问题撤回后状态变换
   * @param {String} s 当前问题状态
   * @returns 下一个问题状态
   */
  proBeforeStatus(s) {
    let status, action;
    switch (s) {
      case proStatus.fail:
      case proStatus.pass:
        status = proStatus.unCheck;
        action = 4;
        break;
      case proStatus.change_fail:
      case proStatus.change_pass:
        status = proStatus.change_unCheck;
        action = 5;
        break;
    }
    return { status: status, action: action };
  }
};