diff --git a/frontend/src/pages/Workflow/Definition/components/CategoryManageDialog.tsx b/frontend/src/pages/Workflow/Definition/components/CategoryManageDialog.tsx index 4631b8af..445f4874 100644 --- a/frontend/src/pages/Workflow/Definition/components/CategoryManageDialog.tsx +++ b/frontend/src/pages/Workflow/Definition/components/CategoryManageDialog.tsx @@ -5,6 +5,16 @@ import { DialogHeader, DialogTitle, } from "@/components/ui/dialog"; +import { + AlertDialog, + AlertDialogAction, + AlertDialogCancel, + AlertDialogContent, + AlertDialogDescription, + AlertDialogFooter, + AlertDialogHeader, + AlertDialogTitle, +} from "@/components/ui/alert-dialog"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { @@ -74,6 +84,8 @@ const CategoryManageDialog: React.FC = ({ const [editMode, setEditMode] = useState(false); const [editRecord, setEditRecord] = useState(null); const [iconSelectOpen, setIconSelectOpen] = useState(false); + const [deleteDialogOpen, setDeleteDialogOpen] = useState(false); + const [deleteRecord, setDeleteRecord] = useState(null); const form = useForm({ defaultValues: { @@ -155,16 +167,26 @@ const CategoryManageDialog: React.FC = ({ setEditMode(true); }; - // 删除 - const handleDelete = async (record: WorkflowCategoryResponse) => { + // 打开删除确认对话框 + const handleDeleteClick = (record: WorkflowCategoryResponse) => { + setDeleteRecord(record); + setDeleteDialogOpen(true); + }; + + // 确认删除 + const confirmDelete = async () => { + if (!deleteRecord) return; + try { - await deleteWorkflowCategory(record.id); + await deleteWorkflowCategory(deleteRecord.id); toast({ title: "删除成功", - description: `分类 "${record.name}" 已删除`, + description: `分类 "${deleteRecord.name}" 已删除`, }); loadCategories(); onSuccess?.(); + setDeleteDialogOpen(false); + setDeleteRecord(null); } catch (error) { console.error('删除失败:', error); toast({ @@ -234,6 +256,7 @@ const CategoryManageDialog: React.FC = ({ }; return ( + <> @@ -341,7 +364,7 @@ const CategoryManageDialog: React.FC = ({ variant="ghost" size="sm" className="h-8 w-8 p-0" - onClick={() => handleDelete(record)} + onClick={() => handleDeleteClick(record)} > @@ -533,6 +556,56 @@ const CategoryManageDialog: React.FC = ({ )} + + {/* 删除确认对话框 */} + + + + 确认删除分类 + +
+

您确定要删除以下分类吗?此操作无法撤销。

+ {deleteRecord && ( +
+
+ 分类名称: + {deleteRecord.name} +
+
+ 分类代码: + + {deleteRecord.code} + +
+ {deleteRecord.icon && ( +
+ 图标: + +
+ )} + {deleteRecord.description && ( +
+ 描述: + {deleteRecord.description} +
+ )} +
+ )} +
+
+
+ + 取消 + + 确认删除 + + +
+
+ ); };