Browse Source

fix 6036 加班统计列表导出缺少合计加班时长字段信息

master
巴林闲侠 2 years ago
parent
commit
9c91887940
  1. 13
      api/app/lib/controllers/attendance/index.js

13
api/app/lib/controllers/attendance/index.js

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

Loading…
Cancel
Save