Commit 2a7b6d6a authored by chenshouchao's avatar chenshouchao

feat: 提交任务接口联调

parent fa9375be
This diff is collapsed.
......@@ -34,6 +34,7 @@ const RESTAPI = {
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_CANCEL_WORKFLOWJOB: `${BACKEND_API_URI_PREFIX}/cpp/workflow/cancel`, //取消工作流
API_SUBMIT_WORKFLOW: `${BACKEND_API_URI_PREFIX}/cpp/workflow/submit`, //提交工作流
};
export default RESTAPI;
......@@ -202,9 +202,8 @@ const getDataFileDelPackage = (params: getDataFileDelPackageParams) => {
});
};
// 点击使用模版,获取模版数据
const fetchTemplateConfigInfo = (params: {id: string}) => {
const fetchTemplateConfigInfo = (params: { id: string }) => {
return request({
url: `${Api.API_FETCH_TEMPLATE_INFO}/${params.id}`,
method: "get",
......@@ -212,14 +211,29 @@ const fetchTemplateConfigInfo = (params: {id: string}) => {
};
// 点击工作列表,查看工作流详情
const fetchWorkFlowJob = (params: {id: string}) => {
const fetchWorkFlowJob = (params: { id: string }) => {
return request({
url: `${Api.API_WORK_FLOW_JOB}/${params.id}`,
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 {
current,
......@@ -238,5 +252,6 @@ export {
getDataFileDel,
getDataFileDelPackage,
fetchTemplateConfigInfo,
fetchWorkFlowJob
fetchWorkFlowJob,
submitWorkFlow,
};
......@@ -12,7 +12,7 @@ type MyInputProps = {
placeholder?: string;
fullWidth?: boolean; // 宽度是否和容器一致
InputProps?: any; // input加前后icon可以用这个
error?: boolean;
error?: boolean;
helperText?: string;
};
......
......@@ -26,10 +26,10 @@
box-sizing: border-box;
position: relative;
}
.backgroundTitleTextIcon{
.backgroundTitleTextIcon {
visibility: hidden;
}
.backgroundTitleTextIconShow{
.backgroundTitleTextIconShow {
visibility: visible;
}
.backgroundTitleText {
......@@ -65,6 +65,17 @@
.taskConfigBox {
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 {
margin-bottom: 20px;
position: relative;
......@@ -76,7 +87,7 @@
line-height: 22px;
margin-bottom: 12px;
}
.parameterContent{
.parameterContent {
position: relative;
}
.parameterDesc {
......
......@@ -16,15 +16,19 @@ import IconButton from "@mui/material/IconButton";
import { ITemplateConfig } from "./interface";
import _ from "lodash";
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 { getCheckResult } from "./util";
import { IResponse } from "@/api/http";
import { templateConfigJson } from "./mock";
import { useMessage } from "@/components/MySnackbar";
import { toJS } from "mobx";
import { useStores } from "@/store";
const ProjectSubmitWork = () => {
const Message = useMessage();
const { currentProjectStore } = useStores();
const projectId = toJS(currentProjectStore.currentProjectInfo.id);
const [templateConfigInfo, setTemplateConfigInfo] =
useState<ITemplateConfig>();
const location: any = useLocation();
......@@ -42,6 +46,12 @@ const ProjectSubmitWork = () => {
// }
});
const { run: submitWorkFlowRun } = useMyRequest(submitWorkFlow, {
onSuccess: (res) => {
console.log(res);
},
});
useEffect(() => {
run({
id: location?.state?.id,
......@@ -52,6 +62,7 @@ const ProjectSubmitWork = () => {
const result: ITemplateConfig = _.cloneDeep(templateConfigInfo);
result.tasks.forEach((tack) => {
if (tack.id === taskId) {
let isCheck = true;
tack.parameters.forEach((parameter) => {
if (parameter.name === parameterName) {
parameter.value = value;
......@@ -61,6 +72,10 @@ const ProjectSubmitWork = () => {
} else {
return;
}
if (getCheckResult(parameter, value).error === true) {
isCheck = false;
}
tack.isCheck = isCheck;
});
} else {
return;
......@@ -90,6 +105,13 @@ const ProjectSubmitWork = () => {
setTemplateConfigInfo(result);
if (check) {
console.log("提交任务");
submitWorkFlowRun({
name,
outputPath,
projectId: projectId as string,
specId: templateConfigInfo?.id as string,
promotedParameters: {},
});
} else {
Message.error("请完善左侧表单再提交");
}
......
......@@ -6,7 +6,7 @@
* @FilePath: /bkunyun/src/views/Project/ProjectSubmitWork/interface.ts
* @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 {
hidden: boolean;
id?: string;
......@@ -24,8 +24,8 @@ export interface IParameter {
tasks: ITask[];
validators: Array<IValidator>;
choices: Array<IChoice>;
error? : boolean;
helperText? : string;
error?: boolean;
helperText?: string;
}
export interface ITask {
......@@ -40,9 +40,9 @@ export interface ITask {
parentNode?: string;
parameters: Array<IParameter>;
edges: Array<IEdge>;
isCheck?: boolean;
}
export interface ITemplateConfig {
title: string;
version: string;
......@@ -54,6 +54,7 @@ export interface ITemplateConfig {
source: string;
productId: string;
tasks: ITask[];
id: string;
}
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