riku
2025-04-27 233a467167e2b363098cc7fa63e7f26d1d15507b
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 {
  basePicUrl,
  baseUrl,
  baseFileUrl,
  baseIconUrl,
} from '../../config/index';
import dayjs from "dayjs";
 
// 企业台账总体情况
export function getLedgerSummary(data) {
  data.iconUrl = basePicUrl + data.iconUrl;
  return data;
}
 
// 企业台账总体情况列表
export function getLedgerSummaryList(dataList) {
  return dataList.map(item => {
    return getLedgerSummary(item);
  });
}
 
export function getLedgerIsUploadedMap(dataList) {
  let mapSelf = new Map(); // 自巡查
  let mapLedger = new Map(); // 台账
 
  dataList.forEach(s => {
    let map = s.ledgerTypeId == -1 ? mapSelf : mapLedger;
 
    if (!map.has(s.ledgerType)) {
      map.set(s.ledgerType, {
        total: 0,
        upload: 0,
        children: [],
      });
    }
    let m = map.get(s.ledgerType);
    // 统计总数和上传情况
    m.total++;
    if (s.needUpdate) {
      // 必填项根据上传状态计数
      if (s.upLoad) m.upload++;
    } else {
      // 选填项默认已上传
      m.upload++;
    }
    m.children.push({
      name: s.ledgerName,
      icon: s.iconUrl,
      upload: s.upLoad,
      realTime: s.realTime,
      needUpdate: s.needUpdate,
      onTime: s.onTime,
    });
  });
 
  return { mapSelf, mapLedger };
}
 
// 企业每项台账是否上传
export function getLedgerIsUploaded(dataList) {
  const { mapSelf, mapLedger } = getLedgerIsUploadedMap(dataList);
 
  const selfCheckInfo = [];
  const ledgerInfo = [];
  for (const [key, value] of mapSelf) {
    // 每一大类的完成情况,0:必填项全部未提交;1:部分提交;2:全部提交
    let status = 0;
    if (value.upload == 0) {
      status = 0;
    } else if (value.upload < value.total) {
      status = 1;
    } else {
      status = 2;
    }
    selfCheckInfo.push({
      name: key,
      total: value.total,
      upload: value.upload,
      status: status,
      children: value.children,
    });
  }
  for (const [key, value] of mapLedger) {
    let status = 0;
    if (value.upload == 0) {
      status = 0;
    } else if (value.upload < value.total) {
      status = 1;
    } else {
      status = 2;
    }
    ledgerInfo.push({
      name: key,
      total: value.total,
      upload: value.upload,
      status: status,
      children: value.children,
    });
  }
  return { selfCheckInfo, ledgerInfo };
}
 
// 企业台账详情
export function getLedgerDetail(data) {
  if (data.path1) {
    data.path1 = data.path1.split(';').map((value, index) => {
      return basePicUrl + value;
    }); 
  }
  if (data.updateDate) {
    data.updateDate = dayjs(data.updateDate).format('YYYY年MM月DD日')    
  }
  return data;
}
 
// 企业台账详情列表
export function getLedgerDetailList(dataList) {
  return dataList.map(item => {
    return getLedgerDetail(item);
  });
}