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); }); }