diff --git a/package.json b/package.json index e29653abf3b8412710e67562b22982ee810ca305..13e936dde8192223dd94e6c3dadcb1a8c6db9181 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "apollo_form_pase", - "version": "0.0.3", + "version": "0.0.4", "description": "", "main": "dist/index.js", "module": "dist/index.esm.js", diff --git a/src/index.js b/src/index.js index 5f89fd0755b3b6d775f0ca288bb3e9db2178499e..f46e8f86ab61aa5d714d22593a3fdcf502d11aac 100644 --- a/src/index.js +++ b/src/index.js @@ -1,13 +1,14 @@ import { HandleClass } from './behavior'; class HandleBehavior { constructor(props) { - this.formData = null; + this.formData = props.formData || null; } initBehavior = (formData) => { if (!this.formData) { this.formData = formData } if (!this.formData) return + this.hiddenFilds(); this.formData.map(item => { if (!item.behaviors || !Array.isArray(item.behaviors) || item.behaviors.length === 0) return; const value = this.handleFormaterValue(item.value, item); @@ -16,7 +17,6 @@ class HandleBehavior { return this; } getFormData = () => { - return this.formData } @@ -60,5 +60,8 @@ class HandleBehavior { const componentData = this.formData.find(ls => ls.name === key) || {}; this.handleBehavior({ currentValue: value, componentData }) } + hiddenFilds = () => { + this.formData = this.formData.filter(item => item.type !== 'hidden') + } } export default HandleBehavior