diff --git a/backend/app/main.py b/backend/app/main.py index 4f034a5..748bdc3 100644 --- a/backend/app/main.py +++ b/backend/app/main.py @@ -330,7 +330,7 @@ def create_app(): await work.save() work_content.work_id = work.id await work_content.save() - return BaseResponse() + return BaseResponse(data=work.uuid) @app.put("/api/flows", tags=["Flow"], description="任务修改", response_model=BaseResponse) async def update_flow(work_uuid: str, body: WorkRequest, user: DB.User = Depends(get_current_user)): diff --git a/frontend/src/api/flow.js b/frontend/src/api/flow.js index 77883e0..4c62ff6 100644 --- a/frontend/src/api/flow.js +++ b/frontend/src/api/flow.js @@ -20,6 +20,9 @@ export const flowUpdate = async (id, data = {}) => { return request("/api/flows?work_uuid=" + id, "PUT", data) } +export const flowCreate = async (data = {}) => { + return request("/api/flows", "POST", data) +} diff --git a/frontend/src/pages/Client/index.jsx b/frontend/src/pages/Client/index.jsx index 3a33f5a..8526c55 100644 --- a/frontend/src/pages/Client/index.jsx +++ b/frontend/src/pages/Client/index.jsx @@ -54,13 +54,13 @@ const ClientPage = () => { ] - return actionRef?.current?.reload()} />}> + return actionRef?.current?.reload()} />} actionRef={actionRef} rowKey='id' search={false} scroll={{ x: 'max-content' }} - options={false} columns={columns} request={onRequest} /> diff --git a/frontend/src/pages/Flow/Detail.jsx b/frontend/src/pages/Flow/Detail.jsx index 79e9aa9..e7c090c 100644 --- a/frontend/src/pages/Flow/Detail.jsx +++ b/frontend/src/pages/Flow/Detail.jsx @@ -14,7 +14,7 @@ import { ReactFlowProvider, } from '@xyflow/react'; import '@xyflow/react/dist/style.css'; -import { flowDetail, flowUpdate } from "../../api/flow"; +import { flowCreate, flowDetail, flowUpdate } from "../../api/flow"; import EditNode from "./components/EditNode"; import CustomNode from "./components/CustomNode"; import { ProForm, ProFormText, ProFormTextArea } from "@ant-design/pro-components"; @@ -55,6 +55,7 @@ const nodeTypes = { const FlowDetail = () => { const { modal, message } = App.useApp(); const { work_uuid } = useParams() + const isCreate = work_uuid === 'create'; const navigate = useNavigate(); const formRef = useRef(null); const [nodes, setNodes, onNodesChange] = useNodesState(initialNodes); @@ -100,6 +101,7 @@ const FlowDetail = () => { } const loadDetail = async () => { try { + if (isCreate) return; const res = await flowDetail(work_uuid); const { data: { content: { content: infoList } } } = res; if (res?.success) { @@ -138,8 +140,8 @@ const FlowDetail = () => { try { await formRef.current.validateFields(); modal.confirm({ - title: "保存", - content: "确认保存修改内容?", + title: isCreate ? "创建" : "保存", + content: isCreate ? "创建工作?" : "确认保存修改内容?", onOk: async () => { const content = []; nodes.forEach(e => { @@ -152,13 +154,18 @@ const FlowDetail = () => { uuid: e.id }) }); - const res = await flowUpdate(record.uuid, { + const reqParams = { content, ...formRef.current.getFieldsValue() - }) + } + const res = await (isCreate ? flowCreate(reqParams) : flowUpdate(record.uuid, reqParams)) if (res?.success) { - message.success("保存成功"); - loadDetail(); + if (isCreate) { + navigate("/flow/detail/" + res?.data); + } else { + message.success("操作成功"); + loadDetail(); + } } else { message.error(res.message); } @@ -179,7 +186,7 @@ const FlowDetail = () => { - + }>
{ return ( } type='primary' onClick={() => navigate("/flow/detail/create")}>创建 + )} actionRef={actionRef} rowKey='id' search={false} scroll={{ x: 'max-content' }} - options={false} columns={columns} request={onRequest} />