Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DiDi
cube-ui
提交
92e790e5
C
cube-ui
项目概览
DiDi
/
cube-ui
12 个月 前同步成功
通知
34
Star
9078
Fork
1508
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
cube-ui
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
92e790e5
编写于
8月 21, 2018
作者:
D
dolymood
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(form): item validator validate sync
上级
624524ac
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
19 addition
and
22 deletion
+19
-22
src/components/form/form-item.vue
src/components/form/form-item.vue
+19
-22
未找到文件。
src/components/form/form-item.vue
浏览文件 @
92e790e5
...
...
@@ -11,6 +11,7 @@
v-model=
"originValid"
:disabled=
"validatorDisabled"
:model=
"validatorModel"
:model-key=
"validatorModelKey"
:rules=
"fieldValue.rules"
:messages=
"fieldValue.messages"
@
input=
"validatorChangeHandler"
...
...
@@ -59,12 +60,16 @@
}
},
data
()
{
const
validatorModelKey
=
'
value
'
const
modelKey
=
this
.
field
.
modelKey
const
modelValue
=
modelKey
?
this
.
form
.
model
[
modelKey
]
:
null
return
{
validatorDisabled
:
false
,
validatorModelKey
,
modelValue
:
modelValue
,
validatorModel
:
modelValue
validatorModel
:
{
[
validatorModelKey
]:
modelValue
}
}
},
computed
:
{
...
...
@@ -112,10 +117,13 @@
this
.
modelValue
=
newModel
}
},
modelValue
(
newModel
)
{
// update form model
this
.
form
.
model
[
this
.
fieldValue
.
modelKey
]
=
newModel
this
.
updateValidatorModel
()
modelValue
:
{
handler
(
newModel
)
{
// update form model
this
.
form
.
model
[
this
.
fieldValue
.
modelKey
]
=
newModel
this
.
updateValidatorModel
()
},
sync
:
true
},
originValid
(
newVal
)
{
this
.
lastOriginValid
=
newVal
...
...
@@ -144,22 +152,11 @@
if
((
!
debounceTime
&&
debounceTime
!==
0
)
||
debounceTime
<
0
||
this
.
fieldValue
.
trigger
===
'
blur
'
)
return
this
.
getValidatorModel
=
debounce
((
modelValue
)
=>
{
this
.
pending
=
false
this
.
validatorModel
=
modelValue
this
.
validatorModel
[
this
.
validatorModelKey
]
=
modelValue
this
.
form
.
updatePending
()
this
.
asyncSameCheck
()
this
.
validate
()
return
modelValue
},
debounceTime
,
false
,
this
.
validatorModel
)
},
asyncSameCheck
()
{
const
validator
=
this
.
$refs
.
validator
const
validatorModel
=
this
.
validatorModel
if
(
validator
)
{
// same value, Vue do not trigger watch handler
// so need to force validate
if
(
validatorModel
===
validator
.
model
)
{
validator
&&
validator
.
validate
()
}
}
},
debounceTime
,
false
,
this
.
validatorModel
[
this
.
validatorModelKey
])
},
focusInHandler
()
{
this
.
focused
=
true
...
...
@@ -167,7 +164,7 @@
focusOutHandler
()
{
this
.
focused
=
false
this
.
updateValidatorModel
()
this
.
asyncSameCheck
()
this
.
validate
()
},
initFocusEvents
()
{
if
(
this
.
fieldValue
.
trigger
===
'
blur
'
)
{
...
...
@@ -176,7 +173,7 @@
formItem
.
addEventListener
(
EVENT_FOCUSOUT
,
this
.
focusOutHandler
,
false
)
this
.
getValidatorModel
=
(
modelValue
)
=>
{
if
(
this
.
focused
)
{
return
this
.
validatorModel
return
this
.
validatorModel
[
this
.
validatorModelKey
]
}
else
{
this
.
pending
=
false
this
.
form
.
updatePending
()
...
...
@@ -192,7 +189,7 @@
},
updateValidatorModel
()
{
this
.
pending
=
true
this
.
validatorModel
=
this
.
getValidatorModel
(
this
.
modelValue
)
this
.
validatorModel
[
this
.
validatorModelKey
]
=
this
.
getValidatorModel
(
this
.
modelValue
)
if
(
this
.
pending
)
{
this
.
form
.
setPending
(
this
.
pending
)
this
.
originValid
=
undefined
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录