1
This commit is contained in:
parent
b807f856a5
commit
c86f0decf6
@ -73,6 +73,7 @@ const ProjectGroupList: React.FC = () => {
|
|||||||
const [currentProject, setCurrentProject] = useState<ProjectGroup>();
|
const [currentProject, setCurrentProject] = useState<ProjectGroup>();
|
||||||
const [list, setList] = useState<ProjectGroup[]>([]);
|
const [list, setList] = useState<ProjectGroup[]>([]);
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
|
const [deleteDialogOpen, setDeleteDialogOpen] = useState<Record<string | number, boolean>>({});
|
||||||
const {toast} = useToast();
|
const {toast} = useToast();
|
||||||
|
|
||||||
const form = useForm<SearchFormValues>({
|
const form = useForm<SearchFormValues>({
|
||||||
@ -116,6 +117,7 @@ const ProjectGroupList: React.FC = () => {
|
|||||||
duration: 3000,
|
duration: 3000,
|
||||||
});
|
});
|
||||||
loadData(form.getValues());
|
loadData(form.getValues());
|
||||||
|
setDeleteDialogOpen(prev => ({...prev, [id]: false}));
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
toast({
|
toast({
|
||||||
variant: "destructive",
|
variant: "destructive",
|
||||||
@ -126,6 +128,14 @@ const ProjectGroupList: React.FC = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const openDeleteDialog = (id: number) => {
|
||||||
|
setDeleteDialogOpen(prev => ({...prev, [id]: true}));
|
||||||
|
};
|
||||||
|
|
||||||
|
const closeDeleteDialog = (id: number) => {
|
||||||
|
setDeleteDialogOpen(prev => ({...prev, [id]: false}));
|
||||||
|
};
|
||||||
|
|
||||||
const handleAdd = () => {
|
const handleAdd = () => {
|
||||||
setCurrentProject(undefined);
|
setCurrentProject(undefined);
|
||||||
setModalVisible(true);
|
setModalVisible(true);
|
||||||
@ -232,12 +242,18 @@ const ProjectGroupList: React.FC = () => {
|
|||||||
<EditOutlined className="mr-1"/>
|
<EditOutlined className="mr-1"/>
|
||||||
编辑
|
编辑
|
||||||
</Button>
|
</Button>
|
||||||
<AlertDialog>
|
<AlertDialog
|
||||||
|
open={deleteDialogOpen[row.original.id] || false}
|
||||||
|
onOpenChange={(open) => {
|
||||||
|
if (!open) closeDeleteDialog(row.original.id);
|
||||||
|
}}
|
||||||
|
>
|
||||||
<AlertDialogTrigger asChild>
|
<AlertDialogTrigger asChild>
|
||||||
<Button
|
<Button
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
size="sm"
|
size="sm"
|
||||||
className="text-destructive"
|
className="text-destructive"
|
||||||
|
onClick={() => openDeleteDialog(row.original.id)}
|
||||||
>
|
>
|
||||||
<DeleteOutlined className="mr-1"/>
|
<DeleteOutlined className="mr-1"/>
|
||||||
删除
|
删除
|
||||||
@ -251,7 +267,9 @@ const ProjectGroupList: React.FC = () => {
|
|||||||
</AlertDialogDescription>
|
</AlertDialogDescription>
|
||||||
</AlertDialogHeader>
|
</AlertDialogHeader>
|
||||||
<AlertDialogFooter>
|
<AlertDialogFooter>
|
||||||
<AlertDialogCancel>取消</AlertDialogCancel>
|
<AlertDialogCancel onClick={() => closeDeleteDialog(row.original.id)}>
|
||||||
|
取消
|
||||||
|
</AlertDialogCancel>
|
||||||
<AlertDialogAction
|
<AlertDialogAction
|
||||||
onClick={() => handleDelete(row.original.id)}
|
onClick={() => handleDelete(row.original.id)}
|
||||||
>
|
>
|
||||||
@ -394,12 +412,18 @@ const ProjectGroupList: React.FC = () => {
|
|||||||
<EditOutlined className="mr-1"/>
|
<EditOutlined className="mr-1"/>
|
||||||
编辑
|
编辑
|
||||||
</Button>
|
</Button>
|
||||||
<AlertDialog>
|
<AlertDialog
|
||||||
|
open={deleteDialogOpen[item.id] || false}
|
||||||
|
onOpenChange={(open) => {
|
||||||
|
if (!open) closeDeleteDialog(item.id);
|
||||||
|
}}
|
||||||
|
>
|
||||||
<AlertDialogTrigger asChild>
|
<AlertDialogTrigger asChild>
|
||||||
<Button
|
<Button
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
size="sm"
|
size="sm"
|
||||||
className="text-destructive"
|
className="text-destructive"
|
||||||
|
onClick={() => openDeleteDialog(item.id)}
|
||||||
>
|
>
|
||||||
<DeleteOutlined className="mr-1"/>
|
<DeleteOutlined className="mr-1"/>
|
||||||
删除
|
删除
|
||||||
@ -413,7 +437,9 @@ const ProjectGroupList: React.FC = () => {
|
|||||||
</AlertDialogDescription>
|
</AlertDialogDescription>
|
||||||
</AlertDialogHeader>
|
</AlertDialogHeader>
|
||||||
<AlertDialogFooter>
|
<AlertDialogFooter>
|
||||||
<AlertDialogCancel>取消</AlertDialogCancel>
|
<AlertDialogCancel onClick={() => closeDeleteDialog(item.id)}>
|
||||||
|
取消
|
||||||
|
</AlertDialogCancel>
|
||||||
<AlertDialogAction
|
<AlertDialogAction
|
||||||
onClick={() => handleDelete(item.id)}
|
onClick={() => handleDelete(item.id)}
|
||||||
>
|
>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user