feat: 删除任务

This commit is contained in:
李如威 2025-09-22 17:57:53 +08:00
parent b2af30448d
commit fcb84098a4
3 changed files with 20 additions and 5 deletions

View File

@ -386,7 +386,7 @@ def create_app():
return StreamingResponse(_event(), media_type="text/event-stream")
@app.delete("/api/flows/status", tags=["Flow"], description="任务删除", response_model=BaseResponse)
@app.delete("/api/flows", tags=["Flow"], description="任务删除", response_model=BaseResponse)
async def del_client(work_uuid: str, user: DB.User = Depends(get_current_user)):
work = await DB.Work.filter(uuid=work_uuid).first()
if not work:

View File

@ -24,6 +24,11 @@ export const flowCreate = async (data = {}) => {
return request("/api/flows", "POST", data)
}
export const flowDel = async (id) => {
return request("/api/flows?work_uuid=" + id, "DELETE")
}

View File

@ -1,15 +1,16 @@
import { ProTable } from "@ant-design/pro-components"
import { Button, Card, Popconfirm, Space, Typography } from "antd"
import { App, Button, Card, message, Popconfirm, Space, Typography } from "antd"
import { useAuth } from "../../context/AuthContext";
import { LoadingOutlined, PlusOutlined } from "@ant-design/icons";
import { useEffect, useRef, useState } from "react";
import { tableList, flowRun, flowStop } from "../../api/flow";
import { tableList, flowRun, flowStop, flowDel } from "../../api/flow";
import { useNavigate } from "react-router-dom";
import './Detail.css';
export default () => {
const { user, logout } = useAuth();
const [status, setStatus] = useState({});
const { message } = App.useApp();
const eventSourceRef = useRef(null);
const navigate = useNavigate();
const needReload = useRef(false);
@ -43,6 +44,11 @@ export default () => {
}
return true;
}
const onDelete = async (record) => {
const res = await flowDel(record.uuid);
message.success("删除成功");
actionRef?.current?.reload();
}
const columns = [
{
dataIndex: 'index',
@ -112,7 +118,11 @@ export default () => {
user?.level === 0 && <Button key='2' type="link" style={{ padding: '0 0', border: 'none' }} onClick={() => {
navigate("/flow/detail/" + record.uuid);
}}>编辑</Button>,
user?.level === 0 && <Button key='3' type="link" danger style={{ padding: '0 0', border: 'none' }}>删除</Button>,
user?.level === 0 &&
<Popconfirm key='3' title="是否删除工作?" okText="删除" cancelText="取消" onConfirm={async () => await onDelete(record)}>
<Button key='3' type="link" danger style={{ padding: '0 0', border: 'none' }}>删除</Button>
</Popconfirm>
,
]
}
];
@ -150,7 +160,7 @@ export default () => {
needReload.current = false;
actionRef?.current?.reload();
}
setStatus({ ...data})
setStatus({ ...data })
} catch (err) {
console.error("Failed to parse SSE data:", err);
}