Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
vue-gjjs
Overview
Overview
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
fukai
vue-gjjs
Commits
60c6413e
Commit
60c6413e
authored
Apr 12, 2023
by
李少勇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
校验方法优化
parent
7964a004
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
46 deletions
+48
-46
check.js
src/business/gitopn/model/check.js
+1
-1
operationFunc.js
src/mixin/operationFunc.js
+47
-45
No files found.
src/business/gitopn/model/check.js
View file @
60c6413e
...
@@ -1054,7 +1054,7 @@ export default {
...
@@ -1054,7 +1054,7 @@ export default {
"gidgrp.rec.atxinr"
:
null
,
"gidgrp.rec.atxinr"
:
null
,
"gidgrp.rec.secuilflg"
:
null
,
"gidgrp.rec.secuilflg"
:
null
,
"gidgrp.cbs.max.cur"
:
[
"gidgrp.cbs.max.cur"
:
[
{
required
:
true
,
message
:
"此字段为必填字段"
,
trigger
:
'
blur
'
}
{
required
:
true
,
message
:
"此字段为必填字段"
,
trigger
:
'
change
'
}
],
],
"gidgrp.rec.fingua"
:
[
"gidgrp.rec.fingua"
:
[
{
required
:
true
,
message
:
"是否对外担保不能为空"
,
trigger
:
'change'
}
{
required
:
true
,
message
:
"是否对外担保不能为空"
,
trigger
:
'change'
}
...
...
src/mixin/operationFunc.js
View file @
60c6413e
// 此文件存放交易流转的一些公共方法
// 此文件存放交易流转的一些公共方法
import
Api
from
'~/service/Api'
;
import
Api
from
'~/service/Api'
;
import
Utils
from
"../utils"
export
default
{
export
default
{
data
()
{
return
{
validEdRules
:
[]
}
},
methods
:
{
methods
:
{
// 提交
// 提交
handleSubmit
()
{
handleSubmit
()
{
...
@@ -51,16 +47,6 @@ export default {
...
@@ -51,16 +47,6 @@ export default {
// 检核
// 检核
handleCheck
()
{
handleCheck
()
{
return
new
Promise
((
resolve
)
=>
{
return
new
Promise
((
resolve
)
=>
{
// 第二次点击校验时候,如果执行过后端接口校验,则需要先在rules中让之前后端校验通过,然后再把校验规则置为不校验即null
if
(
this
.
validEdRules
.
length
)
{
this
.
validEdRules
.
map
((
item
)
=>
{
this
.
rules
[
item
]
=
[{
validator
:
(
rule
,
value
,
callback
)
=>
{
callback
()
}
}]
})
}
// 前端检验
// 前端检验
this
.
$refs
[
'modelForm'
].
validate
(
async
(
validStatic
)
=>
{
this
.
$refs
[
'modelForm'
].
validate
(
async
(
validStatic
)
=>
{
if
(
validStatic
)
{
if
(
validStatic
)
{
...
@@ -73,53 +59,69 @@ export default {
...
@@ -73,53 +59,69 @@ export default {
if
(
rtnmsg
.
respCode
===
SUCCESS
)
{
if
(
rtnmsg
.
respCode
===
SUCCESS
)
{
let
errorRules
=
rtnmsg
.
data
;
let
errorRules
=
rtnmsg
.
data
;
let
keysList
=
Object
.
keys
(
errorRules
)
let
keysList
=
Object
.
keys
(
errorRules
)
this
.
validEdRules
=
Object
.
keys
(
errorRules
)
// 如果后端返回的对象为空,则后端校验成功
// 二次点击校验让之前校验的规则置为null
if
(
errorRules
&&
!
keysList
.
length
)
{
if
(
this
.
validEdRules
.
length
)
{
// 清除之前的校验状态
this
.
validEdRules
.
map
((
item
)
=>
{
this
.
$refs
[
'modelForm'
].
clearValidate
();
this
.
rules
[
item
]
=
null
})
}
keysList
.
map
((
ruleKey
)
=>
{
this
.
rules
[
ruleKey
]
=
[
{
validator
:
(
rule
,
value
,
callback
)
=>
{
if
(
errorRules
[
ruleKey
])
{
callback
(
new
Error
(
errorRules
[
ruleKey
]));
}
}
},
];
});
// 后端校验
this
.
$refs
[
'modelForm'
].
validate
((
valid
)
=>
{
if
(
valid
)
{
this
.
$notify
({
this
.
$notify
({
title
:
'成功'
,
title
:
"成功"
,
message
:
'校验成功'
,
message
:
"校验成功"
,
type
:
'success'
,
type
:
"success"
,
});
});
resolve
()
resolve
()
}
else
{
loading
.
close
();
return
}
const
tab
=
this
.
showBackendErrors
(
errorRules
)
if
(
tab
)
{
// tab切换之后,需出发tab-click的事件
if
(
tab
.
name
!==
this
.
tabVal
)
{
this
.
isChecking
=
true
this
.
tabClick
(
tab
);
}
this
.
$notify
({
this
.
$notify
({
title
:
'失败'
,
title
:
"错误"
,
message
:
'校验失败'
,
message
:
"校核失败"
,
type
:
'error'
,
type
:
"error"
,
});
});
loading
.
close
();
return
}
}
});
}
}
loading
.
close
();
}
else
{
}
else
{
// 前端校验失败
this
.
$notify
({
this
.
$notify
({
title
:
'失败'
,
title
:
'失败'
,
message
:
'校验失败'
,
message
:
'校验失败'
,
type
:
'error'
,
type
:
'error'
,
});
});
this
.
$nextTick
(()
=>
{
let
isError
=
document
.
querySelectorAll
(
'.is-error'
)
isError
[
0
].
scrollIntoView
({
block
:
'center'
,
behavior
:
'smooth'
})
})
}
}
})
})
})
})
},
},
// 后端校验
showBackendErrors
(
fieldErrors
)
{
// 清除之前的校验状态
if
(
!
this
.
$refs
.
modelForm
)
{
return
}
if
(
!
this
.
isChecking
)
{
this
.
$refs
.
modelForm
.
clearValidate
();
}
else
{
// 当 checkAll 操作时,由面板切换所触发的 executeRule 请求时,不清空 checkAll 的错误信息
this
.
isChecking
=
false
;
}
const
fields
=
this
.
$refs
.
modelForm
.
fields
;
const
tab
=
Utils
.
positioningErrorMsg
(
fieldErrors
,
fields
);
return
tab
;
},
// 暂存
// 暂存
async
handleStash
()
{
async
handleStash
()
{
const
loading
=
this
.
loading
(
'正在暂存数据'
);
const
loading
=
this
.
loading
(
'正在暂存数据'
);
...
...
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