list.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450
  1. $(function(){
  2. //全选
  3. $("#CheckedAll").click(function(){
  4. //所有checkbox跟着全选的checkbox走。
  5. $('[name=items]:checkbox').attr("checked", this.checked );
  6. _btnStatus();
  7. });
  8. $('[name=items]:checkbox').click(function(){
  9. //定义一个临时变量,避免重复使用同一个选择器选择页面中的元素,提升程序效率。
  10. var $tmp=$('[name=items]:checkbox');
  11. //用filter方法筛选出选中的复选框。并直接给CheckedAll赋值。
  12. $('#CheckedAll').attr('checked',$tmp.length==$tmp.filter(':checked').length);
  13. _btnStatus();
  14. /*
  15. //一行做过多的事情需要写更多注释。复杂选择器还可能影响效率。因此不推荐如下写法。
  16. $('#CheckedAll').attr('checked',!$('[name=items]:checkbox').filter(':not(:checked)').length);
  17. */
  18. });
  19. //输出值
  20. $("#send").click(function(){
  21. var str="你选中的是:\r\n";
  22. $('[name=items]:checkbox:checked').each(function(){
  23. str+=$(this).val()+"\r\n";
  24. })
  25. //alert(str);
  26. });
  27. if(typeof rowHover != 'undefined' && rowHover instanceof Function)rowHover();
  28. //rowHover();
  29. });
  30. function changePage(url){
  31. loadDialog = openTips({isTitle:true,content:"<div style='width:100%;text-align:center;background:#fff'><img src='/shares/images/loading.gif'/></div>",width:100,height:100,isDrag:false
  32. ,allowClose:false,isResize:false,title:"加载数据",showMax:false,showMin:false,cls:"uploadCls"});
  33. submitTargetAUrl(url,"_self");
  34. }
  35. function selectRow(id,index____,row,param_____)
  36. {
  37. //var index_=window.parent.document.getElementById("index");
  38. //var param_=window.parent.document.getElementById("param");
  39. var index_=$("#index",window.parent.document);
  40. var param_=$("#param",window.parent.document);
  41. var index=$(index_).val();
  42. var param=$(param_).val();
  43. //alert("index:"+index);
  44. //alert("param:"+$(param_).val());
  45. //alert(param);
  46. $trs=$("#view-data tbody").children();
  47. //alert($trs.length);
  48. var tr=$trs[Number(row)+1];
  49. $tds=$(tr).children();
  50. var td=$tds[index];
  51. //opener.document.all("place").value=$(td).text();
  52. var result=$("#"+param,window.parent.opener.document);
  53. var resultInfo=$("#"+param+"-info",window.parent.opener.document);
  54. $(result).val(id);
  55. $(resultInfo).text($(td).text());
  56. //alert($(td).text());
  57. window.parent.close();
  58. }
  59. function initButtons(iNowPage,pages)
  60. {
  61. if (iNowPage==1)
  62. {
  63. $("#home").disabled=true;
  64. $("#last").disabled=true;
  65. }
  66. if(iNowPage==pages)
  67. {
  68. $("#end").disabled=true;
  69. $("#next").disabled=true;
  70. }
  71. }
  72. function noSourceExplorer()
  73. {
  74. if (event.button == 2 | event.button == 3)
  75. {
  76. alert("welcome use jbpm4.0");
  77. }
  78. }
  79. function showError()
  80. {
  81. var strError = new String;
  82. var err = source.parseError;
  83. strError = 'Error!\n' +
  84. 'file url: '+err.url +' \n'+
  85. 'line no.:'+err.line +'\n'+
  86. 'char: '+ err.linepos + '\n' +
  87. 'source: '+err.srcText+'\n'+
  88. 'code: '+err.errorCode+'\n'+
  89. 'description: '+err.reason+'\n';
  90. window.alert(strError);
  91. }
  92. function _btnStatus()
  93. {
  94. var $tmp=$('[name=items]:checkbox');
  95. length_=$tmp.filter(':checked').length;
  96. if (length_==0){
  97. $('[name=Del]').attr('disabled',true);
  98. }
  99. else
  100. {
  101. $('[name=Del]').attr('disabled',false);
  102. }
  103. }
  104. function isSelected()
  105. {
  106. var $tmp=$('[name=items]:checkbox');
  107. length_=$tmp.filter(':checked').length;
  108. if (length_==0){
  109. return false;
  110. }
  111. else
  112. {
  113. return true;
  114. }
  115. }
  116. function ShowTROut(tmpRow)
  117. {
  118. window.alert("000");
  119. tmpRow.CLASSNAME="tablerow2";
  120. }
  121. function ShowTROver(tmpRow)
  122. {
  123. tmpRow.CLASSNAME="tablerow";
  124. }
  125. function showCataDocs()
  126. {
  127. }
  128. function trim(str)
  129. {
  130. for(var i = 0 ; i<str.length && str.charAt(i)==" " ; i++ ) ;
  131. return str.substring(i,str.length);
  132. }
  133. function stringToSelect(str,field)
  134. {
  135. for(var beg=0 ; beg < str.length ; beg = end+1)
  136. {
  137. if(-1 == (end = str.indexOf(",",beg))) end = str.length;
  138. var entry = trim(str.substring(beg,end));
  139. if(entry!="") field.options[field.options.length++].text = entry;
  140. }
  141. }
  142. function selectToString(field)
  143. {
  144. if (field.length!=0)
  145. {
  146. var str = "";
  147. for(i=0 ; i < field.options.length-1 ; i++)
  148. str += field.options[i].text + ",";
  149. return str += field.options[i].text;
  150. }
  151. else return "";
  152. }
  153. function commCmd(a,id){
  154. if (a=="-" || a=="DelAction.do") {
  155. var url = "DelAction.do?id="+id;
  156. submitAUrl(url);
  157. }else{
  158. var url = a + "?id="+id;
  159. submitAUrl(url);
  160. }
  161. }
  162. function updateCmd(a,id,txt){
  163. var url = a + "?id="+id;
  164. addTab(url, txt, url, true, false);
  165. }
  166. function seeCmd(a,id){
  167. if (a=="-") return ;
  168. popup(a+"?id="+id);
  169. }
  170. function add()
  171. {
  172. add_=$('[name=addAppName]').val();
  173. //$(window.parent.document).find('#iframe-form').attr("src",add_);
  174. //location.href=add_;
  175. popup(add_);
  176. }
  177. function del_()
  178. {
  179. del_=$('[name=delAppName]').val();
  180. var str="";
  181. $('[name=items]:checkbox:checked').each(function(){
  182. str+=$(this).val()+";";
  183. })
  184. //alert(str);
  185. if (str=="") { return;}
  186. //id=window.confirm("删除操作,要继续吗?");
  187. //if (id ==false)
  188. //{
  189. // return;
  190. //}
  191. location.href=del_+"?v="+$('[name=appName]').val()+"&id="+str;
  192. }
  193. var recordId;
  194. var trId;
  195. function dlgDel(id,tr_id){
  196. recordId=id;
  197. trId=tr_id;
  198. $("#dialogDel").dialog('open');
  199. }
  200. function del()
  201. {
  202. $.ajax({
  203. type:'GET',
  204. dataType:'string',
  205. url:$('[name=delAppName]').val()+'?id='+recordId,
  206. cache:false,
  207. error:function(data){
  208. $("#errInfo").info("操作没有完成!");
  209. },
  210. success:function(data){
  211. delTr();
  212. $("#errInfo").info("操作完成!");
  213. }
  214. });
  215. }
  216. function delTr(){
  217. //alert(trId);
  218. $("#tr"+trId).remove();
  219. }
  220. function edit(id)
  221. {
  222. var edit_=$('[name=editAppName]').val();
  223. if (edit_=="-" || edit_=="null")
  224. {
  225. window.alert("禁止操作");
  226. return("" );
  227. }
  228. //$(window.parent.document).find('#iframe-form').attr("src",edit_+"?id="+id);
  229. popup(edit_+"?id="+id);
  230. //location.href=edit_+"?id="+id;
  231. }
  232. function see(id)
  233. {
  234. alert("a");
  235. var edit_=$('[name=seeAppName]').val();
  236. if (edit_=="-" || edit_=="null")
  237. {
  238. window.alert("禁止操作");
  239. return("" );
  240. }
  241. //$(window.parent.document).find('#iframe-form').attr("src",edit_+"?id="+id);
  242. popup(edit_+"?id="+id);
  243. // location.href=edit_+"?id="+id;
  244. }
  245. function homePage()
  246. {
  247. engineName=document.ViewForm.engineName.value;
  248. catKey=document.ViewForm.catKeyName.value;
  249. findKey=document.ViewForm.findKey.value;
  250. p=Number(document.ViewForm.iNowPage.value);
  251. if (p==1) {return false};
  252. var url=engineName+"?p=1&c="+catKey+"&k="+findKey;
  253. document.ViewForm.action=url;
  254. document.ViewForm.submit();
  255. }
  256. function lastPage()
  257. {
  258. engineName=$('[name=engineName]').val();
  259. catKey=$('[name=catKeyName]').val();
  260. findKey=$('[name=findKey]').val();
  261. iNowPage=$('[name=iNowPage]').val();
  262. p=Number(iNowPage);
  263. if (p==1) {return false};
  264. p--;
  265. var url= engineName+"?p="+p+"&c="+catKey+"&k="+findKey;
  266. document.ViewForm.action=url;
  267. document.ViewForm.submit();
  268. }
  269. function nextPage()
  270. {
  271. engineName=$('[name=engineName]').val();
  272. catKey=$('[name=catKeyName]').val();
  273. findKey=$('[name=findKey]').val();
  274. iNowPage=$('[name=iNowPage]').val();
  275. pages=Number($('[name=pages]').val());
  276. iStart=$('[name=iStart]').val();
  277. p=Number(iNowPage);
  278. if (p==pages)
  279. {
  280. return("");
  281. }
  282. p++;
  283. var url=engineName+"?p="+p+"&c="+catKey+"&k="+findKey;
  284. document.ViewForm.action=url;
  285. document.ViewForm.submit();
  286. }
  287. function endPage()
  288. {
  289. engineName=document.ViewForm.engineName.value;
  290. catKey=document.ViewForm.catKeyName.value;
  291. findKey=document.ViewForm.findKey.value;
  292. p=Number(document.ViewForm.iNowPage.value);
  293. pages=Number(document.ViewForm.pages.value);
  294. if (p==pages)
  295. {
  296. return("");
  297. }
  298. var url= engineName+"?p="+pages+"&c="+catKey;
  299. document.ViewForm.action=url;
  300. document.ViewForm.submit();
  301. }
  302. function jumpPage()
  303. {
  304. jump=document.ViewForm.jump.value;
  305. var patrn=/^\d+$/;
  306. if(!patrn.test(jump)) {
  307. alert("请输入数字");
  308. return false;
  309. }
  310. engineName=document.ViewForm.engineName.value;
  311. p=Number(jump);
  312. pages=Number(document.ViewForm.pages.value);
  313. if(p==0) p=1;
  314. if (p>pages) p=pages;
  315. url="?p="+p;
  316. location.href=url;
  317. }
  318. function selectCat()
  319. {
  320. engineName=document.ViewForm.engineName.value;
  321. appName=document.ViewForm.appName.value;
  322. rows=document.ViewForm.rows.value;
  323. var tmp=$('[name=CatKey]').val();
  324. //alert(tmp)
  325. if (tmp=="")
  326. {
  327. window.alert('没有分类');
  328. return;
  329. }
  330. var url= engineName+"?v="+appName;
  331. url=url+"&c="+tmp;
  332. url=url+"&rows="+rows;
  333. location.href=url;
  334. }
  335. function selectRow_()
  336. {
  337. engineName=document.ViewForm.engineName.value;
  338. appName=document.ViewForm.appName.value;
  339. var url= engineName+"?v="+appName;
  340. var rows =$('[name=Rows]').val();
  341. url=url+"&rows="+rows;
  342. document.ViewForm.action=url;
  343. document.ViewForm.submit();
  344. }
  345. function expandAction(code)
  346. {
  347. if (isSelected())
  348. {
  349. var tmp=code+"?ids="+getSelectIds();
  350. //location.href=tmp;
  351. $(window.parent.document).find('#iframe-form').attr("src",tmp);
  352. }
  353. }
  354. function search()
  355. {
  356. appName=ViewForm.appName.value;
  357. sending.style.visibility="visible";
  358. location.href=("list.do?v="+appName+"&FindKey="+ViewForm.SearchInput.value);
  359. }
  360. function tr1(o1,num){
  361. o=document.all("tmpDelete"+num);
  362. if (!o.checked) o1.className="tr2";
  363. }
  364. function tr2(o1,num){
  365. o=document.all("tmpDelete"+num);
  366. if (!o.checked) o1.className="tr1";
  367. }
  368. function selectCheck(o1,num){
  369. recNums=ViewForm.recNums.value;
  370. iCount=ViewForm.iCount.value;
  371. selectSingleCheckBox(o1,num);
  372. refreshButton(recNums,iCount);
  373. }
  374. function find_(){
  375. appName=ViewForm.appName.value;
  376. //sending.style.visibility="visible";
  377. location.href="content/searchframe.jsp?v="+appName;
  378. }
  379. function popup(url)
  380. {
  381. //alert("aaa");
  382. var width = 700;
  383. var height = 510;
  384. var left = (screen.width - width)/2;
  385. var top = (screen.height - height)/2;
  386. var params = 'width='+width+', height='+height;
  387. params += ', top='+top+', left='+left;
  388. params += ', directories=no';
  389. params += ', location=no';
  390. params += ', menubar=no';
  391. params += ', resizable=yes';
  392. params += ', scrollbars=yes';
  393. params += ', status=no';
  394. params += ', toolbar=no';
  395. newwin=window.open(url,'window123', params);
  396. if (window.focus) {newwin.focus()}
  397. return false;
  398. }
  399. //获取列表选中的数据
  400. function getSelectIds(){
  401. var str="";
  402. $('[name=items]:checkbox:checked').each(function(){
  403. str+=$(this).val()+";";
  404. });
  405. return str;
  406. }
  407. //列表查找功能
  408. function find(){
  409. var appName=$("#appName").val();
  410. var liName=$("#li-name").val();
  411. location.href=liName+"?v="+appName+"&k="+$("#keyWord").val(); ;
  412. }
  413. //打印客户预约列表
  414. function printBacList(){
  415. submitTargetAUrl("printBacList.do","_blank");
  416. }