123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858 |
- /**
- * 该js用于页面的查询功能
- * 2015-11-25 梁俊鹏
- * **/
- var userId = top.com.sinosoft.lz.system.user.LoginInfo.getUser_id();//用户id
- var menupageid = "";
- if(window.location.search.split("&&")[0].split("=")[0]=="?menu_id"){
- menupageid = window.location.search.split("&&")[0].split("=")[1];//menu表的id
- }else{//通过url到sys_menu 表中查出对应的menu_id
- var pageurl = window.location.toString().split("?")[0];
- pageurl = pageurl.substring(pageurl.indexOf("/nwyj"));
- var url = "/nwyj/ws/mcs/MemoryConditionService/queryMenuId/";
- var params = {
- "pageurl":pageurl
- };
- $.ajax({
- url : url,
- type : 'post',
- data : params,
- async:false,
- dataType : 'text',
- success : function(data) {
- menupageid = data;
- },
- error : function(e) {
- $.messager.alert('访问服务失败!');
- }
- });
- }
- $(function(){
- //绑定更多点击时的样式变换
- $(".more_hide").live("click",function(){
- var $moreSelf = $(this);
- $moreSelf.removeClass("more_hide");
- $moreSelf.addClass("more_show");
- });
- $(".more_show").live("click",function(){
- var $moreSelf = $(this);
- $moreSelf.removeClass("more_show");
- $moreSelf.addClass("more_hide");
- });
-
- //输入框绑定事件
- $(".Textinput").live("change",inputChange);
- //单个时间框绑定
- $(".date").live("blur",inputChange);
-
- //双时间框绑定
- $(".beginTime").live("blur",function(){
- var $begin = $(this);
- var $end = $begin.parent().find(".endTime");
- timeChange($end,$begin);
- });
- //双时间框绑定
- $(".endTime").live("blur",function(){
- var $end = $(this);
- var $begin = $end.parent().find(".beginTime");
- timeChange($end,$begin);
- });
-
- });
-
-
-
- function getQueryFormParams($dom){
- var $input = $dom.find("table").eq(0).find("input[type=text]");
- var params = {};
- for (var i = 0; i < $input.length; i++) {
- if($input.eq(i).val()!=""){
- var domName = $input.eq(i).attr("name");
- var value = $input.eq(i).val();
- params[domName] = value;
- }
- }
- return params;
- }
- /***用于获取更多查询列表中的值**/
- function getSelectCon(conditiondatas){
- var searchCondition = {};
- if(!!conditiondatas){
- var list = conditiondatas.list;
- searchCondition["condition"] = "";
- for(var i=0;i<list.length;i++){
- var className = list[i].className;
- var equalType = list[i].equalType;
- var $con = $("#selectConditions").find("."+className).eq(0);
- var selValue = $con.data("data-selValue");
- selValue = selValue == undefined ? "":selValue;
- if(selValue!="" && selValue.length > 1){
- searchCondition["condition"] += "(";
- var numArr = selValue.split(",");
- for(var j=0;j<numArr.length;j++){
- if("equal" == equalType ){//等号匹配方式
- searchCondition["condition"] += className +" = '"+numArr[j]+"'";
- }else if("BA" == equalType && numArr[j].split("_").length>1){//两值之间
- var startvalue = numArr[j].split("_")[0];
- var endvalue = numArr[j].split("_")[1];
- if(endvalue!="+"){
- if(parseInt(endvalue)>=0){
- searchCondition["condition"] += className +" between "+startvalue+" and "+endvalue;
- }else{
- searchCondition["condition"] += className +" between '"+startvalue+"' and '"+endvalue+"'";
- }
- }else{
- if(parseInt(startvalue)>=0){
- searchCondition["condition"] += className +" >= "+startvalue+" ";
- }else{
- searchCondition["condition"] += className +" >= '"+startvalue+"' ";
- }
- }
- }else{//默认like匹配
- if('TEAM_LEVEL'==className){
- if("10kV"==numArr[j]){
- searchCondition["condition"] +="("+"replace("+className+",'110kV','')" +" like '%"+numArr[j]+"%')";
- // searchCondition["condition"] += "("+replace(className,'110kV','') +" like '"+numArr[j]+"%' and "+replace(className,'110kV','')+" not like '%,"+numArr[j]+"' or "+replace(className,'110kV','')+" like '%,"+numArr[j]+",%' or "+replace(className,'110kV','') +" like '%"+numArr[j]+"%'"+")";
- }else{
- searchCondition["condition"] += "("+className +" like '"+numArr[j]+",%' or "+className+" like '%,"+numArr[j]+"' or "+className+" like '%,"+numArr[j]+",%' or "+className +" like '%"+numArr[j]+"%'"+")";
- }
- }else{
-
- searchCondition["condition"] += className +" like '%"+numArr[j]+"%'";
- }
- }
- if(j!=numArr.length-1){
- searchCondition["condition"] += " or ";
- }
- }
- searchCondition["condition"] += ")";
- }else {
- if(selValue!=""){
- if("equal" == equalType ){
- searchCondition["condition"] += className +" = '"+selValue+"'";
- }else{
- searchCondition["condition"] += className +" like '%"+selValue+"%'";
- }
- }
- }
- if(selValue!=""){
- searchCondition["condition"] += " and ";
- }
- }
- }
- searchCondition["condition"] = searchCondition["condition"]==undefined?"":searchCondition["condition"];
- var inputvalue = getInputValue();
- searchCondition["condition"] = inputvalue["condition"] + searchCondition["condition"];
- if(!(searchCondition["condition"]=="" || searchCondition["condition"]==" ")){
- showSaveDom();
- }
- return searchCondition;
- }
- /***用于获取更多查询列表中的值11**/
- function getSelectCon1(conditiondatas){
- var searchCondition = {};
- var list = conditiondatas.list;
- for(var i=0;i<list.length;i++){
- var className = list[i].className;
- var $con = $("#selectConditions").find("."+className).eq(0);
- var selValue = $con.data("data-selValue");
- selValue = selValue == undefined ? "":selValue;
- if(selValue!="" && selValue.length > 1){
- var numArr = selValue.split(",");
- searchCondition[className] = "";
- for(var j=0;j<numArr.length;j++){
- searchCondition[className] += numArr[j]+"_";
- }
- }else {
- if(selValue!=""){
- searchCondition[className] = selValue;
- }
- }
- }
- if(searchCondition.length==0){
- showSaveDom();
- }
- return searchCondition;
- }
-
- /****************当搜索之时,显示保存字样***********************/
- function showSaveDom(){
- $("#deleteMeCon").hide();
- $("#saveMeCon").show();
- window.setTimeout(hidesave, 10000);
- }
-
- /*******隐藏保存字样********/
- function hidesave(){
- $("#saveMeCon").hide();
- $("#deleteMeCon").show();
- }
-
-
- /**用于获取输入框的值***/
- function getInputValue(){
- var inputvalue = {"condition":" "};
- var $input = $("#conditions").find("input");
- for(var i=0;i<$input.length;i++ ){
- var inputone = $input.eq(i);
- if(typeof(inputone.attr("name"))!="undefined"){
- var inputName = inputone.attr("name");
- var value = inputone.val();
- if(!!value){
- if(inputone.hasClass("dateIcon")){
- if(i+1<$input.length && $input.eq(i+1).hasClass("dateIcon")){
- var value1 = inputone.val();
- var value2 = $input.eq(i+1).val();
- if(value2==""){
- value2 = getDateTime11();
- }
- if($input.eq(i+1).hasClass("noToChar")){
- inputvalue.condition += " "+inputName + " between '" +
- value1.substring(0,value1.lastIndexOf("-")) +"' and '" + value2.substring(0,value2.lastIndexOf("-")) +"' ";
- }else{
- inputvalue.condition += " to_char("+inputName + ",'yyyy-mm-dd') between '" +
- value1 +"' and '" + value2 +"' ";
- }
- i++;
- }
- }else if(inputone.hasClass("date")){
- inputvalue.condition += inputName +" = '"+value+"'";
- }else{
- inputvalue.condition += inputName +" like '%"+value+"%'";
- }
- inputvalue.condition += " and ";
- }
- }
- }
- return inputvalue;
- }
-
- //时间双选框变化事件
- function timeChange($end,$begin){
- var $id1 = $begin;
- var $id2 = $end;
- var $self = $end;
- var value = "";
- var name = $self.attr("name");
- // var $timeIfr = $(top.document.body).find("div[lang=zh-cn]");//时间框的父节点div,位于顶层页面的div容器下的iframe中的子页面
- // if($timeIfr && $timeIfr.css("display")=="none" ){//若日期框未隐藏
- if(!$id1.val()){//若开始日期为空,则默认开始日期与结束日期一样
- // top.Dialog.alert('开始日期不能为空!');
- // $("#selectConditions ."+name).click();
- // return;
- $id1.val($id2.val());
- }
- // }
- value += $id1.val();
- value += " ~ ";
- value += $id2.val();
- // alert($id2.prop("outerHTML"))
- // alert($id2.val())
- var $seleCondi = $("#selectConditions");
- $seleUl = $seleCondi.find("ul");
- var $thisDom = $seleCondi.find("."+name);
- var $condiOne = $thisDom;
- if(!$id1.val() && !$id2.val()){
- if($thisDom){
- $thisDom.click();
- return;
- }
- }
- if(!$id2.val()){//若结束日期为空,则取当前日期为结束日期
- value += getDateTime11();
- }
- var title = $self.parent().parent().find(".condiTitle").text();
- if($thisDom.html()==null){
- $condiOne = $('<li class="selectCondi '+name+'"><span class="condiTitle">'
- +title+'</span><span class="cons">'+value+'</span></li>');
- $seleUl.append($condiOne);
- }
- $thisDom.find(".cons").html(value);
- $condiOne.data("data1",$id1);
- $condiOne.data("data2",$id2);
- var $seleCondi = $("#selectConditions");
- $seleCondi.append($condiOne);
-
- $(".selectCondi").bind("click",function(){
- var _$self = $(this);
- var data1 = _$self.data("data1");
- var data2 = _$self.data("data2");
- if(!!data1){
- data1.val("");
- }
- if(!!data2){
- data2.val("");
- }
- _$self.remove();
- });
- }
- /****绑定输入框改变值事件*****/
- function inputChange(){
- var $self = $(this);
- var value = $self.val();
- var title = $self.parent().parent().find(".condiTitle").text();
- var $seleCondi = $("#selectConditions");
- $seleUl = $seleCondi.find("ul");
- var name = $self.attr("name");
- var $thisDom = $seleCondi.find("."+name);
- var $condiOne = $thisDom;
- if(value==""){
- $thisDom.click();
- return;
- }
- if($thisDom.html()==null){
- $condiOne = $('<li class="selectCondi '+name+'"><span class="condiTitle">'
- +title+'</span><span class="cons">'+value+'</span></li>');
- $seleUl.append($condiOne);
- }
- $thisDom.find(".cons").html(value);
- $condiOne.data("data",$self);
- var $seleCondi = $("#selectConditions");
- $seleCondi.append($condiOne);
-
- $(".selectCondi").bind("click",function(){
- var _$self = $(this);
- var data = _$self.data("data");
- if(!!data){
- data.val("");
- }
- _$self.remove();
- $(".selectmecon").removeClass("selectmecon");
- });
- }
- /*************生成li列表****************/
- function createLiList($condi,conditiondatas){
- for(var i=0;i<conditiondatas.list.length;i++){
- if(conditiondatas.list[i]==""||conditiondatas.list[i]==undefined){
- continue;
- }
- var conTitle = conditiondatas.list[i].name;
- var $condiTitle = $('<li class="condiTitle">'+conTitle+':</li>');
- var $ul = $('<ul></ul>');
- $ul.append($condiTitle);
- var conRow = conditiondatas.list[i].list;
- var className = conditiondatas.list[i].className;
- var equalType = conditiondatas.list[i].equalType;
- var selectType = conditiondatas.list[i].selectType;
- var dataType = conditiondatas.list[i].dataType;
- selectType = selectType==undefined?"":selectType;
- equalType = equalType==undefined?"":equalType;
- dataType = dataType==undefined?"":dataType;
- for(var j=0;j<conRow.length;j++){
- var selected = conRow[j].selected;
- selected = selected==true?"_defaultSelected":"";
- var $condiCont = $('<li class="item '+className+' '+equalType+' '+selectType+' '+selected+' '+dataType+' " id="conOneId_'+(i+1)+j+'">'+conRow[j].key+'</li>');
- $condiCont.data("data-value",conRow[j].value);
- $condiCont.data("data-class",className);
- $condiCont.data("data-text",conRow[j].key);
- $condiCont.data("data-index",j);
- $ul.append($condiCont);
- if(selectType!="" && selectType=="selectOnly"){
- $condiCont.unbind("click").bind("click",bindSelectOnly);
- }else{
- $condiCont.unbind("click").bind("click",bindSelectOne);
- }
- }
- var $clear = $('<div class="clear"></div>');
- $ul.append($clear);
- $condi.append($ul).append($clear);
- }
- //ul-li列表点击事件
- //$("li.item").unbind("click").bind("click",bindSelectOne);
- }
- /*****************生成已选择条件容器************************/
- function createSelectedDiv($condi){
- var $selectedCon = $('<div class="selContent"><table width="100%"><tr></tr></table></div>');
- var $tr = $selectedCon.find("tr").eq(0);
- $tr.append($('<td style="width:120px;"><div class="condiTitle">您已选择:</div></td>'));
- $tr.append($('<td class="selectConditions" id="selectConditions" text-align="left"></td>'));
- var $tdf = $('<td style="width:155px;"></td>');
- var $searchButt = $('<input type="button" value="查询" id="searchButt"/>');
- var $empButt = $('<input type="button" id="emptyCondition" value="清空条件"/>');
- $tdf.append($searchButt).append(" ").append($empButt);
- $tr.append($tdf);
- $searchButt.render();
- $empButt.render();
- $condi.after($selectedCon);
- $selectedCon.render();
- $condi.render();
- var $seleUl = $('<ul></ul>');
- var $seleCondi = $("#selectConditions");
- $seleCondi.append($seleUl);
-
-
- //清空条件
- $empButt.bind("click",function(){
- $(".selectmecon").removeClass("selectmecon");
- var $selConditions = $("#selectConditions");
- var $selCon = $selConditions.find(".selectCondi");
- if(!!$selCon){
- for(var i=0;i<$selCon.length;i++){
- $selCon[i].click();
- }
- }
- $("form").find("input[type='text']").val("");
- });
- }
- /*****************生成常用过滤条件容器************************/
- function createMemoryCondi(){
- //生成“您常用的过滤条件”
- var $selectedCon = $(".selContent");
- var $alwaysCondi = $('<div class="alwaysCondi"><table width="100%"><tr></tr></table></div>');
- var _$tr = $alwaysCondi.find("tr").eq(0);
- _$tr.append($('<td><div class="alwaysCondiTitle">常用过滤器:</div></td>'));
- _$tr.append($('<td class="alwaysCondiName" id="alwaysCondiName" width="85%"></td>'));
- var $deleteBtn = $('<input id="deleteConBtn" type="button" value="删除过滤器"/>');
- var $cansoledeleteBtn = $('<input id="cansoledeleteBtn" style="display:none" type="button" value="取消"/>');
- _$tr.append($('<td class="deleteMeCon" id="deleteMeCon" width="15%" style="text-align:center;"></td>').append($deleteBtn).append($cansoledeleteBtn));
- $deleteBtn.bind("click",beforeDeleteMeCondition);
- $deleteBtn.render();
- $cansoledeleteBtn.bind("click",cansoledelete);
- $cansoledeleteBtn.render();
- _$tr.append($('<td class="saveMeCon" id="saveMeCon" width="15%" style="text-align:center;display:none"><div>您使用了一个新的搜索,需要<a href="javascript:;" id="saveLink">保存</a>为过滤器吗?</div></td>'));
- $selectedCon.after($alwaysCondi);
- queryCon($alwaysCondi);
- $("#saveLink").bind("click",beforeSaveMemoryCondition);
- }
-
- /*************查询后台**************/
- function queryCon($alwaysCondi){
- var result ;
- var url = "/nwyj/ws/mcs/MemoryConditionService/queryCondition/";
- var params = {
- "userId":userId,
- "menupageid":menupageid
- };
- $.ajax({
- url : url,
- type : 'post',
- data : params,
- async:false,
- dataType : 'text',
- success : function(data) {
- //alert(JSON.stringify(data));
- if(data!=""){
- var aaaa = eval('('+data+')');
- var _$ul = $('<ul></ul>');
- if(aaaa.length>0){
- for (var k = 0; k < aaaa.length; k++) {
- var name = aaaa[k].name;
- var condi = aaaa[k];
- var _$li = $('<li class="memorycondition">'+name+'</li>');
- _$ul.append(_$li);
- _$li.data("data-condi",condi);
- //绑定点击事件
- _$li.bind("click",clickmemorycontent);
- $("#deleteConBtn").show();
- }
- }else{
- $("#deleteConBtn").hide();
- }
- _$ul.append($('<div class="clear"></div>'));
- $alwaysCondi.find("#alwaysCondiName").append(_$ul);
- }
- },
- error : function(e) {
- $.messager.alert('查询过滤器失败!');
- }
- });
- return result;
- }
-
- /*****创建过滤筛选列表*****/
- function createConditionsDom(conditiondatas){
- var $condi = $("#conditions");
- if(conditiondatas){
- createLiList($condi,conditiondatas);
- }
-
- createSelectedDiv($condi);
-
- createMemoryCondi();
- if($("._defaultSelected").length>0){
- $("._defaultSelected").click();
- }
- }
-
- /***********常用过滤条件点击事件方法***************/
- function clickmemorycontent(){
- var $5self = $(this);
- $("#emptyCondition").click();
- //样式
- if($5self.hasClass("selectmecon")){
- $5self.removeClass("selectmecon");
- }else{
- $5self.siblings().removeClass("selectmecon");
- $5self.addClass("selectmecon");
- var datacondi = $5self.data("data-condi").condition;
- for (var h = 0; h < datacondi.length; h++) {
- var condiOne = datacondi[h];
- var contype = condiOne.type;
- var classname = condiOne.name;
- var convalue = condiOne.value;
- if(contype=="li"){
- convalue = convalue.split("__");
- for (var y = 0; y < convalue.length; y++) {
- if(convalue[y]!=""){
- $("#conditions ."+classname).eq(convalue[y]).click();
- }
- }
- }else if(contype=="Textinput"){
- $("#conditions input[name='"+classname+"']").val(convalue);
- $("#conditions input[name='"+classname+"']").change();
-
- }else if(contype=="date"){
- $("#conditions input[name='"+classname+"']").val(convalue);
- $("#conditions input[name='"+classname+"']").blur();
-
- }else if(contype=="dateIcon"){
- var $class = $("#conditions input[name='"+classname+"']");
- if($class.length==2){
- $class.eq(0).val(convalue.split("__")[0]);
- $class.eq(1).val(convalue.split("__")[1]);
- $class.eq(1).blur();
- }
- }
- }
- }
- //功能
- }
-
- /******选中事件 可多选 比较方法为 “like” *******/
- function bindSelectOne(){
- var $self = $(this);
- var itemtext = $self.text();
- var $seleCondi = $("#selectConditions");
- $seleUl = $seleCondi.find("ul");
- var condiTitle = $self.parent().find(".condiTitle").text();
- $self.addClass("selectedCond");
- var className = $self.data("data-class");
- var $thisDom = $seleCondi.find("."+className);
- var $condiOne = $thisDom;
- if($thisDom.html()==null){
- $condiOne = $('<li class="selectCondi '+className+'" ><span class="condiTitle">'+condiTitle+'</span><span class="cons"></span></li>');
- $seleUl.append($condiOne);
- }
- var consText = $condiOne.find(".cons").text();
- if(!!consText){
- itemtext = consText +" , "+ itemtext;
- }
- $condiOne.find(".cons").text(itemtext);
- var index = $self.data("data-index");
- $condiOne.data("data"+index,$self);
- var num = $condiOne.data("data-num");
- if(num!=undefined){
- num += "," +index;
- }else{
- num = index;
- }
- $condiOne.data("data-num",num);
- var value = $condiOne.data("data-selValue");
- var value1 = $self.data("data-value");
- if(value!=undefined){
- value += "," +value1;
- }else{
- value = value1;
- }
- $condiOne.data("data-selValue",value);
- $self.css({"color":"blue","font-weight":"bold"});
- if( $self.data("data-value")=="0000"){//若点击了全部,则选择该项全部
- $self.siblings().each(function(i){
- if(!$self.siblings().eq(i).hasClass("selectedCond")){//未选中的调用点击方法
- $self.siblings().eq(i).click();
- }
- })
- $condiOne.find(".cons").text($self.data("data-text"));
- }
- $self.unbind("click");
- $(".selectedCond").unbind("click").bind("click",cansSelect);
- /******绑定删除选中事件******/
- $(".selectCondi").unbind("click").bind("click",function(){
- var _$self = $(this);
- var number = _$self.data("data-num");
- if(number)
- number = number.toString();
- if(number && (number.length>=0 || number.indexOf("0")!=-1)){
- if(number.length > 1){
- var numArr = number.split(",");
- for(var i=0;i<numArr.length;i++){
- var data = _$self.data("data"+numArr[i]);
- data.css({"color":"#271700","font-weight":"normal"});
- data.removeClass("selectedCond");
- data.unbind("click").bind("click",bindSelectOne);
- }
- }else {
- var data = _$self.data("data"+number);
- data.css({"color":"#271700","font-weight":"normal"});
- data.removeClass("selectedCond");
- data.unbind("click").bind("click",bindSelectOne);
-
- }
- }
- _$self.remove();
- $(".selectmecon").removeClass("selectmecon");
- });
- }
- /******选中事件 只单选 且比较方法为“=” 而非 “like” *******/
- function bindSelectOnly(){
- var $self = $(this);
- var itemtext = $self.text();
- var $seleCondi = $("#selectConditions");
- $seleUl = $seleCondi.find("ul");
- var condiTitle = $self.parent().find(".condiTitle").text();
- $self.addClass("selectedCond");
- var className = $self.data("data-class");
- var $thisDom = $seleCondi.find("."+className);
- var $condiOne = $thisDom;
- if($condiOne.html()==null){
- $condiOne = $('<li class="selectCondi selectCondiOnly '+className+'" ><span class="condiTitle">'+condiTitle+'</span><span class="cons"></span></li>');
- $seleUl.append($condiOne);
- }else{
- $condiOne.click();
- $condiOne = $('<li class="selectCondi selectCondiOnly '+className+'"><span class="condiTitle">'+condiTitle+'</span><span class="cons"></span></li>');
- $seleUl.append($condiOne);
- }
- $condiOne.find(".cons").text(itemtext);
- $condiOne.data("data-dom",$self);
- var value = $condiOne.data("data-selValue");
- var value1 = $self.data("data-value");
- if(value!=undefined){
- value += "," +value1;
- }else{
- value = value1;
- }
- $condiOne.data("data-selValue",value);
- $self.css({"color":"blue","font-weight":"bold"});
- if( $self.data("data-value")=="0000"){//若点击了 njhuy7全部,则选择该项全部
- $self.siblings().click();
- $condiOne.find(".cons").text($self.data("data-text"));
- }
- $self.unbind("click");
- $(".selectedCond").unbind("click").bind("click",cansSelect);
- /******绑定删除选中事件******/
- $(".selectCondiOnly").bind("click",function(){
- var _$self = $(this);
- var $dom = _$self.data("data-dom");
- $dom.css({"color":"#271700","font-weight":"normal"});
- $dom.removeClass("selectedCond");
- $dom.unbind("click").bind("click",bindSelectOnly);
- _$self.remove();
- $(".selectmecon").removeClass("selectmecon");
- });
- }
-
- /**********删除过滤器之前的方法**********/
- function beforeDeleteMeCondition(){
- var $self = $(this);
- $self.hide();
- $("#cansoledeleteBtn").show();
- var $conditions = $(".memorycondition");
- if($conditions){
- for (var i = 0; i < $conditions.length; i++) {
- $conditions.eq(i).addClass("beforeDelete").unbind("click").bind("click",deleteMeCondition);
- }
- }
- }
- /**********取消 删除过滤器的方法**********/
- function cansoledelete(){
- var $self = $(this);
- $self.hide();
- $("#deleteConBtn").show();
- var $conditions = $(".memorycondition");
- if($conditions){
- for (var i = 0; i < $conditions.length; i++) {
- $conditions.eq(i).removeClass("beforeDelete").unbind("click").bind("click",clickmemorycontent);
- }
- }
- }
- /**********删除过滤器的方法**********/
- function deleteMeCondition(){
- var $self = $(this);
- var datacondi = $self.data("data-condi");
- var fd_id = datacondi.fd_id;
- var params = {
- "fd_id" : fd_id
- };
- $.ajax({
- url : "/nwyj/ws/mcs/MemoryConditionService/deleteCondition/",
- type : 'post',
- data : params,
- dataType : 'json',
- success : function(data) {
- $self.remove();
- var $li = $("#alwaysCondiName ul li");
- if($li.length==0){
- $("#cansoledeleteBtn").hide();
- $("#deleteConBtn").hide();
- }
- },
- error : function(e) {
- $.messager.alert('删除失败!');
- }
- });
- }
-
- /***********新增过滤器之前*************/
- function beforeSaveMemoryCondition(){
- var diag = new top.Dialog();
- diag.URL="/nwyj/page/saveSearchCondition.jsp";
- diag.Title="保存过滤器 ";
- diag.Width=500;
- diag.Height=80;
- diag.ShowButtonRow=true;
- diag.OKEvent = function(){
- var conditionName = diag.innerFrame.contentWindow.document.getElementById('memoryCondiName').value;
- var paramsData = beforeAddGetValue();
- diag.close();
- addNewCondition(conditionName,paramsData);
- };
- diag.show();
- }
-
-
- function addNewCondition(conditionName,paramsData){
- var url = "/nwyj/ws/mcs/MemoryConditionService/addCondition/";
- var params = {
- "userId":userId,
- "menupageid":menupageid,
- "name":conditionName,
- "paramsData":paramsData
- };
- $.ajax({
- url : url,
- type : 'post',
- data : params,
- dataType : 'json',
- success : function(data) {
- var $alwaysCondi = $(".alwaysCondi");
- $alwaysCondi.find("#alwaysCondiName").html("");
- queryCon($alwaysCondi);
- },
- error : function(e) {
- $.messager.alert('添加失败!');
- }
- });
-
- }
- /***************新增过滤器时,获取值*******************/
- function beforeAddGetValue(){
- var paramsData = "";
- var $con = $("#conditions ul");
- for (var i = 0; i < $con.length; i++) {
- var $input = $con.eq(i).find("input");
- if($input.length>0){
- if($input.hasClass("dateIcon") && $input.eq(0).val()!=""){//双选日期框
- paramsData += $input.eq(0).attr("name") + "!dateIcon:";
- if($input.length==2){
- paramsData += $input.eq(0).val() + "__" + $input.eq(1).val();
- paramsData += ",";
- }
- }else{//单个日期框和输入框
- if($input.val()!=""){
- if($input.hasClass("date")){
- paramsData += $input.attr("name") + "!date:";
- }else if($input.hasClass("Textinput")){
- paramsData += $input.attr("name") + "!Textinput:";
- }
-
- paramsData += $input.val();
- paramsData += ",";
- }
- }
- }else {
- var $licon = $con.eq(i).find(".item");
- if($licon){
- if($con.eq(i).find(".selectedCond").length>0){//若该字段有选中项
- paramsData += $licon.eq(0).attr("class").split(" ")[1] + "!li:";
- for (var j = 0; j < $licon.length; j++) {
- if($licon.eq(j).hasClass("selectedCond")){
- paramsData += j + "__";
- }
- }
- paramsData += ",";
- }
- }
- }
-
- }
- return paramsData;
- }
- /**
- * 点击选项,取消选择该项
- */
- function cansSelect(){
- /******改变样式*****/
- $(this).css({"color":"#271700","font-weight":"normal"});
- $(this).removeClass("selectedCond");
- /******改变样式*****/
- var index = $(this).data("data-index");//取出下标
- var className =$(this).data("data-class");//取出类名
- var $seldom = $("#selectConditions").find("."+className).eq(0);//通过类名找到已选择中响应的选项
- //alert($seldom.data("data-"+index).html());
- var nums = $seldom.data("data-num");//取出节点中选中的所有项的下标
- var domValue = $(this).data("data-value");
- if(domValue=="0000"){//如果点击了全选,则全部删除
- $seldom.click();
- }
- nums += "";
- nums = nums.split(",");
- var nums1 = "";
- var $allCon = $("#conditions ."+className);
- var value = "";
- var selValue = "";
- for (var i = 0; i < nums.length; i++) {
- if(nums.length==1){//若当前只选择了一项,只有一个值时
- $seldom.click();
- }else{
- if(nums[i]==0){//如果选择了全选,则去掉全选
- $allCon.eq(0).removeClass("selectedCond");
- $allCon.eq(0).css({"color":"#271700","font-weight":"normal"});
- $allCon.eq(0).unbind("click").bind("click",bindSelectOne);
- }else if(index!=nums[i]){//不加要取消选择的该项index
- nums1 += nums[i]+",";
- value += $allCon.eq(nums[i]).text()+",";
- selValue += $allCon.eq(nums[i]).data("data-value")+",";
- }
-
- }
- }
- if(value.lastIndexOf(",")==value.length-1){
- value = value.substring(0, value.length-1);
- }
- if(nums1.lastIndexOf(",")==nums1.length-1){
- nums1 = nums1.substring(0, nums1.length-1);
- }
- if(selValue.lastIndexOf(",")==selValue.length-1){
- selValue = selValue.substring(0, selValue.length-1);
- }
- $seldom.data("data-num",nums1);//重新取num值重新绑定
- //$seldom.data("data-value",value);//重新取value值重新绑定
- $seldom.data("data-selValue",selValue);//重新取sel-value值重新绑定
- //$seldom.data("data-"+index,null);//将已选中响应的data解绑
- $seldom.find(".cons").text(value);
- //$seldom.height($seldom.find(".cons").height());
- //重新绑定方法
- if($(this).hasClass("selectOnly")){
- $(this).unbind("click").bind("click",bindSelectOnly);
- }else{
- $(this).unbind("click").bind("click",bindSelectOne);
- }
- $(".selectmecon").removeClass("selectmecon");
- $seldom = null;
- }
-
- //获得当前系统时间
- function getDateTime11(){
- var s="";
- var d = allGetServerTime();
- var vYear = d.getFullYear();
- var vMon = d.getMonth() + 1;
- var vDay = d.getDate();
- /*var h = d.getHours();
- var m = d.getMinutes(); */
- s=vYear+"-"+(vMon<10 ? "0" + vMon : vMon)+"-"+(vDay<10 ? "0"+ vDay : vDay)/*+" "+(h<10 ? "0"+ h : h)+":"+(m<10 ? "0" + m : m)*/;
- return s;
- }
|