';
if(me.content.find("div.m-form-group").length >0)
{
if(option.isMoveLeft)
{
html = '
';
me.content.append(html);
if(index!=0)
{
$("#"+andOrControlId).ligerComboBox({width:65,data:option.andOrData,value:"and"});
}
$("#"+fieldControlId).ligerComboBox({width:100,data:option.fields,textField:"text",extendField:"type",
onSelected:function(value,text,row){
//改变条件控件
if(row.type=="NUMERIC")
{
$("#"+conditionControlId).ligerComboBox("setData",option.numberTypeData)
}
else if(row.type=="DATE"){
$("#"+conditionControlId).ligerComboBox("setData",option.dateTypeData)
}
else{
$("#"+conditionControlId).ligerComboBox("setData",option.stringTypeData)
}
$("#"+conditionControlId).ligerComboBox("setValue"," = ");
}
});
$("#"+conditionControlId).ligerComboBox({width:80});
if(andOr!=undefined)
{
$("#"+andOrControlId).ligerComboBox("setValue",andOr);
}
if(field!=undefined)
{
$("#"+fieldControlId).ligerComboBox("setValue",field);
}
if(condition!=undefined)
{
$("#"+conditionControlId).ligerComboBox("setValue",condition);
}
if(value!=undefined)
{
me.changeValueType(index,value);
//$("#"+conditionControlId).ligerComboBox("setValue",condition);
}
//绑定事件
$("#"+conditionControlId).ligerComboBox({
onSelected:function(value,text){
//改变值控件
me.changeValueType(index);
}
});
option.index = index+1;
},
//改变值控件类型
changeValueType:function(index,value){
try{
var me = this;
var option = me.options;
var groupId = me.textFieldID+"_"+index;
var fieldControlId = groupId+"_"+option.fieldControlFlag;
var conditionControlId = groupId+"_"+option.conditionControlFlag;
var field = $("#"+fieldControlId).ligerComboBox("getSelected");
var condition = $("#"+conditionControlId).ligerComboBox("getValue");
if(field==null || condition==null)
{
return;
}
var dict =field.dict;
var dataType = field.type;
var type="textbox";
if(dataType == "NUMERIC")//数值
{
type = "numberbox";
}
else if(dataType == "DATE") //时间
{
type = "datebox";
}
else{
if(dict!=null && dict!="0")//字典控件
{
if(condition == " IN " || condition == " NOT IN ")
{
type = "mult_combobox";
}
else{
type = "combobox";
}
}
else{
if(condition == " IN " || condition == " NOT IN ")
{
type = "mult_textbox";
}
}
}
me.createValueControl(index,type,dict,value);
}
catch(e)
{
return;
}
},
//创建值控件
createValueControl:function(index,type,dict,value){
var me = this;
var option = me.options;
var groupId = me.textFieldID+"_"+index;
var valueControlId = groupId+"_"+option.valueControlFlag;
var valueDiv =$("#"+groupId+"_"+option.valueControlFlag+"_div");
var oldType = valueDiv.attr("controlType");
if(oldType != type || value!=undefined)
{
if(value==undefined) value = "";
valueDiv.attr("controlType",type)
if(type=="combobox") //字典
{
valueDiv.html('
');
var parms = {dictId:dict};
$.extend(parms,option.stdDictParms);
$("#"+valueControlId).ligerComboBox({width:200,url:option.stdDictUrl,urlParms:parms,value:value});
}
else if(type=="datebox") //时间
{
valueDiv.html('
');
$("#"+valueControlId).ligerDateEditor({width:200,value:value});
}
else if(type=="numberbox") //数值
{
valueDiv.html('
');
$("#"+valueControlId).ligerTextBox({width: 200,digits:true,value:value});
}
else if(type=="mult_combobox") //多选字典
{
valueDiv.html('
');
var parms = {dictId:dict};
$.extend(parms,option.stdDictParms);
$("#"+valueControlId).ligerMultbox({width:200,stdDictUrl:option.stdDictUrl,urlParms:parms,value:value});
}
else if(type=="mult_textbox") //多项文本
{
valueDiv.html('
');
$("#"+valueControlId).ligerMultbox({width:200,value:value});
}
else //文本框
{
valueDiv.html('
');
}
}
}
});
/******************* 搜索控件 *************************************/
//add by hzp at 20160223
$.fn.ligerSearch = function ()
{
return $.ligerui.run.call(this, "ligerSearch", arguments);
};
$.ligerDefaults.Search = {
onChange: null, //改变值事件
onClick: null, //搜索按钮事件
disabled: false,
readonly: false //是否只读
};
$.ligerMethos.Search = {};
$.ligerui.controls.Search = function (element, options)
{
$.ligerui.controls.Search.base.constructor.call(this, element, options);
};
$.ligerui.controls.Search.ligerExtend($.ligerui.controls.Input, {
__getType: function ()
{
return 'Search';
},
_extendMethods: function ()
{
return $.ligerMethos.Search;
},
_init: function () {
$.ligerui.controls.Search.base._init.call(this);
},
_render: function ()
{
var g = this, p = this.options;
g.inputText = null;
g.value = null;
g.textFieldID = "";
if (this.element.tagName.toLowerCase() == "input" && this.element.type && this.element.type == "text")
{
g.inputText = $(this.element);
if (this.element.id)
g.textFieldID = this.element.id;
}
else
{
g.inputText = $('
');
g.inputText.appendTo($(this.element));
}
if (g.textFieldID == "" && p.textFieldID)
g.textFieldID = p.textFieldID;
g.searchBtn = $('
');
g.wrapper = g.inputText.wrap('
').parent();
g.wrapper.append(g.searchBtn);
g.inputText.addClass("l-text-field");
//设置宽度
if(p.width)
{
g.wrapper.width(p.width);
g.inputText.width(p.width-12);
}
if (p.disabled)
{
g.wrapper.addClass("l-text-disabled");
}
//初始化
if (g.value!=null)
{
g.setValue(g.value);
}
//点击事件
if(!p.disabled && p.onClick!=null && typeof(p.onClick)=="function")
{
g.searchBtn.click(function(){
p.onClick(g.getValue());
});
}
//值改变事件
if(!p.disabled && p.onChange!=null && typeof(p.onChange)=="function")
{
g.inputText.change(function () {
p.onChange(g.getValue());
});
}
g.inputText.blur(function ()
{
if (!p.disabled)
g.wrapper.removeClass("l-text-focus");
}).focus(function ()
{
if (!p.disabled)
g.wrapper.addClass("l-text-focus");
});
g.wrapper.hover(function ()
{
if (!p.disabled)
g.wrapper.addClass("l-text-over");
}, function ()
{
g.wrapper.removeClass("l-text-over");
});
},
setValue: function (value)
{
var g = this, p = this.options;
if (!value || value == "NaN") value = "";
this.inputText.val(value)
},
getValue:function()
{
return this.inputText.val();
}
});
/******************* 多选控件 *************************************/
//add by hzp at 20160223
$.fn.ligerMultbox = function ()
{
return $.ligerui.run.call(this, "ligerMultbox", arguments);
};
$.ligerDefaults.Multbox = {
disabled: false,
readonly: false, //是否只读
boxType:"text",
gridOptions: {
},
valueField: 'CustomerID',
textField: 'CustomerID'
};
$.ligerMethos.Multbox = {};
$.ligerui.controls.Multbox = function (element, options)
{
$.ligerui.controls.Multbox.base.constructor.call(this, element, options);
};
$.ligerui.controls.Multbox.ligerExtend($.ligerui.controls.Input, {
__getType: function ()
{
return 'Multbox';
},
_extendMethods: function ()
{
return $.ligerMethos.Multbox;
},
_init: function () {
$.ligerui.controls.Multbox.base._init.call(this);
},
_render: function ()
{
var g = this, p = this.options;
g.inputValue = null;
g.inputControl = null;
g.value = null;
g.textFieldID = "";
if (this.element.tagName.toLowerCase() == "input" && this.element.type)
{
if(this.element.type == "text")
{
$(this.element).attr("type","hidden");
}
g.inputValue = $(this.element);
if (this.element.id)
g.textFieldID = this.element.id;
}
if (g.textFieldID == "" && p.textFieldID)
g.textFieldID = p.textFieldID;
g.addBtn = $('
');
g.addBtnWrapper = g.addBtn.wrap('
').parent();
g.addBtnWrapper.append('
');
g.wrapper = g.inputValue.wrap('
').parent();
g.wrapper.append('
').after(g.addBtnWrapper);
g.inputControl = $("#"+g.textFieldID+"_control");
g.content = $("#"+g.textFieldID+"_content");
g.wrapper.wrap('
');
//字典控件
if(p.stdDictUrl!=null)
{
p.boxType = "combo";
/*g.inputControl.ligerComboBox({width:135,url:p.stdDictUrl,urlParms:p.urlParms});
if(g.inputControl[0].type == "text")
{
$(g.inputControl).attr("type","hidden");
}*/
}
g.setWidth();
//初始化
if (p.value!=null)
{
g.setValue(p.value);
}
//禁用
if (p.disabled)
{
g.wrapper.addClass("l-text-disabled");
//按钮失效
return;
}
//添加按钮
g.addBtn.click(function(){
if(p.boxType != "text")
{
//弹窗多选字典数据
var val = g.getValue();
g.selectDialog(val,function(val,text){
g.setValue(val,text);
});
}
else
{
g.inputControl.val('');
$(this).next().show();
}
})
//添加确认按钮
$("#"+g.textFieldID+"_control_ok").click(function(){
var val = g.inputControl.val();
var text = g.inputControl.val();
if(val!=null && val.length>0)
{
if(g.inputControl.prev().hasClass('l-text-combobox')){
text = g.inputControl.ligerComboBox("getText");
}
if(val.indexOf(',')>=0)
{
$.ligerDialog.error("不能包含特殊字符!");
return;
}
g.newItem(val,text);
$(this).parent().hide();
}
});
//添加取消按钮
$("#"+g.textFieldID+"_control_cancle").click(function(){
$(this).parent().hide();
});
},
newItem:function(val,text){
var me = this;
var b = true;
$.each(me.content.find("div"),function(index,item){
var value = $(item).attr("value");
if(value == val)
{
b=false;
return;
}
});
if(b)
{
me.content.append('
');
}
},
setWidth:function(){
var me = this;
var option = me.options;
if(option.width!=null)
{
me.wrapper.css({width:option.width});
me.content.css({width:option.width-5});
me.addBtnWrapper.css({width:option.width});
}
},
setValue: function (val,text)
{
var me = this, option = me.options;
if (!val || val == "NaN") val = "";
me.content.find("div").remove();
if(text!=undefined&&text.length>0)
{
var arr = val.split(',');
var arrText = text.split(',');
if(arr.length == arrText.length)
{
for(var i=0;i
0)
{
var arr = val.split(',');
if(option.boxType!="text")
{
$.ajax({ //获取表的字段列表
type: "POST",
url : option.stdDictUrl,
dataType : "json",
data:option.urlParms,
cache:false,
success :function(data){
if(data.successFlg) {
if(data.detailModelList!=null && data.detailModelList.length>0)
{
for(var i=0;i0)
{
var arr = val.split(',');
for(var i=0;i0) {
me.controls.push({name:name,control:$(this)});
}
});
$("input", jform).each(function ()
{
try{
var name = $(this).attr("name");
var control = null;
var controlType = "html"; //html为html控件 ui为ligerUI控件
var rule = null; //校验规则
var message = null; //校验提示信息
if(name!=undefined && name.length>0)
{
//是否已存在
for(var i=0;i0)
{
switch (rule)
{
case "email":
{
break;
}
case "url":
{
break;
}
case "date":
{
break;
}
case "dateISO":
{
break;
}
case "number":
{
break;
}
case "digits":
{
break;
}
case "equalTo"://你的输入不相同
{
break;
}
case "extension"://请输入有效的后缀
{
break;
}
case "maxlength"://最多可以输入 {0} 个字符
{
if(value.length>ruleValue)
{
return message.format(ruleValue);
}
break;
}
case "minlength"://最少要输入 {0} 个字符
{
if(value.lengthruleValue)
{
return message.format(ruleValue);
}
break;
}
case "min"://请输入不小于 {0} 的数值
{
if(value0)
{
error += ";"+re;
}
else{
error = re;
}
}
}
}
//是否报错
if(error.length>0)
{
if(message!=null && message.length > 0)
{
me.showError(control,message);
}
else{
me.showError(control,error);
}
suc = false;
}
else{
me.clearError(control);
}
}
}
return suc;
}
catch(e)
{
return false;
}
},
//清除某个控件错误提示
clearError:function(control){
var me = this;
var dom;
if(control.controlType == "ui")
{
dom = $(control.control.element).closest(".m-form-control");
}
else{
dom = control.control.closest(".m-form-control");
}
dom.removeClass('m-from-error').find('.m-from-error-msg').remove();
},
//某个控件错误提示
showError:function(control,error){
var me = this;
var dom;
if(control.controlType == "ui")
{
dom = $(control.control.element).closest(".m-form-control");
}
else{
dom = control.control.closest(".m-form-control");
}
if(dom.hasClass('m-from-error'))
{
me.clearError(control);
}
var el = $('');
dom.addClass('m-from-error').append(el);
el.hover(function ()
{
$(this).ligerTip({content:error});
},function (){
$(this).ligerHideTip();
});
},
//只读操作
readOnly:function(){
},
//获取数据
getData:function(){
var me = this, option = this.options;
var data = {};
for(var i=0;i