feat: 个人资料补充工号、女性岗位类型、专项附加扣除字段

- 后端 GET /profile 返回 employeeNo/femaleWorkerType/specialDeduction
- 后端 PUT /profile 支持更新 specialDeduction(员工自行填报)
- 前端只读区补充:工号、女性岗位类型(仅女性显示)
- 前端可编辑区补充:专项附加扣除(元/月)
This commit is contained in:
freedakgmail
2026-08-17 19:09:28 +08:00
parent 4eb882b1e2
commit 88b0fcdc7d
2 changed files with 27 additions and 5 deletions
+8
View File
@@ -922,6 +922,9 @@ router.get('/profile', portalAuth, async (req: any, res, next) => {
education: emp.education || '',
city: emp.city || '',
birthDate,
employeeNo: emp.employeeNo || '',
femaleWorkerType: emp.femaleWorkerType || '',
specialDeduction: emp.specialDeduction ?? 0,
},
})
} catch (err) { next(err) }
@@ -937,6 +940,7 @@ router.put('/profile', portalAuth, async (req: any, res, next) => {
const {
emergencyContact, emergencyPhone, address,
bankAccount, bankName, education, city,
specialDeduction,
} = req.body
// 构建更新数据(仅允许员工自行编辑的字段)
@@ -951,6 +955,10 @@ router.put('/profile', portalAuth, async (req: any, res, next) => {
if (bankAccount !== undefined && bankAccount) {
updateData.bankAccount = encrypt(bankAccount)
}
// 专项附加扣除(子女教育、赡养老人等,员工自行填报)
if (specialDeduction !== undefined) {
updateData.specialDeduction = Number(specialDeduction) || 0
}
await prisma.employee.update({ where: { id: employeeId }, data: updateData })
+19 -5
View File
@@ -5,7 +5,7 @@
*/
import { useState, useEffect } from 'react'
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 Card from '../../components/ui/Card'
import Button from '../../components/ui/Button'
@@ -23,6 +23,7 @@ export default function MyProfile() {
bankName: '',
education: '',
city: '',
specialDeduction: 0,
})
const { data: profile, isLoading } = useQuery<any>({
@@ -40,6 +41,7 @@ export default function MyProfile() {
bankName: profile.bankName || '',
education: profile.education || '',
city: profile.city || '',
specialDeduction: profile.specialDeduction ?? 0,
})
}
}, [profile])
@@ -75,13 +77,15 @@ export default function MyProfile() {
const readOnlyFields = [
{ label: '姓名', value: profile.name, icon: User },
{ label: '工号', value: profile.employeeNo || '未填写', icon: Briefcase },
{ label: '性别', value: profile.gender === '男' ? '男' : profile.gender === '女' ? '女' : '未填写', icon: User },
{ label: '出生日期', value: profile.birthDate || '未填写', icon: Calendar },
{ label: '手机号', value: profile.phone || '未填写', icon: Phone },
{ label: '证件号码', value: profile.idCardNo || '未填写', icon: IdCard },
{ label: '部门', value: profile.department || '未填写', icon: User },
{ label: '岗位', value: profile.position || '未填写', icon: User },
{ label: '入职日期', value: profile.hireDate || '未填写', icon: User },
{ label: '出生日期', value: profile.birthDate || '未填写', icon: User },
{ label: '部门', value: profile.department || '未填写', icon: Briefcase },
{ label: '岗位', value: profile.position || '未填写', icon: Briefcase },
...(profile.gender === '女' ? [{ label: '女性岗位类型', value: profile.femaleWorkerType === 'CADRE' ? '干部/管理岗' : profile.femaleWorkerType === 'WORKER' ? '工人/操作岗' : '未填写', icon: User }] : []),
{ label: '入职日期', value: profile.hireDate || '未填写', icon: Calendar },
]
const educationOptions = ['博士', '硕士', '本科', '大专', '高中', '其他']
@@ -207,6 +211,16 @@ export default function MyProfile() {
disabled={!editing}
/>
</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>
{editing && (