feat: 解聘补偿增加「模拟计算」按钮 — 只计算不实际保存
- Step 4 费用结算增加「模拟计算」按钮 - 点击后计算补偿金并暂存到右侧列表,重置向导 - 不调用保存接口,不创建解聘记录 - 「确认保存」仍走原有流程保存到后端
This commit is contained in:
@@ -294,6 +294,53 @@ export default function Termination() {
|
||||
})
|
||||
}
|
||||
|
||||
// 模拟计算:只计算并暂存,不实际保存解聘记录
|
||||
const handleSimulate = () => {
|
||||
if (!costResult || !selectedEmployee) return
|
||||
setSavedItems((prev) => {
|
||||
if (prev.some((item) => item.employeeId === employeeId)) {
|
||||
return prev.map((item) =>
|
||||
item.employeeId === employeeId
|
||||
? {
|
||||
employeeId,
|
||||
name: selectedEmployee.name,
|
||||
department: selectedEmployee.department,
|
||||
reason,
|
||||
reasonLabel,
|
||||
terminationDate,
|
||||
severancePay: costResult.severancePay,
|
||||
noticePay: costResult.noticePay,
|
||||
doublePay: costResult.doublePay,
|
||||
grandTotal: costResult.grandTotal,
|
||||
years: costResult.years,
|
||||
remainingMonths: costResult.remainingMonths,
|
||||
compMonths: costResult.compMonths,
|
||||
}
|
||||
: item
|
||||
)
|
||||
}
|
||||
return [
|
||||
...prev,
|
||||
{
|
||||
employeeId,
|
||||
name: selectedEmployee.name,
|
||||
department: selectedEmployee.department,
|
||||
reason,
|
||||
reasonLabel,
|
||||
terminationDate,
|
||||
severancePay: costResult.severancePay,
|
||||
noticePay: costResult.noticePay,
|
||||
doublePay: costResult.doublePay,
|
||||
grandTotal: costResult.grandTotal,
|
||||
years: costResult.years,
|
||||
remainingMonths: costResult.remainingMonths,
|
||||
compMonths: costResult.compMonths,
|
||||
},
|
||||
]
|
||||
})
|
||||
handleReset()
|
||||
}
|
||||
|
||||
// 保存成功后暂存到右侧列表
|
||||
useEffect(() => {
|
||||
if (saveMutation.isSuccess && costResult && selectedEmployee) {
|
||||
@@ -816,9 +863,14 @@ export default function Termination() {
|
||||
下一步<ChevronRight className="w-4 h-4 ml-1" />
|
||||
</Button>
|
||||
) : (
|
||||
<Button onClick={handleSave} disabled={saveMutation.isPending}>
|
||||
<Shield className="w-4 h-4 mr-1" />确认保存
|
||||
</Button>
|
||||
<div className="flex gap-2">
|
||||
<Button variant="secondary" onClick={handleSimulate}>
|
||||
<Calculator className="w-4 h-4 mr-1" />模拟计算
|
||||
</Button>
|
||||
<Button onClick={handleSave} disabled={saveMutation.isPending}>
|
||||
<Shield className="w-4 h-4 mr-1" />确认保存
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user