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
2f3d326e
Commit
2f3d326e
authored
Apr 14, 2023
by
李少勇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改前端校验失败不展开收缩框问题
parent
7ed79ee0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
25 deletions
+40
-25
operationFunc.js
src/mixin/operationFunc.js
+40
-25
No files found.
src/mixin/operationFunc.js
View file @
2f3d326e
...
...
@@ -88,36 +88,50 @@ export default {
message
:
'校验失败'
,
type
:
'error'
,
});
this
.
$nextTick
(()
=>
{
console
.
log
(
'========'
,
this
.
$refs
[
'modelForm'
])
let
isError
=
document
.
querySelectorAll
(
'.is-error'
)
let
fields
=
this
.
$refs
[
'modelForm'
].
fields
fields
.
map
((
fieldItem
)
=>
{
if
(
fieldItem
.
validateState
===
'error'
)
{
let
errorComponentName
=
fieldItem
.
$options
.
componentName
// console.log('fieldItem===', fieldItem)
// 切换tab
if
(
errorComponentName
===
'ElTabPane'
)
{
fieldItem
.
$parent
.
currentName
=
fieldItem
.
name
// 切换收缩框
}
else
if
(
errorComponentName
===
'ElCollapseItem'
)
{
if
(
fieldItem
.
collapse
.
activeNames
.
indexOf
(
fieldItem
.
name
)
<
0
)
{
fieldItem
.
collapse
.
activeNames
.
push
(
fieldItem
.
name
)
}
}
}
})
isError
[
0
].
scrollIntoView
({
block
:
'center'
,
behavior
:
'smooth'
})
})
this
.
showFrontendErrors
()
}
})
})
},
// 前端校验失败时候,tab和Collapse组件效果处理
showFrontendErrors
()
{
this
.
$nextTick
(()
=>
{
let
fields
=
this
.
$refs
[
'modelForm'
].
fields
fields
.
map
((
fieldItem
)
=>
{
if
(
fieldItem
.
validateState
===
'error'
)
{
let
parentVC
=
fieldItem
let
firstErrorTab
=
null
let
collapsePanel
=
null
while
(
!
firstErrorTab
)
{
const
vcName
=
parentVC
.
$options
.
componentName
// 没有Tabs的表单
if
(
vcName
===
"ElForm"
)
{
break
;
}
if
(
vcName
===
"ElTabPane"
)
{
firstErrorTab
=
parentVC
break
;
}
if
(
vcName
===
"ElCollapseItem"
)
{
collapsePanel
=
parentVC
;
}
parentVC
=
parentVC
.
$parent
;
}
if
(
firstErrorTab
)
{
const
tabs
=
firstErrorTab
.
$parent
tabs
.
currentName
=
firstErrorTab
.
name
}
if
(
collapsePanel
&&
collapsePanel
.
collapse
.
activeNames
.
indexOf
(
collapsePanel
.
name
)
<
0
)
{
collapsePanel
.
collapse
.
activeNames
.
push
(
collapsePanel
.
name
)
}
}
})
let
isError
=
document
.
querySelectorAll
(
'.is-error'
)
isError
[
0
].
scrollIntoView
({
block
:
'center'
,
behavior
:
'smooth'
})
})
},
// 后端校验
showBackendErrors
(
fieldErrors
)
{
...
...
@@ -132,6 +146,7 @@ export default {
this
.
isChecking
=
false
;
}
const
fields
=
this
.
$refs
.
modelForm
.
fields
;
console
.
log
(
'backFileds'
,
fields
)
const
tab
=
Utils
.
positioningErrorMsg
(
fieldErrors
,
fields
);
return
tab
;
},
...
...
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