feat(代理中心页): 计算历史薪资并展示

This commit is contained in:
hzj 2025-11-21 18:58:30 +08:00
parent 650f714f48
commit a8d3ec68be

View File

@ -114,7 +114,7 @@
<div style="font-weight: 500; color: rgba(0, 0, 0, 0.4); margin-bottom: 5px">
{{ t('history_salary') }}
</div>
<div style="font-weight: 600">${{ salaryInfo.hostSalary }}</div>
<div style="font-weight: 600">${{ totalSalary }}</div>
</div>
<div>
<div style="font-weight: 500; color: rgba(0, 0, 0, 0.4); margin-bottom: 5px">
@ -341,6 +341,7 @@ import { getTeamId, getUserId } from '@/utils/userStore.js'
import { clearSelectedPayee } from '@/utils/payeeStore.js'
import { getTeamMemberCount, getTeamBill, getTeamMemberWork } from '@/api/teamBill.js'
import { getUserIdentity } from '@/api/wallet.js'
import GeneralHeader from '@/components/GeneralHeader.vue'
import workReportBox from '@/components/workReportBox.vue'
@ -351,6 +352,8 @@ const router = useRouter()
//
locale.value && setDocumentDirection(locale.value)
const totalSalary = ref('0') //
//
const taskTab = ref('host')
const tabHost = ref(null)
@ -413,7 +416,7 @@ const fetchMemberWorkData = async () => {
}
const response = await getTeamMemberWork(userId)
if (response && response.status && response.body) {
if (response.status && response.body) {
const data = response.body
// target
@ -452,6 +455,30 @@ const fetchMemberWorkData = async () => {
} else {
console.warn('No targets data available')
}
const targets = response.body.targets || []
const userIdentity = await getUserIdentity()
// -
const totalAmount = targets.reduce((sum, target) => {
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)
}
return sum + salary
}, 0)
totalSalary.value = totalAmount.toFixed(2)
} else {
console.warn('No member work data available')
}