feat(代理中心页): 计算历史薪资并展示
This commit is contained in:
parent
650f714f48
commit
a8d3ec68be
@ -114,7 +114,7 @@
|
|||||||
<div style="font-weight: 500; color: rgba(0, 0, 0, 0.4); margin-bottom: 5px">
|
<div style="font-weight: 500; color: rgba(0, 0, 0, 0.4); margin-bottom: 5px">
|
||||||
{{ t('history_salary') }}
|
{{ t('history_salary') }}
|
||||||
</div>
|
</div>
|
||||||
<div style="font-weight: 600">${{ salaryInfo.hostSalary }}</div>
|
<div style="font-weight: 600">${{ totalSalary }}</div>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<div style="font-weight: 500; color: rgba(0, 0, 0, 0.4); margin-bottom: 5px">
|
<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 { clearSelectedPayee } from '@/utils/payeeStore.js'
|
||||||
|
|
||||||
import { getTeamMemberCount, getTeamBill, getTeamMemberWork } from '@/api/teamBill.js'
|
import { getTeamMemberCount, getTeamBill, getTeamMemberWork } from '@/api/teamBill.js'
|
||||||
|
import { getUserIdentity } from '@/api/wallet.js'
|
||||||
|
|
||||||
import GeneralHeader from '@/components/GeneralHeader.vue'
|
import GeneralHeader from '@/components/GeneralHeader.vue'
|
||||||
import workReportBox from '@/components/workReportBox.vue'
|
import workReportBox from '@/components/workReportBox.vue'
|
||||||
@ -351,6 +352,8 @@ const router = useRouter()
|
|||||||
// 监听语言变化并设置文档方向
|
// 监听语言变化并设置文档方向
|
||||||
locale.value && setDocumentDirection(locale.value)
|
locale.value && setDocumentDirection(locale.value)
|
||||||
|
|
||||||
|
const totalSalary = ref('0') //历史收入
|
||||||
|
|
||||||
// 任务标签
|
// 任务标签
|
||||||
const taskTab = ref('host')
|
const taskTab = ref('host')
|
||||||
const tabHost = ref(null)
|
const tabHost = ref(null)
|
||||||
@ -413,7 +416,7 @@ const fetchMemberWorkData = async () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const response = await getTeamMemberWork(userId)
|
const response = await getTeamMemberWork(userId)
|
||||||
if (response && response.status && response.body) {
|
if (response.status && response.body) {
|
||||||
const data = response.body
|
const data = response.body
|
||||||
|
|
||||||
// 取第一条target数据(最新的工作数据)
|
// 取第一条target数据(最新的工作数据)
|
||||||
@ -452,6 +455,30 @@ const fetchMemberWorkData = async () => {
|
|||||||
} else {
|
} else {
|
||||||
console.warn('No targets data available')
|
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 {
|
} else {
|
||||||
console.warn('No member work data available')
|
console.warn('No member work data available')
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user