refactor: 全量迁移前端 API 调用到统一 api-services 服务层

- 新建 api-services-raw.ts 导出原始 axios 方法供特殊端点使用
- 完成 api-services.ts 全领域覆盖(auth/employee/roster/dashboard/attendance/payroll/socialInsurance/commercialInsurance/termination/policies/evidence/audit/calendar/companyFiles/notifications/settings/ai/platform/portal/survey/search)
- 迁移所有 47+ 页面文件:pages/、pages/roster/、pages/portal/、pages/platform/、pages/auth/、pages/dashboard/、pages/compliance/
- 移除所有直接 import api from '../../lib/api' 引用
- 修复 Termination.tsx / WorkProcess.tsx 中 string|null 类型错误
- 修复 SocialInsurance.tsx 中 api-services-raw delete 导入名
- 修复 PlatformLogin.tsx 变量遮蔽问题
- tsc --noEmit 零错误,vite build 成功
This commit is contained in:
selfrelease
2026-08-01 16:13:19 +08:00
parent fb924dea98
commit 16f22e6622
64 changed files with 1197 additions and 597 deletions
+11 -11
View File
@@ -4,7 +4,7 @@
*/
import { useEffect, useState } from 'react'
import { Search, Plus, Edit2, Trash2, AlertTriangle, Clock, Baby, HeartPulse, Activity, X } from 'lucide-react'
import api from '../lib/api'
import { specialStatusApi, employeeApi } from '../lib/api-services'
import { Input, Select, Label } from '../components/ui/Input'
import Button from '../components/ui/Button'
@@ -140,9 +140,9 @@ export default function SpecialStatus() {
if (search) params.search = search
if (typeFilter) params.type = typeFilter
if (statusFilter) params.status = statusFilter
const res = await api.get('/special-statuses', { params }) as any
setList(res.data.list)
setTotal(res.data.total)
const res = await specialStatusApi.list({ page, pageSize, search: search || undefined, type: typeFilter || undefined, status: statusFilter || undefined } as any) as any
setList(res.list)
setTotal(res.total)
} finally {
setLoading(false)
}
@@ -150,8 +150,8 @@ export default function SpecialStatus() {
const fetchStats = async () => {
try {
const res = await api.get('/special-statuses/stats/overview') as any
setStats(res.data)
const res = await specialStatusApi.stats() as any
setStats(res)
} catch {
// 忽略
}
@@ -159,8 +159,8 @@ export default function SpecialStatus() {
const fetchEmployees = async () => {
try {
const res = await api.get('/employees/all-lite') as any
setEmployees(res.data || [])
const res = await employeeApi.allLite() as any
setEmployees(res || [])
} catch {
// 忽略
}
@@ -212,9 +212,9 @@ export default function SpecialStatus() {
if (data.medicalMonths) data.medicalMonths = parseInt(data.medicalMonths)
if (editing) {
await api.put(`/special-statuses/${editing.id}`, data)
await specialStatusApi.update(editing.id, data)
} else {
await api.post('/special-statuses', data)
await specialStatusApi.create(data)
}
setEditOpen(false)
fetchList()
@@ -227,7 +227,7 @@ export default function SpecialStatus() {
const handleDelete = async () => {
if (!deleteTarget) return
try {
await api.delete(`/special-statuses/${deleteTarget.id}`)
await specialStatusApi.remove(deleteTarget.id)
setDeleteTarget(null)
fetchList()
fetchStats()