Commit 4af3d4d3 authored by chenshouchao's avatar chenshouchao

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

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