Commit 4af3d4d3 authored by chenshouchao's avatar chenshouchao

feat: 完成参数设置文件夹选择功能

parent 79073268
......@@ -16,7 +16,10 @@ import ButtonComponent from "@/components/mui/Button";
import OperatorList from "./components/OperatorList";
import Flow from "../Project/components/Flow";
import ParameterSetting from "./components/ParameterSetting";
import { useMessage } from "@/components/MySnackbar";
import { ITask } from "../Project/ProjectSubmitWork/interface";
import _ from "lodash";
import { getCustomTemplateParameterCheckResult } from "./util";
import styles from "./index.module.css";
......@@ -37,6 +40,7 @@ interface IProps {
const WorkFlowEdit = (props: IProps) => {
const { onBack } = props;
const Message = useMessage();
const [templateConfigInfo, setTemplateConfigInfo] = useState<ITask[]>([]);
const [leftContentType, setLeftContentType] = useState("list");
......@@ -57,8 +61,34 @@ const WorkFlowEdit = (props: IProps) => {
const handleConfirm = () => {
if (popperTitle === "返回后,当前页面已填写内容将不保存,确认返回吗?") {
onBack && onBack();
}
};
const handlePreserve = () => {
console.log("提交");
console.log(templateConfigInfo);
// 校验
if (templateConfigInfo.length === 0) {
Message.error("工作流不能为空!");
return;
}
let templateConfigInfoClone: ITask[] = _.cloneDeep(templateConfigInfo);
let check = true;
templateConfigInfoClone.forEach((task) => {
task.parameters.forEach((parameter) => {
const checkResult = getCustomTemplateParameterCheckResult(parameter);
parameter.error = checkResult.error;
parameter.helperText = checkResult.helperText;
if (checkResult.error) {
check = false;
}
});
});
setTemplateConfigInfo(templateConfigInfoClone);
if (!check) {
Message.error("工作流校验未通过,请检查!");
} else {
console.log("提交");
console.log("弹表单窗");
}
};
......@@ -74,10 +104,6 @@ const WorkFlowEdit = (props: IProps) => {
<div className={styles.swBox}>
<div className={styles.swHeader}>
<div className={styles.swHeaderLeft}>
{/* <MyPopconfirm
title="返回后,当前页面已填写内容将不保存,确认返回吗?"
onConfirm={onBack}
> */}
<IconButton
color="primary"
aria-label="upload picture"
......@@ -98,20 +124,12 @@ const WorkFlowEdit = (props: IProps) => {
}}
/>
</IconButton>
{/* </MyPopconfirm> */}
</div>
<div className={styles.swHeaderRight}>
{/* <MyPopconfirm
title="提交前请先确认参数填写无误,确认提交吗?"
onConfirm={() => console.log(2)}
> */}
<ButtonComponent
text="保存"
click={(e: any) =>
handleShowPopper(e, "提交前请先确认参数填写无误,确认提交吗?")
}
click={() => handlePreserve}
></ButtonComponent>
{/* </MyPopconfirm> */}
</div>
</div>
<div className={styles.swContent}>
......@@ -140,7 +158,8 @@ const WorkFlowEdit = (props: IProps) => {
{leftContentType !== "list" && (
<ParameterSetting
templateConfigInfo={templateConfigInfo}
taskId={""}
setTemplateConfigInfo={setTemplateConfigInfo}
taskId={selectTaskId || ""}
/>
)}
</div>
......
......@@ -28,14 +28,16 @@ export const getCustomTemplateParameterCheckResult = (
helperText,
};
}
if (parameter.validators.length > 0) {
parameter.validators.forEach((validator) => {
const reg = new RegExp(validator.regex);
if (!reg.test(parameter.defaultValue)) {
error = true;
helperText = validator.message;
}
});
if (Array.isArray(parameter.validators)) {
if (parameter.validators.length > 0) {
parameter.validators.forEach((validator) => {
const reg = new RegExp(validator.regex);
if (!reg.test(parameter.defaultValue)) {
error = true;
helperText = validator.message;
}
});
}
}
return {
error,
......
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