feat: 增加DEFAULT_USER_PASSWORD,作为创建用户时的默认密码,添加p-limit库,添加DB_PARALLEL_LIMIT = 32环境变量作为“数据库批次操作默认并发数” 限制只有超级管理员才能创建超级管理员用户 删除用户时可以级联删除SelectionLog 添加zustand全局状态管理 一对多的院系管理功能 ,支持增删改查院系管理员信息、用户可以在header中切换管理的院系

This commit is contained in:
2025-11-18 20:07:42 +08:00
parent 7f3190a223
commit 2a80a44972
31 changed files with 1651 additions and 96 deletions

View File

@@ -0,0 +1,84 @@
'use client'
import React from 'react'
import { trpc } from '@/lib/trpc'
import {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
} from '@/components/ui/alert-dialog'
import { toast } from 'sonner'
interface DeptAdminDeleteDialogProps {
deptAdminId: number | null
isOpen: boolean
onClose: () => void
onDeptAdminDeleted: () => void
}
export function DeptAdminDeleteDialog({
deptAdminId,
isOpen,
onClose,
onDeptAdminDeleted,
}: DeptAdminDeleteDialogProps) {
// 获取院系管理员详情
const { data: deptAdmin } = trpc.deptAdmin.getById.useQuery(
{ id: deptAdminId! },
{ enabled: !!deptAdminId && isOpen }
)
// 删除院系管理员 mutation
const deleteDeptAdminMutation = trpc.deptAdmin.delete.useMutation({
onSuccess: () => {
onClose()
toast.success('院系管理员删除成功')
onDeptAdminDeleted()
},
onError: (error) => {
toast.error(error.message || '删除院系管理员失败')
},
})
const handleConfirm = () => {
if (deptAdminId) {
deleteDeptAdminMutation.mutate({ id: deptAdminId })
}
}
return (
<AlertDialog open={isOpen} onOpenChange={(open) => !open && onClose()}>
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle></AlertDialogTitle>
<AlertDialogDescription>
{deptAdmin ? (
<>
<strong>{deptAdmin.user?.name || deptAdmin.uid}</strong> <strong>{deptAdmin.dept?.name || deptAdmin.deptCode}</strong>
<br />
</>
) : (
'确定要删除该院系管理员吗?此操作无法撤销。'
)}
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel disabled={deleteDeptAdminMutation.isPending}></AlertDialogCancel>
<AlertDialogAction
onClick={handleConfirm}
disabled={deleteDeptAdminMutation.isPending}
className="bg-destructive text-destructive-foreground hover:bg-destructive/90"
>
{deleteDeptAdminMutation.isPending ? '删除中...' : '确认删除'}
</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
)
}