feat: AIHR 智能人力资源管理系统初始提交

- 员工花名册管理(加密存储、导入导出)
- 薪酬管理(发薪批次、薪酬模版、加班费计算、工资条)
- 社保公积金(多城市配置、版本管理、基数调整)
- 解聘管理(6步流程、证据链、工作交接)
- AI 助手(合同审查、风险预测、RAG 知识库)
- Dashboard 仪表盘
- 设置与通知
This commit is contained in:
selfrelease
2026-07-24 13:53:11 +08:00
commit 0df8aa77d9
109 changed files with 38190 additions and 0 deletions
+157
View File
@@ -0,0 +1,157 @@
import { useState } from 'react'
import { Link } from 'react-router-dom'
import { Building2, Eye, EyeOff } from 'lucide-react'
import api from '../../lib/api'
import { Input, Label } from '../../components/ui/Input'
import Button from '../../components/ui/Button'
export default function ForgotPassword() {
const [showPassword, setShowPassword] = useState(false)
const [error, setError] = useState('')
const [success, setSuccess] = useState(false)
const [loading, setLoading] = useState(false)
const [step, setStep] = useState<1 | 2>(1)
const [phone, setPhone] = useState('')
const [code, setCode] = useState('')
const [newPassword, setNewPassword] = useState('')
const [sentCode, setSentCode] = useState('')
const sendCode = async () => {
setError('')
if (!/^1[3-9]\d{9}$/.test(phone)) {
setError('手机号格式不正确')
return
}
setLoading(true)
try {
const res = await api.post('/auth/forgot-password/send-code', { phone }) as any
setSentCode(res.data?.code || '')
setStep(2)
} catch (err: any) {
setError(err.response?.data?.error?.message || '发送失败,请稍后重试')
} finally {
setLoading(false)
}
}
const resetPwd = async () => {
setError('')
if (code.length !== 6) {
setError('请输入6位验证码')
return
}
if (newPassword.length < 8) {
setError('密码至少8位')
return
}
setLoading(true)
try {
await api.post('/auth/forgot-password/verify', { phone, code, newPassword })
setSuccess(true)
} catch (err: any) {
setError(err.response?.data?.error?.message || '重置失败,请稍后重试')
} finally {
setLoading(false)
}
}
return (
<div className="min-h-screen flex items-center justify-center bg-surface px-4">
<div className="w-full max-w-sm">
<div className="flex items-center justify-center gap-2 mb-8">
<Building2 className="w-8 h-8 text-primary" />
<span className="text-xl font-bold"></span>
</div>
<div className="card">
<h1 className="text-lg font-semibold mb-4"></h1>
{success ? (
<div className="text-center py-4">
<div className="text-green-600 mb-3"></div>
<Link to="/login" className="text-primary hover:underline text-sm"></Link>
</div>
) : (
<>
{error && (
<div className="mb-4 px-3 py-2 rounded-md bg-red-50 text-red-700 text-sm">{error}</div>
)}
{sentCode && step === 2 && (
<div className="mb-4 px-3 py-2 rounded-md bg-blue-50 text-blue-700 text-sm">
{sentCode}
</div>
)}
{step === 1 ? (
<div className="space-y-4">
<div>
<Label></Label>
<Input
type="tel"
placeholder="请输入注册手机号"
value={phone}
onChange={(e) => setPhone(e.target.value)}
maxLength={11}
/>
</div>
<Button className="w-full" disabled={loading} onClick={sendCode}>
{loading ? '发送中...' : '获取验证码'}
</Button>
</div>
) : (
<div className="space-y-4">
<div>
<Label></Label>
<Input type="tel" value={phone} disabled />
</div>
<div>
<Label></Label>
<Input
type="text"
placeholder="6位验证码"
value={code}
onChange={(e) => setCode(e.target.value)}
maxLength={6}
/>
</div>
<div>
<Label></Label>
<div className="relative">
<Input
type={showPassword ? 'text' : 'password'}
placeholder="至少8位"
value={newPassword}
onChange={(e) => setNewPassword(e.target.value)}
/>
<button
type="button"
onClick={() => setShowPassword(!showPassword)}
className="absolute right-2 top-1/2 -translate-y-1/2 text-gray-400"
>
{showPassword ? <EyeOff className="w-4 h-4" /> : <Eye className="w-4 h-4" />}
</button>
</div>
</div>
<Button className="w-full" disabled={loading} onClick={resetPwd}>
{loading ? '重置中...' : '重置密码'}
</Button>
<button
className="w-full text-xs text-gray-500 hover:text-gray-700"
onClick={() => { setStep(1); setCode(''); setSentCode('') }}
>
</button>
</div>
)}
<div className="mt-4 text-center text-sm">
<Link to="/login" className="text-primary hover:underline"></Link>
</div>
</>
)}
</div>
</div>
</div>
)
}
+107
View File
@@ -0,0 +1,107 @@
import { useState } from 'react'
import { useNavigate, Link } from 'react-router-dom'
import { Building2, Eye, EyeOff } from 'lucide-react'
import { useForm } from 'react-hook-form'
import { zodResolver } from '@hookform/resolvers/zod'
import { z } from 'zod'
import { useAuthStore } from '../../store/authStore'
import api from '../../lib/api'
import { Input, Label } from '../../components/ui/Input'
import Button from '../../components/ui/Button'
const schema = z.object({
phone: z.string().regex(/^1[3-9]\d{9}$/, '手机号格式不正确'),
password: z.string().min(1, '请输入密码'),
})
type FormData = z.infer<typeof schema>
export default function Login() {
const navigate = useNavigate()
const { setAuth } = useAuthStore()
const [showPassword, setShowPassword] = useState(false)
const [error, setError] = useState('')
const [loading, setLoading] = useState(false)
const { register, handleSubmit, formState: { errors } } = useForm<FormData>({
resolver: zodResolver(schema),
defaultValues: {
phone: '13800000001',
password: '12345678',
},
})
const onSubmit = async (data: FormData) => {
setError('')
setLoading(true)
try {
const res = await api.post('/auth/login', data) as any
setAuth(res.data.user, res.data.accessToken, res.data.refreshToken)
navigate('/')
} catch (err: any) {
setError(err.response?.data?.error?.message || '登录失败,请稍后重试')
} finally {
setLoading(false)
}
}
return (
<div className="min-h-screen flex items-center justify-center bg-surface px-4">
<div className="w-full max-w-sm">
<div className="flex items-center justify-center gap-2 mb-8">
<Building2 className="w-8 h-8 text-primary" />
<span className="text-xl font-bold"></span>
</div>
<div className="card">
<h1 className="text-lg font-semibold mb-4"></h1>
{error && (
<div className="mb-4 px-3 py-2 rounded-md bg-red-50 text-red-700 text-sm">{error}</div>
)}
<form onSubmit={handleSubmit(onSubmit)} className="space-y-4">
<div>
<Label></Label>
<Input
type="tel"
placeholder="请输入手机号"
{...register('phone')}
maxLength={11}
/>
{errors.phone && <p className="text-xs text-red-500 mt-1">{errors.phone.message}</p>}
</div>
<div>
<Label></Label>
<div className="relative">
<Input
type={showPassword ? 'text' : 'password'}
placeholder="请输入密码"
{...register('password')}
/>
<button
type="button"
onClick={() => setShowPassword(!showPassword)}
className="absolute right-2 top-1/2 -translate-y-1/2 text-gray-400"
>
{showPassword ? <EyeOff className="w-4 h-4" /> : <Eye className="w-4 h-4" />}
</button>
</div>
{errors.password && <p className="text-xs text-red-500 mt-1">{errors.password.message}</p>}
</div>
<Button type="submit" className="w-full" disabled={loading}>
{loading ? '登录中...' : '登录'}
</Button>
</form>
<div className="mt-4 flex items-center justify-between text-sm">
<Link to="/forgot-password" className="text-primary hover:underline"></Link>
<Link to="/register" className="text-primary hover:underline"></Link>
</div>
</div>
</div>
</div>
)
}
+126
View File
@@ -0,0 +1,126 @@
import { useState } from 'react'
import { useNavigate, Link } from 'react-router-dom'
import { Building2, Eye, EyeOff } from 'lucide-react'
import { useForm } from 'react-hook-form'
import { zodResolver } from '@hookform/resolvers/zod'
import { z } from 'zod'
import { useAuthStore } from '../../store/authStore'
import api from '../../lib/api'
import { Input, Label } from '../../components/ui/Input'
import Button from '../../components/ui/Button'
const schema = z.object({
orgName: z.string().min(2, '企业名称至少2个字').max(50, '企业名称最多50个字'),
phone: z.string().regex(/^1[3-9]\d{9}$/, '手机号格式不正确'),
password: z.string().min(8, '密码至少8位').max(32, '密码最多32位'),
confirmPassword: z.string(),
}).refine((data) => data.password === data.confirmPassword, {
message: '两次密码不一致',
path: ['confirmPassword'],
})
type FormData = z.infer<typeof schema>
export default function Register() {
const navigate = useNavigate()
const { setAuth } = useAuthStore()
const [showPassword, setShowPassword] = useState(false)
const [error, setError] = useState('')
const [loading, setLoading] = useState(false)
const { register, handleSubmit, formState: { errors } } = useForm<FormData>({
resolver: zodResolver(schema),
})
const onSubmit = async (data: FormData) => {
setError('')
setLoading(true)
try {
const res = await api.post('/auth/register', data) as any
setAuth(res.data.user, res.data.accessToken, res.data.refreshToken)
navigate('/')
} catch (err: any) {
setError(err.response?.data?.error?.message || '注册失败,请稍后重试')
} finally {
setLoading(false)
}
}
return (
<div className="min-h-screen flex items-center justify-center bg-surface px-4">
<div className="w-full max-w-sm">
<div className="flex items-center justify-center gap-2 mb-8">
<Building2 className="w-8 h-8 text-primary" />
<span className="text-xl font-bold"></span>
</div>
<div className="card">
<h1 className="text-lg font-semibold mb-4"></h1>
{error && (
<div className="mb-4 px-3 py-2 rounded-md bg-red-50 text-red-700 text-sm">{error}</div>
)}
<form onSubmit={handleSubmit(onSubmit)} className="space-y-4">
<div>
<Label></Label>
<Input
placeholder="请输入企业名称"
{...register('orgName')}
/>
{errors.orgName && <p className="text-xs text-red-500 mt-1">{errors.orgName.message}</p>}
</div>
<div>
<Label></Label>
<Input
type="tel"
placeholder="请输入手机号"
{...register('phone')}
maxLength={11}
/>
{errors.phone && <p className="text-xs text-red-500 mt-1">{errors.phone.message}</p>}
</div>
<div>
<Label></Label>
<div className="relative">
<Input
type={showPassword ? 'text' : 'password'}
placeholder="至少8位"
{...register('password')}
/>
<button
type="button"
onClick={() => setShowPassword(!showPassword)}
className="absolute right-2 top-1/2 -translate-y-1/2 text-gray-400"
>
{showPassword ? <EyeOff className="w-4 h-4" /> : <Eye className="w-4 h-4" />}
</button>
</div>
{errors.password && <p className="text-xs text-red-500 mt-1">{errors.password.message}</p>}
</div>
<div>
<Label></Label>
<Input
type={showPassword ? 'text' : 'password'}
placeholder="请再次输入密码"
{...register('confirmPassword')}
/>
{errors.confirmPassword && <p className="text-xs text-red-500 mt-1">{errors.confirmPassword.message}</p>}
</div>
<Button type="submit" className="w-full" disabled={loading}>
{loading ? '注册中...' : '注册'}
</Button>
</form>
<div className="mt-4 text-center text-sm">
<Link to="/login" className="text-primary hover:underline"></Link>
</div>
</div>
</div>
</div>
)
}