feat: 个人资料补充工号、女性岗位类型、专项附加扣除字段
- 后端 GET /profile 返回 employeeNo/femaleWorkerType/specialDeduction - 后端 PUT /profile 支持更新 specialDeduction(员工自行填报) - 前端只读区补充:工号、女性岗位类型(仅女性显示) - 前端可编辑区补充:专项附加扣除(元/月)
This commit is contained in:
@@ -922,6 +922,9 @@ router.get('/profile', portalAuth, async (req: any, res, next) => {
|
|||||||
education: emp.education || '',
|
education: emp.education || '',
|
||||||
city: emp.city || '',
|
city: emp.city || '',
|
||||||
birthDate,
|
birthDate,
|
||||||
|
employeeNo: emp.employeeNo || '',
|
||||||
|
femaleWorkerType: emp.femaleWorkerType || '',
|
||||||
|
specialDeduction: emp.specialDeduction ?? 0,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
} catch (err) { next(err) }
|
} catch (err) { next(err) }
|
||||||
@@ -937,6 +940,7 @@ router.put('/profile', portalAuth, async (req: any, res, next) => {
|
|||||||
const {
|
const {
|
||||||
emergencyContact, emergencyPhone, address,
|
emergencyContact, emergencyPhone, address,
|
||||||
bankAccount, bankName, education, city,
|
bankAccount, bankName, education, city,
|
||||||
|
specialDeduction,
|
||||||
} = req.body
|
} = req.body
|
||||||
|
|
||||||
// 构建更新数据(仅允许员工自行编辑的字段)
|
// 构建更新数据(仅允许员工自行编辑的字段)
|
||||||
@@ -951,6 +955,10 @@ router.put('/profile', portalAuth, async (req: any, res, next) => {
|
|||||||
if (bankAccount !== undefined && bankAccount) {
|
if (bankAccount !== undefined && bankAccount) {
|
||||||
updateData.bankAccount = encrypt(bankAccount)
|
updateData.bankAccount = encrypt(bankAccount)
|
||||||
}
|
}
|
||||||
|
// 专项附加扣除(子女教育、赡养老人等,员工自行填报)
|
||||||
|
if (specialDeduction !== undefined) {
|
||||||
|
updateData.specialDeduction = Number(specialDeduction) || 0
|
||||||
|
}
|
||||||
|
|
||||||
await prisma.employee.update({ where: { id: employeeId }, data: updateData })
|
await prisma.employee.update({ where: { id: employeeId }, data: updateData })
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
import { useState, useEffect } from 'react'
|
import { useState, useEffect } from 'react'
|
||||||
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'
|
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'
|
||||||
import { User, Phone, IdCard, MapPin, Banknote, GraduationCap, AlertCircle, Check, Save } from 'lucide-react'
|
import { User, Phone, IdCard, MapPin, Banknote, GraduationCap, AlertCircle, Check, Save, Briefcase, Calendar } from 'lucide-react'
|
||||||
import { portalApi } from '../../lib/api-services'
|
import { portalApi } from '../../lib/api-services'
|
||||||
import Card from '../../components/ui/Card'
|
import Card from '../../components/ui/Card'
|
||||||
import Button from '../../components/ui/Button'
|
import Button from '../../components/ui/Button'
|
||||||
@@ -23,6 +23,7 @@ export default function MyProfile() {
|
|||||||
bankName: '',
|
bankName: '',
|
||||||
education: '',
|
education: '',
|
||||||
city: '',
|
city: '',
|
||||||
|
specialDeduction: 0,
|
||||||
})
|
})
|
||||||
|
|
||||||
const { data: profile, isLoading } = useQuery<any>({
|
const { data: profile, isLoading } = useQuery<any>({
|
||||||
@@ -40,6 +41,7 @@ export default function MyProfile() {
|
|||||||
bankName: profile.bankName || '',
|
bankName: profile.bankName || '',
|
||||||
education: profile.education || '',
|
education: profile.education || '',
|
||||||
city: profile.city || '',
|
city: profile.city || '',
|
||||||
|
specialDeduction: profile.specialDeduction ?? 0,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}, [profile])
|
}, [profile])
|
||||||
@@ -75,13 +77,15 @@ export default function MyProfile() {
|
|||||||
|
|
||||||
const readOnlyFields = [
|
const readOnlyFields = [
|
||||||
{ label: '姓名', value: profile.name, icon: User },
|
{ label: '姓名', value: profile.name, icon: User },
|
||||||
|
{ label: '工号', value: profile.employeeNo || '未填写', icon: Briefcase },
|
||||||
{ label: '性别', value: profile.gender === '男' ? '男' : profile.gender === '女' ? '女' : '未填写', icon: User },
|
{ label: '性别', value: profile.gender === '男' ? '男' : profile.gender === '女' ? '女' : '未填写', icon: User },
|
||||||
|
{ label: '出生日期', value: profile.birthDate || '未填写', icon: Calendar },
|
||||||
{ label: '手机号', value: profile.phone || '未填写', icon: Phone },
|
{ label: '手机号', value: profile.phone || '未填写', icon: Phone },
|
||||||
{ label: '证件号码', value: profile.idCardNo || '未填写', icon: IdCard },
|
{ label: '证件号码', value: profile.idCardNo || '未填写', icon: IdCard },
|
||||||
{ label: '部门', value: profile.department || '未填写', icon: User },
|
{ label: '部门', value: profile.department || '未填写', icon: Briefcase },
|
||||||
{ label: '岗位', value: profile.position || '未填写', icon: User },
|
{ label: '岗位', value: profile.position || '未填写', icon: Briefcase },
|
||||||
{ label: '入职日期', value: profile.hireDate || '未填写', icon: User },
|
...(profile.gender === '女' ? [{ label: '女性岗位类型', value: profile.femaleWorkerType === 'CADRE' ? '干部/管理岗' : profile.femaleWorkerType === 'WORKER' ? '工人/操作岗' : '未填写', icon: User }] : []),
|
||||||
{ label: '出生日期', value: profile.birthDate || '未填写', icon: User },
|
{ label: '入职日期', value: profile.hireDate || '未填写', icon: Calendar },
|
||||||
]
|
]
|
||||||
|
|
||||||
const educationOptions = ['博士', '硕士', '本科', '大专', '高中', '其他']
|
const educationOptions = ['博士', '硕士', '本科', '大专', '高中', '其他']
|
||||||
@@ -207,6 +211,16 @@ export default function MyProfile() {
|
|||||||
disabled={!editing}
|
disabled={!editing}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
<div>
|
||||||
|
<Label>专项附加扣除(元/月)</Label>
|
||||||
|
<Input
|
||||||
|
type="number"
|
||||||
|
value={form.specialDeduction}
|
||||||
|
onChange={(e) => setForm({ ...form, specialDeduction: Number(e.target.value) || 0 })}
|
||||||
|
placeholder="子女教育、赡养老人等,0表示无"
|
||||||
|
disabled={!editing}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{editing && (
|
{editing && (
|
||||||
|
|||||||
Reference in New Issue
Block a user