c34f09693499b9758e2646760cc3aa3e43726bff.svn-base 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858
  1. /**
  2. * 该js用于页面的查询功能
  3. * 2015-11-25 梁俊鹏
  4. * **/
  5. var userId = top.com.sinosoft.lz.system.user.LoginInfo.getUser_id();//用户id
  6. var menupageid = "";
  7. if(window.location.search.split("&&")[0].split("=")[0]=="?menu_id"){
  8. menupageid = window.location.search.split("&&")[0].split("=")[1];//menu表的id
  9. }else{//通过url到sys_menu 表中查出对应的menu_id
  10. var pageurl = window.location.toString().split("?")[0];
  11. pageurl = pageurl.substring(pageurl.indexOf("/nwyj"));
  12. var url = "/nwyj/ws/mcs/MemoryConditionService/queryMenuId/";
  13. var params = {
  14. "pageurl":pageurl
  15. };
  16. $.ajax({
  17. url : url,
  18. type : 'post',
  19. data : params,
  20. async:false,
  21. dataType : 'text',
  22. success : function(data) {
  23. menupageid = data;
  24. },
  25. error : function(e) {
  26. $.messager.alert('访问服务失败!');
  27. }
  28. });
  29. }
  30. $(function(){
  31. //绑定更多点击时的样式变换
  32. $(".more_hide").live("click",function(){
  33. var $moreSelf = $(this);
  34. $moreSelf.removeClass("more_hide");
  35. $moreSelf.addClass("more_show");
  36. });
  37. $(".more_show").live("click",function(){
  38. var $moreSelf = $(this);
  39. $moreSelf.removeClass("more_show");
  40. $moreSelf.addClass("more_hide");
  41. });
  42. //输入框绑定事件
  43. $(".Textinput").live("change",inputChange);
  44. //单个时间框绑定
  45. $(".date").live("blur",inputChange);
  46. //双时间框绑定
  47. $(".beginTime").live("blur",function(){
  48. var $begin = $(this);
  49. var $end = $begin.parent().find(".endTime");
  50. timeChange($end,$begin);
  51. });
  52. //双时间框绑定
  53. $(".endTime").live("blur",function(){
  54. var $end = $(this);
  55. var $begin = $end.parent().find(".beginTime");
  56. timeChange($end,$begin);
  57. });
  58. });
  59. function getQueryFormParams($dom){
  60. var $input = $dom.find("table").eq(0).find("input[type=text]");
  61. var params = {};
  62. for (var i = 0; i < $input.length; i++) {
  63. if($input.eq(i).val()!=""){
  64. var domName = $input.eq(i).attr("name");
  65. var value = $input.eq(i).val();
  66. params[domName] = value;
  67. }
  68. }
  69. return params;
  70. }
  71. /***用于获取更多查询列表中的值**/
  72. function getSelectCon(conditiondatas){
  73. var searchCondition = {};
  74. if(!!conditiondatas){
  75. var list = conditiondatas.list;
  76. searchCondition["condition"] = "";
  77. for(var i=0;i<list.length;i++){
  78. var className = list[i].className;
  79. var equalType = list[i].equalType;
  80. var $con = $("#selectConditions").find("."+className).eq(0);
  81. var selValue = $con.data("data-selValue");
  82. selValue = selValue == undefined ? "":selValue;
  83. if(selValue!="" && selValue.length > 1){
  84. searchCondition["condition"] += "(";
  85. var numArr = selValue.split(",");
  86. for(var j=0;j<numArr.length;j++){
  87. if("equal" == equalType ){//等号匹配方式
  88. searchCondition["condition"] += className +" = '"+numArr[j]+"'";
  89. }else if("BA" == equalType && numArr[j].split("_").length>1){//两值之间
  90. var startvalue = numArr[j].split("_")[0];
  91. var endvalue = numArr[j].split("_")[1];
  92. if(endvalue!="+"){
  93. if(parseInt(endvalue)>=0){
  94. searchCondition["condition"] += className +" between "+startvalue+" and "+endvalue;
  95. }else{
  96. searchCondition["condition"] += className +" between '"+startvalue+"' and '"+endvalue+"'";
  97. }
  98. }else{
  99. if(parseInt(startvalue)>=0){
  100. searchCondition["condition"] += className +" >= "+startvalue+" ";
  101. }else{
  102. searchCondition["condition"] += className +" >= '"+startvalue+"' ";
  103. }
  104. }
  105. }else{//默认like匹配
  106. if('TEAM_LEVEL'==className){
  107. if("10kV"==numArr[j]){
  108. searchCondition["condition"] +="("+"replace("+className+",'110kV','')" +" like '%"+numArr[j]+"%')";
  109. // 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]+"%'"+")";
  110. }else{
  111. searchCondition["condition"] += "("+className +" like '"+numArr[j]+",%' or "+className+" like '%,"+numArr[j]+"' or "+className+" like '%,"+numArr[j]+",%' or "+className +" like '%"+numArr[j]+"%'"+")";
  112. }
  113. }else{
  114. searchCondition["condition"] += className +" like '%"+numArr[j]+"%'";
  115. }
  116. }
  117. if(j!=numArr.length-1){
  118. searchCondition["condition"] += " or ";
  119. }
  120. }
  121. searchCondition["condition"] += ")";
  122. }else {
  123. if(selValue!=""){
  124. if("equal" == equalType ){
  125. searchCondition["condition"] += className +" = '"+selValue+"'";
  126. }else{
  127. searchCondition["condition"] += className +" like '%"+selValue+"%'";
  128. }
  129. }
  130. }
  131. if(selValue!=""){
  132. searchCondition["condition"] += " and ";
  133. }
  134. }
  135. }
  136. searchCondition["condition"] = searchCondition["condition"]==undefined?"":searchCondition["condition"];
  137. var inputvalue = getInputValue();
  138. searchCondition["condition"] = inputvalue["condition"] + searchCondition["condition"];
  139. if(!(searchCondition["condition"]=="" || searchCondition["condition"]==" ")){
  140. showSaveDom();
  141. }
  142. return searchCondition;
  143. }
  144. /***用于获取更多查询列表中的值11**/
  145. function getSelectCon1(conditiondatas){
  146. var searchCondition = {};
  147. var list = conditiondatas.list;
  148. for(var i=0;i<list.length;i++){
  149. var className = list[i].className;
  150. var $con = $("#selectConditions").find("."+className).eq(0);
  151. var selValue = $con.data("data-selValue");
  152. selValue = selValue == undefined ? "":selValue;
  153. if(selValue!="" && selValue.length > 1){
  154. var numArr = selValue.split(",");
  155. searchCondition[className] = "";
  156. for(var j=0;j<numArr.length;j++){
  157. searchCondition[className] += numArr[j]+"_";
  158. }
  159. }else {
  160. if(selValue!=""){
  161. searchCondition[className] = selValue;
  162. }
  163. }
  164. }
  165. if(searchCondition.length==0){
  166. showSaveDom();
  167. }
  168. return searchCondition;
  169. }
  170. /****************当搜索之时,显示保存字样***********************/
  171. function showSaveDom(){
  172. $("#deleteMeCon").hide();
  173. $("#saveMeCon").show();
  174. window.setTimeout(hidesave, 10000);
  175. }
  176. /*******隐藏保存字样********/
  177. function hidesave(){
  178. $("#saveMeCon").hide();
  179. $("#deleteMeCon").show();
  180. }
  181. /**用于获取输入框的值***/
  182. function getInputValue(){
  183. var inputvalue = {"condition":" "};
  184. var $input = $("#conditions").find("input");
  185. for(var i=0;i<$input.length;i++ ){
  186. var inputone = $input.eq(i);
  187. if(typeof(inputone.attr("name"))!="undefined"){
  188. var inputName = inputone.attr("name");
  189. var value = inputone.val();
  190. if(!!value){
  191. if(inputone.hasClass("dateIcon")){
  192. if(i+1<$input.length && $input.eq(i+1).hasClass("dateIcon")){
  193. var value1 = inputone.val();
  194. var value2 = $input.eq(i+1).val();
  195. if(value2==""){
  196. value2 = getDateTime11();
  197. }
  198. if($input.eq(i+1).hasClass("noToChar")){
  199. inputvalue.condition += " "+inputName + " between '" +
  200. value1.substring(0,value1.lastIndexOf("-")) +"' and '" + value2.substring(0,value2.lastIndexOf("-")) +"' ";
  201. }else{
  202. inputvalue.condition += " to_char("+inputName + ",'yyyy-mm-dd') between '" +
  203. value1 +"' and '" + value2 +"' ";
  204. }
  205. i++;
  206. }
  207. }else if(inputone.hasClass("date")){
  208. inputvalue.condition += inputName +" = '"+value+"'";
  209. }else{
  210. inputvalue.condition += inputName +" like '%"+value+"%'";
  211. }
  212. inputvalue.condition += " and ";
  213. }
  214. }
  215. }
  216. return inputvalue;
  217. }
  218. //时间双选框变化事件
  219. function timeChange($end,$begin){
  220. var $id1 = $begin;
  221. var $id2 = $end;
  222. var $self = $end;
  223. var value = "";
  224. var name = $self.attr("name");
  225. // var $timeIfr = $(top.document.body).find("div[lang=zh-cn]");//时间框的父节点div,位于顶层页面的div容器下的iframe中的子页面
  226. // if($timeIfr && $timeIfr.css("display")=="none" ){//若日期框未隐藏
  227. if(!$id1.val()){//若开始日期为空,则默认开始日期与结束日期一样
  228. // top.Dialog.alert('开始日期不能为空!');
  229. // $("#selectConditions ."+name).click();
  230. // return;
  231. $id1.val($id2.val());
  232. }
  233. // }
  234. value += $id1.val();
  235. value += " ~ ";
  236. value += $id2.val();
  237. // alert($id2.prop("outerHTML"))
  238. // alert($id2.val())
  239. var $seleCondi = $("#selectConditions");
  240. $seleUl = $seleCondi.find("ul");
  241. var $thisDom = $seleCondi.find("."+name);
  242. var $condiOne = $thisDom;
  243. if(!$id1.val() && !$id2.val()){
  244. if($thisDom){
  245. $thisDom.click();
  246. return;
  247. }
  248. }
  249. if(!$id2.val()){//若结束日期为空,则取当前日期为结束日期
  250. value += getDateTime11();
  251. }
  252. var title = $self.parent().parent().find(".condiTitle").text();
  253. if($thisDom.html()==null){
  254. $condiOne = $('<li class="selectCondi '+name+'"><span class="condiTitle">'
  255. +title+'</span><span class="cons">'+value+'</span></li>');
  256. $seleUl.append($condiOne);
  257. }
  258. $thisDom.find(".cons").html(value);
  259. $condiOne.data("data1",$id1);
  260. $condiOne.data("data2",$id2);
  261. var $seleCondi = $("#selectConditions");
  262. $seleCondi.append($condiOne);
  263. $(".selectCondi").bind("click",function(){
  264. var _$self = $(this);
  265. var data1 = _$self.data("data1");
  266. var data2 = _$self.data("data2");
  267. if(!!data1){
  268. data1.val("");
  269. }
  270. if(!!data2){
  271. data2.val("");
  272. }
  273. _$self.remove();
  274. });
  275. }
  276. /****绑定输入框改变值事件*****/
  277. function inputChange(){
  278. var $self = $(this);
  279. var value = $self.val();
  280. var title = $self.parent().parent().find(".condiTitle").text();
  281. var $seleCondi = $("#selectConditions");
  282. $seleUl = $seleCondi.find("ul");
  283. var name = $self.attr("name");
  284. var $thisDom = $seleCondi.find("."+name);
  285. var $condiOne = $thisDom;
  286. if(value==""){
  287. $thisDom.click();
  288. return;
  289. }
  290. if($thisDom.html()==null){
  291. $condiOne = $('<li class="selectCondi '+name+'"><span class="condiTitle">'
  292. +title+'</span><span class="cons">'+value+'</span></li>');
  293. $seleUl.append($condiOne);
  294. }
  295. $thisDom.find(".cons").html(value);
  296. $condiOne.data("data",$self);
  297. var $seleCondi = $("#selectConditions");
  298. $seleCondi.append($condiOne);
  299. $(".selectCondi").bind("click",function(){
  300. var _$self = $(this);
  301. var data = _$self.data("data");
  302. if(!!data){
  303. data.val("");
  304. }
  305. _$self.remove();
  306. $(".selectmecon").removeClass("selectmecon");
  307. });
  308. }
  309. /*************生成li列表****************/
  310. function createLiList($condi,conditiondatas){
  311. for(var i=0;i<conditiondatas.list.length;i++){
  312. if(conditiondatas.list[i]==""||conditiondatas.list[i]==undefined){
  313. continue;
  314. }
  315. var conTitle = conditiondatas.list[i].name;
  316. var $condiTitle = $('<li class="condiTitle">'+conTitle+':</li>');
  317. var $ul = $('<ul></ul>');
  318. $ul.append($condiTitle);
  319. var conRow = conditiondatas.list[i].list;
  320. var className = conditiondatas.list[i].className;
  321. var equalType = conditiondatas.list[i].equalType;
  322. var selectType = conditiondatas.list[i].selectType;
  323. var dataType = conditiondatas.list[i].dataType;
  324. selectType = selectType==undefined?"":selectType;
  325. equalType = equalType==undefined?"":equalType;
  326. dataType = dataType==undefined?"":dataType;
  327. for(var j=0;j<conRow.length;j++){
  328. var selected = conRow[j].selected;
  329. selected = selected==true?"_defaultSelected":"";
  330. var $condiCont = $('<li class="item '+className+' '+equalType+' '+selectType+' '+selected+' '+dataType+' " id="conOneId_'+(i+1)+j+'">'+conRow[j].key+'</li>');
  331. $condiCont.data("data-value",conRow[j].value);
  332. $condiCont.data("data-class",className);
  333. $condiCont.data("data-text",conRow[j].key);
  334. $condiCont.data("data-index",j);
  335. $ul.append($condiCont);
  336. if(selectType!="" && selectType=="selectOnly"){
  337. $condiCont.unbind("click").bind("click",bindSelectOnly);
  338. }else{
  339. $condiCont.unbind("click").bind("click",bindSelectOne);
  340. }
  341. }
  342. var $clear = $('<div class="clear"></div>');
  343. $ul.append($clear);
  344. $condi.append($ul).append($clear);
  345. }
  346. //ul-li列表点击事件
  347. //$("li.item").unbind("click").bind("click",bindSelectOne);
  348. }
  349. /*****************生成已选择条件容器************************/
  350. function createSelectedDiv($condi){
  351. var $selectedCon = $('<div class="selContent"><table width="100%"><tr></tr></table></div>');
  352. var $tr = $selectedCon.find("tr").eq(0);
  353. $tr.append($('<td style="width:120px;"><div class="condiTitle">您已选择:</div></td>'));
  354. $tr.append($('<td class="selectConditions" id="selectConditions" text-align="left"></td>'));
  355. var $tdf = $('<td style="width:155px;"></td>');
  356. var $searchButt = $('<input type="button" value="查询" id="searchButt"/>');
  357. var $empButt = $('<input type="button" id="emptyCondition" value="清空条件"/>');
  358. $tdf.append($searchButt).append("&nbsp;&nbsp;").append($empButt);
  359. $tr.append($tdf);
  360. $searchButt.render();
  361. $empButt.render();
  362. $condi.after($selectedCon);
  363. $selectedCon.render();
  364. $condi.render();
  365. var $seleUl = $('<ul></ul>');
  366. var $seleCondi = $("#selectConditions");
  367. $seleCondi.append($seleUl);
  368. //清空条件
  369. $empButt.bind("click",function(){
  370. $(".selectmecon").removeClass("selectmecon");
  371. var $selConditions = $("#selectConditions");
  372. var $selCon = $selConditions.find(".selectCondi");
  373. if(!!$selCon){
  374. for(var i=0;i<$selCon.length;i++){
  375. $selCon[i].click();
  376. }
  377. }
  378. $("form").find("input[type='text']").val("");
  379. });
  380. }
  381. /*****************生成常用过滤条件容器************************/
  382. function createMemoryCondi(){
  383. //生成“您常用的过滤条件”
  384. var $selectedCon = $(".selContent");
  385. var $alwaysCondi = $('<div class="alwaysCondi"><table width="100%"><tr></tr></table></div>');
  386. var _$tr = $alwaysCondi.find("tr").eq(0);
  387. _$tr.append($('<td><div class="alwaysCondiTitle">常用过滤器:</div></td>'));
  388. _$tr.append($('<td class="alwaysCondiName" id="alwaysCondiName" width="85%"></td>'));
  389. var $deleteBtn = $('<input id="deleteConBtn" type="button" value="删除过滤器"/>');
  390. var $cansoledeleteBtn = $('<input id="cansoledeleteBtn" style="display:none" type="button" value="取消"/>');
  391. _$tr.append($('<td class="deleteMeCon" id="deleteMeCon" width="15%" style="text-align:center;"></td>').append($deleteBtn).append($cansoledeleteBtn));
  392. $deleteBtn.bind("click",beforeDeleteMeCondition);
  393. $deleteBtn.render();
  394. $cansoledeleteBtn.bind("click",cansoledelete);
  395. $cansoledeleteBtn.render();
  396. _$tr.append($('<td class="saveMeCon" id="saveMeCon" width="15%" style="text-align:center;display:none"><div>您使用了一个新的搜索,需要<a href="javascript:;" id="saveLink">保存</a>为过滤器吗?</div></td>'));
  397. $selectedCon.after($alwaysCondi);
  398. queryCon($alwaysCondi);
  399. $("#saveLink").bind("click",beforeSaveMemoryCondition);
  400. }
  401. /*************查询后台**************/
  402. function queryCon($alwaysCondi){
  403. var result ;
  404. var url = "/nwyj/ws/mcs/MemoryConditionService/queryCondition/";
  405. var params = {
  406. "userId":userId,
  407. "menupageid":menupageid
  408. };
  409. $.ajax({
  410. url : url,
  411. type : 'post',
  412. data : params,
  413. async:false,
  414. dataType : 'text',
  415. success : function(data) {
  416. //alert(JSON.stringify(data));
  417. if(data!=""){
  418. var aaaa = eval('('+data+')');
  419. var _$ul = $('<ul></ul>');
  420. if(aaaa.length>0){
  421. for (var k = 0; k < aaaa.length; k++) {
  422. var name = aaaa[k].name;
  423. var condi = aaaa[k];
  424. var _$li = $('<li class="memorycondition">'+name+'</li>');
  425. _$ul.append(_$li);
  426. _$li.data("data-condi",condi);
  427. //绑定点击事件
  428. _$li.bind("click",clickmemorycontent);
  429. $("#deleteConBtn").show();
  430. }
  431. }else{
  432. $("#deleteConBtn").hide();
  433. }
  434. _$ul.append($('<div class="clear"></div>'));
  435. $alwaysCondi.find("#alwaysCondiName").append(_$ul);
  436. }
  437. },
  438. error : function(e) {
  439. $.messager.alert('查询过滤器失败!');
  440. }
  441. });
  442. return result;
  443. }
  444. /*****创建过滤筛选列表*****/
  445. function createConditionsDom(conditiondatas){
  446. var $condi = $("#conditions");
  447. if(conditiondatas){
  448. createLiList($condi,conditiondatas);
  449. }
  450. createSelectedDiv($condi);
  451. createMemoryCondi();
  452. if($("._defaultSelected").length>0){
  453. $("._defaultSelected").click();
  454. }
  455. }
  456. /***********常用过滤条件点击事件方法***************/
  457. function clickmemorycontent(){
  458. var $5self = $(this);
  459. $("#emptyCondition").click();
  460. //样式
  461. if($5self.hasClass("selectmecon")){
  462. $5self.removeClass("selectmecon");
  463. }else{
  464. $5self.siblings().removeClass("selectmecon");
  465. $5self.addClass("selectmecon");
  466. var datacondi = $5self.data("data-condi").condition;
  467. for (var h = 0; h < datacondi.length; h++) {
  468. var condiOne = datacondi[h];
  469. var contype = condiOne.type;
  470. var classname = condiOne.name;
  471. var convalue = condiOne.value;
  472. if(contype=="li"){
  473. convalue = convalue.split("__");
  474. for (var y = 0; y < convalue.length; y++) {
  475. if(convalue[y]!=""){
  476. $("#conditions ."+classname).eq(convalue[y]).click();
  477. }
  478. }
  479. }else if(contype=="Textinput"){
  480. $("#conditions input[name='"+classname+"']").val(convalue);
  481. $("#conditions input[name='"+classname+"']").change();
  482. }else if(contype=="date"){
  483. $("#conditions input[name='"+classname+"']").val(convalue);
  484. $("#conditions input[name='"+classname+"']").blur();
  485. }else if(contype=="dateIcon"){
  486. var $class = $("#conditions input[name='"+classname+"']");
  487. if($class.length==2){
  488. $class.eq(0).val(convalue.split("__")[0]);
  489. $class.eq(1).val(convalue.split("__")[1]);
  490. $class.eq(1).blur();
  491. }
  492. }
  493. }
  494. }
  495. //功能
  496. }
  497. /******选中事件 可多选 比较方法为 “like” *******/
  498. function bindSelectOne(){
  499. var $self = $(this);
  500. var itemtext = $self.text();
  501. var $seleCondi = $("#selectConditions");
  502. $seleUl = $seleCondi.find("ul");
  503. var condiTitle = $self.parent().find(".condiTitle").text();
  504. $self.addClass("selectedCond");
  505. var className = $self.data("data-class");
  506. var $thisDom = $seleCondi.find("."+className);
  507. var $condiOne = $thisDom;
  508. if($thisDom.html()==null){
  509. $condiOne = $('<li class="selectCondi '+className+'" ><span class="condiTitle">'+condiTitle+'</span><span class="cons"></span></li>');
  510. $seleUl.append($condiOne);
  511. }
  512. var consText = $condiOne.find(".cons").text();
  513. if(!!consText){
  514. itemtext = consText +" , "+ itemtext;
  515. }
  516. $condiOne.find(".cons").text(itemtext);
  517. var index = $self.data("data-index");
  518. $condiOne.data("data"+index,$self);
  519. var num = $condiOne.data("data-num");
  520. if(num!=undefined){
  521. num += "," +index;
  522. }else{
  523. num = index;
  524. }
  525. $condiOne.data("data-num",num);
  526. var value = $condiOne.data("data-selValue");
  527. var value1 = $self.data("data-value");
  528. if(value!=undefined){
  529. value += "," +value1;
  530. }else{
  531. value = value1;
  532. }
  533. $condiOne.data("data-selValue",value);
  534. $self.css({"color":"blue","font-weight":"bold"});
  535. if( $self.data("data-value")=="0000"){//若点击了全部,则选择该项全部
  536. $self.siblings().each(function(i){
  537. if(!$self.siblings().eq(i).hasClass("selectedCond")){//未选中的调用点击方法
  538. $self.siblings().eq(i).click();
  539. }
  540. })
  541. $condiOne.find(".cons").text($self.data("data-text"));
  542. }
  543. $self.unbind("click");
  544. $(".selectedCond").unbind("click").bind("click",cansSelect);
  545. /******绑定删除选中事件******/
  546. $(".selectCondi").unbind("click").bind("click",function(){
  547. var _$self = $(this);
  548. var number = _$self.data("data-num");
  549. if(number)
  550. number = number.toString();
  551. if(number && (number.length>=0 || number.indexOf("0")!=-1)){
  552. if(number.length > 1){
  553. var numArr = number.split(",");
  554. for(var i=0;i<numArr.length;i++){
  555. var data = _$self.data("data"+numArr[i]);
  556. data.css({"color":"#271700","font-weight":"normal"});
  557. data.removeClass("selectedCond");
  558. data.unbind("click").bind("click",bindSelectOne);
  559. }
  560. }else {
  561. var data = _$self.data("data"+number);
  562. data.css({"color":"#271700","font-weight":"normal"});
  563. data.removeClass("selectedCond");
  564. data.unbind("click").bind("click",bindSelectOne);
  565. }
  566. }
  567. _$self.remove();
  568. $(".selectmecon").removeClass("selectmecon");
  569. });
  570. }
  571. /******选中事件 只单选 且比较方法为“=” 而非 “like” *******/
  572. function bindSelectOnly(){
  573. var $self = $(this);
  574. var itemtext = $self.text();
  575. var $seleCondi = $("#selectConditions");
  576. $seleUl = $seleCondi.find("ul");
  577. var condiTitle = $self.parent().find(".condiTitle").text();
  578. $self.addClass("selectedCond");
  579. var className = $self.data("data-class");
  580. var $thisDom = $seleCondi.find("."+className);
  581. var $condiOne = $thisDom;
  582. if($condiOne.html()==null){
  583. $condiOne = $('<li class="selectCondi selectCondiOnly '+className+'" ><span class="condiTitle">'+condiTitle+'</span><span class="cons"></span></li>');
  584. $seleUl.append($condiOne);
  585. }else{
  586. $condiOne.click();
  587. $condiOne = $('<li class="selectCondi selectCondiOnly '+className+'"><span class="condiTitle">'+condiTitle+'</span><span class="cons"></span></li>');
  588. $seleUl.append($condiOne);
  589. }
  590. $condiOne.find(".cons").text(itemtext);
  591. $condiOne.data("data-dom",$self);
  592. var value = $condiOne.data("data-selValue");
  593. var value1 = $self.data("data-value");
  594. if(value!=undefined){
  595. value += "," +value1;
  596. }else{
  597. value = value1;
  598. }
  599. $condiOne.data("data-selValue",value);
  600. $self.css({"color":"blue","font-weight":"bold"});
  601. if( $self.data("data-value")=="0000"){//若点击了 njhuy7全部,则选择该项全部
  602. $self.siblings().click();
  603. $condiOne.find(".cons").text($self.data("data-text"));
  604. }
  605. $self.unbind("click");
  606. $(".selectedCond").unbind("click").bind("click",cansSelect);
  607. /******绑定删除选中事件******/
  608. $(".selectCondiOnly").bind("click",function(){
  609. var _$self = $(this);
  610. var $dom = _$self.data("data-dom");
  611. $dom.css({"color":"#271700","font-weight":"normal"});
  612. $dom.removeClass("selectedCond");
  613. $dom.unbind("click").bind("click",bindSelectOnly);
  614. _$self.remove();
  615. $(".selectmecon").removeClass("selectmecon");
  616. });
  617. }
  618. /**********删除过滤器之前的方法**********/
  619. function beforeDeleteMeCondition(){
  620. var $self = $(this);
  621. $self.hide();
  622. $("#cansoledeleteBtn").show();
  623. var $conditions = $(".memorycondition");
  624. if($conditions){
  625. for (var i = 0; i < $conditions.length; i++) {
  626. $conditions.eq(i).addClass("beforeDelete").unbind("click").bind("click",deleteMeCondition);
  627. }
  628. }
  629. }
  630. /**********取消 删除过滤器的方法**********/
  631. function cansoledelete(){
  632. var $self = $(this);
  633. $self.hide();
  634. $("#deleteConBtn").show();
  635. var $conditions = $(".memorycondition");
  636. if($conditions){
  637. for (var i = 0; i < $conditions.length; i++) {
  638. $conditions.eq(i).removeClass("beforeDelete").unbind("click").bind("click",clickmemorycontent);
  639. }
  640. }
  641. }
  642. /**********删除过滤器的方法**********/
  643. function deleteMeCondition(){
  644. var $self = $(this);
  645. var datacondi = $self.data("data-condi");
  646. var fd_id = datacondi.fd_id;
  647. var params = {
  648. "fd_id" : fd_id
  649. };
  650. $.ajax({
  651. url : "/nwyj/ws/mcs/MemoryConditionService/deleteCondition/",
  652. type : 'post',
  653. data : params,
  654. dataType : 'json',
  655. success : function(data) {
  656. $self.remove();
  657. var $li = $("#alwaysCondiName ul li");
  658. if($li.length==0){
  659. $("#cansoledeleteBtn").hide();
  660. $("#deleteConBtn").hide();
  661. }
  662. },
  663. error : function(e) {
  664. $.messager.alert('删除失败!');
  665. }
  666. });
  667. }
  668. /***********新增过滤器之前*************/
  669. function beforeSaveMemoryCondition(){
  670. var diag = new top.Dialog();
  671. diag.URL="/nwyj/page/saveSearchCondition.jsp";
  672. diag.Title="保存过滤器 ";
  673. diag.Width=500;
  674. diag.Height=80;
  675. diag.ShowButtonRow=true;
  676. diag.OKEvent = function(){
  677. var conditionName = diag.innerFrame.contentWindow.document.getElementById('memoryCondiName').value;
  678. var paramsData = beforeAddGetValue();
  679. diag.close();
  680. addNewCondition(conditionName,paramsData);
  681. };
  682. diag.show();
  683. }
  684. function addNewCondition(conditionName,paramsData){
  685. var url = "/nwyj/ws/mcs/MemoryConditionService/addCondition/";
  686. var params = {
  687. "userId":userId,
  688. "menupageid":menupageid,
  689. "name":conditionName,
  690. "paramsData":paramsData
  691. };
  692. $.ajax({
  693. url : url,
  694. type : 'post',
  695. data : params,
  696. dataType : 'json',
  697. success : function(data) {
  698. var $alwaysCondi = $(".alwaysCondi");
  699. $alwaysCondi.find("#alwaysCondiName").html("");
  700. queryCon($alwaysCondi);
  701. },
  702. error : function(e) {
  703. $.messager.alert('添加失败!');
  704. }
  705. });
  706. }
  707. /***************新增过滤器时,获取值*******************/
  708. function beforeAddGetValue(){
  709. var paramsData = "";
  710. var $con = $("#conditions ul");
  711. for (var i = 0; i < $con.length; i++) {
  712. var $input = $con.eq(i).find("input");
  713. if($input.length>0){
  714. if($input.hasClass("dateIcon") && $input.eq(0).val()!=""){//双选日期框
  715. paramsData += $input.eq(0).attr("name") + "!dateIcon:";
  716. if($input.length==2){
  717. paramsData += $input.eq(0).val() + "__" + $input.eq(1).val();
  718. paramsData += ",";
  719. }
  720. }else{//单个日期框和输入框
  721. if($input.val()!=""){
  722. if($input.hasClass("date")){
  723. paramsData += $input.attr("name") + "!date:";
  724. }else if($input.hasClass("Textinput")){
  725. paramsData += $input.attr("name") + "!Textinput:";
  726. }
  727. paramsData += $input.val();
  728. paramsData += ",";
  729. }
  730. }
  731. }else {
  732. var $licon = $con.eq(i).find(".item");
  733. if($licon){
  734. if($con.eq(i).find(".selectedCond").length>0){//若该字段有选中项
  735. paramsData += $licon.eq(0).attr("class").split(" ")[1] + "!li:";
  736. for (var j = 0; j < $licon.length; j++) {
  737. if($licon.eq(j).hasClass("selectedCond")){
  738. paramsData += j + "__";
  739. }
  740. }
  741. paramsData += ",";
  742. }
  743. }
  744. }
  745. }
  746. return paramsData;
  747. }
  748. /**
  749. * 点击选项,取消选择该项
  750. */
  751. function cansSelect(){
  752. /******改变样式*****/
  753. $(this).css({"color":"#271700","font-weight":"normal"});
  754. $(this).removeClass("selectedCond");
  755. /******改变样式*****/
  756. var index = $(this).data("data-index");//取出下标
  757. var className =$(this).data("data-class");//取出类名
  758. var $seldom = $("#selectConditions").find("."+className).eq(0);//通过类名找到已选择中响应的选项
  759. //alert($seldom.data("data-"+index).html());
  760. var nums = $seldom.data("data-num");//取出节点中选中的所有项的下标
  761. var domValue = $(this).data("data-value");
  762. if(domValue=="0000"){//如果点击了全选,则全部删除
  763. $seldom.click();
  764. }
  765. nums += "";
  766. nums = nums.split(",");
  767. var nums1 = "";
  768. var $allCon = $("#conditions ."+className);
  769. var value = "";
  770. var selValue = "";
  771. for (var i = 0; i < nums.length; i++) {
  772. if(nums.length==1){//若当前只选择了一项,只有一个值时
  773. $seldom.click();
  774. }else{
  775. if(nums[i]==0){//如果选择了全选,则去掉全选
  776. $allCon.eq(0).removeClass("selectedCond");
  777. $allCon.eq(0).css({"color":"#271700","font-weight":"normal"});
  778. $allCon.eq(0).unbind("click").bind("click",bindSelectOne);
  779. }else if(index!=nums[i]){//不加要取消选择的该项index
  780. nums1 += nums[i]+",";
  781. value += $allCon.eq(nums[i]).text()+",";
  782. selValue += $allCon.eq(nums[i]).data("data-value")+",";
  783. }
  784. }
  785. }
  786. if(value.lastIndexOf(",")==value.length-1){
  787. value = value.substring(0, value.length-1);
  788. }
  789. if(nums1.lastIndexOf(",")==nums1.length-1){
  790. nums1 = nums1.substring(0, nums1.length-1);
  791. }
  792. if(selValue.lastIndexOf(",")==selValue.length-1){
  793. selValue = selValue.substring(0, selValue.length-1);
  794. }
  795. $seldom.data("data-num",nums1);//重新取num值重新绑定
  796. //$seldom.data("data-value",value);//重新取value值重新绑定
  797. $seldom.data("data-selValue",selValue);//重新取sel-value值重新绑定
  798. //$seldom.data("data-"+index,null);//将已选中响应的data解绑
  799. $seldom.find(".cons").text(value);
  800. //$seldom.height($seldom.find(".cons").height());
  801. //重新绑定方法
  802. if($(this).hasClass("selectOnly")){
  803. $(this).unbind("click").bind("click",bindSelectOnly);
  804. }else{
  805. $(this).unbind("click").bind("click",bindSelectOne);
  806. }
  807. $(".selectmecon").removeClass("selectmecon");
  808. $seldom = null;
  809. }
  810. //获得当前系统时间
  811. function getDateTime11(){
  812. var s="";
  813. var d = allGetServerTime();
  814. var vYear = d.getFullYear();
  815. var vMon = d.getMonth() + 1;
  816. var vDay = d.getDate();
  817. /*var h = d.getHours();
  818. var m = d.getMinutes(); */
  819. s=vYear+"-"+(vMon<10 ? "0" + vMon : vMon)+"-"+(vDay<10 ? "0"+ vDay : vDay)/*+" "+(h<10 ? "0"+ h : h)+":"+(m<10 ? "0" + m : m)*/;
  820. return s;
  821. }