 import {formControlTpl} from './formTpl';
 const formNode = '.J_formContent';
 
 class BaseFormControl {
     constructor(config) {
         this.element = $(formControlTpl);
         if (config) {
             this.config = this._getConfig(config);
         }
     }
 
     
     _getConfig(config) {
         return $.extend(true, {}, {
             domData: {}
         }, config);
     }
 
     appendFormControl(dom) {
         
         if (this.config.domData.title) {
             this.element.find('.cd-title').html(this.config.domData.title);
         } else {
             this.element.find('.cd-title').hide();
         }
 
         if (this.config.domData.tip) {
             this.element.find('.cd-tips').html(this.config.domData.tip);
         } else {
             this.element.find('.cd-tips').hide();
         }
 
         this.element.find('.cd-body').html(dom);
 
         if (this.config.domData.validate && this.config.domData.validate.must) {
             this.element.find('.cd-title').addClass('cd-required');
         }
         
         if (this.config.domData.node) {
             $(this.config.domData.node).append(this.element);
         } else {
             if (this.config.formContent) {
                 this.config.formContent.find(formNode).append(this.element);
             } else {
                 $(formNode).length && $(formNode).append(this.element);
             }
         }
     }
 
     
     render() {
         throw new Error('没有覆盖render方法!');
     }
 
     
     setData() {
     }
 
     
     getValue(key) {
         let data = this.getData();
         if (data) {
             if (key) {
                 return data[key];
             }
             else if (this.config.domData && this.config.domData.name) {
                 return data[this.config.domData.name];
             }
         }
         return null;
     }
 
     
     getData() {
         throw new Error('没有覆盖getData方法!');
     }
 
     
     validateData() {
     }
 
     
     dispose() {
 
 
     }
 }
 
 export default BaseFormControl;
 