删除选中
import { Button, Popconfirm, message } from "antd";
import axios from "axios";
import R from "../model/R";
export default function A6DeleteSelected({
ids,
onSuccess,
}: {
ids: React.Key[];
onSuccess?: () => void;
}) {
const disable = ids.length === 0;
async function onConfirm() {
const resp = await axios.delete<R<string>>(
"http://localhost:8080/api/students",
{ data: ids }
);
message.success(resp.data.data);
onSuccess && onSuccess();
}
return (
<Popconfirm title="是否删除选中的学生" onConfirm={onConfirm}>
<Button danger type="primary" size="small" disabled={disable}>
删除选中
</Button>
</Popconfirm>
);
}