fix: 修复首页数据不一致 — 1)风险分布用去重数据 2)无工资数据时不估算社保 3)TaskCenter显示全部待办不再截取10条 4)修复dedupedTodos引用顺序
This commit is contained in:
@@ -692,8 +692,8 @@ export async function getDashboardData(orgId: string) {
|
||||
socialEmpTotal = totalSocialEmp
|
||||
housingOrgTotal = totalHousingOrg
|
||||
housingEmpTotal = totalHousingEmp
|
||||
} else if (socialConfig && employeeCount > 0) {
|
||||
// 用平均工资作为估算基数
|
||||
} else if (socialConfig && employeeCount > 0 && payslips.length > 0) {
|
||||
// 用平均工资作为估算基数(仅当有工资条数据时才估算)
|
||||
const avgBase = employeeCount > 0 ? Math.max(socialConfig.baseMin, Math.min(socialConfig.baseMax, totalBaseSalary / Math.max(employeeCount, 1))) : socialConfig.baseMin
|
||||
socialOrgTotal = avgBase * (socialConfig.pensionOrg + socialConfig.medicalOrg + socialConfig.unemploymentOrg + socialConfig.injuryOrg + socialConfig.maternityOrg) / 100 * employeeCount
|
||||
socialEmpTotal = avgBase * (socialConfig.pensionEmp + socialConfig.medicalEmp + socialConfig.unemploymentEmp) / 100 * employeeCount
|
||||
@@ -773,12 +773,6 @@ export async function getDashboardData(orgId: string) {
|
||||
orgTotalCost: yearTotalPay + yearSocialOrg + yearHousingOrg + yearOvertimePay + yearSeverance,
|
||||
}
|
||||
|
||||
const riskDistribution = {
|
||||
contract: riskItems.filter((r: typeof riskItems[number]) => r.type === 'CONTRACT').length,
|
||||
salary: riskItems.filter((r: typeof riskItems[number]) => r.type === 'SALARY').length,
|
||||
termination: riskItems.filter((r: typeof riskItems[number]) => r.type === 'TERMINATION').length,
|
||||
}
|
||||
|
||||
// 为所有风险项计算优先级和量化信息
|
||||
const todosWithCost = riskItems.map((r: typeof riskItems[number]) => {
|
||||
const estimatedLoss = r.estimatedLoss || 0
|
||||
@@ -832,6 +826,13 @@ export async function getDashboardData(orgId: string) {
|
||||
}
|
||||
const dedupedTodos = Array.from(dedupedTodoMap.values())
|
||||
|
||||
// 风险分布:使用去重后的数据,与待办列表一致
|
||||
const riskDistribution = {
|
||||
contract: dedupedTodos.filter((t) => t.type === 'CONTRACT').length,
|
||||
salary: dedupedTodos.filter((t) => t.type === 'SALARY').length,
|
||||
termination: dedupedTodos.filter((t) => t.type === 'TERMINATION').length,
|
||||
}
|
||||
|
||||
// 按优先级排序:URGENT > HIGH > MEDIUM > LOW
|
||||
const priorityOrder = { URGENT: 0, HIGH: 1, MEDIUM: 2, LOW: 3 }
|
||||
todosWithCost.sort((a, b) => priorityOrder[a.priority] - priorityOrder[b.priority])
|
||||
|
||||
Reference in New Issue
Block a user