Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
B
bkunyun
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
bkunyun
Commits
f395b90d
Commit
f395b90d
authored
Jul 14, 2022
by
chenshouchao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 解决版本校验错误问题
parent
f637e0cd
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
23 deletions
+14
-23
index.tsx
src/views/WorkFlowEdit/index.tsx
+14
-23
No files found.
src/views/WorkFlowEdit/index.tsx
View file @
f395b90d
...
...
@@ -115,7 +115,7 @@ const WorkFlowEdit = observer((props: IProps) => {
},
[
id
,
fetchTemplateConfigInfoRun
]);
// 校验模板名称
const
checkTitle
=
(
title
:
string
)
=>
{
const
checkTitle
=
()
=>
{
if
(
!
title
)
{
setTitleHelper
({
error
:
true
,
...
...
@@ -140,11 +140,12 @@ const WorkFlowEdit = observer((props: IProps) => {
};
// 校验新版本号是否大于旧版本号
const
checkNewOldVersion
=
useCallback
(()
=>
{
let
versionArr
=
version
.
split
(
"."
);
let
oldversionArr
=
oldversion
.
split
(
"."
);
versionArr
.
map
((
item
)
=>
Number
(
item
));
oldversionArr
.
map
((
item
)
=>
Number
(
item
));
const
checkNewOldVersion
=
(
version
:
string
,
oldversion
:
string
)
=>
{
let
versionArr
:
any
[]
=
version
.
split
(
"."
);
let
oldversionArr
:
any
[]
=
oldversion
.
split
(
"."
);
versionArr
=
versionArr
.
map
((
item
)
=>
Number
(
item
));
oldversionArr
=
oldversionArr
.
map
((
item
)
=>
Number
(
item
));
if
(
versionArr
[
0
]
<
oldversionArr
[
0
])
{
setVersionHelper
({
error
:
true
,
...
...
@@ -161,7 +162,7 @@ const WorkFlowEdit = observer((props: IProps) => {
});
return
false
;
}
else
if
(
versionArr
[
1
]
===
oldversionArr
[
1
])
{
if
(
versionArr
[
2
]
<
oldversionArr
[
2
])
{
if
(
versionArr
[
2
]
<
=
oldversionArr
[
2
])
{
setVersionHelper
({
error
:
true
,
helperText
:
...
...
@@ -172,27 +173,17 @@ const WorkFlowEdit = observer((props: IProps) => {
}
}
return
true
;
}
,
[
version
,
oldversion
])
;
};
// 校验版本号格式
const
checkVersion
=
(
version
:
string
)
=>
{
const
versionArr
=
version
.
split
(
"."
);
if
(
oldversion
)
{
if
(
!
checkNewOldVersion
())
{
if
(
!
checkNewOldVersion
(
version
,
oldversion
))
{
return
;
}
}
const
reg
=
new
RegExp
(
"^([0-9]|[0-9]
\\
d)$"
);
if
(
versionArr
.
length
!==
3
)
{
setVersionHelper
({
error
:
true
,
helperText
:
"格式不正确,必须为X.Y.Z格式,且XYZ必须为0~99的正整数"
,
});
}
else
if
(
versionArr
.
every
((
item
)
=>
{
return
reg
.
test
(
item
);
})
)
{
console
.
log
(
version
);
if
(
/^
[
1-9
]\d?(\.(
0|
[
1-9
]\d?)){2}
$/
.
test
(
version
))
{
setVersionHelper
({
error
:
false
,
helperText
:
""
,
...
...
@@ -209,7 +200,7 @@ const WorkFlowEdit = observer((props: IProps) => {
const
handleTitleChange
=
(
e
:
any
)
=>
{
const
title
=
e
.
target
.
value
;
setTitle
(
title
);
checkTitle
(
title
);
checkTitle
();
// 格式不正确,必须在15字符以内,仅限大小写字母、数字、中文
};
...
...
@@ -290,7 +281,7 @@ const WorkFlowEdit = observer((props: IProps) => {
// 表单弹窗确定,新建/编辑自定义模板保存
const
handleOncofirm
=
()
=>
{
checkTitle
(
title
);
checkTitle
();
checkVersion
(
version
);
if
(
!
titleHelper
.
error
&&
!
versionHelper
.
error
)
{
saveUserSpecRun
({
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment