| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279 |
- String.prototype.trim=function(){
- return this.replace(/(^\s*)|(\s*$)/g, "");
- }
- /*
- * 获取插入的HTML
- * */
- function getHtml(treeNode){
- var widgetType = treeNode.widgetType;
- if(widgetType == null || widgetType == '' || widgetType == undefined){
- widgetType = 'text';
- }
- var widgetWidth = treeNode.widgetWidth;
- if(widgetWidth == null || widgetWidth == '' || widgetWidth == undefined){
- widgetWidth = '150';
- }
- var parentNode = treeNode.getParentNode().name;
- var startName = parentNode.substr(parentNode.indexOf("(")+1);
- var dbName = startName.substr(0,startName.indexOf(")"));
- widgetType = widgetType.trim();
- var dataType = treeNode.validateRule;
- if(widgetType == 'text'){
- return getTextWidgetHtml(dbName,treeNode.name,widgetWidth,dataType);
- }else if(widgetType == 'textarea'){
- return getTextAreaHtml(dbName,treeNode.name,widgetWidth,dataType);
- }else if(widgetType == 'select'){
- return getSelectHtml(dbName,treeNode.name,treeNode.dictType,widgetWidth,dataType);
- }else if(widgetType == 'radios'){
- return getRadioHtml(dbName,treeNode.name,treeNode.dictType,widgetWidth,dataType);
- }else if(widgetType == 'checkboxs'){
- return getCheckboxHtml(dbName,treeNode.name,treeNode.dictType,widgetWidth,dataType);
- }else if(widgetType == 'button'){
- return getButtonHtml(treeNode.name);
- }else if(widgetType == 'dateText'){
- return getDateTextHtml(dbName,treeNode.name,widgetWidth,dataType);
- }else if(widgetType == 'timeText'){
- return getTimeTextHtml(dbName,treeNode.name,widgetWidth,dataType);
- }
- }
-
- /**
- * 获取精确到秒的文本输入控件
- * @param dbName
- * @param fieldName
- * @param widgetWidth
- * @param dataType
- * @returns
- */
- function getTimeTextHtml(dbName,fieldName,widgetWidth,dataType){
- var html = '<input type="text" style="text-align:left;width:'+widgetWidth+'px;" ';
- html += ' name= "' + dbName + "." + fieldName + '" ';
- html += ' autofield="' + dbName + "." + fieldName + '" ';
- html += ' title="'+fieldName+'" ';
- html += ' orgheight="" orgalign="left" orgfontsize="" orghide="0" ';
- html += appendDataType(dataType);
- html += ' leipiplugins="text" orgtype="fullDate" orgwidth="'+widgetWidth+'"/>';
- return html;
- }
-
- /**
- * 获取精确到天的文本输入控件
- * @param dbName
- * @param fieldName
- * @param widgetWidth
- * @param dataType
- * @returns
- */
- function getDateTextHtml(dbName,fieldName,widgetWidth,dataType){
- var html = '<input type="text" style="text-align:left;width:'+widgetWidth+'px;" ';
- html += ' name= "' + dbName + "." + fieldName + '" ';
- html += ' autofield="' + dbName + "." + fieldName + '" ';
- html += ' title="'+fieldName+'" ';
- html += ' orgheight="" orgalign="left" orgfontsize="" orghide="0" ';
- html += appendDataType(dataType);
- html += ' leipiplugins="text" orgtype="standardDate" orgwidth="'+widgetWidth+'"/>';
- return html;
- }
-
-
- /**
- * 获取按钮控件对应的html
- * @param fieldName
- * @returns {String}
- */
- function getButtonHtml(fieldName){
- var html = '<span leipiplugins="button"><input name="'+fieldName+'" type="button" leipiplugins="button" style="background-color: #009688;border: medium none;border-radius: 2px;color: #fff;cursor: pointer;display: inline-block;font-size: 14px;height: 38px;line-height: 38px;opacity: 0.9;padding: 0 18px;text-align: center;white-space: nowrap; " value="'+fieldName+'"/></span>';
- return html;
- }
-
- /**
- * 获取多选输入框对应的HTML
- * @param dbName
- * @param fieldName
- * @param dictType
- * @param widgetWidth
- * @param dataType
- */
- function getCheckboxHtml(dbName,fieldName,dictType,widgetWidth,dataType){
- var name = dbName + "." + fieldName;
- var html = '<span leipiplugins="checkboxs" autofield="'+name+'" dictionary="" title="'+fieldName+'" ';
- html += appendDataType(dataType);
- if(dictType != null && dictType != '' && dictType != undefined){
- getDictResult(dictType, function(res){
- if(res.success){
- var result = res.obj;
- var typeList = result.list;
- html += appendTypeGroupId(result.groupId);
- if(typeList != null && typeList.length > 0){
- for(var i = 0; i < typeList.length; i++){
- var type = typeList[i];
- html +='<input name="leipiNewField" checkedtext="'+type.typename+'" value="'+type.typecode+'" type="checkbox"/>'+type.typename+' ';
- }
- }else{
- html+=' selector="" >';
- html += '<input name="leipiNewField" checkedtext="" value="" type="checkbox"/>未设置相关的选项值 ';
- }
- }else{
- html+=' selector="" >';
- html += '<input name="leipiNewField" checkedtext="" value="" type="checkbox"/>未设置相关的选项值 ';
- }
- });
- }else{
- html += ' selector="" >'
- html += '<input name="leipiNewField" checkedtext="" value="" type="checkbox"/>未设置相关的选项值 ';
- }
- html += '</span>';
- return html;
- }
- /**
- * 获取单选框对应的HTML
- * @param dbName
- * @param fieldName
- * @param dictType
- * @param widgetWidth
- * @param dataType
- */
- function getRadioHtml(dbName,fieldName,dictType,widgetWidth,dataType){
- var name = dbName + "." + fieldName;
- var html = '<span leipiplugins="radios" autofield="'+name+'" dictionary="" name="leipiNewField" title="'+fieldName+'" ';
- html += appendDataType(dataType);
- if(dictType != null && dictType != '' && dictType != undefined){
- getDictResult(dictType, function(res){
- if(res.success){
- var result = res.obj;
- var typeList = result.list;
- html += appendTypeGroupId(result.groupId);
- if(typeList != null && typeList.length > 0){
- for(var i = 0; i < typeList.length; i++){
- var type = typeList[i];
- html +='<input name="leipiNewField" checkedtext="'+type.typename+'" value="'+type.typecode+'" type="radio"/>'+type.typename+' ';
- }
- }else{
- html+=' selector="" >';
- html += '<input name="leipiNewField" checkedtext="" value="" type="radio"/>未设置相关的选项值 ';
- }
- }else{
- html+=' selector="" >';
- html += '<input name="leipiNewField" checkedtext="" value="" type="radio"/>未设置相关的选项值 ';
- }
- });
- }else{
- html+=' selector="" >';
- html += '<input name="leipiNewField" checkedtext="" value="" type="radio"/>未设置相关的选项值 ';
- }
- html += '</span>';
- return html;
- }
-
- /**
- * 获取下拉选择框对应的HTML
- * @param dbName 数据库名称
- * @param fieldName 字段名称
- * @param dictType 字典类型
- * @param widgetWidth 控件宽度
- * @param dataType 验证规则
- */
- function getSelectHtml(dbName,fieldName,dictType,widgetWidth,dataType){
- var name = dbName + "." + fieldName;
- var html = '<span leipiplugins="select"><select name="leipiNewField" title="'+fieldName+'" leipiplugins="select" size="1" ';
- html += appendDataType(dataType);
- if(dictType != null && dictType != '' && dictType != undefined){
- getDictResult(dictType,function(res){
- if(res.success){
- var result = res.obj;
- var typeList = result.list;
- var typeGroupId = result.groupId;
- if(typeGroupId != null && typeGroupId != '' && typeGroupId != undefined){
- html += ' selector="'+typeGroupId+'" orgwidth="'+widgetWidth+'" autofield="'+name+'" style="width: '+widgetWidth+'px;">';
- }
- if(typeList != null && typeList.length > 0){
- for(var i = 0; i < typeList.length; i++){
- var type = typeList[i];
- html +='<option value="'+type.typecode+'">'+type.typename+'</option>';
- }
- }else{
- html += ' selector="" orgwidth="'+widgetWidth+'" autofield="'+name+'" style="width: '+widgetWidth+'px;">';
- html +='<option value="">---请选择----</option>';
- }
- }else{
- html += ' selector="" orgwidth="'+widgetWidth+'" autofield="'+name+'" style="width: '+widgetWidth+'px;">';
- html +='<option value="">---请选择----</option>';
- }
- });
- }else{
- html += ' selector="" orgwidth="'+widgetWidth+'" autofield="'+name+'" style="width: '+widgetWidth+'px;">';
- html +='<option value="">---请选择----</option>';
- }
- html += '</select> </span>';
- return html;
- }
-
- /*
- 获取多行文本输入框HTML
- */
- function getTextAreaHtml(dbName,fieldName,widgetWidth,dataType){
- var name = dbName + "." + fieldName;
- var html = ' <textarea title="'+fieldName+'" name="'+name+'" leipiplugins="textarea" '
- +'value="" autofield="'+name+'" orgrich="1" orgfontsize="" orgwidth="'+widgetWidth+'" orgheight="80" ';
- html += appendDataType(dataType);
- html +='style="width: '+widgetWidth+'px; height: 80px; margin: 0px;"></textarea>';
- return html;
- }
-
- /*
- 获取单行文本输入框的HTML
- */
- function getTextWidgetHtml(dbName,fieldName,widgetWidth,dataType){
- var html = '<input type="text" style="text-align:left;width:'+widgetWidth+'px;" ';
- html += ' name= "' + dbName + "." + fieldName + '" ';
- html += ' autofield="' + dbName + "." + fieldName + '" ';
- html += ' title="'+fieldName+'" ';
- html += ' orgheight="" orgalign="left" orgtype="text" orgfontsize="" orghide="0" ';
- html += appendDataType(dataType);
- html += ' leipiplugins="text" orgwidth="'+widgetWidth+'"/>';
- return html;
- }
-
- /**
- * 拼接typeGroupId
- * @param typeGroupId
- * @returns {String}
- */
- function appendTypeGroupId(typeGroupId){
- var html = '';
- if(typeGroupId != null && typeGroupId != '' && typeGroupId != undefined){
- html+=' selector="'+typeGroupId+'" >';
- }else{
- html += 'selector="" >';
- }
- return html;
- }
-
- function appendDataType(dataType){
- var html = '';
- if(dataType != '' && dataType != null && dataType != undefined){
- html += ' datatype="'+dataType+'" ';
- }else{
- html += ' datatype="" ';
- }
- html += ' ignore="ignore" ';
- return html;
- }
-
- function getDictResult(dictType,resultFun){
- $.ajax({
- url:'autoFormController.do?getDictTypeList',
- type:'POST',
- dataType:'JSON',
- async:false,
- data:{
- dictType:dictType
- },
- success:function(res){
- if(typeof resultFun == 'function'){
- resultFun(res);
- }
- }
- });
- }
-
|