feat(工资结算记录): 历史薪资设置只计算已结算的记录
This commit is contained in:
parent
e6c0fa5fc9
commit
bf729514d4
@ -397,22 +397,27 @@ const fetchWorkReports = async (userId) => {
|
||||
}))
|
||||
|
||||
// 计算总薪资 - 根据用户身份选择对应的薪资字段
|
||||
const totalAmount = targets.reduce((sum, target) => {
|
||||
const totalAmount = targets.reduce((sum, target, index) => {
|
||||
let salary = 0
|
||||
|
||||
// 根据用户身份决定使用哪个薪资字段
|
||||
if (userIdentity.body?.agent) {
|
||||
// agent 为 true 时,使用 ownSalary
|
||||
salary = parseFloat(
|
||||
(target.target?.settlementResult?.ownSalary || 0) +
|
||||
(target.target?.settlementResult?.memberSalary || 0)
|
||||
)
|
||||
} else if (userIdentity.body?.anchor) {
|
||||
// anchor 为 true 时,使用 memberSalary
|
||||
salary = parseFloat(target.target?.settlementResult?.memberSalary || 0)
|
||||
// 跳过第一项(当月还在计算中),从第二项开始计算
|
||||
if (index > 0) {
|
||||
// 根据用户身份决定使用哪个薪资字段
|
||||
if (userIdentity.body?.agent) {
|
||||
// agent 为 true 时,使用 ownSalary
|
||||
salary = parseFloat(
|
||||
(target.target?.settlementResult?.ownSalary || 0) +
|
||||
(target.target?.settlementResult?.memberSalary || 0)
|
||||
)
|
||||
} else if (userIdentity.body?.anchor) {
|
||||
// anchor 为 true 时,使用 memberSalary
|
||||
salary = parseFloat(target.target?.settlementResult?.memberSalary || 0)
|
||||
}
|
||||
return sum + salary
|
||||
} else {
|
||||
// 对于第一项,只返回当前的sum,不添加任何值
|
||||
return sum
|
||||
}
|
||||
|
||||
return sum + salary
|
||||
}, 0)
|
||||
|
||||
totalSalary.value = totalAmount.toFixed(2)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user