Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
梁建民
/
scm_app
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
6da1867e
authored
May 07, 2026
by
liangjianmin
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
fix(apply): 优化表单验证逻辑以提高可读性和维护性
重构 validateForm 方法,使用规则数组简化验证逻辑,减少重复代码。
parent
161df589
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
32 deletions
pages/apply/index.vue
pages/apply/index.vue
View file @
6da1867e
...
...
@@ -166,42 +166,23 @@
*/
validateForm
()
{
var
{
apply_type
,
order_sn
,
customer_name
,
apply_fee_amount
,
relief_detail
,
relief_reason
}
=
this
.
form
;
if
(
!
apply_type
)
{
this
.
errorMsg
=
'请选择申请类型'
;
return
false
;
}
if
(
!
order_sn
)
{
this
.
errorMsg
=
'请输入订单号'
;
return
false
;
}
if
(
!
apply_fee_amount
)
{
this
.
errorMsg
=
'请输入申请免收金额'
;
return
false
;
}
if
(
isNaN
(
apply_fee_amount
)
||
Number
(
apply_fee_amount
)
<=
0
)
{
this
.
errorMsg
=
'请输入有效的申请免收金额'
;
return
false
;
}
if
(
!
relief_detail
)
{
this
.
errorMsg
=
'请选择减免明细'
;
return
false
;
}
if
(
!
relief_reason
)
{
this
.
errorMsg
=
'请输入免收原因'
;
var
rules
=
[
{
invalid
:
!
apply_type
,
msg
:
'请选择申请类型'
},
{
invalid
:
!
order_sn
,
msg
:
'请输入订单号'
},
{
invalid
:
!
apply_fee_amount
,
msg
:
'请输入申请免收金额'
},
{
invalid
:
isNaN
(
apply_fee_amount
)
||
Number
(
apply_fee_amount
)
<=
0
,
msg
:
'请输入有效的申请免收金额'
},
{
invalid
:
!
relief_detail
,
msg
:
'请选择减免明细'
},
{
invalid
:
!
relief_reason
,
msg
:
'请输入免收原因'
},
{
invalid
:
!
customer_name
,
msg
:
'请输入有效的订单号以获取客户名称'
}
];
var
failedRule
=
rules
.
find
(
rule
=>
rule
.
invalid
);
if
(
failedRule
)
{
this
.
errorMsg
=
failedRule
.
msg
;
return
false
;
}
if
(
!
customer_name
)
{
this
.
errorMsg
=
'请输入有效的订单号以获取客户名称'
;
return
false
;
}
this
.
errorMsg
=
''
;
return
true
;
},
...
...
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