Commit 5342de1f authored by chenshouchao's avatar chenshouchao

fix: 解决自定义模板保存校验错误的问题

parent 9592bb2f
...@@ -46,7 +46,10 @@ const FileSelect = observer((props: FileSelectProps) => { ...@@ -46,7 +46,10 @@ const FileSelect = observer((props: FileSelectProps) => {
const [keyWord, setKeyWord] = useState(""); const [keyWord, setKeyWord] = useState("");
const fileSelectOnConfirm = () => { const fileSelectOnConfirm = () => {
onConfirm(path); console.log(path);
console.log(selectFileName);
console.log(selectItem);
// onConfirm(path);
}; };
// 搜索值改变 // 搜索值改变
...@@ -57,14 +60,6 @@ const FileSelect = observer((props: FileSelectProps) => { ...@@ -57,14 +60,6 @@ const FileSelect = observer((props: FileSelectProps) => {
setKeyWord(e.target.value); setKeyWord(e.target.value);
}; };
// 按回车搜索
// const handleKeyWordChangeKeyUp = (e: any) => {
// if (e.keyCode === 13) {
// searchFileList();
// getDataSetListSearch();
// }
// };
// 文件夹下钻 // 文件夹下钻
const handleViewFolders = (item: any) => { const handleViewFolders = (item: any) => {
if (debounce) { if (debounce) {
...@@ -250,7 +245,6 @@ const FileSelect = observer((props: FileSelectProps) => { ...@@ -250,7 +245,6 @@ const FileSelect = observer((props: FileSelectProps) => {
} else if (type === "dataset") { } else if (type === "dataset") {
return [...folderList, ...dataSetList]; return [...folderList, ...dataSetList];
} else { } else {
// type === path
return [...folderList]; return [...folderList];
} }
}, [list, dataSetList, type]); }, [list, dataSetList, type]);
...@@ -310,7 +304,6 @@ const FileSelect = observer((props: FileSelectProps) => { ...@@ -310,7 +304,6 @@ const FileSelect = observer((props: FileSelectProps) => {
: index > pathArr.length - 4 : index > pathArr.length - 4
? item ? item
: ""} : ""}
{/* && index > pathArr.length - 4 */}
{index === pathArr.length - 1 || {index === pathArr.length - 1 ||
(index <= pathArr.length - 4 && index > 0) ? null : ( (index <= pathArr.length - 4 && index > 0) ? null : (
<i className={style.showPathI}>{">"}</i> <i className={style.showPathI}>{">"}</i>
...@@ -346,7 +339,6 @@ const FileSelect = observer((props: FileSelectProps) => { ...@@ -346,7 +339,6 @@ const FileSelect = observer((props: FileSelectProps) => {
getDataSetList(); getDataSetList();
} }
} }
// type?: "file" | "dataset" | "path";
}, [ }, [
type, type,
keyWord, keyWord,
......
...@@ -121,26 +121,30 @@ const WorkFlowEdit = observer((props: IProps) => { ...@@ -121,26 +121,30 @@ const WorkFlowEdit = observer((props: IProps) => {
error: true, error: true,
helperText: "必须输入模板名称", helperText: "必须输入模板名称",
}); });
return false;
} else if (title.length > 15) { } else if (title.length > 15) {
setTitleHelper({ setTitleHelper({
error: true, error: true,
helperText: "格式不正确,必须在15字符以内,仅限大小写字母、数字、中文", helperText: "格式不正确,必须在15字符以内,仅限大小写字母、数字、中文",
}); });
return false;
} else if (!checkIsNumberLetterChinese(title)) { } else if (!checkIsNumberLetterChinese(title)) {
setTitleHelper({ setTitleHelper({
error: true, error: true,
helperText: "格式不正确,必须在15字符以内,仅限大小写字母、数字、中文", helperText: "格式不正确,必须在15字符以内,仅限大小写字母、数字、中文",
}); });
return false;
} else { } else {
setTitleHelper({ setTitleHelper({
error: false, error: false,
helperText: "", helperText: "",
}); });
return true;
} }
}; };
// 校验新版本号是否大于旧版本号 // 校验新版本号是否大于旧版本号
const checkNewOldVersion = (version: string, oldversion: string) => { const checkNewOldVersion = (version: string, oldversion: string): boolean => {
let versionArr: any[] = version.split("."); let versionArr: any[] = version.split(".");
let oldversionArr: any[] = oldversion.split("."); let oldversionArr: any[] = oldversion.split(".");
versionArr = versionArr.map((item) => Number(item)); versionArr = versionArr.map((item) => Number(item));
...@@ -152,6 +156,7 @@ const WorkFlowEdit = observer((props: IProps) => { ...@@ -152,6 +156,7 @@ const WorkFlowEdit = observer((props: IProps) => {
helperText: helperText:
"新版本号必须大于老版本号,且必须为X.Y.Z格式,XYZ必须为0~99的正整数", "新版本号必须大于老版本号,且必须为X.Y.Z格式,XYZ必须为0~99的正整数",
}); });
return false;
} else if (versionArr[0] === oldversionArr[0]) { } else if (versionArr[0] === oldversionArr[0]) {
if (versionArr[1] < oldversionArr[1]) { if (versionArr[1] < oldversionArr[1]) {
setVersionHelper({ setVersionHelper({
...@@ -159,6 +164,7 @@ const WorkFlowEdit = observer((props: IProps) => { ...@@ -159,6 +164,7 @@ const WorkFlowEdit = observer((props: IProps) => {
helperText: helperText:
"新版本号必须大于老版本号,且必须为X.Y.Z格式,XYZ必须为0~99的正整数", "新版本号必须大于老版本号,且必须为X.Y.Z格式,XYZ必须为0~99的正整数",
}); });
return false;
} else if (versionArr[1] === oldversionArr[1]) { } else if (versionArr[1] === oldversionArr[1]) {
if (versionArr[2] <= oldversionArr[2]) { if (versionArr[2] <= oldversionArr[2]) {
setVersionHelper({ setVersionHelper({
...@@ -166,9 +172,11 @@ const WorkFlowEdit = observer((props: IProps) => { ...@@ -166,9 +172,11 @@ const WorkFlowEdit = observer((props: IProps) => {
helperText: helperText:
"新版本号必须大于老版本号,且必须为X.Y.Z格式,XYZ必须为0~99的正整数", "新版本号必须大于老版本号,且必须为X.Y.Z格式,XYZ必须为0~99的正整数",
}); });
return false;
} }
} }
} }
return true;
}; };
// 校验版本号格式 // 校验版本号格式
...@@ -179,13 +187,18 @@ const WorkFlowEdit = observer((props: IProps) => { ...@@ -179,13 +187,18 @@ const WorkFlowEdit = observer((props: IProps) => {
helperText: "", helperText: "",
}); });
if (oldversion) { if (oldversion) {
checkNewOldVersion(version, oldversion); if (checkNewOldVersion(version, oldversion)) {
return true;
} else {
return false;
}
} }
} else { } else {
setVersionHelper({ setVersionHelper({
error: true, error: true,
helperText: "格式不正确,必须为X.Y.Z格式,且XYZ必须为0~99的正整数", helperText: "格式不正确,必须为X.Y.Z格式,且XYZ必须为0~99的正整数",
}); });
return false;
} }
}; };
...@@ -276,7 +289,7 @@ const WorkFlowEdit = observer((props: IProps) => { ...@@ -276,7 +289,7 @@ const WorkFlowEdit = observer((props: IProps) => {
const handleOncofirm = () => { const handleOncofirm = () => {
checkTitle(title); checkTitle(title);
checkVersion(version); checkVersion(version);
if (!titleHelper.error && !versionHelper.error) { if (checkTitle(title) && checkVersion(version)) {
saveUserSpecRun({ saveUserSpecRun({
title, title,
version, version,
......
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