Commit 8d55fa8d authored by 吴永生#A02208's avatar 吴永生#A02208

Merge branch 'feat-20220705-customTemplate' of http://120.77.149.83/root/bkunyun…

Merge branch 'feat-20220705-customTemplate' of http://120.77.149.83/root/bkunyun into feat-20220705-customTemplate
parents bdfc974c 2489ece8
...@@ -22,7 +22,7 @@ interface MyInputProps extends Omit<TextFieldProps, "value"> { ...@@ -22,7 +22,7 @@ interface MyInputProps extends Omit<TextFieldProps, "value"> {
InputProps?: any; // input加前后icon可以用这个 InputProps?: any; // input加前后icon可以用这个
error?: boolean; error?: boolean;
helperText?: string; helperText?: string;
}; }
const MyInput = (props: MyInputProps) => { const MyInput = (props: MyInputProps) => {
const { const {
...@@ -39,6 +39,7 @@ const MyInput = (props: MyInputProps) => { ...@@ -39,6 +39,7 @@ const MyInput = (props: MyInputProps) => {
InputProps, InputProps,
error = false, error = false,
helperText, helperText,
disabled,
} = props; } = props;
return ( return (
...@@ -58,6 +59,7 @@ const MyInput = (props: MyInputProps) => { ...@@ -58,6 +59,7 @@ const MyInput = (props: MyInputProps) => {
InputProps={{ InputProps={{
...InputProps, ...InputProps,
}} }}
disabled={disabled}
value={value} value={value}
/> />
); );
......
...@@ -377,7 +377,8 @@ const ProjectSubmitWork = observer(() => { ...@@ -377,7 +377,8 @@ const ProjectSubmitWork = observer(() => {
{!activePatchId && ( {!activePatchId && (
<div className={styles.taskInfo}> <div className={styles.taskInfo}>
<div className={styles.title}>任务结果</div> <div className={styles.title}>任务结果</div>
{workFlowJobInfo?.outputs && ( {workFlowJobInfo?.outputs &&
Object.keys(workFlowJobInfo?.outputs).length > 0 && (
<div className={styles.taskResults}> <div className={styles.taskResults}>
{randerOutputs1.map((item, index) => { {randerOutputs1.map((item, index) => {
return ( return (
...@@ -395,7 +396,9 @@ const ProjectSubmitWork = observer(() => { ...@@ -395,7 +396,9 @@ const ProjectSubmitWork = observer(() => {
e, e,
"即将跳转至项目数据内该任务的结果目录,确认继续吗?" "即将跳转至项目数据内该任务的结果目录,确认继续吗?"
); );
setGoToProjectDataPath(getFolderPath(item.path)); setGoToProjectDataPath(
getFolderPath(item.path)
);
}} }}
> >
<img <img
...@@ -416,7 +419,8 @@ const ProjectSubmitWork = observer(() => { ...@@ -416,7 +419,8 @@ const ProjectSubmitWork = observer(() => {
})} })}
</div> </div>
)} )}
{!workFlowJobInfo?.outputs && ( {workFlowJobInfo?.outputs &&
Object.keys(workFlowJobInfo?.outputs).length === 0 && (
<div className={styles.notResults}>暂无结果文件</div> <div className={styles.notResults}>暂无结果文件</div>
)} )}
<div className={styles.title}>任务信息</div> <div className={styles.title}>任务信息</div>
......
...@@ -110,11 +110,12 @@ const AddTemplate = observer((props: IAddTemplateProps) => { ...@@ -110,11 +110,12 @@ const AddTemplate = observer((props: IAddTemplateProps) => {
}; };
useEffect(() => { useEffect(() => {
setSelectTemplateData([]);
getAddTemplateList({ getAddTemplateList({
projectId: projectId as string, projectId: projectId as string,
productId: productId as string, productId: productId as string,
}); });
}, [getAddTemplateList, projectId, productId]); }, [templateType, getAddTemplateList, projectId, productId]);
const hiddenBoxArr = useMemo(() => { const hiddenBoxArr = useMemo(() => {
const length = const length =
......
...@@ -255,6 +255,38 @@ const ParameterSetting = (props: IParameterSettingProps) => { ...@@ -255,6 +255,38 @@ const ParameterSetting = (props: IParameterSettingProps) => {
if (parameter.id === parameterId) { if (parameter.id === parameterId) {
console.log(e.target.checked); console.log(e.target.checked);
parameter.hidden = !e.target.checked; parameter.hidden = !e.target.checked;
const checkResult = getCustomTemplateParameterCheckResult(
parameter,
parameter.defaultValue
);
parameter.error = checkResult.error;
parameter.helperText = checkResult.helperText;
}
});
}
setTemplateConfigInfo(result);
},
[templateConfigInfo, setTemplateConfigInfo]
);
const handleParameterChange = useCallback(
(e: any, parameterId: string) => {
console.log(e.target.value, taskId, parameterId);
const result: ITask[] = _.cloneDeep(templateConfigInfo);
console.log(result);
const taskIndex = result.findIndex((item) => {
return item.id === taskId;
});
if (taskIndex !== -1) {
result[taskIndex].parameters.forEach((parameter) => {
if (parameter.id === parameterId) {
parameter.defaultValue = e.target.value;
const checkResult = getCustomTemplateParameterCheckResult(
parameter,
e.target.value
);
parameter.error = checkResult.error;
parameter.helperText = checkResult.helperText;
} }
}); });
} }
...@@ -263,7 +295,8 @@ const ParameterSetting = (props: IParameterSettingProps) => { ...@@ -263,7 +295,8 @@ const ParameterSetting = (props: IParameterSettingProps) => {
[templateConfigInfo, setTemplateConfigInfo] [templateConfigInfo, setTemplateConfigInfo]
); );
const renderInput = useCallback((parameter: IParameter) => { const renderInput = useCallback(
(parameter: IParameter) => {
return ( return (
<Tooltip title={parameter.description} placement="top"> <Tooltip title={parameter.description} placement="top">
<div> <div>
...@@ -273,7 +306,9 @@ const ParameterSetting = (props: IParameterSettingProps) => { ...@@ -273,7 +306,9 @@ const ParameterSetting = (props: IParameterSettingProps) => {
InputProps={{ InputProps={{
endAdornment: ( endAdornment: (
<img <img
onClick={() => handleOpenFileSelect(taskId, parameter.name)} onClick={() =>
handleOpenFileSelect(taskId, parameter.name)
}
src={fileSelectIcon} src={fileSelectIcon}
alt="" alt=""
className={styles.fileSelectImg} className={styles.fileSelectImg}
...@@ -292,7 +327,9 @@ const ParameterSetting = (props: IParameterSettingProps) => { ...@@ -292,7 +327,9 @@ const ParameterSetting = (props: IParameterSettingProps) => {
InputProps={{ InputProps={{
endAdornment: ( endAdornment: (
<img <img
onClick={() => handleOpenFileSelect(taskId, parameter.name)} onClick={() =>
handleOpenFileSelect(taskId, parameter.name)
}
src={fileSelectIcon} src={fileSelectIcon}
alt="" alt=""
className={styles.fileSelectImg} className={styles.fileSelectImg}
...@@ -311,7 +348,9 @@ const ParameterSetting = (props: IParameterSettingProps) => { ...@@ -311,7 +348,9 @@ const ParameterSetting = (props: IParameterSettingProps) => {
InputProps={{ InputProps={{
endAdornment: ( endAdornment: (
<img <img
onClick={() => handleOpenFileSelect(taskId, parameter.name)} onClick={() =>
handleOpenFileSelect(taskId, parameter.name)
}
src={fileSelectIcon} src={fileSelectIcon}
alt="" alt=""
className={styles.fileSelectImg} className={styles.fileSelectImg}
...@@ -398,7 +437,9 @@ const ParameterSetting = (props: IParameterSettingProps) => { ...@@ -398,7 +437,9 @@ const ParameterSetting = (props: IParameterSettingProps) => {
</div> </div>
</Tooltip> </Tooltip>
); );
}, []); },
[handleParameterChange]
);
// 输入参数 // 输入参数
const inParameters: Array<IParameter> = useMemo(() => { const inParameters: Array<IParameter> = useMemo(() => {
...@@ -463,7 +504,7 @@ const ParameterSetting = (props: IParameterSettingProps) => { ...@@ -463,7 +504,7 @@ const ParameterSetting = (props: IParameterSettingProps) => {
return ( return (
<div <div
className={styles.parameter} className={styles.parameter}
key={parameter.id || "" + parameterIndex} key={`${parameter.id}${parameterIndex}`}
> >
<div className={styles.parameterTop}> <div className={styles.parameterTop}>
<div className={styles.parameterLeft}> <div className={styles.parameterLeft}>
...@@ -509,44 +550,6 @@ const ParameterSetting = (props: IParameterSettingProps) => { ...@@ -509,44 +550,6 @@ const ParameterSetting = (props: IParameterSettingProps) => {
setFileSelectOpen(true); setFileSelectOpen(true);
}; };
const handleParameterChange = useCallback(
(e: any, parameterId: string) => {
console.log(e.target.value, taskId, parameterId);
const result: ITask[] = _.cloneDeep(templateConfigInfo);
console.log(result);
result.forEach((task) => {
if (task.id === taskId) {
let isCheck = true;
task.parameters.forEach((parameter) => {
if (parameter.id === parameterId) {
parameter.defaultValue = e.target.value;
const checkResult = getCustomTemplateParameterCheckResult(
parameter,
e.target.value
);
parameter.error = checkResult.error;
parameter.helperText = checkResult.helperText;
}
if (
getCustomTemplateParameterCheckResult(
parameter,
parameter.defaultValue
).error === true
) {
isCheck = false;
}
});
task.isCheck = isCheck;
} else {
return;
}
});
setTemplateConfigInfo(result);
// setParameter(e.target.value, taskId, parameterName);
},
[templateConfigInfo, setTemplateConfigInfo]
);
// 参数组tabs // 参数组tabs
const paramsTabList = useMemo(() => { const paramsTabList = useMemo(() => {
return [ return [
...@@ -631,7 +634,10 @@ const ParameterSetting = (props: IParameterSettingProps) => { ...@@ -631,7 +634,10 @@ const ParameterSetting = (props: IParameterSettingProps) => {
<div className={styles.paramsList}> <div className={styles.paramsList}>
{inParameters.map((parameter, index) => { {inParameters.map((parameter, index) => {
return ( return (
<div className={styles.inOutParameterBox} key={index}> <div
className={styles.inOutParameterBox}
key={`${parameter.id}${index}`}
>
<div className={styles.inOutParameterTop}> <div className={styles.inOutParameterTop}>
<div className={styles.inOutParameterleft}> <div className={styles.inOutParameterleft}>
<div <div
...@@ -666,9 +672,12 @@ const ParameterSetting = (props: IParameterSettingProps) => { ...@@ -666,9 +672,12 @@ const ParameterSetting = (props: IParameterSettingProps) => {
<div className={styles.inOutBox}> <div className={styles.inOutBox}>
<div className={styles.paramsTitle}>输出</div> <div className={styles.paramsTitle}>输出</div>
<div className={styles.paramsList}> <div className={styles.paramsList}>
{inParameters.map((parameter, index) => { {outParameters.map((parameter, index) => {
return ( return (
<div className={styles.inOutParameterBox} key={index}> <div
className={styles.inOutParameterBox}
key={`${parameter.id}${index}`}
>
<div className={styles.inOutParameterTop}> <div className={styles.inOutParameterTop}>
<div className={styles.inOutParameterleft}> <div className={styles.inOutParameterleft}>
<div <div
......
...@@ -23,6 +23,12 @@ export const getCustomTemplateParameterCheckResult = ( ...@@ -23,6 +23,12 @@ export const getCustomTemplateParameterCheckResult = (
} }
} }
} }
if (error) {
return {
error,
helperText,
};
}
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);
......
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