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
e1f562c5
Commit
e1f562c5
authored
Jul 26, 2022
by
潘际乾
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
表单v-if控制的tab显示后新增表单项的校验触发方式更改
parent
61c0f6b1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
3 deletions
+31
-3
commonProcess.js
src/mixin/commonProcess.js
+31
-3
No files found.
src/mixin/commonProcess.js
View file @
e1f562c5
...
@@ -21,7 +21,7 @@ export default {
...
@@ -21,7 +21,7 @@ export default {
},
},
mounted
()
{
mounted
()
{
if
(
!
this
.
isInDisplay
)
{
if
(
!
this
.
isInDisplay
)
{
this
.
ruleCheck
()
this
.
generateFormRules
()
}
}
},
},
methods
:
{
methods
:
{
...
@@ -29,7 +29,16 @@ export default {
...
@@ -29,7 +29,16 @@ export default {
* 表单校验 rules 的赋值
* 表单校验 rules 的赋值
* @returns void
* @returns void
*/
*/
ruleCheck
()
{
generateFormRules
()
{
if
(
this
.
root
)
{
if
(
!
this
.
root
.
rules
)
{
return
;
}
else
{
// 新添加的表单项,需要重新确定下 validator 的触发 trigger
this
.
updateRulesTrigger
();
return
}
}
if
(
!
this
.
pattern
)
if
(
!
this
.
pattern
)
return
return
// const keySet = new Set(Object.keys(this.pattern).concat(Object.keys(this.checkRules).concat(Object.keys(this.defaultRules))))
// const keySet = new Set(Object.keys(this.pattern).concat(Object.keys(this.checkRules).concat(Object.keys(this.defaultRules))))
...
@@ -76,7 +85,8 @@ export default {
...
@@ -76,7 +85,8 @@ export default {
* @returns
* @returns
*/
*/
getTriggerType
(
prop
)
{
getTriggerType
(
prop
)
{
const
fields
=
this
.
$refs
.
modelForm
.
fields
;
const
modelForm
=
this
.
root
?
this
.
root
.
$refs
.
modelForm
:
this
.
$refs
.
modelForm
const
fields
=
modelForm
.
fields
;
for
(
let
i
=
0
;
i
<
fields
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
fields
.
length
;
i
++
)
{
const
field
=
fields
[
i
];
const
field
=
fields
[
i
];
if
(
field
.
prop
===
prop
)
{
if
(
field
.
prop
===
prop
)
{
...
@@ -90,6 +100,24 @@ export default {
...
@@ -90,6 +100,24 @@ export default {
return
"blur"
;
return
"blur"
;
},
},
/**
/**
* 表单有些 tab 是通过 v-if 控制的,这些表单项初始时的 trigger 均为 blur,需要手动更新
*/
updateRulesTrigger
()
{
const
rules
=
this
.
root
.
rules
for
(
const
key
in
rules
)
{
if
(
Object
.
hasOwnProperty
.
call
(
rules
,
key
))
{
const
rule
=
rules
[
key
];
const
triggerType
=
this
.
getTriggerType
(
key
)
for
(
let
i
=
0
;
i
<
rule
.
length
;
i
++
)
{
const
r
=
rule
[
i
];
if
(
r
.
validator
&&
r
.
trigger
!==
triggerType
)
{
r
.
trigger
=
triggerType
;
}
}
}
}
},
/**
* Tabs切换事件
* Tabs切换事件
* @param {VM} tab
* @param {VM} 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