Commit 2a7b6d6a authored by chenshouchao's avatar chenshouchao

feat: 提交任务接口联调

parent fa9375be
This diff is collapsed.
...@@ -34,6 +34,7 @@ const RESTAPI = { ...@@ -34,6 +34,7 @@ const RESTAPI = {
API_WORKBENCH_WORKFLOWJOB_LIST: `${BACKEND_API_URI_PREFIX}/cpp/workbench/project/workflowjob`, //查询工作流任务 API_WORKBENCH_WORKFLOWJOB_LIST: `${BACKEND_API_URI_PREFIX}/cpp/workbench/project/workflowjob`, //查询工作流任务
API_WORKBENCH_DEL_WORKFLOWJOB: `${BACKEND_API_URI_PREFIX}/cpp/workflow/job/`, //删除工作流任务 API_WORKBENCH_DEL_WORKFLOWJOB: `${BACKEND_API_URI_PREFIX}/cpp/workflow/job/`, //删除工作流任务
API_WORKBENCH_CANCEL_WORKFLOWJOB: `${BACKEND_API_URI_PREFIX}/cpp/workflow/cancel`, //取消工作流 API_WORKBENCH_CANCEL_WORKFLOWJOB: `${BACKEND_API_URI_PREFIX}/cpp/workflow/cancel`, //取消工作流
API_SUBMIT_WORKFLOW: `${BACKEND_API_URI_PREFIX}/cpp/workflow/submit`, //提交工作流
}; };
export default RESTAPI; export default RESTAPI;
...@@ -202,9 +202,8 @@ const getDataFileDelPackage = (params: getDataFileDelPackageParams) => { ...@@ -202,9 +202,8 @@ const getDataFileDelPackage = (params: getDataFileDelPackageParams) => {
}); });
}; };
// 点击使用模版,获取模版数据 // 点击使用模版,获取模版数据
const fetchTemplateConfigInfo = (params: {id: string}) => { const fetchTemplateConfigInfo = (params: { id: string }) => {
return request({ return request({
url: `${Api.API_FETCH_TEMPLATE_INFO}/${params.id}`, url: `${Api.API_FETCH_TEMPLATE_INFO}/${params.id}`,
method: "get", method: "get",
...@@ -212,14 +211,29 @@ const fetchTemplateConfigInfo = (params: {id: string}) => { ...@@ -212,14 +211,29 @@ const fetchTemplateConfigInfo = (params: {id: string}) => {
}; };
// 点击工作列表,查看工作流详情 // 点击工作列表,查看工作流详情
const fetchWorkFlowJob = (params: {id: string}) => { const fetchWorkFlowJob = (params: { id: string }) => {
return request({ return request({
url: `${Api.API_WORK_FLOW_JOB}/${params.id}`, url: `${Api.API_WORK_FLOW_JOB}/${params.id}`,
method: "get", method: "get",
}); });
}; };
type submitWorkFlowParams = {
name: string;
projectId: string;
specId: string;
outputPath: string;
promotedParameters: any;
};
// 提交工作流
const submitWorkFlow = (params: submitWorkFlowParams) => {
return request({
url: Api.API_SUBMIT_WORKFLOW,
method: "post",
data: params,
});
};
export { export {
current, current,
...@@ -238,5 +252,6 @@ export { ...@@ -238,5 +252,6 @@ export {
getDataFileDel, getDataFileDel,
getDataFileDelPackage, getDataFileDelPackage,
fetchTemplateConfigInfo, fetchTemplateConfigInfo,
fetchWorkFlowJob fetchWorkFlowJob,
submitWorkFlow,
}; };
...@@ -26,10 +26,10 @@ ...@@ -26,10 +26,10 @@
box-sizing: border-box; box-sizing: border-box;
position: relative; position: relative;
} }
.backgroundTitleTextIcon{ .backgroundTitleTextIcon {
visibility: hidden; visibility: hidden;
} }
.backgroundTitleTextIconShow{ .backgroundTitleTextIconShow {
visibility: visible; visibility: visible;
} }
.backgroundTitleText { .backgroundTitleText {
...@@ -65,6 +65,17 @@ ...@@ -65,6 +65,17 @@
.taskConfigBox { .taskConfigBox {
padding: 24px 44px 40px 44px; padding: 24px 44px 40px 44px;
} }
.flowTitle {
/* line-height: 22px; */
line-height: 16px;
/* margin-bottom: 24px; */
margin: 3px 0 27px;
color: rgba(30, 38, 51, 1);
font-size: 14px;
font-weight: 600;
border-left: 3px solid rgba(19, 112, 255, 1);
padding-left: 3px;
}
.parameter { .parameter {
margin-bottom: 20px; margin-bottom: 20px;
position: relative; position: relative;
...@@ -76,7 +87,7 @@ ...@@ -76,7 +87,7 @@
line-height: 22px; line-height: 22px;
margin-bottom: 12px; margin-bottom: 12px;
} }
.parameterContent{ .parameterContent {
position: relative; position: relative;
} }
.parameterDesc { .parameterDesc {
......
...@@ -16,15 +16,19 @@ import IconButton from "@mui/material/IconButton"; ...@@ -16,15 +16,19 @@ import IconButton from "@mui/material/IconButton";
import { ITemplateConfig } from "./interface"; import { ITemplateConfig } from "./interface";
import _ from "lodash"; import _ from "lodash";
import useMyRequest from "@/hooks/useMyRequest"; import useMyRequest from "@/hooks/useMyRequest";
import { fetchTemplateConfigInfo } from "@/api/project_api"; import { fetchTemplateConfigInfo, submitWorkFlow } from "@/api/project_api";
import { useLocation, useNavigate } from "react-router-dom"; import { useLocation, useNavigate } from "react-router-dom";
import { getCheckResult } from "./util"; import { getCheckResult } from "./util";
import { IResponse } from "@/api/http"; import { IResponse } from "@/api/http";
import { templateConfigJson } from "./mock"; import { templateConfigJson } from "./mock";
import { useMessage } from "@/components/MySnackbar"; import { useMessage } from "@/components/MySnackbar";
import { toJS } from "mobx";
import { useStores } from "@/store";
const ProjectSubmitWork = () => { const ProjectSubmitWork = () => {
const Message = useMessage(); const Message = useMessage();
const { currentProjectStore } = useStores();
const projectId = toJS(currentProjectStore.currentProjectInfo.id);
const [templateConfigInfo, setTemplateConfigInfo] = const [templateConfigInfo, setTemplateConfigInfo] =
useState<ITemplateConfig>(); useState<ITemplateConfig>();
const location: any = useLocation(); const location: any = useLocation();
...@@ -42,6 +46,12 @@ const ProjectSubmitWork = () => { ...@@ -42,6 +46,12 @@ const ProjectSubmitWork = () => {
// } // }
}); });
const { run: submitWorkFlowRun } = useMyRequest(submitWorkFlow, {
onSuccess: (res) => {
console.log(res);
},
});
useEffect(() => { useEffect(() => {
run({ run({
id: location?.state?.id, id: location?.state?.id,
...@@ -52,6 +62,7 @@ const ProjectSubmitWork = () => { ...@@ -52,6 +62,7 @@ const ProjectSubmitWork = () => {
const result: ITemplateConfig = _.cloneDeep(templateConfigInfo); const result: ITemplateConfig = _.cloneDeep(templateConfigInfo);
result.tasks.forEach((tack) => { result.tasks.forEach((tack) => {
if (tack.id === taskId) { if (tack.id === taskId) {
let isCheck = true;
tack.parameters.forEach((parameter) => { tack.parameters.forEach((parameter) => {
if (parameter.name === parameterName) { if (parameter.name === parameterName) {
parameter.value = value; parameter.value = value;
...@@ -61,6 +72,10 @@ const ProjectSubmitWork = () => { ...@@ -61,6 +72,10 @@ const ProjectSubmitWork = () => {
} else { } else {
return; return;
} }
if (getCheckResult(parameter, value).error === true) {
isCheck = false;
}
tack.isCheck = isCheck;
}); });
} else { } else {
return; return;
...@@ -90,6 +105,13 @@ const ProjectSubmitWork = () => { ...@@ -90,6 +105,13 @@ const ProjectSubmitWork = () => {
setTemplateConfigInfo(result); setTemplateConfigInfo(result);
if (check) { if (check) {
console.log("提交任务"); console.log("提交任务");
submitWorkFlowRun({
name,
outputPath,
projectId: projectId as string,
specId: templateConfigInfo?.id as string,
promotedParameters: {},
});
} else { } else {
Message.error("请完善左侧表单再提交"); Message.error("请完善左侧表单再提交");
} }
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* @FilePath: /bkunyun/src/views/Project/ProjectSubmitWork/interface.ts * @FilePath: /bkunyun/src/views/Project/ProjectSubmitWork/interface.ts
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/ */
type IType = 'BATCH' | 'FLOW' type IType = "BATCH" | "FLOW";
export interface IParameter { export interface IParameter {
hidden: boolean; hidden: boolean;
id?: string; id?: string;
...@@ -24,8 +24,8 @@ export interface IParameter { ...@@ -24,8 +24,8 @@ export interface IParameter {
tasks: ITask[]; tasks: ITask[];
validators: Array<IValidator>; validators: Array<IValidator>;
choices: Array<IChoice>; choices: Array<IChoice>;
error? : boolean; error?: boolean;
helperText? : string; helperText?: string;
} }
export interface ITask { export interface ITask {
...@@ -40,9 +40,9 @@ export interface ITask { ...@@ -40,9 +40,9 @@ export interface ITask {
parentNode?: string; parentNode?: string;
parameters: Array<IParameter>; parameters: Array<IParameter>;
edges: Array<IEdge>; edges: Array<IEdge>;
isCheck?: boolean;
} }
export interface ITemplateConfig { export interface ITemplateConfig {
title: string; title: string;
version: string; version: string;
...@@ -54,6 +54,7 @@ export interface ITemplateConfig { ...@@ -54,6 +54,7 @@ export interface ITemplateConfig {
source: string; source: string;
productId: string; productId: string;
tasks: ITask[]; tasks: ITask[];
id: string;
} }
export type IDomType = export type IDomType =
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment