diff --git a/app/departments/page.tsx b/app/departments/page.tsx index ed38aff..2f5ee38 100644 --- a/app/departments/page.tsx +++ b/app/departments/page.tsx @@ -13,9 +13,10 @@ import { departmentApi, type Department, type PaginatedResponse, type Pagination import { useAppContext } from "@/lib/app-context" import { Pagination, usePagination } from "@/components/pagination" import { LoadingInline } from "@/components/loading" +import { AxiosError } from "axios" export default function DepartmentsPage() { - const { Confirm } = useAppContext() + const { Confirm, Alert } = useAppContext() const [departments, setDepartments] = useState([]) const [loading, setLoading] = useState(true) const [dialogOpen, setDialogOpen] = useState(false) @@ -94,8 +95,13 @@ export default function DepartmentsPage() { try { await departmentApi.delete(id) fetchDepartments() - } catch (error) { + } catch (error: unknown) { console.error("删除部门失败:", error) + if (error instanceof AxiosError) { + Alert("删除失败", error.response?.data?.error || "删除部门失败,请重试") + } else { + Alert("删除失败", "删除部门失败,请重试") + } } } } diff --git a/app/employees/page.tsx b/app/employees/page.tsx index e22bbaa..85cd6d7 100644 --- a/app/employees/page.tsx +++ b/app/employees/page.tsx @@ -14,9 +14,10 @@ import { employeeApi, departmentApi, type Employee, type Department, type Pagina import { useAppContext } from "@/lib/app-context" import { Pagination, usePagination } from "@/components/pagination" import { LoadingInline } from "@/components/loading" +import { AxiosError } from "axios" export default function EmployeesPage() { - const { Confirm } = useAppContext() + const { Confirm, Alert } = useAppContext() const [employees, setEmployees] = useState([]) const [departments, setDepartments] = useState([]) const [managers, setManagers] = useState([]) @@ -147,8 +148,13 @@ export default function EmployeesPage() { try { await employeeApi.delete(id) fetchEmployees() - } catch (error) { + } catch (error: unknown) { console.error("删除员工失败:", error) + if (error instanceof AxiosError) { + Alert("删除失败", error.response?.data?.error || "删除员工失败,请重试") + } else { + Alert("删除失败", "删除员工失败,请重试") + } } } } diff --git a/app/evaluations/page.tsx b/app/evaluations/page.tsx index 9a82e2e..bb1004d 100644 --- a/app/evaluations/page.tsx +++ b/app/evaluations/page.tsx @@ -54,6 +54,7 @@ import { Pagination, usePagination } from "@/components/pagination" import { LoadingInline } from "@/components/loading" import { toast } from "sonner" import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip" +import { AxiosError } from "axios" export default function EvaluationsPage() { const { Alert, Confirm, getStatusBadge, isTouch } = useAppContext() @@ -78,6 +79,12 @@ export default function EvaluationsPage() { const [statusFilter, setStatusFilter] = useState("all") const [employeeFilter, setEmployeeFilter] = useState("all") + // 周期筛选相关状态 + const [periodFilter, setPeriodFilter] = useState("") + const [yearFilter, setYearFilter] = useState("") + const [monthFilter, setMonthFilter] = useState("") + const [quarterFilter, setQuarterFilter] = useState("") + // 添加绩效视图Tab相关状态 const [viewTab, setViewTab] = useState<"my" | "team">("my") // 默认显示我的绩效 @@ -142,6 +149,20 @@ export default function EvaluationsPage() { params.status = statusFilter } + // 周期筛选参数 + if (periodFilter) { + params.period = periodFilter + } + if (yearFilter) { + params.year = yearFilter + } + if (monthFilter) { + params.month = monthFilter + } + if (quarterFilter) { + params.quarter = quarterFilter + } + // 根据Tab和角色设置员工筛选 if (viewTab === "my") { // 我的绩效:只显示自己的 @@ -177,7 +198,7 @@ export default function EvaluationsPage() { } finally { setLoading(false) } - }, [currentUser, currentPage, pageSize, statusFilter, employeeFilter, viewTab, isHR, isManager, refreshUnreadEvaluations]) + }, [currentUser, currentPage, pageSize, statusFilter, employeeFilter, periodFilter, yearFilter, monthFilter, quarterFilter, viewTab, isHR, isManager, refreshUnreadEvaluations]) // 获取模板列表 const fetchTemplates = async () => { @@ -401,6 +422,10 @@ export default function EvaluationsPage() { setViewTab(tab) setStatusFilter("all") setEmployeeFilter("all") + setPeriodFilter("") + setYearFilter("") + setMonthFilter("") + setQuarterFilter("") resetPagination() } @@ -451,9 +476,13 @@ export default function EvaluationsPage() { // 成功提示 Alert("创建成功", `已为 ${formData.employee_ids.length} 个员工创建考核`) - } catch (error) { + } catch (error: unknown) { console.error("创建评估失败:", error) - Alert("创建失败", "创建考核失败,请重试") + if (error instanceof AxiosError) { + Alert("创建失败", error.response?.data?.error || "创建考核失败,请重试") + } else { + Alert("创建失败", "创建考核失败,请重试") + } } } @@ -1212,6 +1241,7 @@ export default function EvaluationsPage() { {loading && }
+ {/* 状态筛选 */} + + {/* 员工筛选 */} {viewTab === "team" && ( )} + + {/* 周期筛选 */} + + + {/* 年份筛选 */} + + + {/* 月份筛选 - 只在月度周期时显示 */} + {periodFilter === "monthly" && ( + + )} + + {/* 季度筛选 - 只在季度周期时显示 */} + {periodFilter === "quarterly" && ( + + )} + + {/* 重置筛选 */}