History leve处理
This commit is contained in:
parent
d50ace8464
commit
ce96ca8304
@ -41,7 +41,7 @@
|
|||||||
<div class="report-details">
|
<div class="report-details">
|
||||||
<div class="detail-row">
|
<div class="detail-row">
|
||||||
<div class="detail-item">
|
<div class="detail-item">
|
||||||
<span class="detail-label">Target:</span>
|
<span class="detail-label">Level:</span>
|
||||||
<span class="detail-value">{{ report.target }}</span>
|
<span class="detail-value">{{ report.target }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="detail-item">
|
<div class="detail-item">
|
||||||
@ -128,7 +128,7 @@
|
|||||||
<div class="daily-date">{{ formatDateNumber(daily.dateNumber) }}</div>
|
<div class="daily-date">{{ formatDateNumber(daily.dateNumber) }}</div>
|
||||||
<div class="daily-info">
|
<div class="daily-info">
|
||||||
<div class="daily-target">
|
<div class="daily-target">
|
||||||
<span>Target: {{ formatGiftValue(daily.acceptGiftValue) }}</span>
|
<span>Level: {{ getLevelFromPolicy(daily.acceptGiftValue) }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="daily-time">
|
<div class="daily-time">
|
||||||
<span>Time: </span>
|
<span>Time: </span>
|
||||||
@ -215,11 +215,11 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, onMounted } from 'vue'
|
import {onMounted, ref} from 'vue'
|
||||||
import { useRouter } from 'vue-router'
|
import {useRouter} from 'vue-router'
|
||||||
import MobileHeader from '../components/MobileHeader.vue'
|
import MobileHeader from '../components/MobileHeader.vue'
|
||||||
import { getTeamMemberWork } from '../api/teamBill.js'
|
import {getTeamMemberWork, getTeamReleasePolicy} from '../api/teamBill.js'
|
||||||
import {getUserId} from "@/utils/userStore.js";
|
import {getTeamId, getUserId} from "@/utils/userStore.js";
|
||||||
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const totalSalary = ref('0.00')
|
const totalSalary = ref('0.00')
|
||||||
@ -229,12 +229,61 @@ const loading = ref(false)
|
|||||||
const showDetailModal = ref(false)
|
const showDetailModal = ref(false)
|
||||||
const selectedReport = ref(null)
|
const selectedReport = ref(null)
|
||||||
const originalTargetsData = ref([]) // 保存原始数据
|
const originalTargetsData = ref([]) // 保存原始数据
|
||||||
|
const policyData = ref(null) // 添加政策数据
|
||||||
|
const loadingPolicy = ref(false) // 政策加载状态
|
||||||
|
|
||||||
// 工作报告数据
|
// 工作报告数据
|
||||||
const workReports = ref([])
|
const workReports = ref([])
|
||||||
const levelData = ref(null)
|
|
||||||
const dailyTargets = ref([])
|
const dailyTargets = ref([])
|
||||||
|
|
||||||
|
// 获取政策数据
|
||||||
|
const fetchPolicyData = async () => {
|
||||||
|
try {
|
||||||
|
loadingPolicy.value = true
|
||||||
|
const teamId = getTeamId()
|
||||||
|
if (!teamId) {
|
||||||
|
console.warn('No team ID available')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await getTeamReleasePolicy(teamId)
|
||||||
|
if (response && response.status && response.body) {
|
||||||
|
policyData.value = response.body
|
||||||
|
console.debug('Policy data loaded:', policyData.value)
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Failed to fetch policy data:', error)
|
||||||
|
} finally {
|
||||||
|
loadingPolicy.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 根据政策数据和礼物价值计算等级
|
||||||
|
const getLevelFromPolicy = (giftValue) => {
|
||||||
|
if (!policyData.value?.policy || !giftValue) {
|
||||||
|
return 1 // 默认等级
|
||||||
|
}
|
||||||
|
|
||||||
|
const numValue = parseFloat(giftValue)
|
||||||
|
if (isNaN(numValue)) {
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
// 按target从大到小排序,找到第一个小于等于giftValue的level
|
||||||
|
const sortedPolicy = [...policyData.value.policy].sort((a, b) => {
|
||||||
|
return parseFloat(b.target) - parseFloat(a.target)
|
||||||
|
})
|
||||||
|
|
||||||
|
for (const policy of sortedPolicy) {
|
||||||
|
if (numValue >= parseFloat(policy.target)) {
|
||||||
|
return policy.level
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果都不匹配,返回最低等级
|
||||||
|
return Math.min(...policyData.value.policy.map(p => p.level))
|
||||||
|
}
|
||||||
|
|
||||||
// 获取工作报告数据
|
// 获取工作报告数据
|
||||||
const fetchWorkReports = async (userId) => {
|
const fetchWorkReports = async (userId) => {
|
||||||
try {
|
try {
|
||||||
@ -250,7 +299,7 @@ const fetchWorkReports = async (userId) => {
|
|||||||
id: target.id,
|
id: target.id,
|
||||||
date: target.billTitle,
|
date: target.billTitle,
|
||||||
status: getStatusText(target.status),
|
status: getStatusText(target.status),
|
||||||
target: formatGiftValue(target.target?.acceptGiftValue) || '-',
|
target: getLevelFromPolicy(target.target?.acceptGiftValue), // 使用政策数据计算等级
|
||||||
salary: formatSalaryValue(target.target?.settlementResult?.ownSalary) || '-',
|
salary: formatSalaryValue(target.target?.settlementResult?.ownSalary) || '-',
|
||||||
agentSalary: formatSalaryValue(target.target?.settlementResult?.memberSalary) || '-',
|
agentSalary: formatSalaryValue(target.target?.settlementResult?.memberSalary) || '-',
|
||||||
totalSalary: formatSalaryValue(target.target?.settlementResult?.totalSalary) || '-',
|
totalSalary: formatSalaryValue(target.target?.settlementResult?.totalSalary) || '-',
|
||||||
@ -387,8 +436,10 @@ const closeHelpModal = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 组件挂载时获取数据
|
// 组件挂载时获取数据
|
||||||
onMounted(() => {
|
onMounted(async () => {
|
||||||
fetchWorkReports(getUserId())
|
// 先获取政策数据,再获取工作报告
|
||||||
|
await fetchPolicyData()
|
||||||
|
await fetchWorkReports(getUserId())
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user