解决input字段组件的校验提示不会自动清除的问题。

master
vdpAdmin 2021-12-28 15:30:05 +08:00
parent 4ccff6e219
commit 3b49bc5fb7
2 changed files with 24 additions and 2 deletions

View File

@ -27,7 +27,7 @@ export default {
//--------------------- 组件内部方法 begin ------------------// //--------------------- 组件内部方法 begin ------------------//
initFieldModel() { initFieldModel() {
if (this.field.formItemFlag === false) { if (!this.field.formItemFlag) {
return return
} }
@ -175,10 +175,18 @@ export default {
}, },
clearFieldRules() { clearFieldRules() {
if (!this.field.formItemFlag) {
return
}
this.rules.splice(0, this.rules.length) //清空已有 this.rules.splice(0, this.rules.length) //清空已有
}, },
buildFieldRules() { buildFieldRules() {
if (!this.field.formItemFlag) {
return
}
this.rules.splice(0, this.rules.length) //清空已有 this.rules.splice(0, this.rules.length) //清空已有
if (!!this.field.options.required) { if (!!this.field.options.required) {
this.rules.push({ this.rules.push({
@ -326,6 +334,9 @@ export default {
handleInputCustomEvent(value) { handleInputCustomEvent(value) {
this.syncUpdateFormModel(value) this.syncUpdateFormModel(value)
/* 主动触发表单的单个字段校验,用于清除字段可能存在的校验错误提示 */
this.dispatch('VFormRender', 'fieldValidation', [this.field.options.name])
if (!!this.field.options.onInput) { if (!!this.field.options.onInput) {
let customFn = new Function('value', this.field.options.onInput) let customFn = new Function('value', this.field.options.onInput)
customFn.call(this, value) customFn.call(this, value)
@ -529,6 +540,14 @@ export default {
this.customToolbar = customToolbar this.customToolbar = customToolbar
}, },
/**
* 是否子表单内嵌的组件
* @returns {boolean}
*/
isSubFormItem() {
return !!this.parentWidget ? this.parentWidget.type === 'sub-form' : false
}
//--------------------- 以上为组件支持外部调用的API方法 end ------------------// //--------------------- 以上为组件支持外部调用的API方法 end ------------------//
} }

View File

@ -18,7 +18,10 @@
export default { export default {
name: "container-item-wrapper", name: "container-item-wrapper",
props: { props: {
widget: Object, widget: {
type: Object,
required: true
}
}, },
computed: { computed: {
customClass() { customClass() {