You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1936 lines
51 KiB
1936 lines
51 KiB
1 month ago
|
$.extend({
|
||
|
refreshControl:function(op,obj){
|
||
|
obj.attr("data-options",$.json2str(op));
|
||
|
$.render(obj.attr("dtype"),op,obj);
|
||
|
},
|
||
|
render:function(type,options,obj){
|
||
|
if(type=="text_group"){
|
||
|
return _render_text_group(options,obj);
|
||
|
} else if(type.indexOf("input_")==0){
|
||
|
//输入类控件
|
||
|
return _render_input(type,options,obj);
|
||
|
} else if(type=="textarea"){
|
||
|
//textarea控件
|
||
|
return _render_textarea(type,options);
|
||
|
} else if(type=="tree"){
|
||
|
//树tree控件
|
||
|
return _render_tree(type,options);
|
||
|
} else if(type=="tree_accordion"){
|
||
|
//accordion树控件
|
||
|
return _render_tree_accordion(type,options);
|
||
|
} else if(type=="treegrid"){
|
||
|
//treegrid树控件
|
||
|
return _render_treegrid(type,options);
|
||
|
} else if(type=="twotree"){
|
||
|
//twotree树控件
|
||
|
return _render_twotree(type,options);
|
||
|
} else if(type=="twotreegrid"){
|
||
|
//twotreegrid控件
|
||
|
return _render_twotreegrid(type,options);
|
||
|
} else if(type=="inputpop"){
|
||
|
//inputpop控件
|
||
|
return _render_inputpop(type,options);
|
||
|
} else if(type=="inputpop_grid"){
|
||
|
//inputpop_grid控件
|
||
|
return _render_inputpop_grid(type,options);
|
||
|
} else if(type=="inputpop_tree"){
|
||
|
//inputpop_tree控件
|
||
|
return _render_inputpop_tree(type,options);
|
||
|
} else if(type=="inputpop_treegrid"){
|
||
|
//inputpop_treegrid控件
|
||
|
return _render_inputpop_treegrid(type,options);
|
||
|
} else if(type=="grid"){
|
||
|
//grid控件
|
||
|
return _render_grid(type,options);
|
||
|
} else if(type=="btn"){
|
||
|
//按钮控件
|
||
|
return _render_button(type,options);
|
||
|
} else if(type=="btn_dropdown"){
|
||
|
//按钮控件
|
||
|
return _render_btn_dropdown(type,options);
|
||
|
} else if(type=="badge"){
|
||
|
//角标(徽章)控件
|
||
|
return _render_badge(type,options);
|
||
|
} else if(type=="img_uploader"){
|
||
|
//图片控件,可带图片预览功能
|
||
|
return _render_img_uploader(type,options);
|
||
|
} else if(type=="file_uploader"){
|
||
|
//附件控件
|
||
|
return _render_file_uploader(type,options);
|
||
|
}else if(type=="ctr_datetime"){
|
||
|
return _render_ctr_datetime(options);
|
||
|
}else if(type=="ctr_date"){
|
||
|
return _render_ctr_date(options);
|
||
|
}else if(type=="ctr_time"){
|
||
|
return _render_ctr_time(options)
|
||
|
}else if(type=="ctr_moth"){
|
||
|
return _render_ctr_moth(options)
|
||
|
}else if(type=="ctr_time_quantum"){
|
||
|
return _render_ctr_time_quantum(options)
|
||
|
}else if(type=="ctr_button_radio"){
|
||
|
return _render_ctr_button_radio(options)
|
||
|
}else if(type=="ctr_button_checkbox"){
|
||
|
return _render_ctr_button_checkbox(options)
|
||
|
}else if(type=="ctr_radio"){
|
||
|
return _render_ctr_radio(options)
|
||
|
}else if(type=="ctr_checkbox"){
|
||
|
return _render_ctr_checkbox(options)
|
||
|
}else if(type=="ctr_select_radio"){
|
||
|
return _render_ctr_select_radio(options)
|
||
|
}else if(type=="ctr_select_checkbox"){
|
||
|
return _render_ctr_select_checkbox(options)
|
||
|
}else if(type=="ctr_filter_radio"){
|
||
|
return _render_ctr_filter_radio(options)
|
||
|
}else if(type=="h_layout"){
|
||
|
return _render_h_layout(options,obj);
|
||
|
}
|
||
|
}
|
||
|
});
|
||
|
/**
|
||
|
* 初始化横向布局
|
||
|
* @param op
|
||
|
* @returns
|
||
|
*/
|
||
|
var _hlayoutindex=0;
|
||
|
function _render_h_layout(options,obj){
|
||
|
_hlayoutindex++;
|
||
|
options = $.extend({
|
||
|
id:"hlayout"+_hlayoutindex
|
||
|
},options);
|
||
|
|
||
|
var ic=obj;//容器
|
||
|
if(!ic){
|
||
|
ic=$("<div dtype='h_layout' class='h_layout d-item'></div>");
|
||
|
var left=$('<div class="h_layout_left d-con"></div>').appendTo(ic);
|
||
|
var right=$('<div class="h_layout_right d-con"></div>').appendTo(ic);
|
||
|
if(options.specify=="right"){
|
||
|
right.css("width",options.width);
|
||
|
}else{
|
||
|
left.css("width",options.width);
|
||
|
}
|
||
|
|
||
|
//单击事件
|
||
|
ic.find(".d-con,.d-item").click(function(event){
|
||
|
_setSelectStatus(this,event);
|
||
|
});
|
||
|
ic.click(function(event){
|
||
|
_setSelectStatus(this,event);
|
||
|
});
|
||
|
}else{
|
||
|
var left=ic.find(".h_layout_left");
|
||
|
var right=ic.find(".h_layout_right");;
|
||
|
if(options.specify=="right"){
|
||
|
right.css("width",options.width);
|
||
|
left.css("width","auto");
|
||
|
}else{
|
||
|
left.css("width",options.width);
|
||
|
right.css("width","auto");
|
||
|
}
|
||
|
}
|
||
|
ic.attr("id",options.id);
|
||
|
ic.attr("data-options",$.json2str(options));
|
||
|
return ic;
|
||
|
}
|
||
|
/**
|
||
|
* 初始化text_group
|
||
|
* @param options
|
||
|
* @returns
|
||
|
*/
|
||
|
var _textgroupindex=0;
|
||
|
function _render_text_group(options,obj){
|
||
|
_textgroupindex++;
|
||
|
options = $.extend({
|
||
|
id:"text"+_textgroupindex,
|
||
|
name:"text"+_textgroupindex,
|
||
|
label:"文本"+_textgroupindex
|
||
|
},options);
|
||
|
|
||
|
var ic=obj;//容器
|
||
|
if(!ic){
|
||
|
ic=$("<div dtype='text_group' class='text-group d-item'></div>");
|
||
|
|
||
|
//单击事件
|
||
|
ic.click(function(event){
|
||
|
_setSelectStatus(this,event);
|
||
|
});
|
||
|
}
|
||
|
ic.attr("data-options",$.json2str(options));
|
||
|
ic.empty();//清空
|
||
|
|
||
|
//标签
|
||
|
var label = $('<label for="'+options.id+'" class="control-label">'+options.label+'</label>').appendTo(ic);
|
||
|
//输入框的容器
|
||
|
var inputcon=$('<div></div>').appendTo(ic);
|
||
|
//输入框
|
||
|
var input=$('<input type="text" class="form-control" id="'+options.id+'" value="'+options.defaultValue+'" placeholder="'+options.placeholder+'">').appendTo(inputcon);
|
||
|
|
||
|
return ic;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 设置选中状态
|
||
|
* @param obj
|
||
|
* @param event
|
||
|
* @returns
|
||
|
*/
|
||
|
function _setSelectStatus(obj,event){
|
||
|
$(".d-active").removeClass("d-active");
|
||
|
$(obj).addClass("d-active");
|
||
|
//渲染属性,事件窗口
|
||
|
_renderPropEvent(obj);
|
||
|
event.stopPropagation();
|
||
|
}
|
||
|
/**
|
||
|
* 生成属性,事件窗口内容
|
||
|
* @param obj
|
||
|
* @returns
|
||
|
*/
|
||
|
function _renderPropEvent(obj){
|
||
|
var dtype=$(obj).attr("dtype");
|
||
|
if(dtype){
|
||
|
var prop=null;
|
||
|
var event=null;
|
||
|
$.ajax({
|
||
|
url:'wdk?action=form.common&method=getControlPropAndEvent&ajaxparam='+new Date().getTime(),
|
||
|
method:"post",
|
||
|
data:{
|
||
|
controlName:dtype
|
||
|
},
|
||
|
success:function(data){
|
||
|
data=$.str2json(data);
|
||
|
if(data.proplist){
|
||
|
prop=data.proplist;
|
||
|
}
|
||
|
if(data.eventlist){
|
||
|
event=data.eventlist;
|
||
|
}
|
||
|
parent.renderPropEvent({prop:prop,event:event,options:$.str2json($(obj).attr("data-options"))});
|
||
|
}
|
||
|
});
|
||
|
|
||
|
}else{
|
||
|
parent.renderPropEvent({prop:[],event:[],options:null});
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
/**
|
||
|
* 初始化input控件,包括文本、数字、邮箱、手机、电话、密码。不含textarea
|
||
|
* @param type 控件类型,如input_email
|
||
|
* @param op 控件初始化参数
|
||
|
* @returns
|
||
|
*/
|
||
|
function _render_input(type,op,obj){
|
||
|
var label = type;
|
||
|
var placeholder = "请输入"+type;
|
||
|
var validType = "";
|
||
|
var inputtype = "text";
|
||
|
|
||
|
if(type=="input_text"){
|
||
|
label = "文本";
|
||
|
placeholder = "请输入文本";
|
||
|
} else if(type=="input_number"){
|
||
|
label = "数字";
|
||
|
placeholder = "请输入数字";
|
||
|
validType = "integer";
|
||
|
} else if(type=="input_money"){
|
||
|
label = "金额";
|
||
|
placeholder = "请输入金额";
|
||
|
validType = "money";
|
||
|
} else if(type=="input_email"){
|
||
|
label = "邮箱";
|
||
|
placeholder = "请输入邮箱";
|
||
|
validType = "emailAddress";
|
||
|
} else if(type=="input_mobile"){
|
||
|
label = "手机";
|
||
|
placeholder = "请输入手机";
|
||
|
} else if(type=="input_phone"){
|
||
|
label = "电话";
|
||
|
placeholder = "请输入电话号码";
|
||
|
} else if(type=="input_password"){
|
||
|
label = "密码";
|
||
|
placeholder = "请输入密码";
|
||
|
inputtype = "password";
|
||
|
}
|
||
|
var options={
|
||
|
id:$.getUUID(),
|
||
|
label:label,
|
||
|
placeholder:placeholder,
|
||
|
initvalue:"",
|
||
|
required:false,
|
||
|
missingMessage:"",
|
||
|
editable:true,
|
||
|
validType:validType
|
||
|
};//默认值
|
||
|
options = $.extend(options,op);//合并属性
|
||
|
|
||
|
var ic=obj;//容器
|
||
|
if(!ic){
|
||
|
ic=$("<div dtype='"+type+"' class='text-group form-group d-item'></div>");
|
||
|
|
||
|
//单击事件
|
||
|
ic.click(function(event){
|
||
|
_setSelectStatus(this,event);
|
||
|
});
|
||
|
}
|
||
|
ic.attr("data-options",$.json2str(options));
|
||
|
ic.empty();//清空
|
||
|
|
||
|
//标签
|
||
|
var label = $('<label for="'+options.id+'" class="control-label">'+options.label+'</label>').appendTo(ic);
|
||
|
//输入框的容器
|
||
|
var inputcon=$('<div></div>').appendTo(ic);
|
||
|
//输入框
|
||
|
var input=$('<input type="'+inputtype+'" class="form-control " id="'+options.id+'" name="'+options.id+'" value="'+options.initvalue+'" placeholder="'+options.placeholder+'">').appendTo(inputcon);
|
||
|
var validators={};
|
||
|
var validTypeArray = options.validType.split(",");
|
||
|
for(var i=0;i<validTypeArray.length;i++){
|
||
|
if(validTypeArray[i]!=""){
|
||
|
validators[validTypeArray[i]]={message:""};
|
||
|
}
|
||
|
}
|
||
|
$(".validator-form").bootstrapValidator('addField',$("#"+options.id),{
|
||
|
validators:validators
|
||
|
});
|
||
|
//保存参数到控件
|
||
|
ic.data("options",options);
|
||
|
|
||
|
return ic;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 初始化textarea控件
|
||
|
* @param type 控件类型,如textarea
|
||
|
* @param op 控件初始化参数
|
||
|
* @returns
|
||
|
*/
|
||
|
function _render_textarea(type,op){
|
||
|
var label = "描述";
|
||
|
var placeholder = "请输入内容";
|
||
|
var options={
|
||
|
id:$.getUUID(),
|
||
|
label:label,
|
||
|
placeholder:placeholder,
|
||
|
initvalue:"",
|
||
|
required:false,
|
||
|
missingMessage:"",
|
||
|
editable:true,
|
||
|
rows:3,
|
||
|
disabled:false
|
||
|
};//默认值
|
||
|
$.extend(options,op);//合并属性
|
||
|
|
||
|
var ic;//容器
|
||
|
if(!options.did){
|
||
|
options.did=$.getUUID();
|
||
|
ic=$("<div did='"+options.did+"' dtype='"+type+"' class='text-group d-item'></div>");
|
||
|
}else{
|
||
|
ic=$("[did='"+options.did+"']");
|
||
|
}
|
||
|
ic.empty();//清空
|
||
|
|
||
|
//标签
|
||
|
var label = $('<label for="'+options.id+'" class="control-label">'+options.label+'</label>').appendTo(ic);
|
||
|
//输入框的容器
|
||
|
var inputcon=$('<div></div>').appendTo(ic);
|
||
|
//输入框
|
||
|
var input=$('<textarea rows="'+options.rows+'" class="form-control" id="'+options.id+'" name="'+options.id+'" '+ (options.disabled?'disabled="disabled"':'') + ' >'
|
||
|
+options.initvalue+'</textarea>').appendTo(inputcon);
|
||
|
//保存参数到控件
|
||
|
ic.data("options",options);
|
||
|
|
||
|
//单击事件
|
||
|
ic.click(function(event){
|
||
|
_setSelectStatus(this,event);
|
||
|
});
|
||
|
return ic;
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
/**
|
||
|
* 初始化树控件tree
|
||
|
* @param type 控件类型
|
||
|
* @param op 控件初始化参数
|
||
|
* @returns
|
||
|
*/
|
||
|
function _render_tree(type,op){
|
||
|
var label = "";
|
||
|
var options={
|
||
|
id:$.getUUID(),
|
||
|
label:label,
|
||
|
checkbox:false,//是否显示复选框
|
||
|
expandall:false,//加载完毕后是否展开所有,如果采用异步方式(asyn==true),该属性失效
|
||
|
cascadeCheck:false,//是否级联检查checkbox。父子节点之间的checkbox是否联动,是否有半选状态。 ture:父子checkbox勾选联动,存在半选状态;false:父子checkbox不联动;默认:false。
|
||
|
asyn:false,//是否异步加载。true:使用异步方式加载;false:使用同步方式加载;默认:false。
|
||
|
url:'',
|
||
|
queryParams:{}
|
||
|
};//默认值
|
||
|
$.extend(options,op);//合并属性
|
||
|
|
||
|
var ic;//容器
|
||
|
if(!options.did){
|
||
|
options.did=$.getUUID();
|
||
|
ic=$("<div did='"+options.did+"' dtype='"+type+"' class='text-group d-item'></div>");
|
||
|
}else{
|
||
|
ic=$("[did='"+options.did+"']");
|
||
|
}
|
||
|
ic.empty();//清空
|
||
|
|
||
|
|
||
|
//标签
|
||
|
var label = $('<label for="'+options.id+'" class="control-label">'+options.label+'</label>').appendTo(ic);
|
||
|
//控件的容器
|
||
|
var inputcon=$('<div></div>').appendTo(ic);
|
||
|
//控件
|
||
|
var ctr = '<div id="'+options.id+'" class="ztree" ></div>'+
|
||
|
' <script type="text/javascript"> '+
|
||
|
' $.tree({'+
|
||
|
' id:"'+options.id+'",'+
|
||
|
' checkbox:true,'+
|
||
|
' expandall:false,'+
|
||
|
' cascadeCheck:false,'+
|
||
|
' asyn:true,'+
|
||
|
' url:"products/demo/demo-org-tree.json",'+
|
||
|
' queryParams:{}'+
|
||
|
' });'+
|
||
|
' </script>';
|
||
|
|
||
|
|
||
|
var input=$(ctr).appendTo(inputcon);
|
||
|
//保存参数到控件
|
||
|
ic.data("options",options);
|
||
|
|
||
|
//单击事件
|
||
|
ic.click(function(event){
|
||
|
_setSelectStatus(this,event);
|
||
|
});
|
||
|
return ic;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 初始化accordion树控件tree_accordion
|
||
|
* @param type 控件类型
|
||
|
* @param op 控件初始化参数
|
||
|
* @returns
|
||
|
*/
|
||
|
function _render_tree_accordion(type,op){
|
||
|
var label = "";
|
||
|
var placeholder = "";
|
||
|
var options={
|
||
|
id:$.getUUID(),
|
||
|
label:label,
|
||
|
url:''
|
||
|
};//默认值
|
||
|
$.extend(options,op);//合并属性
|
||
|
|
||
|
var ic;//容器
|
||
|
if(!options.did){
|
||
|
options.did=$.getUUID();
|
||
|
ic=$("<div did='"+options.did+"' dtype='"+type+"' class='text-group d-item'></div>");
|
||
|
}else{
|
||
|
ic=$("[did='"+options.did+"']");
|
||
|
}
|
||
|
ic.empty();//清空
|
||
|
|
||
|
|
||
|
//标签
|
||
|
var label = $('<label for="'+options.id+'" class="control-label">'+options.label+'</label>').appendTo(ic);
|
||
|
//控件的容器
|
||
|
var inputcon=$('<div></div>').appendTo(ic);
|
||
|
//控件
|
||
|
var ctrContent ='<div id="tree_'+options.id+'" >'
|
||
|
+'<script>'
|
||
|
+'$.accordion({'
|
||
|
+'containerid:"#tree_'+options.id+'",'
|
||
|
+'url:"'+options.url+'",'
|
||
|
+'onclick:function(){'
|
||
|
+'var node=this.data;'
|
||
|
+'alert(node.text);'
|
||
|
+'}'
|
||
|
+'});'
|
||
|
+'</script>'
|
||
|
+'</div>';
|
||
|
var input=$(ctrContent).appendTo(inputcon);
|
||
|
|
||
|
//保存参数到控件
|
||
|
ic.data("options",options);
|
||
|
|
||
|
//单击事件
|
||
|
ic.click(function(event){
|
||
|
_setSelectStatus(this,event);
|
||
|
});
|
||
|
return ic;
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
/**
|
||
|
* 初始化treegrid控件
|
||
|
* @param type 控件类型
|
||
|
* @param op 控件初始化参数
|
||
|
* @returns
|
||
|
*/
|
||
|
function _render_treegrid(type,op){
|
||
|
var label = "";
|
||
|
var options={
|
||
|
id:$.getUUID(),
|
||
|
label:label,
|
||
|
checkbox:false,//是否显示复选框
|
||
|
expandall:false,//加载完毕后是否展开所有,如果采用异步方式(asyn==true),该属性失效
|
||
|
cascadeCheck:false,//是否级联检查checkbox。父子节点之间的checkbox是否联动,是否有半选状态。 ture:父子checkbox勾选联动,存在半选状态;false:父子checkbox不联动;默认:false。
|
||
|
asyn:false,//是否异步加载。true:使用异步方式加载;false:使用同步方式加载;默认:false。
|
||
|
url:'',
|
||
|
queryParams:{}
|
||
|
};//默认值
|
||
|
$.extend(options,op);//合并属性
|
||
|
|
||
|
var ic;//容器
|
||
|
if(!options.did){
|
||
|
options.did=$.getUUID();
|
||
|
ic=$("<div did='"+options.did+"' dtype='"+type+"' class='text-group d-item'></div>");
|
||
|
}else{
|
||
|
ic=$("[did='"+options.did+"']");
|
||
|
}
|
||
|
ic.empty();//清空
|
||
|
|
||
|
|
||
|
//标签
|
||
|
var label = $('<label for="'+options.id+'" class="control-label">'+options.label+'</label>').appendTo(ic);
|
||
|
//控件的容器
|
||
|
var inputcon=$('<div></div>').appendTo(ic);
|
||
|
//控件
|
||
|
var ctr = '<div id="'+options.id+'" class="ztree" ></div>'+
|
||
|
' <script type="text/javascript"> '+
|
||
|
' $.tree({'+
|
||
|
' id:"'+options.id+'",'+
|
||
|
' checkbox:true,'+
|
||
|
' expandall:false,'+
|
||
|
' cascadeCheck:false,'+
|
||
|
' asyn:true,'+
|
||
|
' url:"products/demo/demo-org-tree.json",'+
|
||
|
' queryParams:{}'+
|
||
|
' });'+
|
||
|
' </script>';
|
||
|
|
||
|
|
||
|
var input=$(ctr).appendTo(inputcon);
|
||
|
//保存参数到控件
|
||
|
ic.data("options",options);
|
||
|
|
||
|
//单击事件
|
||
|
ic.click(function(event){
|
||
|
_setSelectStatus(this,event);
|
||
|
});
|
||
|
return ic;
|
||
|
}
|
||
|
|
||
|
|
||
|
/**
|
||
|
* 初始化twotree控件
|
||
|
* @param type 控件类型
|
||
|
* @param op 控件初始化参数
|
||
|
* @returns
|
||
|
*/
|
||
|
function _render_twotree(type,op){
|
||
|
var label = "";
|
||
|
var options={
|
||
|
id:$.getUUID(),
|
||
|
label:label,
|
||
|
checkbox:false,//是否显示复选框
|
||
|
expandall:false,//加载完毕后是否展开所有,如果采用异步方式(asyn==true),该属性失效
|
||
|
cascadeCheck:false,//是否级联检查checkbox。父子节点之间的checkbox是否联动,是否有半选状态。 ture:父子checkbox勾选联动,存在半选状态;false:父子checkbox不联动;默认:false。
|
||
|
asyn:false,//是否异步加载。true:使用异步方式加载;false:使用同步方式加载;默认:false。
|
||
|
url:'',
|
||
|
queryParams:{}
|
||
|
};//默认值
|
||
|
$.extend(options,op);//合并属性
|
||
|
|
||
|
var ic;//容器
|
||
|
if(!options.did){
|
||
|
options.did=$.getUUID();
|
||
|
ic=$("<div did='"+options.did+"' dtype='"+type+"' class='text-group d-item'></div>");
|
||
|
}else{
|
||
|
ic=$("[did='"+options.did+"']");
|
||
|
}
|
||
|
ic.empty();//清空
|
||
|
|
||
|
|
||
|
//标签
|
||
|
var label = $('<label for="'+options.id+'" class="control-label">'+options.label+'</label>').appendTo(ic);
|
||
|
//控件的容器
|
||
|
var inputcon=$('<div></div>').appendTo(ic);
|
||
|
//控件
|
||
|
var ctr = '<div id="'+options.id+'" class="ztree" ></div>'+
|
||
|
' <script type="text/javascript"> '+
|
||
|
' $.tree({'+
|
||
|
' id:"'+options.id+'",'+
|
||
|
' checkbox:true,'+
|
||
|
' expandall:false,'+
|
||
|
' cascadeCheck:false,'+
|
||
|
' asyn:true,'+
|
||
|
' url:"products/demo/demo-org-tree.json",'+
|
||
|
' queryParams:{}'+
|
||
|
' });'+
|
||
|
' </script>';
|
||
|
|
||
|
|
||
|
var input=$(ctr).appendTo(inputcon);
|
||
|
//保存参数到控件
|
||
|
ic.data("options",options);
|
||
|
|
||
|
//单击事件
|
||
|
ic.click(function(event){
|
||
|
_setSelectStatus(this,event);
|
||
|
});
|
||
|
return ic;
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
/**
|
||
|
* 初始化twotreegrid控件
|
||
|
* @param type 控件类型
|
||
|
* @param op 控件初始化参数
|
||
|
* @returns
|
||
|
*/
|
||
|
function _render_twotreegrid(type,op){
|
||
|
var label = "";
|
||
|
var options={
|
||
|
id:$.getUUID(),
|
||
|
label:label,
|
||
|
checkbox:false,//是否显示复选框
|
||
|
expandall:false,//加载完毕后是否展开所有,如果采用异步方式(asyn==true),该属性失效
|
||
|
cascadeCheck:false,//是否级联检查checkbox。父子节点之间的checkbox是否联动,是否有半选状态。 ture:父子checkbox勾选联动,存在半选状态;false:父子checkbox不联动;默认:false。
|
||
|
asyn:false,//是否异步加载。true:使用异步方式加载;false:使用同步方式加载;默认:false。
|
||
|
url:'',
|
||
|
queryParams:{}
|
||
|
};//默认值
|
||
|
$.extend(options,op);//合并属性
|
||
|
|
||
|
var ic;//容器
|
||
|
if(!options.did){
|
||
|
options.did=$.getUUID();
|
||
|
ic=$("<div did='"+options.did+"' dtype='"+type+"' class='text-group d-item'></div>");
|
||
|
}else{
|
||
|
ic=$("[did='"+options.did+"']");
|
||
|
}
|
||
|
ic.empty();//清空
|
||
|
|
||
|
|
||
|
//标签
|
||
|
var label = $('<label for="'+options.id+'" class="control-label">'+options.label+'</label>').appendTo(ic);
|
||
|
//控件的容器
|
||
|
var inputcon=$('<div></div>').appendTo(ic);
|
||
|
//控件
|
||
|
var ctr = '<div id="'+options.id+'" class="ztree" ></div>'+
|
||
|
' <script type="text/javascript"> '+
|
||
|
' $.tree({'+
|
||
|
' id:"'+options.id+'",'+
|
||
|
' checkbox:true,'+
|
||
|
' expandall:false,'+
|
||
|
' cascadeCheck:false,'+
|
||
|
' asyn:true,'+
|
||
|
' url:"products/demo/demo-org-tree.json",'+
|
||
|
' queryParams:{}'+
|
||
|
' });'+
|
||
|
' </script>';
|
||
|
|
||
|
|
||
|
var input=$(ctr).appendTo(inputcon);
|
||
|
//保存参数到控件
|
||
|
ic.data("options",options);
|
||
|
|
||
|
//单击事件
|
||
|
ic.click(function(event){
|
||
|
_setSelectStatus(this,event);
|
||
|
});
|
||
|
return ic;
|
||
|
}
|
||
|
|
||
|
|
||
|
/**
|
||
|
* 初始化inputpop控件
|
||
|
* @param type 控件类型
|
||
|
* @param op 控件初始化参数
|
||
|
* @returns
|
||
|
*/
|
||
|
function _render_inputpop(type,op){
|
||
|
var label = "";
|
||
|
var placeholder = "";
|
||
|
|
||
|
var options={
|
||
|
id:$.getUUID(),
|
||
|
label:label,
|
||
|
placeholder:placeholder,
|
||
|
initvalue:"",
|
||
|
url:"",
|
||
|
required:false,
|
||
|
missingMessage:"",
|
||
|
editable:true,
|
||
|
disabled:false
|
||
|
};//默认值
|
||
|
$.extend(options,op);//合并属性
|
||
|
|
||
|
var ic;//容器
|
||
|
if(!options.did){
|
||
|
options.did=$.getUUID();
|
||
|
ic=$("<div did='"+options.did+"' dtype='"+type+"' class='text-group d-item'></div>");
|
||
|
}else{
|
||
|
ic=$("[did='"+options.did+"']");
|
||
|
}
|
||
|
ic.empty();//清空
|
||
|
|
||
|
//标签
|
||
|
var label = $('<label for="'+options.id+'" class="control-label">'+options.label+'</label>').appendTo(ic);
|
||
|
//输入框的容器
|
||
|
var inputcon=$('<div class="btn-group"></div>').appendTo(ic);
|
||
|
|
||
|
|
||
|
//输入框
|
||
|
var input=$('<input type="text" class="form-control dropdown-toggle" id="'+options.id+'" name="'+options.id+'" value="'+options.initvalue+'" placeholder="'+options.placeholder+'"'
|
||
|
+(options.disabled?'disabled="disabled"':'')
|
||
|
+' data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" >'
|
||
|
+'<ul class="dropdown-menu" style="width:100%;">'
|
||
|
+'<div id="tree_'+options.id+'"></div>'
|
||
|
+'<script>'
|
||
|
+'$.accordion({'
|
||
|
+'containerid:tree_'+options.id+','
|
||
|
+'url:"'+options.url+'",'
|
||
|
+'onclick:function(){'
|
||
|
+'var node=this.data;'
|
||
|
+'$("#'+options.id+'").val(node.text);'
|
||
|
+'}'
|
||
|
+'});'
|
||
|
+'</script>'
|
||
|
+'</ul>'
|
||
|
).appendTo(inputcon);
|
||
|
//保存参数到控件
|
||
|
ic.data("options",options);
|
||
|
|
||
|
//单击事件
|
||
|
ic.click(function(event){
|
||
|
_setSelectStatus(this,event);
|
||
|
});
|
||
|
return ic;
|
||
|
}
|
||
|
|
||
|
|
||
|
/**
|
||
|
* 初始化inputpop_tree控件,目前只是从inputpop拷贝过来,功能尚未实现
|
||
|
* @param type 控件类型
|
||
|
* @param op 控件初始化参数
|
||
|
* @returns
|
||
|
*/
|
||
|
function _render_inputpop_tree(type,op){
|
||
|
var label = "";
|
||
|
var placeholder = "";
|
||
|
|
||
|
var options={
|
||
|
id:$.getUUID(),
|
||
|
label:label,
|
||
|
placeholder:placeholder,
|
||
|
initvalue:"",
|
||
|
url:"",
|
||
|
required:false,
|
||
|
missingMessage:"",
|
||
|
editable:true,
|
||
|
disabled:false
|
||
|
};//默认值
|
||
|
$.extend(options,op);//合并属性
|
||
|
|
||
|
var ic;//容器
|
||
|
if(!options.did){
|
||
|
options.did=$.getUUID();
|
||
|
ic=$("<div did='"+options.did+"' dtype='"+type+"' class='text-group d-item'></div>");
|
||
|
}else{
|
||
|
ic=$("[did='"+options.did+"']");
|
||
|
}
|
||
|
ic.empty();//清空
|
||
|
|
||
|
//标签
|
||
|
var label = $('<label for="'+options.id+'" class="control-label">'+options.label+'</label>').appendTo(ic);
|
||
|
//输入框的容器
|
||
|
var inputcon=$('<div class="btn-group"></div>').appendTo(ic);
|
||
|
|
||
|
|
||
|
//输入框
|
||
|
var input=$('<input type="text" class="form-control dropdown-toggle" id="'+options.id+'" name="'+options.id+'" value="'+options.initvalue+'" placeholder="'+options.placeholder+'"'
|
||
|
+(options.disabled?'disabled="disabled"':'')
|
||
|
+' data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" >'
|
||
|
+'<ul class="dropdown-menu" style="width:100%;">'
|
||
|
+'<div id="tree_'+options.id+'"></div>'
|
||
|
+'<script>'
|
||
|
+'$.accordion({'
|
||
|
+'containerid:tree_'+options.id+','
|
||
|
+'url:"'+options.url+'",'
|
||
|
+'onclick:function(){'
|
||
|
+'var node=this.data;'
|
||
|
+'$("#'+options.id+'").val(node.text);'
|
||
|
+'}'
|
||
|
+'});'
|
||
|
+'</script>'
|
||
|
+'</ul>'
|
||
|
).appendTo(inputcon);
|
||
|
//保存参数到控件
|
||
|
ic.data("options",options);
|
||
|
|
||
|
//单击事件
|
||
|
ic.click(function(event){
|
||
|
_setSelectStatus(this,event);
|
||
|
});
|
||
|
return ic;
|
||
|
}
|
||
|
|
||
|
|
||
|
/**
|
||
|
* 初始化inputpop_grid控件,目前只是从inputpop拷贝过来,功能尚未实现
|
||
|
* @param type 控件类型
|
||
|
* @param op 控件初始化参数
|
||
|
* @returns
|
||
|
*/
|
||
|
function _render_inputpop_grid(type,op){
|
||
|
var label = "";
|
||
|
var placeholder = "";
|
||
|
|
||
|
var options={
|
||
|
id:$.getUUID(),
|
||
|
label:label,
|
||
|
placeholder:placeholder,
|
||
|
initvalue:"",
|
||
|
url:"",
|
||
|
required:false,
|
||
|
missingMessage:"",
|
||
|
editable:true,
|
||
|
disabled:false
|
||
|
};//默认值
|
||
|
$.extend(options,op);//合并属性
|
||
|
|
||
|
var ic;//容器
|
||
|
if(!options.did){
|
||
|
options.did=$.getUUID();
|
||
|
ic=$("<div did='"+options.did+"' dtype='"+type+"' class='text-group d-item'></div>");
|
||
|
}else{
|
||
|
ic=$("[did='"+options.did+"']");
|
||
|
}
|
||
|
ic.empty();//清空
|
||
|
|
||
|
//标签
|
||
|
var label = $('<label for="'+options.id+'" class="control-label">'+options.label+'</label>').appendTo(ic);
|
||
|
//输入框的容器
|
||
|
var inputcon=$('<div class="btn-group"></div>').appendTo(ic);
|
||
|
|
||
|
|
||
|
//输入框
|
||
|
var input=$('<input type="text" class="form-control dropdown-toggle" id="'+options.id+'" name="'+options.id+'" value="'+options.initvalue+'" placeholder="'+options.placeholder+'"'
|
||
|
+(options.disabled?'disabled="disabled"':'')
|
||
|
+' data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" >'
|
||
|
+'<ul class="dropdown-menu" style="width:100%;">'
|
||
|
+'<div id="tree_'+options.id+'"></div>'
|
||
|
+'<script>'
|
||
|
+'$.accordion({'
|
||
|
+'containerid:tree_'+options.id+','
|
||
|
+'url:"'+options.url+'",'
|
||
|
+'onclick:function(){'
|
||
|
+'var node=this.data;'
|
||
|
+'$("#'+options.id+'").val(node.text);'
|
||
|
+'}'
|
||
|
+'});'
|
||
|
+'</script>'
|
||
|
+'</ul>'
|
||
|
).appendTo(inputcon);
|
||
|
//保存参数到控件
|
||
|
ic.data("options",options);
|
||
|
|
||
|
//单击事件
|
||
|
ic.click(function(event){
|
||
|
_setSelectStatus(this,event);
|
||
|
});
|
||
|
return ic;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 初始化inputpop_treegrid控件,目前只是从inputpop拷贝过来,功能尚未实现
|
||
|
* @param type 控件类型
|
||
|
* @param op 控件初始化参数
|
||
|
* @returns
|
||
|
*/
|
||
|
function _render_inputpop_treegrid(type,op){
|
||
|
var label = "";
|
||
|
var placeholder = "";
|
||
|
|
||
|
var options={
|
||
|
id:$.getUUID(),
|
||
|
label:label,
|
||
|
placeholder:placeholder,
|
||
|
initvalue:"",
|
||
|
url:"",
|
||
|
required:false,
|
||
|
missingMessage:"",
|
||
|
editable:true,
|
||
|
disabled:false
|
||
|
};//默认值
|
||
|
$.extend(options,op);//合并属性
|
||
|
|
||
|
var ic;//容器
|
||
|
if(!options.did){
|
||
|
options.did=$.getUUID();
|
||
|
ic=$("<div did='"+options.did+"' dtype='"+type+"' class='text-group d-item'></div>");
|
||
|
}else{
|
||
|
ic=$("[did='"+options.did+"']");
|
||
|
}
|
||
|
ic.empty();//清空
|
||
|
|
||
|
//标签
|
||
|
var label = $('<label for="'+options.id+'" class="control-label">'+options.label+'</label>').appendTo(ic);
|
||
|
//输入框的容器
|
||
|
var inputcon=$('<div class="btn-group"></div>').appendTo(ic);
|
||
|
|
||
|
|
||
|
//输入框
|
||
|
var input=$('<input type="text" class="form-control dropdown-toggle" id="'+options.id+'" name="'+options.id+'" value="'+options.initvalue+'" placeholder="'+options.placeholder+'"'
|
||
|
+(options.disabled?'disabled="disabled"':'')
|
||
|
+' data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" >'
|
||
|
+'<ul class="dropdown-menu" style="width:100%;">'
|
||
|
+'<div id="tree_'+options.id+'"></div>'
|
||
|
+'<script>'
|
||
|
+'$.accordion({'
|
||
|
+'containerid:tree_'+options.id+','
|
||
|
+'url:"'+options.url+'",'
|
||
|
+'onclick:function(){'
|
||
|
+'var node=this.data;'
|
||
|
+'$("#'+options.id+'").val(node.text);'
|
||
|
+'}'
|
||
|
+'});'
|
||
|
+'</script>'
|
||
|
+'</ul>'
|
||
|
).appendTo(inputcon);
|
||
|
//保存参数到控件
|
||
|
ic.data("options",options);
|
||
|
|
||
|
//单击事件
|
||
|
ic.click(function(event){
|
||
|
_setSelectStatus(this,event);
|
||
|
});
|
||
|
return ic;
|
||
|
}
|
||
|
|
||
|
|
||
|
/**
|
||
|
* 初始化grid控件,功能尚未实现
|
||
|
* @param type 控件类型
|
||
|
* @param op 控件初始化参数
|
||
|
* @returns
|
||
|
*/
|
||
|
function _render_grid(type, op){
|
||
|
var label = "";
|
||
|
var placeholder = "";
|
||
|
|
||
|
var options={
|
||
|
id:$.getUUID(),
|
||
|
label:label,
|
||
|
placeholder:placeholder,
|
||
|
initvalue:"",
|
||
|
url:"",
|
||
|
required:false,
|
||
|
missingMessage:"",
|
||
|
editable:true,
|
||
|
disabled:false
|
||
|
};//默认值
|
||
|
$.extend(options,op);//合并属性
|
||
|
|
||
|
var ic;//容器
|
||
|
if(!options.did){
|
||
|
options.did=$.getUUID();
|
||
|
ic=$("<div did='"+options.did+"' dtype='"+type+"' class='text-group d-item'></div>");
|
||
|
}else{
|
||
|
ic=$("[did='"+options.did+"']");
|
||
|
}
|
||
|
ic.empty();//清空
|
||
|
|
||
|
//标签
|
||
|
var label = $('<label for="'+options.id+'" class="control-label">'+options.label+'</label>').appendTo(ic);
|
||
|
//控件容器
|
||
|
var inputcon=$('<div class="btn-group"></div>').appendTo(ic);
|
||
|
|
||
|
|
||
|
//控件
|
||
|
var inputtext='<div>grid尚未实现</div>';
|
||
|
|
||
|
var input=$(inputtext).appendTo(inputcon);
|
||
|
|
||
|
//保存参数到控件
|
||
|
ic.data("options",options);
|
||
|
|
||
|
//单击事件
|
||
|
ic.click(function(event){
|
||
|
_setSelectStatus(this,event);
|
||
|
});
|
||
|
return ic;
|
||
|
|
||
|
}
|
||
|
/**
|
||
|
* 初始化switch开关控件
|
||
|
* @param type 控件类型
|
||
|
* @param op 控件初始化参数
|
||
|
* @returns
|
||
|
*/
|
||
|
function _render_switch(type,op){
|
||
|
var label = "开关";
|
||
|
|
||
|
var options={
|
||
|
id:$.getUUID(),
|
||
|
label:label,
|
||
|
ontext:"ON",//on状态显示的文本
|
||
|
offtext:"OFF",//OFF状态显示的文本
|
||
|
checked:true,
|
||
|
handlewidth:100
|
||
|
};//默认值
|
||
|
$.extend(options,op);//合并属性
|
||
|
|
||
|
var ic;//容器
|
||
|
if(!options.did){
|
||
|
options.did=$.getUUID();
|
||
|
ic=$("<div did='"+options.did+"' dtype='"+type+"' class='text-group d-item'></div>");
|
||
|
}else{
|
||
|
ic=$("[did='"+options.did+"']");
|
||
|
}
|
||
|
ic.empty();//清空
|
||
|
|
||
|
//标签
|
||
|
var label = $('<label for="'+options.id+'" class="control-label">'+options.label+'</label>').appendTo(ic);
|
||
|
//输入框的容器
|
||
|
var inputcon=$('<div></div>').appendTo(ic);
|
||
|
//输入框
|
||
|
|
||
|
var input=$('<input type="checkbox" class="bs-switch" id="'+options.id+'" name="'+options.id+'" data-on-text="'+options.ontext
|
||
|
+'" data-off-text="'+options.offtext+'" data-handle-width="'+options.handlewidth+'" '+(options.checked?'checked':'')+'>').appendTo(inputcon);
|
||
|
//保存参数到控件
|
||
|
ic.data("options",options);
|
||
|
|
||
|
//单击事件
|
||
|
ic.click(function(event){
|
||
|
_setSelectStatus(this,event);
|
||
|
});
|
||
|
return ic;
|
||
|
}
|
||
|
|
||
|
|
||
|
/**
|
||
|
* 初始化button按钮控件
|
||
|
* @param type 控件类型
|
||
|
* @param op 控件初始化参数
|
||
|
* @returns
|
||
|
*/
|
||
|
function _render_button(type,op){
|
||
|
var label = "按钮";
|
||
|
|
||
|
var options={
|
||
|
id:$.getUUID(),
|
||
|
label:label,
|
||
|
btnstyle:"default"
|
||
|
};//默认值
|
||
|
$.extend(options,op);//合并属性
|
||
|
|
||
|
var ic;//容器
|
||
|
if(!options.did){
|
||
|
options.did=$.getUUID();
|
||
|
ic=$("<div did='"+options.did+"' dtype='"+type+"' class='text-group d-item'></div>");
|
||
|
}else{
|
||
|
ic=$("[did='"+options.did+"']");
|
||
|
}
|
||
|
ic.empty();//清空
|
||
|
|
||
|
//标签
|
||
|
var label = $('<label for="'+options.id+'" class="control-label">'+'</label>').appendTo(ic);
|
||
|
//输入框的容器
|
||
|
var inputcon=$('<div></div>').appendTo(ic);
|
||
|
//输入框
|
||
|
//<button type="button" class="btn btn-default" onclick="alert('默认样式')">(默认样式)Default</button>
|
||
|
var input=$('<button type="button" class="btn btn-'+options.btnstyle+'" id="'+options.id+'" name="'+options.id+'" '
|
||
|
+'>'
|
||
|
+ options.label
|
||
|
+'</button>'
|
||
|
).appendTo(inputcon);
|
||
|
//保存参数到控件
|
||
|
ic.data("options",options);
|
||
|
|
||
|
//单击事件
|
||
|
ic.click(function(event){
|
||
|
_setSelectStatus(this,event);
|
||
|
});
|
||
|
return ic;
|
||
|
}
|
||
|
|
||
|
|
||
|
/**
|
||
|
* 初始化btn_dropdown按钮式下拉菜单控件
|
||
|
* @param type 控件类型
|
||
|
* @param op 控件初始化参数
|
||
|
* @returns
|
||
|
*/
|
||
|
function _render_btn_dropdown(type,op){
|
||
|
var label = "按钮菜单";
|
||
|
|
||
|
var options={
|
||
|
id:$.getUUID(),
|
||
|
label:label,
|
||
|
btnstyle:"default",
|
||
|
caret:false,
|
||
|
data:[
|
||
|
{id:'node1',text:'第一个选项'},
|
||
|
{id:'node2',text:'第二个选项'}
|
||
|
]
|
||
|
};//默认值
|
||
|
$.extend(options,op);//合并属性
|
||
|
|
||
|
var ic;//容器
|
||
|
if(!options.did){
|
||
|
options.did=$.getUUID();
|
||
|
ic=$("<div did='"+options.did+"' dtype='"+type+"' class='text-group d-item'></div>");
|
||
|
}else{
|
||
|
ic=$("[did='"+options.did+"']");
|
||
|
}
|
||
|
ic.empty();//清空
|
||
|
|
||
|
//标签
|
||
|
var label = $('<label for="'+options.id+'" class="control-label">'+options.label+'</label>').appendTo(ic);
|
||
|
//输入框的容器
|
||
|
var inputcon=$('<div></div>').appendTo(ic);
|
||
|
//输入框
|
||
|
var inputtext='<div class="btn-group">'
|
||
|
+ '<button type="button" class="btn btn-warning dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">'
|
||
|
+options.label + (options.caret?'<span class="caret"></span>':'')
|
||
|
+'</button>'
|
||
|
+'<ul class="dropdown-menu">';
|
||
|
for(var i=0;i<options.data.length;i++){
|
||
|
inputtext += '<li id='+options.data[i].id+'><a href="javascript:alert(1)">' + options.data[i].text + '</a></li>';
|
||
|
}
|
||
|
inputtext += '</ul></div>';
|
||
|
var input=$(inputtext).appendTo(inputcon);
|
||
|
//保存参数到控件
|
||
|
ic.data("options",options);
|
||
|
|
||
|
//单击事件
|
||
|
ic.click(function(event){
|
||
|
_setSelectStatus(this,event);
|
||
|
});
|
||
|
return ic;
|
||
|
}
|
||
|
|
||
|
|
||
|
/**
|
||
|
* 初始化badge角标(徽章)控件
|
||
|
* @param type 控件类型
|
||
|
* @param op 控件初始化参数
|
||
|
* @returns
|
||
|
*/
|
||
|
function _render_badge(type,op){
|
||
|
var label = "角标(徽章)";
|
||
|
|
||
|
var options={
|
||
|
id:$.getUUID(),
|
||
|
label:label,
|
||
|
badge:0,
|
||
|
top:false
|
||
|
};//默认值
|
||
|
$.extend(options,op);//合并属性
|
||
|
|
||
|
var ic;//容器
|
||
|
if(!options.did){
|
||
|
options.did=$.getUUID();
|
||
|
ic=$("<div did='"+options.did+"' dtype='"+type+"' class='text-group d-item'></div>");
|
||
|
}else{
|
||
|
ic=$("[did='"+options.did+"']");
|
||
|
}
|
||
|
ic.empty();//清空
|
||
|
|
||
|
//标签
|
||
|
var label = $('<label for="'+options.id+'" class="control-label">'+'</label>').appendTo(ic);
|
||
|
//输入框的容器
|
||
|
var inputcon=$('<div></div>').appendTo(ic);
|
||
|
//输入框
|
||
|
/**
|
||
|
<ul class="nav nav-pills" role="tablist">
|
||
|
<li role="presentation" class="active" ><a href="javascipt:alert('Messages');" >Home <span class="badge">42</span></a></li>
|
||
|
</ul>
|
||
|
*/
|
||
|
var inputtext='<ul class="nav nav-pills" role="tablist">'
|
||
|
+ '<li role="presentation" class="active" >'
|
||
|
+'<a href="javascipt:alert(1);" >' + options.label
|
||
|
+'<span class="badge">'+options.badge+'</span></a></li>';
|
||
|
|
||
|
var input=$(inputtext).appendTo(inputcon);
|
||
|
//保存参数到控件
|
||
|
ic.data("options",options);
|
||
|
|
||
|
//单击事件
|
||
|
ic.click(function(event){
|
||
|
_setSelectStatus(this,event);
|
||
|
});
|
||
|
return ic;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 初始化img_uploader图片上传控件
|
||
|
* @param type 控件类型
|
||
|
* @param op 控件初始化参数
|
||
|
* @returns
|
||
|
*/
|
||
|
function _render_img_uploader(type,op){
|
||
|
var label = "";
|
||
|
|
||
|
var options={
|
||
|
id:$.getUUID(),
|
||
|
label:label,
|
||
|
preview:true//是否带预览功能
|
||
|
};//默认值
|
||
|
$.extend(options,op);//合并属性
|
||
|
|
||
|
var ic;//容器
|
||
|
if(!options.did){
|
||
|
options.did=$.getUUID();
|
||
|
ic=$("<div did='"+options.did+"' dtype='"+type+"' class='text-group d-item'></div>");
|
||
|
}else{
|
||
|
ic=$("[did='"+options.did+"']");
|
||
|
}
|
||
|
ic.empty();//清空
|
||
|
|
||
|
//标签
|
||
|
var label = $('<label for="'+options.id+'" class="control-label">'+options.label+'</label>').appendTo(ic);
|
||
|
//控件容器
|
||
|
var inputcon=$('<div></div>').appendTo(ic);
|
||
|
//控件
|
||
|
var inputtext='<input type="file" id="' + options.id + '" name="' + options.id + '">';
|
||
|
|
||
|
var input=$(inputtext).appendTo(inputcon);
|
||
|
//保存参数到控件
|
||
|
ic.data("options",options);
|
||
|
|
||
|
//单击事件
|
||
|
ic.click(function(event){
|
||
|
_setSelectStatus(this,event);
|
||
|
});
|
||
|
return ic;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 初始化file_uploader附件上传控件
|
||
|
* @param type 控件类型
|
||
|
* @param op 控件初始化参数
|
||
|
* @returns
|
||
|
*/
|
||
|
function _render_file_uploader(type,op){
|
||
|
var label = "";
|
||
|
|
||
|
var options={
|
||
|
id:$.getUUID(),
|
||
|
label:label,
|
||
|
preview:true//是否带预览功能
|
||
|
};//默认值
|
||
|
$.extend(options,op);//合并属性
|
||
|
|
||
|
var ic;//容器
|
||
|
if(!options.did){
|
||
|
options.did=$.getUUID();
|
||
|
ic=$("<div did='"+options.did+"' dtype='"+type+"' class='text-group d-item'></div>");
|
||
|
}else{
|
||
|
ic=$("[did='"+options.did+"']");
|
||
|
}
|
||
|
ic.empty();//清空
|
||
|
|
||
|
//标签
|
||
|
var label = $('<label for="'+options.id+'" class="control-label">'+options.label+'</label>').appendTo(ic);
|
||
|
//控件容器
|
||
|
var inputcon=$('<div></div>').appendTo(ic);
|
||
|
//控件
|
||
|
var inputtext='<input type="file" id="' + options.id + '" name="' + options.id + '">';
|
||
|
|
||
|
var input=$(inputtext).appendTo(inputcon);
|
||
|
//保存参数到控件
|
||
|
ic.data("options",options);
|
||
|
|
||
|
//单击事件
|
||
|
ic.click(function(event){
|
||
|
_setSelectStatus(this,event);
|
||
|
});
|
||
|
return ic;
|
||
|
}
|
||
|
|
||
|
//-------------------------------------
|
||
|
|
||
|
|
||
|
/**
|
||
|
* 渲染日期时间选择控件
|
||
|
*/
|
||
|
function _render_ctr_datetime(op){
|
||
|
//默认属性值
|
||
|
var options={
|
||
|
id:"",
|
||
|
label:"日期时间",
|
||
|
initvalue:"",//初始值
|
||
|
required:false,//是否必填
|
||
|
disabled:false,//是否可用
|
||
|
missingMessage:"该项必填",
|
||
|
startDate:"",//预置开始选择时间
|
||
|
endDate:"",//预置结束选择时间
|
||
|
daysOfWeekDisabled:""//一周的周几不能选
|
||
|
};
|
||
|
|
||
|
$.extend(options,op);//合并属性
|
||
|
|
||
|
var ic;//容器
|
||
|
if(!options.did){
|
||
|
options.did=$.getUUID();
|
||
|
ic=$("<div did='"+options.did+"' dtype='ctr_datetime' class='text-group d-item'></div>");
|
||
|
}else{
|
||
|
ic=$("[did='"+options.did+"']");
|
||
|
}
|
||
|
ic.empty();//清空
|
||
|
//标签
|
||
|
var label = $('<label for="'+options.id+'" class="control-label">'+options.label+'</label>').appendTo(ic);
|
||
|
//日期时间的容器
|
||
|
var inputcon=$('<div></div>').appendTo(ic);
|
||
|
//日期时间框
|
||
|
var input = $('<div id="'+options.id+'" class="form-group input-group date form_datetime">'+
|
||
|
'<input name="'+options.id+'" class="form-control" size="16" type="text" value="'+options.initvalue+'" readonly> '+
|
||
|
'<span class="input-group-addon"><span class="glyphicon glyphicon-remove"></span></span>'+
|
||
|
'<span class="input-group-addon"><span class="glyphicon glyphicon-th"></span></span>'+
|
||
|
'</div>').appendTo(inputcon);
|
||
|
//保存参数到控件
|
||
|
ic.data("options",options);
|
||
|
|
||
|
//单击事件
|
||
|
ic.click(function(event){
|
||
|
_setSelectStatus(this,event);
|
||
|
});
|
||
|
return ic;
|
||
|
}
|
||
|
|
||
|
|
||
|
/**
|
||
|
* 渲染日期选择控件
|
||
|
*/
|
||
|
function _render_ctr_date(op){
|
||
|
//默认属性值
|
||
|
var options={
|
||
|
id:"",
|
||
|
label:"日期",
|
||
|
initvalue:"",//初始值
|
||
|
required:false,//是否必填
|
||
|
disabled:false,//是否可用
|
||
|
missingMessage:"该项必填",
|
||
|
startDate:"",//预置开始选择时间
|
||
|
endDate:"",//预置结束选择时间
|
||
|
daysOfWeekDisabled:""//一周的周几不能选
|
||
|
};
|
||
|
|
||
|
$.extend(options,op);//合并属性
|
||
|
|
||
|
var ic;//容器
|
||
|
if(!options.did){
|
||
|
options.did=$.getUUID();
|
||
|
ic=$("<div did='"+options.did+"' dtype='ctr_date' class='text-group d-item'></div>");
|
||
|
}else{
|
||
|
ic=$("[did='"+options.did+"']");
|
||
|
}
|
||
|
ic.empty();//清空
|
||
|
//标签
|
||
|
var label = $('<label for="'+options.id+'" class="control-label">'+options.label+'</label>').appendTo(ic);
|
||
|
//日期时间的容器
|
||
|
var inputcon=$('<div></div>').appendTo(ic);
|
||
|
//日期时间框
|
||
|
var input = $('<div id="'+options.id+'" class="form-group input-group date form_date">'+
|
||
|
'<input name="'+options.id+'" class="form-control" size="16" type="text" value="'+options.initvalue+'" readonly> '+
|
||
|
'<span class="input-group-addon"><span class="glyphicon glyphicon-remove"></span></span>'+
|
||
|
'<span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>'+
|
||
|
'</div>').appendTo(inputcon);
|
||
|
//保存参数到控件
|
||
|
ic.data("options",options);
|
||
|
|
||
|
//单击事件
|
||
|
ic.click(function(event){
|
||
|
_setSelectStatus(this,event);
|
||
|
});
|
||
|
return ic;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 渲染日期选择控件
|
||
|
*/
|
||
|
function _render_ctr_time(op){
|
||
|
//默认属性值
|
||
|
var options={
|
||
|
id:"",
|
||
|
label:"时间",
|
||
|
initvalue:"",//初始值
|
||
|
required:false,//是否必填
|
||
|
disabled:false,//是否可用
|
||
|
missingMessage:"该项必填"
|
||
|
};
|
||
|
|
||
|
$.extend(options,op);//合并属性
|
||
|
|
||
|
var ic;//容器
|
||
|
if(!options.did){
|
||
|
options.did=$.getUUID();
|
||
|
ic=$("<div did='"+options.did+"' dtype='ctr_time' class='text-group d-item'></div>");
|
||
|
}else{
|
||
|
ic=$("[did='"+options.did+"']");
|
||
|
}
|
||
|
ic.empty();//清空
|
||
|
//标签
|
||
|
var label = $('<label for="'+options.id+'" class="control-label">'+options.label+'</label>').appendTo(ic);
|
||
|
//日期时间的容器
|
||
|
var inputcon=$('<div></div>').appendTo(ic);
|
||
|
//日期时间框
|
||
|
var input = $('<div id="'+options.id+'" class="form-group input-group date form_time">'+
|
||
|
'<input name="'+options.id+'" class="form-control" size="16" type="text" value="'+options.initvalue+'" readonly> '+
|
||
|
'<span class="input-group-addon"><span class="glyphicon glyphicon-remove"></span></span>'+
|
||
|
'<span class="input-group-addon"><span class="glyphicon glyphicon-time"></span></span>'+
|
||
|
'</div>').appendTo(inputcon);
|
||
|
//保存参数到控件
|
||
|
ic.data("options",options);
|
||
|
|
||
|
//单击事件
|
||
|
ic.click(function(event){
|
||
|
_setSelectStatus(this,event);
|
||
|
});
|
||
|
return ic;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 渲染月份选择控件
|
||
|
*/
|
||
|
function _render_ctr_moth(op){
|
||
|
//默认属性值
|
||
|
var options={
|
||
|
id:"",
|
||
|
label:"月份",
|
||
|
initvalue:"",//初始值
|
||
|
required:false,//是否必填
|
||
|
disabled:false,//是否可用
|
||
|
missingMessage:"该项必填",
|
||
|
startDate:"",//预置开始选择时间
|
||
|
endDate:"",//预置结束选择时间
|
||
|
daysOfWeekDisabled:""//一周的周几不能选
|
||
|
};
|
||
|
|
||
|
$.extend(options,op);//合并属性
|
||
|
|
||
|
var ic;//容器
|
||
|
if(!options.did){
|
||
|
options.did=$.getUUID();
|
||
|
ic=$("<div did='"+options.did+"' dtype='ctr_date' class='text-group d-item'></div>");
|
||
|
}else{
|
||
|
ic=$("[did='"+options.did+"']");
|
||
|
}
|
||
|
ic.empty();//清空
|
||
|
//标签
|
||
|
var label = $('<label for="'+options.id+'" class="control-label">'+options.label+'</label>').appendTo(ic);
|
||
|
//日期时间的容器
|
||
|
var inputcon=$('<div></div>').appendTo(ic);
|
||
|
//日期时间框
|
||
|
var input = $('<div id="'+options.id+'" class="form-group input-group date form_date_moth">'+
|
||
|
'<input name="'+options.id+'" class="form-control" size="16" type="text" value="'+options.initvalue+'" readonly> '+
|
||
|
'<span class="input-group-addon"><span class="glyphicon glyphicon-remove"></span></span>'+
|
||
|
'<span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>'+
|
||
|
'</div>'+
|
||
|
'<script type="text/javascript">'+
|
||
|
'$(".form_date_moth").datetimepicker({'+
|
||
|
'language: "zh-CN",'+
|
||
|
'format: "yyyy-mm",'+
|
||
|
'autoclose: true,'+
|
||
|
'todayBtn: true,'+
|
||
|
'startView: "year",'+
|
||
|
'minView:"year",'+
|
||
|
'maxView:"decade"'+
|
||
|
'});'+
|
||
|
'</script>').appendTo(inputcon);
|
||
|
//保存参数到控件
|
||
|
ic.data("options",options);
|
||
|
|
||
|
//单击事件
|
||
|
ic.click(function(event){
|
||
|
_setSelectStatus(this,event);
|
||
|
});
|
||
|
return ic;
|
||
|
}
|
||
|
|
||
|
|
||
|
/**
|
||
|
* 渲染时间段选择选择控件
|
||
|
*/
|
||
|
function _render_ctr_time_quantum(op){
|
||
|
//默认属性值
|
||
|
var options={
|
||
|
id:"",
|
||
|
type:"form_datetime",
|
||
|
label:"日期",
|
||
|
initstart:"",//开始初始值
|
||
|
initend:"",//结束初始值
|
||
|
required:false,//是否必填
|
||
|
disabled:false,//是否可用
|
||
|
missingMessage:"该项必填",
|
||
|
startDate:"",//预置开始选择时间
|
||
|
endDate:"",//预置结束选择时间
|
||
|
daysOfWeekDisabled:""//一周的周几不能选
|
||
|
};
|
||
|
|
||
|
$.extend(options,op);//合并属性
|
||
|
|
||
|
var ic;//容器
|
||
|
if(!options.did){
|
||
|
options.did=$.getUUID();
|
||
|
ic=$("<div did='"+options.did+"' dtype='ctr_time_quantum' class='text-group d-item'></div>");
|
||
|
}else{
|
||
|
ic=$("[did='"+options.did+"']");
|
||
|
}
|
||
|
ic.empty();//清空
|
||
|
//标签
|
||
|
var label = $('<label for="'+options.id+'" class="control-label">'+options.label+'</label>').appendTo(ic);
|
||
|
//时间段的容器
|
||
|
var inputcon=$('<div></div>').appendTo(ic);
|
||
|
//时间段框
|
||
|
|
||
|
var input = $( '<div id="'+options.id+'" name="'+options.id+'" class="form-group">'+
|
||
|
'<div id="start" class="input-group date '+options.type+'" style="float: left;width: 48%;">'+
|
||
|
' <input name="date1" class="form-control" size="16" type="text" value="'+options.initstart+'" readonly>'+
|
||
|
' <span class="input-group-addon">'+
|
||
|
' <span class="glyphicon glyphicon-remove"></span>'+
|
||
|
' </span> '+
|
||
|
' <span class="input-group-addon">'+
|
||
|
' <span class="glyphicon glyphicon-calendar"></span>'+
|
||
|
' </span>'+
|
||
|
'</div>'+
|
||
|
'<span style="margin: 1%;">~</span>'+
|
||
|
'<div id="end" class="input-group date '+options.type+'" style="float: right;width: 48%;">'+
|
||
|
' <input name="date1" class="form-control" size="16" type="text" value="'+options.initend+'" readonly>'+
|
||
|
' <span class="input-group-addon">'+
|
||
|
' <span class="glyphicon glyphicon-remove"></span>'+
|
||
|
' </span> '+
|
||
|
' <span class="input-group-addon">'+
|
||
|
' <span class="glyphicon glyphicon-calendar"></span>'+
|
||
|
' </span>'+
|
||
|
'</div>'+
|
||
|
'</div>').appendTo(inputcon);
|
||
|
//保存参数到控件
|
||
|
ic.data("options",options);
|
||
|
|
||
|
//单击事件
|
||
|
ic.click(function(event){
|
||
|
_setSelectStatus(this,event);
|
||
|
});
|
||
|
return ic;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 渲染按钮式单选控件
|
||
|
*/
|
||
|
function _render_ctr_button_radio(op){
|
||
|
//默认属性值
|
||
|
var options={
|
||
|
id:"",
|
||
|
label:"按钮式单选",
|
||
|
data:[],
|
||
|
initvalue:"",//初始值
|
||
|
required:false,//是否必填
|
||
|
disabled:false,//是否可用
|
||
|
missingMessage:"该项必填"
|
||
|
|
||
|
};
|
||
|
|
||
|
$.extend(options,op);//合并属性
|
||
|
|
||
|
var ic;//容器
|
||
|
if(!options.did){
|
||
|
options.did=$.getUUID();
|
||
|
ic=$("<div did='"+options.did+"' dtype='ctr_button_radio' class='text-group d-item'></div>");
|
||
|
}else{
|
||
|
ic=$("[did='"+options.did+"']");
|
||
|
}
|
||
|
ic.empty();//清空
|
||
|
//标签
|
||
|
var label = $('<label for="'+options.id+'" class="control-label">'+options.label+'</label>').appendTo(ic);
|
||
|
//容器
|
||
|
var inputcon=$('<div></div>').appendTo(ic);
|
||
|
|
||
|
var op = '<div class="button-radio form-group" id="'+options.id+' name="'+options.id+'">';
|
||
|
for(var i = 0;i <options.data.length;i++ ){
|
||
|
if(options.data[i].id === options.initvalue){
|
||
|
op = op+'<div class="radio-child radio-child-active" value="'+options.data[i].id+'">'+options.data[i].text+'</div>';
|
||
|
}else{
|
||
|
op = op+'<div class="radio-child" value="'+options.data[i].id+'">'+options.data[i].text+'</div>';
|
||
|
}
|
||
|
}
|
||
|
op = op + '<input type="hidden"></div>';
|
||
|
|
||
|
var input = $(op).appendTo(inputcon);
|
||
|
//保存参数到控件
|
||
|
ic.data("options",options);
|
||
|
|
||
|
//单击事件
|
||
|
ic.click(function(event){
|
||
|
_setSelectStatus(this,event);
|
||
|
});
|
||
|
return ic;
|
||
|
}
|
||
|
|
||
|
|
||
|
/**
|
||
|
* 渲染按钮式多选控件
|
||
|
*/
|
||
|
function _render_ctr_button_checkbox(op){
|
||
|
//默认属性值
|
||
|
var options={
|
||
|
id:"",
|
||
|
label:"按钮式多选",
|
||
|
data:[],
|
||
|
initvalue:"",//初始值
|
||
|
required:false,//是否必填
|
||
|
disabled:false,//是否可用
|
||
|
missingMessage:"该项必填"
|
||
|
|
||
|
};
|
||
|
|
||
|
$.extend(options,op);//合并属性
|
||
|
|
||
|
var ic;//容器
|
||
|
if(!options.did){
|
||
|
options.did=$.getUUID();
|
||
|
ic=$("<div did='"+options.did+"' dtype='ctr_button_checkbox' class='text-group d-item'></div>");
|
||
|
}else{
|
||
|
ic=$("[did='"+options.did+"']");
|
||
|
}
|
||
|
ic.empty();//清空
|
||
|
//标签
|
||
|
var label = $('<label for="'+options.id+'" class="control-label">'+options.label+'</label>').appendTo(ic);
|
||
|
//容器
|
||
|
var inputcon=$('<div></div>').appendTo(ic);
|
||
|
|
||
|
var op = '<div class="button-checkbox form-group" id="'+options.id+' name="'+options.id+'">';
|
||
|
var initv = options.initvalue.split(",");
|
||
|
for(var i = 0;i <options.data.length;i++ ){
|
||
|
var flag = false;
|
||
|
for(var j = 0 ;j<initv.length;j++){
|
||
|
if(options.data[i].id === initv[j]){
|
||
|
flag = true;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
if(flag){
|
||
|
op = op+'<div class="checkbox-child checkbox-child-active" value="'+options.data[i].id+'">'+options.data[i].text+'</div>';
|
||
|
}else{
|
||
|
op = op+'<div class="checkbox-child" value="'+options.data[i].id+'">'+options.data[i].text+'</div>';
|
||
|
}
|
||
|
}
|
||
|
op = op + '<input type="hidden"></div>';
|
||
|
|
||
|
var input = $(op).appendTo(inputcon);
|
||
|
//保存参数到控件
|
||
|
ic.data("options",options);
|
||
|
|
||
|
//单击事件
|
||
|
ic.click(function(event){
|
||
|
_setSelectStatus(this,event);
|
||
|
});
|
||
|
return ic;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 渲染单选控件
|
||
|
*/
|
||
|
function _render_ctr_radio(op){
|
||
|
//默认属性值
|
||
|
var options={
|
||
|
id:"",
|
||
|
label:"单选",
|
||
|
data:[],
|
||
|
initvalue:"",//初始值
|
||
|
required:false,//是否必填
|
||
|
disabled:false,//是否可用
|
||
|
missingMessage:"该项必填"
|
||
|
};
|
||
|
|
||
|
$.extend(options,op);//合并属性
|
||
|
|
||
|
var ic;//容器
|
||
|
if(!options.did){
|
||
|
options.did=$.getUUID();
|
||
|
ic=$("<div did='"+options.did+"' dtype='ctr_radio' class='text-group d-item'></div>");
|
||
|
}else{
|
||
|
ic=$("[did='"+options.did+"']");
|
||
|
}
|
||
|
ic.empty();//清空
|
||
|
//标签
|
||
|
var label = $('<label for="'+options.id+'" class="control-label">'+options.label+'</label>').appendTo(ic);
|
||
|
//日期时间的容器
|
||
|
var inputcon=$('<div></div>').appendTo(ic);
|
||
|
|
||
|
var inp = '<div class="form-group">';
|
||
|
|
||
|
for(var i = 0 ; i <options.data.length ; i++){
|
||
|
if(options.data[i].id === options.initvalue){
|
||
|
inp = inp + '<input type="radio" id="'+options.id+'" name="'+options.id+'" placeholder="" value="'+options.data[i].id+'" checked>'+options.data[i].text+'';
|
||
|
}else{
|
||
|
inp = inp + '<input type="radio" id="'+options.id+'" name="'+options.id+'" placeholder="" value="'+options.data[i].id+'" >'+options.data[i].text+'';
|
||
|
}
|
||
|
}
|
||
|
inp = inp + '</div>';
|
||
|
//日期时间框
|
||
|
var input = $(inp).appendTo(inputcon);
|
||
|
//保存参数到控件
|
||
|
ic.data("options",options);
|
||
|
|
||
|
//单击事件
|
||
|
ic.click(function(event){
|
||
|
_setSelectStatus(this,event);
|
||
|
});
|
||
|
return ic;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 渲染多选控件
|
||
|
*/
|
||
|
function _render_ctr_checkbox(op){
|
||
|
//默认属性值
|
||
|
var options={
|
||
|
id:"",
|
||
|
label:"多选",
|
||
|
data:[],
|
||
|
initvalue:"",//初始值
|
||
|
required:false,//是否必填
|
||
|
disabled:false,//是否可用
|
||
|
missingMessage:"该项必填"
|
||
|
};
|
||
|
|
||
|
$.extend(options,op);//合并属性
|
||
|
|
||
|
var ic;//容器
|
||
|
if(!options.did){
|
||
|
options.did=$.getUUID();
|
||
|
ic=$("<div did='"+options.did+"' dtype='ctr_checkbox' class='text-group d-item'></div>");
|
||
|
}else{
|
||
|
ic=$("[did='"+options.did+"']");
|
||
|
}
|
||
|
ic.empty();//清空
|
||
|
//标签
|
||
|
var label = $('<label for="'+options.id+'" class="control-label">'+options.label+'</label>').appendTo(ic);
|
||
|
//日期时间的容器
|
||
|
var inputcon=$('<div></div>').appendTo(ic);
|
||
|
|
||
|
var inp = '<div class="form-group">';
|
||
|
|
||
|
var initv = options.initvalue.split(",");
|
||
|
for(var i = 0 ; i <options.data.length ; i++){
|
||
|
var flag = false;
|
||
|
for(var j=0;j<initv.length;j++){
|
||
|
if(options.data[i].id === initv[j]){
|
||
|
flag = true;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
if(flag){
|
||
|
inp = inp + '<input type="checkbox" id="'+options.id+'" name="'+options.id+'" placeholder="" value="'+options.data[i].id+'" checked>'+options.data[i].text+'';
|
||
|
}else{
|
||
|
inp = inp + '<input type="checkbox" id="'+options.id+'" name="'+options.id+'" placeholder="" value="'+options.data[i].id+'" >'+options.data[i].text+'';
|
||
|
}
|
||
|
}
|
||
|
inp = inp+ '</div>';
|
||
|
//日期时间框
|
||
|
var input = $(inp).appendTo(inputcon);
|
||
|
//保存参数到控件
|
||
|
ic.data("options",options);
|
||
|
|
||
|
//单击事件
|
||
|
ic.click(function(event){
|
||
|
_setSelectStatus(this,event);
|
||
|
});
|
||
|
return ic;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 渲染下拉单选控件
|
||
|
*/
|
||
|
function _render_ctr_select_radio(op){
|
||
|
//默认属性值
|
||
|
var options={
|
||
|
id:"",
|
||
|
label:"下拉单选",
|
||
|
data:[],
|
||
|
initvalue:"",//初始值
|
||
|
required:false,//是否必填
|
||
|
disabled:false,//是否可用
|
||
|
missingMessage:"该项必填"
|
||
|
};
|
||
|
|
||
|
$.extend(options,op);//合并属性
|
||
|
|
||
|
var ic;//容器
|
||
|
if(!options.did){
|
||
|
options.did=$.getUUID();
|
||
|
ic=$("<div did='"+options.did+"' dtype='ctr_select_radio' class='text-group d-item'></div>");
|
||
|
}else{
|
||
|
ic=$("[did='"+options.did+"']");
|
||
|
}
|
||
|
ic.empty();//清空
|
||
|
//标签
|
||
|
var label = $('<label for="'+options.id+'" class="control-label">'+options.label+'</label>').appendTo(ic);
|
||
|
//日期时间的容器
|
||
|
var inputcon=$('<div></div>').appendTo(ic);
|
||
|
|
||
|
var inp = '<select class="form-control form-group" id="'+options.id+'" name="'+options.id+'" >';
|
||
|
|
||
|
for(var i = 0 ; i <options.data.length ; i++){
|
||
|
inp = inp + '<option value="'+options.data[i].id+'">'+options.data[i].text+'</option>';
|
||
|
}
|
||
|
inp = inp + '</select>'+
|
||
|
'<script type="text/javascript">'+
|
||
|
' $.buttonSelect({id:"'+options.id+'"});'+
|
||
|
' $.buttonSelect_setValue("'+options.id+'","'+options.initvalue+'");'+
|
||
|
'</script>';
|
||
|
|
||
|
//日期时间框
|
||
|
var input = $(inp).appendTo(inputcon);
|
||
|
//保存参数到控件
|
||
|
ic.data("options",options);
|
||
|
|
||
|
//单击事件
|
||
|
ic.click(function(event){
|
||
|
_setSelectStatus(this,event);
|
||
|
});
|
||
|
return ic;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 渲染下拉多选控件
|
||
|
*/
|
||
|
function _render_ctr_select_checkbox(op){
|
||
|
//默认属性值
|
||
|
var options={
|
||
|
id:"",
|
||
|
label:"下拉多选",
|
||
|
data:[],
|
||
|
initvalue:"",//初始值
|
||
|
required:false,//是否必填
|
||
|
disabled:false,//是否可用
|
||
|
missingMessage:"该项必填"
|
||
|
};
|
||
|
|
||
|
$.extend(options,op);//合并属性
|
||
|
|
||
|
var ic;//容器
|
||
|
if(!options.did){
|
||
|
options.did=$.getUUID();
|
||
|
ic=$("<div did='"+options.did+"' dtype='ctr_select_radio' class='text-group d-item'></div>");
|
||
|
}else{
|
||
|
ic=$("[did='"+options.did+"']");
|
||
|
}
|
||
|
ic.empty();//清空
|
||
|
//标签
|
||
|
var label = $('<label for="'+options.id+'" class="control-label">'+options.label+'</label>').appendTo(ic);
|
||
|
//日期时间的容器
|
||
|
var inputcon=$('<div></div>').appendTo(ic);
|
||
|
|
||
|
var initv = options.initvalue.split(",");
|
||
|
|
||
|
var inp = '<select class="form-control select2 form-group" id="'+options.id+'" name="'+options.id+'" multiple="multiple">';
|
||
|
for(var i = 0 ; i <options.data.length ; i++){
|
||
|
var flag = false;
|
||
|
for(var j = 0 ;j<initv.length;j++){
|
||
|
if(options.data[i].id === initv[j]){
|
||
|
flag = true;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
if(flag){
|
||
|
inp = inp + '<option value="'+options.data[i].id+'" selected>'+options.data[i].text+'</option>';
|
||
|
}else{
|
||
|
inp = inp + '<option value="'+options.data[i].id+'">'+options.data[i].text+'</option>';
|
||
|
}
|
||
|
|
||
|
}
|
||
|
inp = inp + '</select>';
|
||
|
|
||
|
//日期时间框
|
||
|
var input = $(inp).appendTo(inputcon);
|
||
|
//保存参数到控件
|
||
|
ic.data("options",options);
|
||
|
|
||
|
//单击事件
|
||
|
ic.click(function(event){
|
||
|
_setSelectStatus(this,event);
|
||
|
});
|
||
|
return ic;
|
||
|
}
|
||
|
|
||
|
|
||
|
/**
|
||
|
* 渲染可过滤下拉单选控件
|
||
|
*/
|
||
|
function _render_ctr_filter_radio(op){
|
||
|
//默认属性值
|
||
|
var options={
|
||
|
id:"",
|
||
|
label:"下拉单选",
|
||
|
data:[],
|
||
|
initvalue:"",//初始值
|
||
|
required:false,//是否必填
|
||
|
disabled:false,//是否可用
|
||
|
missingMessage:"该项必填"
|
||
|
};
|
||
|
|
||
|
$.extend(options,op);//合并属性
|
||
|
|
||
|
var ic;//容器
|
||
|
if(!options.did){
|
||
|
options.did=$.getUUID();
|
||
|
ic=$("<div did='"+options.did+"' dtype='ctr_filter_radio' class='text-group d-item'></div>");
|
||
|
}else{
|
||
|
ic=$("[did='"+options.did+"']");
|
||
|
}
|
||
|
ic.empty();//清空
|
||
|
//标签
|
||
|
var label = $('<label for="'+options.id+'" class="control-label">'+options.label+'</label>').appendTo(ic);
|
||
|
//日期时间的容器
|
||
|
var inputcon=$('<div></div>').appendTo(ic);
|
||
|
|
||
|
var initv = options.initvalue.split(",");
|
||
|
|
||
|
var inp = '<select class="form-control select2 form-group" id="'+options.id+'" name="'+options.id+'">';
|
||
|
for(var i = 0 ; i <options.data.length ; i++){
|
||
|
var flag = false;
|
||
|
for(var j = 0 ;j<initv.length;j++){
|
||
|
if(options.data[i].id === initv[j]){
|
||
|
flag = true;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
if(flag){
|
||
|
inp = inp + '<option value="'+options.data[i].id+'" selected>'+options.data[i].text+'</option>';
|
||
|
}else{
|
||
|
inp = inp + '<option value="'+options.data[i].id+'">'+options.data[i].text+'</option>';
|
||
|
}
|
||
|
|
||
|
}
|
||
|
inp = inp + '</select>';
|
||
|
|
||
|
//日期时间框
|
||
|
var input = $(inp).appendTo(inputcon);
|
||
|
//保存参数到控件
|
||
|
ic.data("options",options);
|
||
|
|
||
|
//单击事件
|
||
|
ic.click(function(event){
|
||
|
_setSelectStatus(this,event);
|
||
|
});
|
||
|
return ic;
|
||
|
}
|