/**
 * Created by faye on 2017/7/5.
 *
 * 注册配置
 * id table的id
 * datas
 */

var regConf = (function () {
    'use strict';
    var RegConf = function(params) {
        var p=this;
        //参数定义
        p.params = {
            id:''
        };

        for (var param in params) {
            p.params[param] = params[param];
        }

        p.id="#"+p.params.id;
        var generateNameHtml=function (datas) {
            var options=datas.options;
            var optionStr="";
            for(var i=0,j=options.length;i<j;i++){
                var optionName=options[i].name;
                if(optionName){
                    optionStr+=optionName+","
                }
            }
                var html='<tr data-key="name">'+
                '<td>  <select    class="form-control "'+
            'data-placeholder="请选择类型" ><option value="TEXT">文本</option></select></td>'+
            '<td><input placeholder="名称" class="form-control" type="text" value="'+datas.name+'" name="name"></td>'+
            '<td><input placeholder="选项" class="form-control" type="text" value="'+optionStr+'"></td>'+
            '<td><input  class="form-control"  type="number" placeholder="最多填写" value="'+datas.max+'" onkeyup="this.value=this.value.replace(/\D/g,"")" onafterpaste="this.value=this.value.replace(/\D/g,"")" ></td>'+
            '<td><input placeholder="最少填写" class="form-control"  value="'+datas.min +'"type="number" onkeyup="this.value=this.value.replace(/\D/g,"")" onafterpaste="this.value=this.value.replace(/\D/g,"")" ></td>'+
            '<td>';
            if(datas.ismust=="1"){
                html+='<input name="name-ismust" type="radio"  value="1" checked >是'+
                    '<input name="name-ismust" type="radio"   value="0" >否';
            }else{
                html+='<input name="name-ismust" type="radio"  value="1"  >是'+
                    '<input name="name-ismust" type="radio"   value="0" checked >否';
            }
            html+='</td>'+'<td>';
            if(datas.isview=="1") {
                html+= '<input name="name-isview" type="radio"  value="1" checked>是' +
                '<input name="name-isview" type="radio"   value="0" >否';
            }else{

                html+=
                    '<input name="name-isview" type="radio"  value="1" >是' +
                '<input name="name-isview" type="radio"   value="0" checked>否';

            }
            html+='</td>'+
                    '<td><span class="glyphicon glyphicon-th-list" ></span></td>'+
            '</tr>';
            return html;
        };

        var generateMobileHtml=function (datas) {
            var options=datas.options;
            var optionStr="";
            for(var i=0,j=options.length;i<j;i++){
                var optionName=options[i].name;
                if(optionName){
                    optionStr+=optionName+","
                }
            }
            var html='tr data-key="mobile">'+
                'td>  <select  name="questionType"'+
                '  class="form-control "'+
                '    data-placeholder="请选择类型"><option value="MOBILE">手机</option></select></td>'+
                '     <td><input placeholder="名称" class="form-control" type="text" value="'+datas.name+'"></td>'+
                ' <td><input placeholder="选项" class="form-control" type="text" value="'+optionStr+'"></td>'+
                '     <td><input  class="form-control" type="number" placeholder="最多填写" value="'+datas.max+'" onkeyup="this.value=this.value.replace(/\D/g,"")" onafterpaste="this.value=this.value.replace(/\D/g,"")" ></td>'+
                '  <td><input placeholder="最少填写" class="form-control" type="number"  value="'+datas.min+'" onkeyup="this.value=this.value.replace(/\D/g,"")" onafterpaste="this.value=this.value.replace(/\D/g,"")" ></td>'+
                ' <td>';
            if(datas.ismust=="1"){
                html+=' <input name="mobile-ismust" type="radio"   value="1"checked >是'+
                    '   <input name="mobile-ismust" type="radio"    value="0" >否'
            }else{
                html+=' <input name="mobile-ismust" type="radio"   value="1" >是'+
                    '   <input name="mobile-ismust" type="radio"    value="0" checked>否'
            }
            html+= '</td>'+
            '<td>';
            if(datas.isview=="1") {
                html+='<input name="mobile-isview" type="radio"  value="1" checked>是' +
                '<input name="mobile-isview" type="radio"   value="0" >否';
            }else{
                html+= '<input name="mobile-isview" type="radio"  value="1" >是' +
                '<input name="mobile-isview" type="radio"   value="0" checked>否';
            }
            html+= '</td>'+'<td><span class="glyphicon glyphicon-th-list" ></span></td>'+
            '</tr>';
            return html;
        };

        var generateMobileHtml=function (datas) {
            var options=datas.options;
            var optionStr="";
            for(var i=0,j=options.length;i<j;i++){
                var optionName=options[i].name;
                if(optionName){
                    optionStr+=optionName+","
                }
            }
            var html='tr data-key="mobile">'+
                '<td>  <select  name="questionType"'+
                '  class="form-control "'+
                '    data-placeholder="请选择类型"><option value="MOBILE">手机</option></select></td>'+
                '     <td><input placeholder="名称" class="form-control" type="text" value="'+datas.name+'" ></td>'+
                ' <td><input placeholder="选项" class="form-control" type="text" value="'+optionStr+'"></td>'+
                '     <td><input  class="form-control" type="number" placeholder="最多填写" value="'+datas.max+'" onkeyup="this.value=this.value.replace(/\D/g,"")" onafterpaste="this.value=this.value.replace(/\D/g,"")" ></td>'+
                '  <td><input placeholder="最少填写" class="form-control" type="number"  value="'+datas.min+'" onkeyup="this.value=this.value.replace(/\D/g,"")" onafterpaste="this.value=this.value.replace(/\D/g,"")" ></td>'+
                ' <td>';
            if(datas.ismust=="1"){
                html+=' <input name="mobile-ismust" type="radio"   value="1"checked >是'+
                    '   <input name="mobile-ismust" type="radio"    value="0" >否'
            }else{
                html+=' <input name="mobile-ismust" type="radio"   value="1" >是'+
                    '   <input name="mobile-ismust" type="radio"    value="0" checked>否'
            }
            html+= '</td>'+
            '<td>';
            if(datas.isview=="1") {
                html+='<input name="mobile-isview" type="radio"  value="1" checked>是' +
                '<input name="mobile-isview" type="radio"   value="0" >否';
            }else{
                html+= '<input name="mobile-isview" type="radio"  value="1" >是' +
                '<input name="mobile-isview" type="radio"   value="0" checked>否';
            }
            html+= '</td>'+'<td><span class="glyphicon glyphicon-th-list" ></span></td>'+
            '</tr>';
            return html;
        };
        var generateIdcardHtml=function (datas) {
            var options=datas.options;
            var optionStr="";
            for(var i=0,j=options.length;i<j;i++){
                var optionName=options[i].name;
                if(optionName){
                    optionStr+=optionName+","
                }
            }
            var html= '<tr data-key="idcard" >'+
                '<td>  <select  name="questionType"'+
                'class="form-control "'+
                '  data-placeholder="请选择类型"><option value="IDCARD">身份证</option></select></td>'+
                '    <td><input placeholder="名称" class="form-control" type="text" value="'+datas.name+'" ></td>'+
                ' <td><input placeholder="选项" class="form-control" type="text" value="'+optionStr+'"></td>'+
                '     <td><input  class="form-control" type="number" placeholder="最多填写" value="'+datas.max+'" onkeyup="this.value=this.value.replace(/\D/g,"")" onafterpaste="this.value=this.value.replace(/\D/g,"")" ></td>'+
                '<td><input placeholder="最少填写" class="form-control" type="number" value="'+datas.min+'" onkeyup="this.value=this.value.replace(/\D/g,"")" onafterpaste="this.value=this.value.replace(/\D/g,"")" ></td>'+
                '<td>';
            if(datas.ismust=="1"){
                html+= ' <input name="idcard-ismust" type="radio"   value="1" checked>是'+
                    '  <input name="idcard-ismust" type="radio"    value="0" >否';
            }else{
                html+= ' <input name="idcard-ismust" type="radio"   value="1" >是'+
                    '  <input name="idcard-ismust" type="radio"    value="0" checked>否';
            }
            html+= '</td>'+
            '<td>';
            if(datas.isview=="1") {
                html+= '<input name="idcard-isview"  type="radio"     value="1" checked>是'+
                '     <input name="idcard-isview" type="radio"      value="0" >否';
            }else{
                html+= '<input name="idcard-isview"  type="radio"     value="1" >是'+
                '     <input name="idcard-isview" type="radio"      value="0" checked>否';
            }
            html+='</td>'+'<td><span class="glyphicon glyphicon-th-list" ></span></td>'+
            '</tr>';
            return html;
        };

        var generateSexHtml=function (datas) {
            var options=datas.options;
            var optionStr="";
            for(var i=0,j=options.length;i<j;i++){
                var optionName=options[i].name;
                if(optionName){
                    optionStr+=optionName+","
                }
            }
            var html='  <tr data-key="sex">'+
                '   <td>  <select  name="questionType"'+
                'class="form-control "'+
                ' data-placeholder="请选择类型"><option value="SINGLESEL">单选</option></select></td>'+
                '     <td><input placeholder="名称" class="form-control" type="text" value="性别" value="'+datas.name+'"></td>'+
                '   <td><input placeholder="选项" class="form-control" type="text" value="'+optionStr+'" ></td>'+
                '    <td><input  class="form-control" type="number" placeholder="最多填写" value="'+datas.max+'" onkeyup="this.value=this.value.replace(/\D/g,"")" onafterpaste="this.value=this.value.replace(/\D/g,"")" ></td>'+
                ' <td><input placeholder="最少填写" class="form-control" type="number" value="'+datas.min+'" onkeyup="this.value=this.value.replace(/\D/g,"")" onafterpaste="this.value=this.value.replace(/\D/g,"")" ></td>'+
                ' <td>';
            if(datas.ismust=="1"){
                html+= ' <input name="sex-ismust" type="radio"   value="1" checked>是'+
                    '  <input name="sex-ismust" type="radio"    value="0" >否';
            }else{
                html+= ' <input name="sex-ismust" type="radio"   value="1" >是'+
                    '  <input name="sex-ismust" type="radio"    value="0" checked>否';
            }
            html+= '</td>'+
            '<td>';
            if(datas.isview=="1") {
                html+='<input name="sex-isview"  type="radio"     value="1" checked>是'+
                '     <input name="sex-isview" type="radio"      value="0" >否';
            }else{
                html+=  '<input name="sex-isview"  type="radio"     value="1" >是'+
                '     <input name="sex-isview" type="radio"      value="0" checked>否';
            }
            html+='</td>'+'<td><span class="glyphicon glyphicon-th-list" ></span></td>'+
            '</tr>';
            return html;
        };

        var generateBirthdayHtml=function (datas) {
            var options=datas.options;
            var optionStr="";
            for(var i=0,j=options.length;i<j;i++){
                var optionName=options[i].name;
                if(optionName){
                    optionStr+=optionName+","
                }
            }
            var html=' <tr data-key="birthday">'+
                ' <td>  <select  name="questionType"'+
                'class="form-control"'+
                ' data-placeholder="请选择类型"><option value="DATE">日期</option></select></td>'+
                '    <td><input placeholder="名称" class="form-control" type="text" value="生日" value="'+datas.name+'"></td>'+
                '  <td><input placeholder="选项" class="form-control" type="text" value="'+optionStr+'"></td>'+
                '    <td><input  class="form-control" type="number" placeholder="最多填写" value="'+datas.max+'" onkeyup="this.value=this.value.replace(/\D/g,"")" onafterpaste="this.value=this.value.replace(/\D/g,"")" ></td>'+
                ' <td><input placeholder="最少填写" class="form-control" type="number"  value="'+datas.min+'"  onkeyup="this.value=this.value.replace(/\D/g,"")" onafterpaste="this.value=this.value.replace(/\D/g,"")" ></td>'+
                ' <td>';
            if(datas.ismust=="1"){
                html+= ' <input name="birthday-ismust" type="radio"   value="1" checked>是'+
                    '  <input name="birthday-ismust" type="radio"    value="0" >否';
            }else{
                html+= ' <input name="birthday-ismust" type="radio"   value="1" >是'+
                    '  <input name="birthday-ismust" type="radio"    value="0" checked>否';
            }
            html+= '</td>'+
            '<td>';
            if(datas.isview=="1") {
                html+= '<input name="birthday-isview"  type="radio"     value="1" checked>是'+
                '     <input name="sex-isview" type="radio"      value="0" >否';
            }else{
                html+= '<input name="birthday-isview"  type="radio"     value="1" >是'+
                '     <input name="birthday-isview" type="radio"      value="0" checked>否';
            }
           html+= '</td>'+'<td><span class="glyphicon glyphicon-th-list" ></span></td>'+
            '</tr>';
            return html;
        };

        var generateF1Html=function (datas) {
            var options=datas.options;
            var optionStr="";
            for(var i=0,j=options.length;i<j;i++){
                var optionName=options[i].name;
                if(optionName){
                    optionStr+=optionName+","
                }
            }
            var html=' <tr data-key="f1">'+
                '    <td>  <select  name="questionType"'+
                'class="form-control inputType"'+
                ' data-placeholder="请选择类型"></select></td>'+
                '   <td><input placeholder="名称" class="form-control" type="text" value="'+datas.name+'"></td>'+
                '   <td><input placeholder="选项" class="form-control" type="text"  value="'+optionStr+'"></td>'+
                '  <td><input  class="form-control" type="number" placeholder="最多填写" value="'+datas.max+'" onkeyup="this.value=this.value.replace(/\D/g,"")" onafterpaste="this.value=this.value.replace(/\D/g,"")" ></td>'+
                ' <td><input placeholder="最少填写" class="form-control" type="number"  value="'+datas.min+'" onkeyup="this.value=this.value.replace(/\D/g,"")" onafterpaste="this.value=this.value.replace(/\D/g,"")" ></td>'+
                ' <td>';
            if(datas.ismust=="1"){
                html+= ' <input name="f1-ismust" type="radio"   value="1" checked>是'+
                    '  <input name="f1-ismust" type="radio"    value="0" >否';
            }else{
                html+= ' <input name="f1-ismust" type="radio"   value="1" >是'+
                    '  <input name="f1-ismust" type="radio"    value="0" checked>否';
            }
            html+= '</td>'+
            '<td>';
            if(datas.isview=="1") {
                html+= '<input name="f1-isview"  type="radio"     value="1" checked>是'+
                '     <input name="f1-isview" type="radio"      value="0" >否';
            }else{
                html+= '<input name="f1-isview"  type="radio"     value="1" >是'+
                '     <input name="f1-isview" type="radio"      value="0" checked>否';
            }
            html+= '</td>'+'<td><span class="glyphicon glyphicon-th-list" ></span></td>'+
            '</tr>';
            return html;
        };

        var generateF2Html=function (datas) {
            var options=datas.options;
            var optionStr="";
            for(var i=0,j=options.length;i<j;i++){
                var optionName=options[i].name;
                if(optionName){
                    optionStr+=optionName+","
                }
            }
            var html=' <tr data-key="f2">'+
                '    <td>  <select  name="questionType"'+
                'class="form-control inputType"'+
                ' data-placeholder="请选择类型"></select></td>'+
                '   <td><input placeholder="名称" class="form-control" type="text" value="'+datas.name+'"></td>'+
                '   <td><input placeholder="选项" class="form-control" type="text"  value="'+optionStr+'"></td>'+
                '  <td><input  class="form-control" type="number" placeholder="最多填写" value="'+datas.max+'" onkeyup="this.value=this.value.replace(/\D/g,"")" onafterpaste="this.value=this.value.replace(/\D/g,"")" ></td>'+
                ' <td><input placeholder="最少填写" class="form-control" type="number"  value="'+datas.min+'" onkeyup="this.value=this.value.replace(/\D/g,"")" onafterpaste="this.value=this.value.replace(/\D/g,"")" ></td>'+
                ' <td>';
            if(datas.ismust=="1"){
                html+= ' <input name="f2-ismust" type="radio"   value="1" checked>是'+
                    '  <input name="f2-ismust" type="radio"    value="0" >否';
            }else{
                html+= ' <input name="f2-ismust" type="radio"   value="1" >是'+
                    '  <input name="f2-ismust" type="radio"    value="0" checked>否';
            }
            html+= '</td>'+
            '<td>';
            if(datas.isview=="1") {
                html+='<input name="f2-isview"  type="radio"     value="1" checked>是'+
                '     <input name="f2-isview" type="radio"      value="0" >否';
            }else{
                html+= '<input name="f2-isview"  type="radio"     value="1" >是'+
                '     <input name="f2-isview" type="radio"      value="0" checked>否';
            }
            html+= '</td>'+'<td><span class="glyphicon glyphicon-th-list" ></span></td>'+
            '</tr>';
            return html;
        };
        var generateF3Html=function (datas) {
            var options=datas.options;
            var optionStr="";
            for(var i=0,j=options.length;i<j;i++){
                var optionName=options[i].name;
                if(optionName){
                    optionStr+=optionName+","
                }
            }
            var html=' <tr data-key="f3">'+
                '    <td>  <select  name="questionType"'+
                'class="form-control inputType"'+
                ' data-placeholder="请选择类型"></select></td>'+
                '   <td><input placeholder="名称" class="form-control" type="text" value="'+datas.name+'"></td>'+
                '   <td><input placeholder="选项" class="form-control" type="text"  value="'+optionStr+'"></td>'+
                '  <td><input  class="form-control" type="number" placeholder="最多填写" value="'+datas.max+'" onkeyup="this.value=this.value.replace(/\D/g,"")" onafterpaste="this.value=this.value.replace(/\D/g,"")" ></td>'+
                ' <td><input placeholder="最少填写" class="form-control" type="number"  value="'+datas.min+'" onkeyup="this.value=this.value.replace(/\D/g,"")" onafterpaste="this.value=this.value.replace(/\D/g,"")" ></td>'+
                ' <td>';
            if(datas.ismust=="1"){
                html+= ' <input name="f3-ismust" type="radio"   value="1" checked>是'+
                    '  <input name="f3-ismust" type="radio"    value="0" >否';
            }else{
                html+= ' <input name="f3-ismust" type="radio"   value="1" >是'+
                    '  <input name="f3-ismust" type="radio"    value="0" checked>否';
            }
            html+= '</td>'+
            '<td>';
            if(datas.isview=="1") {
                html+='<input name="f3-isview"  type="radio"     value="1" checked>是'+
                '     <input name="f3-isview" type="radio"      value="0" >否';
            }else{
                html+= '<input name="f3-isview"  type="radio"     value="1" >是'+
                '     <input name="f3-isview" type="radio"      value="0" checked>否';
            }
            html+='</td>'+'<td><span class="glyphicon glyphicon-th-list" ></span></td>'+
            '</tr>';
            return html;
        };
        var generateF4Html=function (datas) {
            var options=datas.options;
            var optionStr="";
            for(var i=0,j=options.length;i<j;i++){
                var optionName=options[i].name;
                if(optionName){
                    optionStr+=optionName+","
                }
            }
            var html=' <tr data-key="f4">'+
                '    <td>  <select  name="questionType"'+
                'class="form-control inputType"'+
                ' data-placeholder="请选择类型"></select></td>'+
                '   <td><input placeholder="名称" class="form-control" type="text" value="'+datas.name+'"></td>'+
                '   <td><input placeholder="选项" class="form-control" type="text"  value="'+optionStr+'"></td>'+
                '  <td><input  class="form-control" type="number" placeholder="最多填写" value="'+datas.max+'" onkeyup="this.value=this.value.replace(/\D/g,"")" onafterpaste="this.value=this.value.replace(/\D/g,"")" ></td>'+
                ' <td><input placeholder="最少填写" class="form-control" type="number"  value="'+datas.min+'" onkeyup="this.value=this.value.replace(/\D/g,"")" onafterpaste="this.value=this.value.replace(/\D/g,"")" ></td>'+
                ' <td>';
            if(datas.ismust=="1"){
                html+= ' <input name="f4-ismust" type="radio"   value="1" checked>是'+
                    '  <input name="f4-ismust" type="radio"    value="0" >否';
            }else{
                html+= ' <input name="f4-ismust" type="radio"   value="1" >是'+
                    '  <input name="f4-ismust" type="radio"    value="0" checked>否';
            }
            html+= '</td>'+
            '<td>';
            if(datas.isview=="1") {
                html+= '<input name="f4-isview"  type="radio"     value="1" checked>是'+
                '     <input name="f4-isview" type="radio"      value="0" >否';
            }else{
                html+= '<input name="f4-isview"  type="radio"     value="1" >是'+
                '     <input name="f4-isview" type="radio"      value="0" checked>否';
            }
            html+= '</td>'+'<td><span class="glyphicon glyphicon-th-list" ></span></td>'+
            '</tr>';
            return html;
        };
        var generateF5Html=function (datas) {
            var options=datas.options;
            var optionStr="";
            for(var i=0,j=options.length;i<j;i++){
                var optionName=options[i].name;
                if(optionName){
                    optionStr+=optionName+","
                }
            }
            var html=' <tr data-key="f5">'+
                '    <td>  <select  name="questionType"'+
                'class="form-control inputType"'+
                ' data-placeholder="请选择类型"></select></td>'+
                '   <td><input placeholder="名称" class="form-control" type="text" value="'+datas.name+'"></td>'+
                '   <td><input placeholder="选项" class="form-control" type="text"  value="'+optionStr+'"></td>'+
                '  <td><input  class="form-control" type="number" placeholder="最多填写" value="'+datas.max+'" onkeyup="this.value=this.value.replace(/\D/g,"")" onafterpaste="this.value=this.value.replace(/\D/g,"")" ></td>'+
                ' <td><input placeholder="最少填写" class="form-control" type="number"  value="'+datas.min+'" onkeyup="this.value=this.value.replace(/\D/g,"")" onafterpaste="this.value=this.value.replace(/\D/g,"")" ></td>'+
                ' <td>';
            if(datas.ismust=="1"){
                html+= ' <input name="f5-ismust" type="radio"   value="1" checked>是'+
                    '  <input name="f5-ismust" type="radio"    value="0" >否';
            }else{
                html+= ' <input name="f5-ismust" type="radio"   value="1" >是'+
                    '  <input name="f5-ismust" type="radio"    value="0" checked>否';
            }
            html+= '</td>'+
            '<td>';
            if(datas.isview=="1") {
                html+= '<input name="f5-isview"  type="radio"     value="1" checked>是'+
                '     <input name="f5-isview" type="radio"      value="0" >否';
            }else{
                html+= '<input name="f5-isview"  type="radio"     value="1" >是'+
                '     <input name="f5-isview" type="radio"      value="0" checked>否';
            }
            html+= '</td>'+'<td><span class="glyphicon glyphicon-th-list" ></span></td>'+
            '</tr>';
            return html;
        };
        var generateF6Html=function (datas) {
            var options=datas.options;
            var optionStr="";
            for(var i=0,j=options.length;i<j;i++){
                var optionName=options[i].name;
                if(optionName){
                    optionStr+=optionName+","
                }
            }
            var html=' <tr data-key="f6">'+
                '    <td>  <select  name="questionType"'+
                'class="form-control inputType"'+
                ' data-placeholder="请选择类型"></select></td>'+
                '   <td><input placeholder="名称" class="form-control" type="text" value="'+datas.name+'"></td>'+
                '   <td><input placeholder="选项" class="form-control" type="text"  value="'+optionStr+'"></td>'+
                '  <td><input  class="form-control" type="number" placeholder="最多填写" value="'+datas.max+'" onkeyup="this.value=this.value.replace(/\D/g,"")" onafterpaste="this.value=this.value.replace(/\D/g,"")" ></td>'+
                ' <td><input placeholder="最少填写" class="form-control" type="number"  value="'+datas.min+'" onkeyup="this.value=this.value.replace(/\D/g,"")" onafterpaste="this.value=this.value.replace(/\D/g,"")" ></td>'+
                ' <td>';
            if(datas.ismust=="1"){
                html+= ' <input name="f6-ismust" type="radio"   value="1" checked>是'+
                    '  <input name="f6-ismust" type="radio"    value="0" >否';
            }else{
                html+= ' <input name="f6-ismust" type="radio"   value="1" >是'+
                    '  <input name="f6-ismust" type="radio"    value="0" checked>否';
            }
            html+= '</td>'+
            '<td>';
            if(datas.isview=="1") {
                html+='<input name="f6-isview"  type="radio"     value="1" checked>是'+
                '     <input name="f6-isview" type="radio"      value="0" >否';
            }else{
                html+= '<input name="f6-isview"  type="radio"     value="1" >是'+
                '     <input name="f6-isview" type="radio"      value="0" checked>否';
            }
            html+= '</td>'+'<td><span class="glyphicon glyphicon-th-list" ></span></td>'+
            '</tr>';
            return html;
        };

        var  initFirstTable=function(){
           var  html='<tr data-key="name">'+
                '<td>  <select    class="form-control "'+
            'data-placeholder="请选择类型" ><option value="TEXT">文本</option></select></td>'+
            '<td><input placeholder="名称" class="form-control" type="text" value="姓名" name="name" ></td>'+
            '<td><input placeholder="选项" class="form-control" type="text" ></td>'+
            '<td><input  class="form-control"  type="number" placeholder="最多填写" value="3" onkeyup="this.value=this.value.replace(/\D/g,"")" onafterpaste="this.value=this.value.replace(/\D/g,"")" ></td>'+
            '<td><input placeholder="最少填写" class="form-control"  value="0" type="number" onkeyup="this.value=this.value.replace(/\D/g,"")" onafterpaste="this.value=this.value.replace(/\D/g,"")" ></td>'+
            '<td>'+
            '<input name="name-ismust" type="radio"  value="1" >是'+
            '<input name="name-ismust" type="radio"   value="0" checked>否'+
            '</td>'+
            '<td>'+
            '<input name="name-isview" type="radio"  value="1">是'+
            '<input name="name-isview" type="radio"   value="0" checked>否'+
            '</td>'+
               '<td><span class="glyphicon glyphicon-th-list" ></span></td>'+
            '</tr>'+
            'tr data-key="mobile">'+
            '<td>  <select  name="questionType"'+
            '  class="form-control "'+
            '    data-placeholder="请选择类型"><option value="MOBILE">手机</option></select></td>'+
            '     <td><input placeholder="名称" class="form-control" type="text" value="手机" ></td>'+
            ' <td><input placeholder="选项" class="form-control" type="text" ></td>'+
            '     <td><input  class="form-control" type="number" placeholder="最多填写" value="11"onkeyup="this.value=this.value.replace(/\D/g,"")" onafterpaste="this.value=this.value.replace(/\D/g,"")" ></td>'+
            '  <td><input placeholder="最少填写" class="form-control" type="number"  value="11" onkeyup="this.value=this.value.replace(/\D/g,"")" onafterpaste="this.value=this.value.replace(/\D/g,"")" ></td>'+
            ' <td>'+
            ' <input name="mobile-ismust" type="radio"   value="1" >是'+
            '   <input name="mobile-ismust" type="radio"    value="0" checked>否'+
            ' </td>'+
            '<td>'+
            '<input name="mobile-isview"  type="radio"     value="1" checked>是'+
            ' <input name="mobile-isview" type="radio"      value="0" checked>否'+
            ' </td>'+
               '<td><span class="glyphicon glyphicon-th-list" ></span></td>'+
            ' </tr>'+
            '<tr data-key="idcard" >'+
            '<td>  <select  name="questionType"'+
            'class="form-control "'+
            '  data-placeholder="请选择类型"><option value="IDCARD">身份证</option></select></td>'+
            '    <td><input placeholder="名称" class="form-control" type="text" value="身份证" ></td>'+
            ' <td><input placeholder="选项" class="form-control" type="text" ></td>'+
            '     <td><input  class="form-control" type="number" placeholder="最多填写" value="18"onkeyup="this.value=this.value.replace(/\D/g,"")" onafterpaste="this.value=this.value.replace(/\D/g,"")" ></td>'+
            '<td><input placeholder="最少填写" class="form-control" type="number" value="18" onkeyup="this.value=this.value.replace(/\D/g,"")" onafterpaste="this.value=this.value.replace(/\D/g,"")" ></td>'+
            '<td>'+
            ' <input name="idcard-ismust" type="radio"   value="1" >是'+
            '  <input name="idcard-ismust" type="radio"    value="0" checked>否'+
            ' </td>'+
            '<td>'+
            '<input name="idcard-isview"  type="radio"     value="1" >是'+
            '     <input name="idcard-isview" type="radio"      value="0" checked>否'+
            ' </td>'+
               '<td><span class="glyphicon glyphicon-th-list" ></span></td>'+
            ' </tr>'+
            '  <tr data-key="sex">'+
            '   <td>  <select  name="questionType"'+
            'class="form-control "'+
            ' data-placeholder="请选择类型"><option value="SINGLESEL">单选</option></select></td>'+
            '     <td><input placeholder="名称" class="form-control" type="text" value="性别" ></td>'+
            '   <td><input placeholder="选项" class="form-control" type="text" value="男,女" ></td>'+
            '    <td><input  class="form-control" type="number" placeholder="最多填写" value="1" value=""onkeyup="this.value=this.value.replace(/\D/g,"")" onafterpaste="this.value=this.value.replace(/\D/g,"")" ></td>'+
            ' <td><input placeholder="最少填写" class="form-control" type="number" value="1" onkeyup="this.value=this.value.replace(/\D/g,"")" onafterpaste="this.value=this.value.replace(/\D/g,"")" ></td>'+
            ' <td>'+
            '  <input name="sex-ismust" type="radio"   value="1" >是'+
            '    <input name="sex-ismust" type="radio"    value="0" checked>否'+
            ' </td>'+
            ' <td>'+
            '<input name="sex-isview" type="radio"     value="1" >是'+
            '    <input name="sex-isview" type="radio"      value="0" checked>否'+
            ' </td>'+
               '<td><span class="glyphicon glyphicon-th-list" ></span></td>'+
            ' </tr>'+
            ' <tr data-key="birthday">'+
            ' <td>  <select  name="questionType"'+
            'class="form-control"'+
            ' data-placeholder="请选择类型"><option value="DATE">日期</option></select></td>'+
            '    <td><input placeholder="名称" class="form-control" type="text" value="生日" ></td>'+
            '  <td><input placeholder="选项" class="form-control" type="text" ></td>'+
            '    <td><input  class="form-control" type="number" placeholder="最多填写" value="0"onkeyup="this.value=this.value.replace(/\D/g,"")" onafterpaste="this.value=this.value.replace(/\D/g,"")" ></td>'+
            ' <td><input placeholder="最少填写" class="form-control" type="number"  value="0"  onkeyup="this.value=this.value.replace(/\D/g,"")" onafterpaste="this.value=this.value.replace(/\D/g,"")" ></td>'+
            ' <td>'+
            ' <input name="birthday-ismust" type="radio"   value="1" >是'+
            '    <input name="birthday-ismust" type="radio"    value="0" checked>否'+
            '</td>'+
            '<td>'+
            ' <input name="birthday-isview" type="radio"     value="1" >是'+
            ' <input name="birthday-isview" type="radio"      value="0" checked>否'+
            ' </td>'+
               '<td><span class="glyphicon glyphicon-th-list" ></span></td>'+
            ' </tr>'+
            ' <tr data-key="f1">'+
            '    <td>  <select  name="questionType"'+
            'class="form-control inputType"'+
            ' data-placeholder="请选择类型"></select></td>'+
            '   <td><input placeholder="名称" class="form-control" type="text" ></td>'+
            '   <td><input placeholder="选项" class="form-control" type="text"  ></td>'+
            '  <td><input  class="form-control" type="number" placeholder="最多填写" value="0" onkeyup="this.value=this.value.replace(/\D/g,"")" onafterpaste="this.value=this.value.replace(/\D/g,"")" ></td>'+
            ' <td><input placeholder="最少填写" class="form-control" type="number"  value="0" onkeyup="this.value=this.value.replace(/\D/g,"")" onafterpaste="this.value=this.value.replace(/\D/g,"")" ></td>'+
            ' <td>'+
            ' <input name="f1-ismust" type="radio"   value="1" >是'+
            ' <input name="f1-ismust" type="radio"    value="0" checked>否'+
            ' </td>'+
            '<td>'+
            ' <input name="f1-isview" type="radio"     value="1" >是'+
            ' <input name="f1-isview" type="radio"      value="0" checked>否'+
            '</td>'+
               '<td><span class="glyphicon glyphicon-th-list" ></span></td>'+
            '</tr>'+
            ' <tr data-key="f2">'+
            ' <td>  <select  name="questionType"'+
            ' class="form-control inputType"'+
            ' data-placeholder="请选择类型"></select></td>'+
            ' <td><input placeholder="名称" class="form-control" type="text" ></td>'+
            ' <td><input placeholder="选项" class="form-control" type="text" ></td>'+
            ' <td><input  class="form-control" type="number" placeholder="最多填写" value="0"onkeyup="this.value=this.value.replace(/\D/g,"")" onafterpaste="this.value=this.value.replace(/\D/g,"")" ></td>'+
            ' <td><input placeholder="最少填写" class="form-control" type="number"  value="0" onkeyup="this.value=this.value.replace(/\D/g,"")" onafterpaste="this.value=this.value.replace(/\D/g,"")" ></td>'+
            ' <td>'+
            '<input name="f2-ismust" type="radio"   value="1" >是'+
            ' <input name="f2-ismust" type="radio"    value="0" checked>否'+
            ' </td>'+
            ' <td>'+
            ' <input name="f2-isview" type="radio"     value="1" >是'+
            '   <input name="f2-isview" type="radio"      value="0" checked>否'+
            ' </td>'+
               '<td><span class="glyphicon glyphicon-th-list" ></span></td>'+
            '</tr>'+
            '<tr data-key="f3">'+
            ' <td>  <select  name="questionType"'+
            'class="form-control inputType"'+
            'data-placeholder="请选择类型"></select></td>'+
            '<td><input placeholder="名称" class="form-control" type="text" ></td>'+
            '<td><input placeholder="选项" class="form-control" type="text" ></td>'+
            '  <td><input  class="form-control" type="number" placeholder="最多填写" value="0"onkeyup="this.value=this.value.replace(/\D/g,"")" onafterpaste="this.value=this.value.replace(/\D/g,"")" ></td>'+
            '<td><input placeholder="最少填写" class="form-control" type="number"   value="0" onkeyup="this.value=this.value.replace(/\D/g,"")" onafterpaste="this.value=this.value.replace(/\D/g,"")" ></td>'+
            ' <td>'+
            ' <input name="f3-ismust" type="radio"   value="1" >是'+
            ' <input name="f3-ismust" type="radio"    value="0" checked>否'+
            '</td>'+
            ' <td>'+
            ' <input name="f3-isview" type="radio"     value="1" >是'+
            '<input name="f3-isview" type="radio"      value="0" checked>否'+
            ' </td>'+
               '<td><span class="glyphicon glyphicon-th-list" ></span></td>'+
            '</tr>'+
            '<tr data-key="f4">'+
            '<td><select  name="questionType"'+
            ' class="form-control inputType"'+
            ' data-placeholder="请选择类型"></select></td>'+
            ' <td><input placeholder="名称" class="form-control" type="text" ></td>'+
            ' <td><input placeholder="选项" class="form-control" type="text" ></td>'+
            '<td><input  class="form-control" type="number" placeholder="最多填写"  value="0"onkeyup="this.value=this.value.replace(/\D/g,"")" onafterpaste="this.value=this.value.replace(/\D/g,"")" ></td>'+
            '<td><input placeholder="最少填写" class="form-control" type="number"  value="0" onkeyup="this.value=this.value.replace(/\D/g,"")" onafterpaste="this.value=this.value.replace(/\D/g,"")" ></td>'+
            '<td>'+
            '<input name="f4-ismust" type="radio"   value="1" >是'+
            '<input name="f4-ismust" type="radio"    value="0" checked>否'+
            '</td>'+
            '<td>'+
            '<input name="f4-isview"  type="radio"     value="1" >是'+
            '<input name="f4-isview"  type="radio"     value="0" checked>否'+
            '</td>'+
               '<td><span class="glyphicon glyphicon-th-list" ></span></td>'+
            '</tr>'+
            '<tr data-key="f5">'+
            '<td><select  name="questionType"'+
            'class="form-control inputType"'+
            'data-placeholder="请选择类型"></select></td>'+
            '<td><input placeholder="名称" class="form-control" type="text" ></td>'+
            '<td><input placeholder="选项" class="form-control" type="text" ></td>'+
            '<td><input  class="form-control" type="number" placeholder="最多填写"  value="0"onkeyup="this.value=this.value.replace(/\D/g,"")" onafterpaste="this.value=this.value.replace(/\D/g,"")" ></td>'+
            '<td><input placeholder="最少填写" class="form-control" type="number"  value="0" onkeyup="this.value=this.value.replace(/\D/g,"")" onafterpaste="this.value=this.value.replace(/\D/g,"")" ></td>'+
            '<td>'+
            '<input name="f5-ismust" type="radio"   value="1" >是'+
            '<input name="f5-ismust" type="radio"   value="0" checked>否'+
            '</td>'+
            '<td>'+
            '<input name="f5-isview" type="radio"     value="1" >是'+
            '<input name="f5-isview" type="radio"      value="0" checked>否'+
            '</td>'+
               '<td><span class="glyphicon glyphicon-th-list" ></span></td>'+
            '</tr>'+
            '<tr data-key="f6">'+
            '<td>  <select  name="questionType"'+
            'class="form-control inputType"'+
            'data-placeholder="请选择类型"></select></td>'+
            '<td><input placeholder="名称" class="form-control" type="text" ></td>'+
            '<td><input placeholder="选项" class="form-control" type="text" ></td>'+
            '<td><input  class="form-control" type="number" placeholder="最多填写"  value="0" onkeyup="this.value=this.value.replace(/\D/g,"")" onafterpaste="this.value=this.value.replace(/\D/g,"")" ></td>'+
            '<td><input placeholder="最少填写" class="form-control" type="number"  value="0" onkeyup="this.value=this.value.replace(/\D/g,"")" onafterpaste="this.value=this.value.replace(/\D/g,"")" ></td>'+
            '<td>'+
            '<input name="f6-ismust" type="radio"   value="1" >是'+
            '<input name="f6-ismust" type="radio"    value="0" checked>否'+
            '</td>'+
            '<td>'+
            '<input name="f6-isview" type="radio"     value="1" >是'+
            '<input name="f6-isview" type="radio"      value="0" checked>否'+
            '</td>'+
               '<td><span class="glyphicon glyphicon-th-list" ></span></td>'+
            '</tr>';
            return html;

        };

        p.initTable=function(datas){
            var html='';
            if(datas){
                var length= datas.length;
                for(var i=0,j=length;i<j;i++){
                    var key=datas[i].key;
                   if(key=="name"){
                       html+=generateNameHtml(datas[i]);
                   }else if(key=="idcard"){
                       html+=generateIdcardHtml(datas[i]);
                   }else if(key=="sex"){
                       html+=generateSexHtml(datas[i]);
                   }else if(key=="mobile"){
                       html+=generateMobileHtml(datas[i]);
                   }else if(key=="birthday"){
                       html+=generateBirthdayHtml(datas[i]);
                   }else if(key=="f1"){
                       html+=generateF1Html(datas[i]);
                   }else if(key=="f2"){
                       html+=generateF2Html(datas[i]);
                   }else if(key=="f3"){
                       html+=generateF3Html(datas[i]);
                   }else if(key=="f4"){
                       html+=generateF4Html(datas[i]);
                   }else if(key=="f5"){
                       html+=generateF5Html(datas[i]);
                   }else if(key=="f6"){
                       html+=generateF6Html(datas[i]);
                   }
                }
            }else{
                html=initFirstTable();
            }
            $(p.id).append(html);
        };

        p.getValues=function () {
            var length= $(p.id+" tr").length;
            var config=[];
            for(var i=0,j=length;i<j;i++){
                var obj=$(p.id+" tr:eq("+i+")");
                var key =obj.attr("data-key");
                var type = obj.find("td:eq(0)>select").val();
                var name=obj.find("td:eq(1)>input").val();
                var option=obj.find("td:eq(2)>input").val();
                var max=obj.find("td:eq(3)>input").val();
                var min=obj.find("td:eq(4)>input").val();
                var ismust=obj.find("td:eq(5)>input[name='"+key+"-ismust']:checked").val();
                var isview=obj.find("td:eq(6)>input[name='"+key+"-isview']:checked").val();
                if(type=="SINGLESEL"||type=="MULITISEL"){
                    if(!option){
                        return null;
                    }
                }
                if(!name||!max||!min){
                    return null;
                }
                var finalOptions=[];
                var options=option.split(",");
                for(var k=0,l=options.length;k<l;k++){
                    var str=options[k];
                    if(str==""||str==null||str==undefined||str=="str==undefined"){
                        delete options[k];
                    }else{
                        finalOptions.push({'name':str});
                    }
                }
                var json={
                    key:key,
                    name:name,
                    type:type,
                    max:max,
                    min:min,
                    ismust:ismust,
                    isview:isview,
                    options:finalOptions
                };
                config.push(json);
            }
            return config;

        }

    };

    return RegConf;
})();
