feat: 创建工作
This commit is contained in:
parent
ab5f99144c
commit
7e9f0eece2
|
|
@ -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)):
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -54,13 +54,13 @@ const ClientPage = () => {
|
|||
|
||||
]
|
||||
|
||||
return <Card title="节点管理" extra={<Create onFinish={() => actionRef?.current?.reload()} />}>
|
||||
return <Card title="节点管理">
|
||||
<ProTable
|
||||
headerTitle={<Create onFinish={() => actionRef?.current?.reload()} />}
|
||||
actionRef={actionRef}
|
||||
rowKey='id'
|
||||
search={false}
|
||||
scroll={{ x: 'max-content' }}
|
||||
options={false}
|
||||
columns={columns}
|
||||
request={onRequest}
|
||||
/>
|
||||
|
|
|
|||
|
|
@ -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 = () => {
|
|||
<Col span={18} >
|
||||
<Card title="工作" extra={<Space>
|
||||
<Button onClick={() => navigate("/flow")}>取消</Button>
|
||||
<Button type='primary' onClick={() => onSave()}>保存</Button>
|
||||
<Button type='primary' onClick={() => onSave()}>{isCreate ? '创建':'保存'}</Button>
|
||||
</Space>}>
|
||||
<div style={{ height: 'calc(100vh - 220px)', width: '100%' }}>
|
||||
<ReactFlow
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { ProTable } from "@ant-design/pro-components"
|
||||
import { Button, Card, Flex, Modal, Popconfirm, Space, Steps, Typography } from "antd"
|
||||
import { Button, Card, Popconfirm, Space, Typography } from "antd"
|
||||
import { useAuth } from "../../context/AuthContext";
|
||||
import { LoadingOutlined } from "@ant-design/icons";
|
||||
import { LoadingOutlined, PlusOutlined } from "@ant-design/icons";
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { tableList, flowRun, flowStop } from "../../api/flow";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
|
|
@ -169,11 +169,13 @@ export default () => {
|
|||
return (
|
||||
<Card title="工作台">
|
||||
<ProTable
|
||||
headerTitle={(
|
||||
<Button icon={<PlusOutlined />} type='primary' onClick={() => navigate("/flow/detail/create")}>创建</Button>
|
||||
)}
|
||||
actionRef={actionRef}
|
||||
rowKey='id'
|
||||
search={false}
|
||||
scroll={{ x: 'max-content' }}
|
||||
options={false}
|
||||
columns={columns}
|
||||
request={onRequest}
|
||||
/>
|
||||
|
|
|
|||
Loading…
Reference in New Issue