|
|
@ -75,12 +75,14 @@ async function exportOvertimeStatistic (ctx) { |
|
|
|
d.departmrnt = d.departmrnt.map(dep => dep.name).join('、') |
|
|
|
d.role = d.role.map(r => r.name).join('、') |
|
|
|
let overtimeStatistic = sumRes.filter(s => s.pepUserId == d.pepUserId) |
|
|
|
let totalDuration = 0 |
|
|
|
for (let dayTypeKey in dayType) { |
|
|
|
for (let overtimeTypeKey in overtimeType) { |
|
|
|
let corOverTimeSta = overtimeStatistic.find(o => o.compensate == overtimeTypeKey && o.dayType == dayTypeKey) |
|
|
|
if (corOverTimeSta) { |
|
|
|
d[overtimeTypeKey + dayTypeKey] = (corOverTimeSta.duration / 3600) |
|
|
|
// .toFixed(1)
|
|
|
|
totalDuration += corOverTimeSta.duration / 3600 |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -88,10 +90,12 @@ async function exportOvertimeStatistic (ctx) { |
|
|
|
d['sum' + overtimeTypeKey] = overtimeStatistic.reduce((sum, o) => { |
|
|
|
if (o.compensate == overtimeTypeKey) { |
|
|
|
sum += o.duration / 3600 |
|
|
|
totalDuration += o.duration / 3600 |
|
|
|
} |
|
|
|
return sum |
|
|
|
}, 0) |
|
|
|
} |
|
|
|
d.totalDuration = totalDuration |
|
|
|
}) |
|
|
|
|
|
|
|
let overtimeTypeHeader = [] |
|
|
@ -100,13 +104,13 @@ async function exportOvertimeStatistic (ctx) { |
|
|
|
sumOvertimeTypeHeader.push({ |
|
|
|
title: `合计${overtimeType[overtimeTypeKey]}加班时长(小时)`, |
|
|
|
key: 'sum' + overtimeTypeKey, |
|
|
|
defaultValue: 0 |
|
|
|
defaultValue: '0' |
|
|
|
}) |
|
|
|
for (let dayTypeKey in dayType) { |
|
|
|
overtimeTypeHeader.push({ |
|
|
|
title: dayType[dayTypeKey] + '-' + overtimeType[overtimeTypeKey], |
|
|
|
key: overtimeTypeKey + dayTypeKey, |
|
|
|
defaultValue: 0 |
|
|
|
defaultValue: '0' |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
@ -129,6 +133,11 @@ async function exportOvertimeStatistic (ctx) { |
|
|
|
},] |
|
|
|
.concat(overtimeTypeHeader) |
|
|
|
.concat(sumOvertimeTypeHeader) |
|
|
|
.concat([{ |
|
|
|
title: '合计加班时长(小时)', |
|
|
|
key: 'totalDuration', |
|
|
|
defaultValue: '0' |
|
|
|
}]) |
|
|
|
|
|
|
|
const fileName = `加班统计_${startDate ? moment(startDate).format('YYYY-MM-DD') : ''}${startDate && endDate ? '-' : ''}${endDate ? moment(endDate).format('YYYY-MM-DD') : ''}${startDate || endDate ? '_' : ''}${moment().format('YYYYMMDDHHmmss')}` + '.csv' |
|
|
|
const filePath = await simpleExcelDown({ data: returnD, header, fileName: fileName }) |
|
|
|