feat: 转正弹窗显示原薪资 + 薪资变化时联动签署
- ConfirmModal 显示原薪资(¥xxx),转正薪资默认填入原薪资 - 转正薪资与原薪资不同时,提示"将发起薪酬调整确认书签署" - confirmMutation onSuccess:薪资变化时弹出签署方式选择弹窗 - scene=POLICY,文件标题为"转正薪酬调整确认书" - 备注记录薪资变化:¥原薪资 → ¥新薪资 Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
@@ -281,13 +281,28 @@ export default function Roster() {
|
|||||||
const confirmMutation = useMutation({
|
const confirmMutation = useMutation({
|
||||||
mutationFn: (data: { employeeId: string; confirmDate: string; regularSalary?: number }) =>
|
mutationFn: (data: { employeeId: string; confirmDate: string; regularSalary?: number }) =>
|
||||||
workProcessApi.create({ type: 'CONFIRM', title: '转正', employeeId: data.employeeId, formData: { employeeId: data.employeeId, confirmDate: data.confirmDate, regularSalary: data.regularSalary }, status: 'DRAFT' }),
|
workProcessApi.create({ type: 'CONFIRM', title: '转正', employeeId: data.employeeId, formData: { employeeId: data.employeeId, confirmDate: data.confirmDate, regularSalary: data.regularSalary }, status: 'DRAFT' }),
|
||||||
onSuccess: () => {
|
onSuccess: (_data, variables) => {
|
||||||
queryClient.invalidateQueries({ queryKey: ['roster'] })
|
queryClient.invalidateQueries({ queryKey: ['roster'] })
|
||||||
queryClient.invalidateQueries({ queryKey: ['dashboard'] })
|
queryClient.invalidateQueries({ queryKey: ['dashboard'] })
|
||||||
queryClient.invalidateQueries({ queryKey: ['roster-profile'] })
|
queryClient.invalidateQueries({ queryKey: ['roster-profile'] })
|
||||||
setShowConfirmModal(false)
|
setShowConfirmModal(false)
|
||||||
setConfirmEmployee(null)
|
const originalSalary = confirmEmployee?.monthlySalary ? Number(confirmEmployee.monthlySalary) : null
|
||||||
|
const newSalary = variables.regularSalary
|
||||||
|
// 薪资有变化时弹出签署方式选择
|
||||||
|
if (newSalary && newSalary !== originalSalary) {
|
||||||
|
setSignChoice({
|
||||||
|
open: true,
|
||||||
|
employeeId: variables.employeeId,
|
||||||
|
employeeName: confirmEmployee?.name || '',
|
||||||
|
scene: 'POLICY',
|
||||||
|
documentTitle: `${confirmEmployee?.name || ''}的转正薪酬调整确认书`,
|
||||||
|
remark: `转正薪资调整:¥${originalSalary || 0} → ¥${newSalary}`,
|
||||||
|
actionName: '转正调薪',
|
||||||
|
})
|
||||||
|
} else {
|
||||||
toast.success('转正已提交')
|
toast.success('转正已提交')
|
||||||
|
}
|
||||||
|
setConfirmEmployee(null)
|
||||||
},
|
},
|
||||||
onError: (err: any) => toast.error(err?.response?.data?.error?.message || '转正失败'),
|
onError: (err: any) => toast.error(err?.response?.data?.error?.message || '转正失败'),
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -335,11 +335,15 @@ export function ConfirmModal({ employee, onClose, onSubmit, loading, error }: {
|
|||||||
loading: boolean
|
loading: boolean
|
||||||
error: any
|
error: any
|
||||||
}) {
|
}) {
|
||||||
|
const originalSalary = employee.monthlySalary ? Number(employee.monthlySalary) : null
|
||||||
const [form, setForm] = useState({
|
const [form, setForm] = useState({
|
||||||
confirmDate: new Date().toISOString().slice(0, 10),
|
confirmDate: new Date().toISOString().slice(0, 10),
|
||||||
regularSalary: '',
|
regularSalary: originalSalary ? String(originalSalary) : '',
|
||||||
})
|
})
|
||||||
|
|
||||||
|
/** 转正薪资与原薪资是否不同 */
|
||||||
|
const salaryChanged = form.regularSalary !== '' && Number(form.regularSalary) !== originalSalary
|
||||||
|
|
||||||
const handleSubmit = () => {
|
const handleSubmit = () => {
|
||||||
onSubmit({
|
onSubmit({
|
||||||
employeeId: employee.id,
|
employeeId: employee.id,
|
||||||
@@ -363,9 +367,15 @@ export function ConfirmModal({ employee, onClose, onSubmit, loading, error }: {
|
|||||||
<Input type="date" value={form.confirmDate} onChange={(e) => setForm({ ...form, confirmDate: e.target.value })} />
|
<Input type="date" value={form.confirmDate} onChange={(e) => setForm({ ...form, confirmDate: e.target.value })} />
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<Label>转正薪资(选填)</Label>
|
<Label>转正薪资{originalSalary ? `(原薪资 ¥${originalSalary})` : ''}</Label>
|
||||||
<Input type="number" value={form.regularSalary} onChange={(e) => setForm({ ...form, regularSalary: e.target.value })} placeholder="不填则保持原薪资" />
|
<Input type="number" value={form.regularSalary} onChange={(e) => setForm({ ...form, regularSalary: e.target.value })} placeholder={originalSalary ? `不填则保持原薪资 ¥${originalSalary}` : '请输入转正薪资'} />
|
||||||
<div className="text-xs text-gray-400 mt-1">填写后将更新员工月工资并记录薪资变更</div>
|
<div className="text-xs text-gray-400 mt-1">
|
||||||
|
{originalSalary
|
||||||
|
? (salaryChanged
|
||||||
|
? <span className="text-amber-600">⚠ 转正薪资与原薪资不同,提交后将发起薪酬调整确认书签署</span>
|
||||||
|
: '填写后将更新员工月工资并记录薪资变更')
|
||||||
|
: '填写后将更新员工月工资并记录薪资变更'}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{error && (
|
{error && (
|
||||||
<div className="text-xs text-danger">
|
<div className="text-xs text-danger">
|
||||||
|
|||||||
Reference in New Issue
Block a user