Commit 09f2b20b authored by chenshouchao's avatar chenshouchao

feat: 完成自定义模板保存联调

parent 4af3d4d3
...@@ -38,6 +38,7 @@ const RESTAPI = { ...@@ -38,6 +38,7 @@ const RESTAPI = {
API_WORKBENCH_WORKFLOW_TASKINFO: `${BACKEND_API_URI_PREFIX}/cpp/workbench/workflowjob/task-info`, //查询任务某个算子详情 API_WORKBENCH_WORKFLOW_TASKINFO: `${BACKEND_API_URI_PREFIX}/cpp/workbench/workflowjob/task-info`, //查询任务某个算子详情
API_OPERATOR_LIST:`${BACKEND_API_URI_PREFIX}/cpp/workflow/actorspecs`, // 获取算子列表 API_OPERATOR_LIST:`${BACKEND_API_URI_PREFIX}/cpp/workflow/actorspecs`, // 获取算子列表
API_VERSION_OPERATOR:`${BACKEND_API_URI_PREFIX}/cpp/workflow/actorversion`, // 获取指定版本算子 API_VERSION_OPERATOR:`${BACKEND_API_URI_PREFIX}/cpp/workflow/actorversion`, // 获取指定版本算子
API_SAVE_USERSPEC:`${BACKEND_API_URI_PREFIX}/cpp/workflow/saveuserspec`, // 保存用户自定义工作流模板
}; };
export default RESTAPI; export default RESTAPI;
...@@ -146,6 +146,16 @@ const fetchVersionOperator = (params: IFetchOperatorListParams) => { ...@@ -146,6 +146,16 @@ const fetchVersionOperator = (params: IFetchOperatorListParams) => {
params, params,
}); });
}; };
// 保存用户自定义工作流模板
const saveUserSpec = (params: any) => {
return request({
url: Api.API_SAVE_USERSPEC,
method: "post",
data: params,
});
};
export { export {
current, current,
menu, menu,
...@@ -157,5 +167,6 @@ export { ...@@ -157,5 +167,6 @@ export {
deleteWorkflowJob, deleteWorkflowJob,
cancelWorkflowJob, cancelWorkflowJob,
fetchOperatorList, fetchOperatorList,
fetchVersionOperator fetchVersionOperator,
saveUserSpec
}; };
...@@ -289,12 +289,17 @@ const AddTemplate = observer((props: IAddTemplateProps) => { ...@@ -289,12 +289,17 @@ const AddTemplate = observer((props: IAddTemplateProps) => {
</div> </div>
{customTemplateInfo?.show ? ( {customTemplateInfo?.show ? (
<WorkFlowEdit <WorkFlowEdit
onBack={() => onBack={() => {
setCustomTemplateInfo({ setCustomTemplateInfo({
id: "", id: "",
show: false, show: false,
}) });
} setSelectTemplateData([]);
getAddTemplateList({
projectId: projectId as string,
productId: productId as string,
});
}}
/> />
) : null} ) : null}
</div> </div>
......
...@@ -19,6 +19,8 @@ import ParameterSetting from "./components/ParameterSetting"; ...@@ -19,6 +19,8 @@ import ParameterSetting from "./components/ParameterSetting";
import { useMessage } from "@/components/MySnackbar"; import { useMessage } from "@/components/MySnackbar";
import { ITask } from "../Project/ProjectSubmitWork/interface"; import { ITask } from "../Project/ProjectSubmitWork/interface";
import _ from "lodash"; import _ from "lodash";
import { saveUserSpec } from "@/api/workbench_api";
import useMyRequest from "@/hooks/useMyRequest";
import { getCustomTemplateParameterCheckResult } from "./util"; import { getCustomTemplateParameterCheckResult } from "./util";
import styles from "./index.module.css"; import styles from "./index.module.css";
...@@ -47,7 +49,14 @@ const WorkFlowEdit = (props: IProps) => { ...@@ -47,7 +49,14 @@ const WorkFlowEdit = (props: IProps) => {
const [popperTitle, setPopperTitle] = useState( const [popperTitle, setPopperTitle] = useState(
"返回后,当前页面已填写内容将不保存,确认返回吗?" "返回后,当前页面已填写内容将不保存,确认返回吗?"
); );
// 返回后,当前页面已填写内容将不保存,确认返回吗? const { run: saveUserSpecRun } = useMyRequest(saveUserSpec, {
onSuccess: (res) => {
onBack && onBack();
console.log(res);
},
});
// useMyRequest
// saveUserSpec
const [anchorEl, setAnchorEl] = useState<any>(null); const [anchorEl, setAnchorEl] = useState<any>(null);
const handleCancel = () => { const handleCancel = () => {
setAnchorEl(null); setAnchorEl(null);
...@@ -80,6 +89,7 @@ const WorkFlowEdit = (props: IProps) => { ...@@ -80,6 +89,7 @@ const WorkFlowEdit = (props: IProps) => {
parameter.error = checkResult.error; parameter.error = checkResult.error;
parameter.helperText = checkResult.helperText; parameter.helperText = checkResult.helperText;
if (checkResult.error) { if (checkResult.error) {
console.log(parameter);
check = false; check = false;
} }
}); });
...@@ -89,6 +99,12 @@ const WorkFlowEdit = (props: IProps) => { ...@@ -89,6 +99,12 @@ const WorkFlowEdit = (props: IProps) => {
Message.error("工作流校验未通过,请检查!"); Message.error("工作流校验未通过,请检查!");
} else { } else {
console.log("弹表单窗"); console.log("弹表单窗");
saveUserSpecRun({
title: "自定义模板标题",
version: "1.0.0",
description: "这里是描述",
tasks: templateConfigInfoClone,
});
} }
}; };
...@@ -128,7 +144,7 @@ const WorkFlowEdit = (props: IProps) => { ...@@ -128,7 +144,7 @@ const WorkFlowEdit = (props: IProps) => {
<div className={styles.swHeaderRight}> <div className={styles.swHeaderRight}>
<ButtonComponent <ButtonComponent
text="保存" text="保存"
click={() => handlePreserve} click={() => handlePreserve()}
></ButtonComponent> ></ButtonComponent>
</div> </div>
</div> </div>
......
...@@ -7,6 +7,13 @@ export const getCustomTemplateParameterCheckResult = ( ...@@ -7,6 +7,13 @@ export const getCustomTemplateParameterCheckResult = (
} => { } => {
let error = false; let error = false;
let helperText = ""; let helperText = "";
// 输出不做校验
if (parameter.parameterGroup === "out") {
return {
error,
helperText,
}
}
// 表单校验 // 表单校验
if (parameter.required) { if (parameter.required) {
// 提交任务时不展示 // 提交任务时不展示
...@@ -28,15 +35,18 @@ export const getCustomTemplateParameterCheckResult = ( ...@@ -28,15 +35,18 @@ export const getCustomTemplateParameterCheckResult = (
helperText, helperText,
}; };
} }
if (Array.isArray(parameter.validators)) { // 有值才做validators旋律校验
if (parameter.validators.length > 0) { if (parameter.defaultValue) {
parameter.validators.forEach((validator) => { if (Array.isArray(parameter.validators)) {
const reg = new RegExp(validator.regex); if (parameter.validators.length > 0) {
if (!reg.test(parameter.defaultValue)) { parameter.validators.forEach((validator) => {
error = true; const reg = new RegExp(validator.regex);
helperText = validator.message; if (!reg.test(parameter.defaultValue)) {
} error = true;
}); helperText = validator.message;
}
});
}
} }
} }
return { return {
......
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