 import BaseFormControl from '../../baseFormControl';
 import JDInput from '../../formType/input';
 import JDLink from '../../formType/link';
 import { LinkTextTpl } from './tpl'
 
 class LinkText extends BaseFormControl {
     constructor(config) {
         super(config);
         this.render();
     }
 
     
     _getConfig(config) {
         return $.extend(true, {}, {
             domData: {},
             moduleData: {}
         }, config);
     }
 
     
     render() {
         const { moduleData, domData } = this.config;
         const validate = domData.validate || {};
         const placeholder = domData.placeholder || '请输入文本';
         if (page_data.appType === 5 && domData.noConfig == true) {
             validate.maxLength == 10 ? placeholder = `请输入主标题，字数不超过${validate.maxLength}个` : placeholder = `请输入副标题，字数不超过${validate.maxLength}个`;
         }
         const domLinkText = template.render(LinkTextTpl)
         this.appendFormControl(domLinkText)
 
         this.text = new JDInput({
             domData: {
                 node: this.element.parents('.cd-data-content'),
                 name: 'text',
                 formType: domData.formType
             },
             maxlength: domData.validate.maxlength,
             placeholder,
             defaultValue: moduleData.text || domData.default,
             char2Modal: domData.char2Modal
         });
 
         let config = {
             domData: {
                 node: this.element.parents('.cd-data-content'),
                 name: 'linkInfo',
             },
             linkName: false,
             addLink: false,
             operation: false,
             tab: ['frequent', 'product', 'activity', 'shopCategory', 'custom'],
             moduleData: moduleData.linkInfo || {},
         };
         if (!domData.noConfig == true) {
             this.link = new JDLink(config);
         }
 
     }
 
     setData(value) {
 
     }
 
     
     getData() {
         let key = this.config.domData.name;
         const { domData } = this.config;
         let result = {};
         let data = $.extend(true, {}, this.text.getData(), !(domData.noConfig == true) ? this.link.getData() : {});
         result[key] = data;
         return result;
     }
 }
 
 export default LinkText;
 