Commit c5555c8c authored by wuyongsheng's avatar wuyongsheng

Merge branch 'feat-20220705-customTemplate' into 'release'

fix: 版本字段修改

See merge request !88
parents 0c43f14b 753e61ad
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: 吴永生#A02208 yongsheng.wu@wholion.com * @Author: 吴永生#A02208 yongsheng.wu@wholion.com
* @Date: 2022-06-21 20:03:56 * @Date: 2022-06-21 20:03:56
* @LastEditors: 吴永生#A02208 yongsheng.wu@wholion.com * @LastEditors: 吴永生#A02208 yongsheng.wu@wholion.com
* @LastEditTime: 2022-07-06 11:55:03 * @LastEditTime: 2022-07-07 10:53:41
* @FilePath: /bkunyun/src/views/Project/ProjectSubmitWork/index.tsx * @FilePath: /bkunyun/src/views/Project/ProjectSubmitWork/index.tsx
* @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
*/ */
...@@ -31,262 +31,262 @@ import MyPopconfirm from "@/components/mui/MyPopconfirm"; ...@@ -31,262 +31,262 @@ import MyPopconfirm from "@/components/mui/MyPopconfirm";
import styles from "./index.module.css"; import styles from "./index.module.css";
const ProjectSubmitWork = () => { const ProjectSubmitWork = () => {
const Message = useMessage(); const Message = useMessage();
const { currentProjectStore } = useStores(); const { currentProjectStore } = useStores();
const projectId = toJS(currentProjectStore.currentProjectInfo.id); const projectId = toJS(currentProjectStore.currentProjectInfo.id);
const [templateConfigInfo, setTemplateConfigInfo] = const [templateConfigInfo, setTemplateConfigInfo] =
useState<ITemplateConfig>(); useState<ITemplateConfig>();
const location: any = useLocation(); const location: any = useLocation();
const navigate = useNavigate(); const navigate = useNavigate();
let configFormRef: any = React.createRef(); let configFormRef: any = React.createRef();
/** 是否全屏 */ /** 是否全屏 */
const [fullScreenShow, setFullScreenShow] = useState<boolean>(false); const [fullScreenShow, setFullScreenShow] = useState<boolean>(false);
const [selectedNodeId, setSelectedNodeId] = useState<string>(""); const [selectedNodeId, setSelectedNodeId] = useState<string>("");
// 前往工作台 // 前往工作台
const goToWorkbench = (toWorkbenchList = false) => { const goToWorkbench = (toWorkbenchList = false) => {
navigate("/product/cadd/projectWorkbench", { navigate("/product/cadd/projectWorkbench", {
state: { type: toWorkbenchList ? "workbenchList" : "" }, state: { type: toWorkbenchList ? "workbenchList" : "" },
}); });
}; };
// 返回 // 返回
const handleGoBack = () => { const handleGoBack = () => {
goToWorkbench(); goToWorkbench();
}; };
if (!location?.state?.id) { if (!location?.state?.id) {
goToWorkbench(); goToWorkbench();
} }
/** 获取模版数据 */ /** 获取模版数据 */
const { run } = useMyRequest(fetchTemplateConfigInfo, { const { run } = useMyRequest(fetchTemplateConfigInfo, {
onSuccess: (res: IResponse<ITemplateConfig>) => { onSuccess: (res: IResponse<ITemplateConfig>) => {
// setTemplateConfigInfo(templateConfigJson as ITemplateConfig); // setTemplateConfigInfo(templateConfigJson as ITemplateConfig);
res.data.tasks.forEach((task) => { res.data.tasks.forEach((task) => {
task.parameters.forEach((parameter) => { task.parameters.forEach((parameter) => {
let value: any = undefined; let value: any = undefined;
if (parameter.defaultValue) { if (parameter.defaultValue) {
if ( if (
parameter.domType.toLowerCase() === "multipleselect" || parameter.domType.toLowerCase() === "multipleselect" ||
parameter.domType.toLowerCase() === "checkbox" parameter.domType.toLowerCase() === "checkbox"
) { ) {
value = parameter.defaultValue.split(","); value = parameter.defaultValue.split(",");
} else { } else {
value = parameter.defaultValue; value = parameter.defaultValue;
} }
} else if ( } else if (
parameter.domType.toLowerCase() === "multipleselect" || parameter.domType.toLowerCase() === "multipleselect" ||
parameter.domType.toLowerCase() === "checkbox" parameter.domType.toLowerCase() === "checkbox"
) { ) {
value = []; value = [];
} else { } else {
value = ""; value = "";
} }
parameter.value = value; parameter.value = value;
}); });
}); });
setTemplateConfigInfo(res.data); setTemplateConfigInfo(res.data);
configFormRef.current.setInitName(res.data.title); configFormRef.current.setInitName(res.data.title);
}, },
onError: () => { onError: () => {
// setTemplateConfigInfo(templateConfigJson as ITemplateConfig); // setTemplateConfigInfo(templateConfigJson as ITemplateConfig);
}, },
}); });
const { run: submitWorkFlowRun } = useMyRequest(submitWorkFlow, { const { run: submitWorkFlowRun } = useMyRequest(submitWorkFlow, {
onSuccess: (res) => { onSuccess: (res) => {
Message.success("提交成功"); Message.success("提交成功");
goToWorkbench(true); goToWorkbench(true);
}, },
}); });
useEffect(() => { useEffect(() => {
run({ run({
id: location?.state?.id, id: location?.state?.id,
}); });
}, [location?.state?.id, run]); }, [location?.state?.id, run]);
const setParameter = (value: any, taskId: string, parameterName: string) => { const setParameter = (value: any, taskId: string, parameterName: string) => {
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; let isCheck = true;
tack.parameters tack.parameters
.filter((parameter) => parameter.hidden === false) .filter((parameter) => parameter.hidden === false)
.forEach((parameter) => { .forEach((parameter) => {
if (parameter.name === parameterName) { if (parameter.name === parameterName) {
parameter.value = value; parameter.value = value;
const checkResult = getCheckResult(parameter, value); const checkResult = getCheckResult(parameter, value);
parameter.error = checkResult.error; parameter.error = checkResult.error;
parameter.helperText = checkResult.helperText; parameter.helperText = checkResult.helperText;
} }
if (getCheckResult(parameter, parameter.value).error === true) { if (getCheckResult(parameter, parameter.value).error === true) {
isCheck = false; isCheck = false;
} }
}); });
tack.isCheck = isCheck; tack.isCheck = isCheck;
} else { } else {
return; return;
} }
}); });
setTemplateConfigInfo(result); setTemplateConfigInfo(result);
}; };
const handleSubmitForm = () => { const handleSubmitForm = () => {
let check = true; let check = true;
const { name, outputPath, nameAndOutputPathCheck } = const { name, outputPath, nameAndOutputPathCheck } =
configFormRef.current.getNameAndPath(); configFormRef.current.getNameAndPath();
if (!nameAndOutputPathCheck) { if (!nameAndOutputPathCheck) {
check = false; check = false;
} }
const result: ITemplateConfig = _.cloneDeep(templateConfigInfo); const result: ITemplateConfig = _.cloneDeep(templateConfigInfo);
result.tasks.forEach((tack) => { result.tasks.forEach((tack) => {
tack.parameters tack.parameters
.filter((parameter) => parameter.hidden === false) .filter((parameter) => parameter.hidden === false)
.forEach((parameter) => { .forEach((parameter) => {
const checkResult = getCheckResult(parameter, parameter.value); const checkResult = getCheckResult(parameter, parameter.value);
parameter.error = checkResult.error; parameter.error = checkResult.error;
parameter.helperText = checkResult.helperText; parameter.helperText = checkResult.helperText;
if (checkResult.error) { if (checkResult.error) {
check = false; check = false;
} }
}); });
}); });
setTemplateConfigInfo(result); setTemplateConfigInfo(result);
if (check) { if (check) {
let promotedParameters: any = {}; let promotedParameters: any = {};
result.tasks.forEach((tack) => { result.tasks.forEach((tack) => {
tack.parameters tack.parameters
.filter((parameter) => parameter.hidden === false) .filter((parameter) => parameter.hidden === false)
.forEach((parameter) => { .forEach((parameter) => {
let value: string = ""; let value: string = "";
if (Array.isArray(parameter.value)) { if (Array.isArray(parameter.value)) {
value = parameter.value.join(","); value = parameter.value.join(",");
} else { } else {
value = parameter.value; value = parameter.value;
} }
if ( if (
parameter.domType.toLowerCase() === "path" || parameter.domType.toLowerCase() === "path" ||
parameter.domType.toLowerCase() === "dataset" || parameter.domType.toLowerCase() === "dataset" ||
parameter.domType.toLowerCase() === "file" parameter.domType.toLowerCase() === "file"
) { ) {
if (value === "ProjectData") { if (value === "ProjectData") {
value = "/home/cloudam"; value = "/home/cloudam";
} else { } else {
value = `/home/cloudam${value.slice(11)}`; value = `/home/cloudam${value.slice(11)}`;
} }
} }
promotedParameters[parameter.name] = { promotedParameters[parameter.name] = {
[parameter.classTypeName]: value, [parameter.classTypeName]: value,
}; };
}); });
}); });
submitWorkFlowRun({ submitWorkFlowRun({
name, name,
outputPath: outputPath:
outputPath === "ProjectData" outputPath === "ProjectData"
? "/home/cloudam" ? "/home/cloudam"
: `/home/cloudam${outputPath.slice(11)}`, : `/home/cloudam${outputPath.slice(11)}`,
projectId: projectId as string, projectId: projectId as string,
specId: templateConfigInfo?.id as string, specId: templateConfigInfo?.id as string,
promotedParameters, promotedParameters,
}); });
} else { } else {
Message.error("请完善左侧表单再提交"); Message.error("请完善左侧表单再提交");
} }
}; };
return ( return (
<div className={styles.swBox}> <div className={styles.swBox}>
{fullScreenShow ? null : ( {fullScreenShow ? null : (
<div className={styles.swHeader}> <div className={styles.swHeader}>
<div className={styles.swHeaderLeft}> <div className={styles.swHeaderLeft}>
<MyPopconfirm <MyPopconfirm
title="返回后,当前页面已填写内容将不保存,确认返回吗?" title="返回后,当前页面已填写内容将不保存,确认返回吗?"
onConfirm={handleGoBack} onConfirm={handleGoBack}
> >
<IconButton <IconButton
color="primary" color="primary"
// onClick={() => handleGoBack()} // onClick={() => handleGoBack()}
aria-label="upload picture" aria-label="upload picture"
component="span" component="span"
size="small" size="small"
> >
<ArrowBackIosNewIcon <ArrowBackIosNewIcon
sx={{ sx={{
color: "rgba(194, 198, 204, 1)", color: "rgba(194, 198, 204, 1)",
width: "12px", width: "12px",
height: "12px", height: "12px",
}} }}
/> />
</IconButton> </IconButton>
</MyPopconfirm> </MyPopconfirm>
<div className={styles.swTemplateTitle}> <div className={styles.swTemplateTitle}>
{templateConfigInfo?.title} {templateConfigInfo?.title}
</div> </div>
<div className={styles.swTemplateVersionBox}> <div className={styles.swTemplateVersionBox}>
<span className={styles.swHeaderLable}>版本:</span> <span className={styles.swHeaderLable}>版本:</span>
<span className={styles.swHeaderValue}> <span className={styles.swHeaderValue}>
{templateConfigInfo?.languageVersion} {templateConfigInfo?.version}
</span> </span>
</div> </div>
<div className={styles.swTemplateUpdateTimeBox}> <div className={styles.swTemplateUpdateTimeBox}>
<span className={styles.swHeaderLable}>更新时间:</span> <span className={styles.swHeaderLable}>更新时间:</span>
<span className={styles.swHeaderValue}> <span className={styles.swHeaderValue}>
{templateConfigInfo?.updateTime {templateConfigInfo?.updateTime
? moment(templateConfigInfo?.updateTime).format( ? moment(templateConfigInfo?.updateTime).format(
"YYYY-MM-DD HH:mm:ss" "YYYY-MM-DD HH:mm:ss"
) )
: "-"} : "-"}
</span> </span>
</div> </div>
<div className={styles.swHeaderGoback}></div> <div className={styles.swHeaderGoback}></div>
</div> </div>
<div className={styles.swHeaderRight}> <div className={styles.swHeaderRight}>
<MyPopconfirm <MyPopconfirm
title="提交前请先确认参数填写无误,确认提交吗?" title="提交前请先确认参数填写无误,确认提交吗?"
onConfirm={handleSubmitForm} onConfirm={handleSubmitForm}
> >
<ButtonComponent <ButtonComponent
text="提交任务" text="提交任务"
// click={handleSubmitForm} // click={handleSubmitForm}
></ButtonComponent> ></ButtonComponent>
</MyPopconfirm> </MyPopconfirm>
</div> </div>
</div> </div>
)} )}
<div className={styles.swContent}> <div className={styles.swContent}>
{fullScreenShow ? null : ( {fullScreenShow ? null : (
<div className={styles.swFormBox}> <div className={styles.swFormBox}>
<ConfigForm <ConfigForm
onRef={configFormRef} onRef={configFormRef}
templateConfigInfo={templateConfigInfo} templateConfigInfo={templateConfigInfo}
setParameter={setParameter} setParameter={setParameter}
setSelectedNodeId={setSelectedNodeId} setSelectedNodeId={setSelectedNodeId}
/> />
</div> </div>
)} )}
<div <div
className={styles.swFlowBox} className={styles.swFlowBox}
style={fullScreenShow ? { height: "100vh" } : undefined} style={fullScreenShow ? { height: "100vh" } : undefined}
> >
<WorkFlow <WorkFlow
templateConfigInfo={templateConfigInfo} templateConfigInfo={templateConfigInfo}
setSelectedNodeId={setSelectedNodeId} setSelectedNodeId={setSelectedNodeId}
selectedNodeId={selectedNodeId} selectedNodeId={selectedNodeId}
/> />
</div> </div>
</div> </div>
<img <img
className={styles.fullScreenBox} className={styles.fullScreenBox}
src={fullScreenShow ? partialScreen : fullScreen} src={fullScreenShow ? partialScreen : fullScreen}
onClick={() => setFullScreenShow(!fullScreenShow)} onClick={() => setFullScreenShow(!fullScreenShow)}
alt="全屏" alt="全屏"
/> />
</div> </div>
); );
}; };
export default ProjectSubmitWork; export default ProjectSubmitWork;
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