diff --git a/src/components/form-designer/form-widget/field-widget/fieldMixin.js b/src/components/form-designer/form-widget/field-widget/fieldMixin.js index 5b9a399..0531a09 100644 --- a/src/components/form-designer/form-widget/field-widget/fieldMixin.js +++ b/src/components/form-designer/form-widget/field-widget/fieldMixin.js @@ -27,7 +27,7 @@ export default { //--------------------- 组件内部方法 begin ------------------// initFieldModel() { - if (this.field.formItemFlag === false) { + if (!this.field.formItemFlag) { return } @@ -175,10 +175,18 @@ export default { }, clearFieldRules() { + if (!this.field.formItemFlag) { + return + } + this.rules.splice(0, this.rules.length) //清空已有 }, buildFieldRules() { + if (!this.field.formItemFlag) { + return + } + this.rules.splice(0, this.rules.length) //清空已有 if (!!this.field.options.required) { this.rules.push({ @@ -326,6 +334,9 @@ export default { handleInputCustomEvent(value) { this.syncUpdateFormModel(value) + /* 主动触发表单的单个字段校验,用于清除字段可能存在的校验错误提示 */ + this.dispatch('VFormRender', 'fieldValidation', [this.field.options.name]) + if (!!this.field.options.onInput) { let customFn = new Function('value', this.field.options.onInput) customFn.call(this, value) @@ -529,6 +540,14 @@ export default { this.customToolbar = customToolbar }, + /** + * 是否子表单内嵌的组件 + * @returns {boolean} + */ + isSubFormItem() { + return !!this.parentWidget ? this.parentWidget.type === 'sub-form' : false + } + //--------------------- 以上为组件支持外部调用的API方法 end ------------------// } diff --git a/src/components/form-render/container-item/container-item-wrapper.vue b/src/components/form-render/container-item/container-item-wrapper.vue index f5a9399..07a6bf0 100644 --- a/src/components/form-render/container-item/container-item-wrapper.vue +++ b/src/components/form-render/container-item/container-item-wrapper.vue @@ -18,7 +18,10 @@ export default { name: "container-item-wrapper", props: { - widget: Object, + widget: { + type: Object, + required: true + } }, computed: { customClass() {