refactor: 消除所有 api-services-raw 残留调用,API 口径完全统一
- dashboardApi 新增 resolveTodo/ignoreTodo/batchResolveTodos/batchIgnoreTodos - notificationsApi 新增 checkContracts/test - settingsApi 新增 confirmRetirementPolicy - socialInsuranceApi 新增 monthlyChanges/housingMonthlyChanges/housingActiveDeclaration - Dashboard.tsx 替换 4 处 apiPatch - Settings.tsx 替换 4 处 apiPost - Notifications.tsx 替换 1 处 apiPost - SocialInsurance.tsx 替换 4 处 apiGet - AIAssistant.tsx 移除未使用的 apiPost 导入 - 所有页面零 api-services-raw 依赖
This commit is contained in:
@@ -219,6 +219,18 @@ export const dashboardApi = {
|
|||||||
/** 年度价值报告保存 */
|
/** 年度价值报告保存 */
|
||||||
annualValueSave: (year: number) =>
|
annualValueSave: (year: number) =>
|
||||||
post('/dashboard/annual-value/save', { year }).then(unwrap<any>()),
|
post('/dashboard/annual-value/save', { year }).then(unwrap<any>()),
|
||||||
|
/** 待办标记已处理 */
|
||||||
|
resolveTodo: (id: string) =>
|
||||||
|
patch(`/dashboard/todos/${id}/resolve`),
|
||||||
|
/** 待办忽略 */
|
||||||
|
ignoreTodo: (id: string) =>
|
||||||
|
patch(`/dashboard/todos/${id}/ignore`),
|
||||||
|
/** 批量标记已处理 */
|
||||||
|
batchResolveTodos: (ids: string[]) =>
|
||||||
|
patch('/dashboard/todos/batch-resolve', { ids }),
|
||||||
|
/** 批量忽略 */
|
||||||
|
batchIgnoreTodos: (ids: string[]) =>
|
||||||
|
patch('/dashboard/todos/batch-ignore', { ids }),
|
||||||
}
|
}
|
||||||
|
|
||||||
// ========== 考勤相关 ==========
|
// ========== 考勤相关 ==========
|
||||||
@@ -511,6 +523,15 @@ export const socialInsuranceApi = {
|
|||||||
/** 社保/公积金记录更正 */
|
/** 社保/公积金记录更正 */
|
||||||
correctRecord: (type: 'social' | 'housing', id: string, data: any) =>
|
correctRecord: (type: 'social' | 'housing', id: string, data: any) =>
|
||||||
put(`/social/records/${type}/${id}/correct`, data).then(unwrap<any>()),
|
put(`/social/records/${type}/${id}/correct`, data).then(unwrap<any>()),
|
||||||
|
/** 社保月度变动 */
|
||||||
|
monthlyChanges: (month: string) =>
|
||||||
|
get('/social/monthly-changes', { params: { month } }).then(unwrap<any>()),
|
||||||
|
/** 公积金月度变动 */
|
||||||
|
housingMonthlyChanges: (month: string) =>
|
||||||
|
get('/social/housing/monthly-changes', { params: { month } }).then(unwrap<any>()),
|
||||||
|
/** 公积金活跃申报 */
|
||||||
|
housingActiveDeclaration: (month: string) =>
|
||||||
|
get('/social/housing/active-declaration', { params: { month } }).then(unwrap<any>()),
|
||||||
}
|
}
|
||||||
|
|
||||||
// ========== 商业保险 ==========
|
// ========== 商业保险 ==========
|
||||||
@@ -665,6 +686,12 @@ export const notificationsApi = {
|
|||||||
/** 更新通知设置 */
|
/** 更新通知设置 */
|
||||||
updateSettings: (data: any) =>
|
updateSettings: (data: any) =>
|
||||||
put('/notifications/settings', data),
|
put('/notifications/settings', data),
|
||||||
|
/** 检查合同到期 */
|
||||||
|
checkContracts: () =>
|
||||||
|
post('/notifications/check-contracts'),
|
||||||
|
/** 测试通知发送 */
|
||||||
|
test: (channel: 'wechat' | 'email') =>
|
||||||
|
post('/notifications/test', { channel }),
|
||||||
}
|
}
|
||||||
|
|
||||||
// ========== 系统设置 ==========
|
// ========== 系统设置 ==========
|
||||||
@@ -697,6 +724,9 @@ export const settingsApi = {
|
|||||||
/** 退休政策 */
|
/** 退休政策 */
|
||||||
retirementPolicy: () =>
|
retirementPolicy: () =>
|
||||||
get('/settings/retirement-policy').then(unwrap<any>()),
|
get('/settings/retirement-policy').then(unwrap<any>()),
|
||||||
|
/** 确认退休政策生效 */
|
||||||
|
confirmRetirementPolicy: (id: string) =>
|
||||||
|
post(`/settings/retirement-policy/${id}/confirm`),
|
||||||
}
|
}
|
||||||
|
|
||||||
// ========== 模板相关 ==========
|
// ========== 模板相关 ==========
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import rehypeRaw from 'rehype-raw'
|
|||||||
import { Document, Packer, Paragraph, HeadingLevel, TextRun, Table, TableRow, TableCell, WidthType, BorderStyle, AlignmentType } from 'docx'
|
import { Document, Packer, Paragraph, HeadingLevel, TextRun, Table, TableRow, TableCell, WidthType, BorderStyle, AlignmentType } from 'docx'
|
||||||
import { saveAs } from 'file-saver'
|
import { saveAs } from 'file-saver'
|
||||||
import { aiApi, rosterApi, employeeApi } from '../lib/api-services'
|
import { aiApi, rosterApi, employeeApi } from '../lib/api-services'
|
||||||
import { post as apiPost } from '../lib/api-services-raw'
|
|
||||||
import { useAuthStore } from '../store/authStore'
|
import { useAuthStore } from '../store/authStore'
|
||||||
import Card from '../components/ui/Card'
|
import Card from '../components/ui/Card'
|
||||||
import Button from '../components/ui/Button'
|
import Button from '../components/ui/Button'
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import { Link } from 'react-router-dom'
|
|||||||
import { PieChart, Pie, Cell, ResponsiveContainer, Tooltip, RadialBarChart, RadialBar, PolarAngleAxis } from 'recharts'
|
import { PieChart, Pie, Cell, ResponsiveContainer, Tooltip, RadialBarChart, RadialBar, PolarAngleAxis } from 'recharts'
|
||||||
import { Users, AlertTriangle, CheckSquare, DollarSign, ArrowRight, RefreshCw, FileText, Calendar, TrendingUp, Briefcase, Calculator, Wallet, Building2, Receipt, Check, X, Clock, LayoutDashboard, ListTodo, ShieldAlert, UserPlus, AlertCircle, Download, ChevronRight, TrendingDown, ShieldCheck, Lightbulb, BookOpen, Sparkles, Repeat, XCircle, Loader2 } from 'lucide-react'
|
import { Users, AlertTriangle, CheckSquare, DollarSign, ArrowRight, RefreshCw, FileText, Calendar, TrendingUp, Briefcase, Calculator, Wallet, Building2, Receipt, Check, X, Clock, LayoutDashboard, ListTodo, ShieldAlert, UserPlus, AlertCircle, Download, ChevronRight, TrendingDown, ShieldCheck, Lightbulb, BookOpen, Sparkles, Repeat, XCircle, Loader2 } from 'lucide-react'
|
||||||
import { dashboardApi, rosterApi, workProcessApi } from '../lib/api-services'
|
import { dashboardApi, rosterApi, workProcessApi } from '../lib/api-services'
|
||||||
import { post as apiPost, patch as apiPatch } from '../lib/api-services-raw'
|
|
||||||
import { useAuthStore } from '../store/authStore'
|
import { useAuthStore } from '../store/authStore'
|
||||||
import Card from '../components/ui/Card'
|
import Card from '../components/ui/Card'
|
||||||
import Button from '../components/ui/Button'
|
import Button from '../components/ui/Button'
|
||||||
@@ -76,17 +75,17 @@ export default function Dashboard() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const resolveMutation = useMutation({
|
const resolveMutation = useMutation({
|
||||||
mutationFn: (id: string) => apiPatch(`/dashboard/todos/${id}/resolve`),
|
mutationFn: (id: string) => dashboardApi.resolveTodo(id),
|
||||||
onSuccess: () => queryClient.invalidateQueries({ queryKey: ['dashboard'] }),
|
onSuccess: () => queryClient.invalidateQueries({ queryKey: ['dashboard'] }),
|
||||||
})
|
})
|
||||||
|
|
||||||
const ignoreMutation = useMutation({
|
const ignoreMutation = useMutation({
|
||||||
mutationFn: (id: string) => apiPatch(`/dashboard/todos/${id}/ignore`),
|
mutationFn: (id: string) => dashboardApi.ignoreTodo(id),
|
||||||
onSuccess: () => queryClient.invalidateQueries({ queryKey: ['dashboard'] }),
|
onSuccess: () => queryClient.invalidateQueries({ queryKey: ['dashboard'] }),
|
||||||
})
|
})
|
||||||
|
|
||||||
const batchResolveMutation = useMutation({
|
const batchResolveMutation = useMutation({
|
||||||
mutationFn: (ids: string[]) => apiPatch('/dashboard/todos/batch-resolve', { ids }),
|
mutationFn: (ids: string[]) => dashboardApi.batchResolveTodos(ids),
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
queryClient.invalidateQueries({ queryKey: ['dashboard'] })
|
queryClient.invalidateQueries({ queryKey: ['dashboard'] })
|
||||||
setSelectedIds(new Set())
|
setSelectedIds(new Set())
|
||||||
@@ -94,7 +93,7 @@ export default function Dashboard() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const batchIgnoreMutation = useMutation({
|
const batchIgnoreMutation = useMutation({
|
||||||
mutationFn: (ids: string[]) => apiPatch('/dashboard/todos/batch-ignore', { ids }),
|
mutationFn: (ids: string[]) => dashboardApi.batchIgnoreTodos(ids),
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
queryClient.invalidateQueries({ queryKey: ['dashboard'] })
|
queryClient.invalidateQueries({ queryKey: ['dashboard'] })
|
||||||
setSelectedIds(new Set())
|
setSelectedIds(new Set())
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'
|
|||||||
import { toast } from 'sonner'
|
import { toast } from 'sonner'
|
||||||
import { Bell, CheckCircle, AlertCircle, Send, Settings as SettingsIcon, X } from 'lucide-react'
|
import { Bell, CheckCircle, AlertCircle, Send, Settings as SettingsIcon, X } from 'lucide-react'
|
||||||
import { notificationsApi } from '../lib/api-services'
|
import { notificationsApi } from '../lib/api-services'
|
||||||
import { post as apiPost } from '../lib/api-services-raw'
|
|
||||||
import Card from '../components/ui/Card'
|
import Card from '../components/ui/Card'
|
||||||
import Button from '../components/ui/Button'
|
import Button from '../components/ui/Button'
|
||||||
import EmptyState from '../components/ui/EmptyState'
|
import EmptyState from '../components/ui/EmptyState'
|
||||||
@@ -52,7 +51,7 @@ export default function Notifications() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const checkContractsMutation = useMutation({
|
const checkContractsMutation = useMutation({
|
||||||
mutationFn: () => apiPost('/notifications/check-contracts'),
|
mutationFn: () => notificationsApi.checkContracts(),
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
toast.success('合同到期检查已触发')
|
toast.success('合同到期检查已触发')
|
||||||
queryClient.invalidateQueries({ queryKey: ['notification-logs'] })
|
queryClient.invalidateQueries({ queryKey: ['notification-logs'] })
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import { toast } from 'sonner'
|
|||||||
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'
|
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'
|
||||||
import { Building2, Users, CreditCard, Plus, Bell, Download, Upload, FileSpreadsheet, Clock, CheckCircle, AlertCircle, ClipboardList } from 'lucide-react'
|
import { Building2, Users, CreditCard, Plus, Bell, Download, Upload, FileSpreadsheet, Clock, CheckCircle, AlertCircle, ClipboardList } from 'lucide-react'
|
||||||
import { settingsApi, notificationsApi } from '../lib/api-services'
|
import { settingsApi, notificationsApi } from '../lib/api-services'
|
||||||
import { post as apiPost, patch as apiPatch } from '../lib/api-services-raw'
|
|
||||||
import { useAuthStore } from '../store/authStore'
|
import { useAuthStore } from '../store/authStore'
|
||||||
import Card from '../components/ui/Card'
|
import Card from '../components/ui/Card'
|
||||||
import Button from '../components/ui/Button'
|
import Button from '../components/ui/Button'
|
||||||
@@ -158,7 +157,7 @@ function RetirementSection({ enabled, onToggle }: { enabled: boolean; onToggle:
|
|||||||
})
|
})
|
||||||
|
|
||||||
const confirmMutation = useMutation({
|
const confirmMutation = useMutation({
|
||||||
mutationFn: (id: string) => apiPost(`/settings/retirement-policy/${id}/confirm`),
|
mutationFn: (id: string) => settingsApi.confirmRetirementPolicy(id),
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
toast.success('退休政策已确认生效')
|
toast.success('退休政策已确认生效')
|
||||||
setConfirming(false)
|
setConfirming(false)
|
||||||
@@ -762,7 +761,7 @@ function NotificationSettings() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const checkMutation = useMutation({
|
const checkMutation = useMutation({
|
||||||
mutationFn: () => apiPost('/notifications/check-contracts') as any,
|
mutationFn: () => notificationsApi.checkContracts() as any,
|
||||||
onSuccess: (res: any) => {
|
onSuccess: (res: any) => {
|
||||||
setCheckResult(`检查完成:发现 ${res.data.checked} 个即将到期的合同,已发送 ${res.data.notified} 条通知`)
|
setCheckResult(`检查完成:发现 ${res.data.checked} 个即将到期的合同,已发送 ${res.data.notified} 条通知`)
|
||||||
queryClient.invalidateQueries({ queryKey: ['notification-logs'] })
|
queryClient.invalidateQueries({ queryKey: ['notification-logs'] })
|
||||||
@@ -770,14 +769,14 @@ function NotificationSettings() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const testWechatMutation = useMutation({
|
const testWechatMutation = useMutation({
|
||||||
mutationFn: () => apiPost('/notifications/test', { channel: 'wechat' }) as any,
|
mutationFn: () => notificationsApi.test('wechat') as any,
|
||||||
onSuccess: (res: any) => {
|
onSuccess: (res: any) => {
|
||||||
toast.success(res.success ? res.data.message : (res.error?.message || '测试失败'))
|
toast.success(res.success ? res.data.message : (res.error?.message || '测试失败'))
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const testEmailMutation = useMutation({
|
const testEmailMutation = useMutation({
|
||||||
mutationFn: () => apiPost('/notifications/test', { channel: 'email' }) as any,
|
mutationFn: () => notificationsApi.test('email') as any,
|
||||||
onSuccess: (res: any) => {
|
onSuccess: (res: any) => {
|
||||||
toast.success(res.success ? res.data.message : (res.error?.message || '测试失败'))
|
toast.success(res.success ? res.data.message : (res.error?.message || '测试失败'))
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import { useConfirm } from '../hooks/useConfirm'
|
|||||||
import { Calculator, Info, Check, Settings as SettingsIcon, Plus, History, Download, AlertCircle, Clock, MapPin, Sparkles, Upload, X, Shield } from 'lucide-react'
|
import { Calculator, Info, Check, Settings as SettingsIcon, Plus, History, Download, AlertCircle, Clock, MapPin, Sparkles, Upload, X, Shield } from 'lucide-react'
|
||||||
import { InlineAlert } from '../components/ui/InlineAlert'
|
import { InlineAlert } from '../components/ui/InlineAlert'
|
||||||
import { socialInsuranceApi, commercialInsuranceApi } from '../lib/api-services'
|
import { socialInsuranceApi, commercialInsuranceApi } from '../lib/api-services'
|
||||||
import { get as apiGet, post as apiPost, put as apiPut, del as apiDel } from '../lib/api-services-raw'
|
|
||||||
import { useAuthStore } from '../store/authStore'
|
import { useAuthStore } from '../store/authStore'
|
||||||
import Card from '../components/ui/Card'
|
import Card from '../components/ui/Card'
|
||||||
import Button from '../components/ui/Button'
|
import Button from '../components/ui/Button'
|
||||||
@@ -119,16 +118,16 @@ export default function SocialInsurance() {
|
|||||||
const { mutateAsync: fetchMonthlyChanges, isPending: monthlyLoading, data: monthlyChanges } = useMutation<any>({
|
const { mutateAsync: fetchMonthlyChanges, isPending: monthlyLoading, data: monthlyChanges } = useMutation<any>({
|
||||||
mutationFn: async () => {
|
mutationFn: async () => {
|
||||||
const [socialRes, housingRes, socialActiveRes, housingActiveRes] = await Promise.all([
|
const [socialRes, housingRes, socialActiveRes, housingActiveRes] = await Promise.all([
|
||||||
apiGet('/social/monthly-changes', { params: { month: monthlyMonth } }) as any,
|
socialInsuranceApi.monthlyChanges(monthlyMonth) as any,
|
||||||
apiGet('/social/housing/monthly-changes', { params: { month: monthlyMonth } }) as any,
|
socialInsuranceApi.housingMonthlyChanges(monthlyMonth) as any,
|
||||||
apiGet('/social/active-declaration', { params: { month: monthlyMonth } }) as any,
|
socialInsuranceApi.activeDeclaration(monthlyMonth) as any,
|
||||||
apiGet('/social/housing/active-declaration', { params: { month: monthlyMonth } }) as any,
|
socialInsuranceApi.housingActiveDeclaration(monthlyMonth) as any,
|
||||||
])
|
])
|
||||||
return {
|
return {
|
||||||
social: socialRes.data,
|
social: socialRes,
|
||||||
housing: housingRes.data,
|
housing: housingRes,
|
||||||
socialActive: socialActiveRes.data,
|
socialActive: socialActiveRes,
|
||||||
housingActive: housingActiveRes.data,
|
housingActive: housingActiveRes,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user