list.js 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415
  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. $("#Del").click(function(){
  28. // $("#dialogDel").dialog('open');
  29. });
  30. $("#dialogDel").dialog({
  31. buttons:[{
  32. text:'是',
  33. iconCls:'icon-ok',
  34. handler:function(){
  35. $('#dialogDel').dialog('close');
  36. del();
  37. }
  38. },{
  39. text:'否',
  40. handler:function(){
  41. $('#dialogDel').dialog('close');
  42. }
  43. }]
  44. });
  45. $('#dialogDel').dialog('close');
  46. });
  47. function initButtons(iNowPage,pages)
  48. {
  49. if (iNowPage==1)
  50. {
  51. $("#home").disabled=true;
  52. $("#last").disabled=true;
  53. }
  54. if(iNowPage==pages)
  55. {
  56. $("#end").disabled=true;
  57. $("#next").disabled=true;
  58. }
  59. }
  60. function noSourceExplorer()
  61. {
  62. if (event.button == 2 | event.button == 3)
  63. {
  64. alert("welcome use jbpm4.0");
  65. }
  66. }
  67. function showError()
  68. {
  69. var strError = new String;
  70. var err = source.parseError;
  71. strError = 'Error!\n' +
  72. 'file url: '+err.url +' \n'+
  73. 'line no.:'+err.line +'\n'+
  74. 'char: '+ err.linepos + '\n' +
  75. 'source: '+err.srcText+'\n'+
  76. 'code: '+err.errorCode+'\n'+
  77. 'description: '+err.reason+'\n';
  78. window.alert(strError);
  79. }
  80. function _btnStatus()
  81. {
  82. var $tmp=$('[name=items]:checkbox');
  83. length_=$tmp.filter(':checked').length;
  84. if (length_==0){
  85. $('[name=Del]').attr('disabled',true);
  86. }
  87. else
  88. {
  89. $('[name=Del]').attr('disabled',false);
  90. }
  91. }
  92. function isSelected()
  93. {
  94. var $tmp=$('[name=items]:checkbox');
  95. length_=$tmp.filter(':checked').length;
  96. if (length_==0){
  97. return false;
  98. }
  99. else
  100. {
  101. return true;
  102. }
  103. }
  104. function ShowTROut(tmpRow)
  105. {
  106. window.alert("000");
  107. tmpRow.CLASSNAME="tablerow2";
  108. }
  109. function ShowTROver(tmpRow)
  110. {
  111. tmpRow.CLASSNAME="tablerow";
  112. }
  113. function showCataDocs()
  114. {
  115. }
  116. function trim(str)
  117. {
  118. for(var i = 0 ; i<str.length && str.charAt(i)==" " ; i++ ) ;
  119. return str.substring(i,str.length);
  120. }
  121. function stringToSelect(str,field)
  122. {
  123. for(var beg=0 ; beg < str.length ; beg = end+1)
  124. {
  125. if(-1 == (end = str.indexOf(",",beg))) end = str.length;
  126. var entry = trim(str.substring(beg,end));
  127. if(entry!="") field.options[field.options.length++].text = entry;
  128. }
  129. }
  130. function selectToString(field)
  131. {
  132. if (field.length!=0)
  133. {
  134. var str = "";
  135. for(i=0 ; i < field.options.length-1 ; i++)
  136. str += field.options[i].text + ",";
  137. return str += field.options[i].text;
  138. }
  139. else return "";
  140. }
  141. function add()
  142. {
  143. add_=$('[name=addAppName]').val();
  144. //$(window.parent.document).find('#iframe-form').attr("src",add_);
  145. //location.href=add_;
  146. popup(add_);
  147. }
  148. function del_()
  149. {
  150. del_=$('[name=delAppName]').val();
  151. var str="";
  152. $('[name=items]:checkbox:checked').each(function(){
  153. str+=$(this).val()+";";
  154. })
  155. //alert(str);
  156. if (str=="") { return;}
  157. //id=window.confirm("删除操作,要继续吗?");
  158. //if (id ==false)
  159. //{
  160. // return;
  161. //}
  162. location.href=del_+"?v="+$('[name=appName]').val()+"&id="+str;
  163. }
  164. var recordId;
  165. var trId;
  166. function dlgDel(id,tr_id){
  167. recordId=id;
  168. trId=tr_id;
  169. $("#dialogDel").dialog('open');
  170. }
  171. function del()
  172. {
  173. $.ajax({
  174. type:'GET',
  175. dataType:'string',
  176. url:$('[name=delAppName]').val()+'?id='+recordId,
  177. cache:false,
  178. error:function(data){
  179. $("#errInfo").info("操作没有完成!");
  180. },
  181. success:function(data){
  182. delTr();
  183. $("#errInfo").info("操作完成!");
  184. }
  185. });
  186. }
  187. function delTr(){
  188. //alert(trId);
  189. $("#tr"+trId).remove();
  190. }
  191. function getSelectIds()
  192. {
  193. var str="";
  194. $('[name=items]:checkbox:checked').each(function(){
  195. str+=$(this).val()+";";
  196. })
  197. //alert(str);
  198. return str;
  199. }
  200. function commCmd(a,id){
  201. alert(a+"=================="+id);
  202. }
  203. function edit(id)
  204. {
  205. var edit_=$('[name=editAppName]').val();
  206. if (edit_=="-" || edit_=="null")
  207. {
  208. window.alert("禁止操作");
  209. return("" );
  210. }
  211. //$(window.parent.document).find('#iframe-form').attr("src",edit_+"?id="+id);
  212. popup(edit_+"?id="+id);
  213. //location.href=edit_+"?id="+id;
  214. }
  215. function see(id)
  216. {
  217. var edit_=$('[name=seeAppName]').val();
  218. if (edit_=="-" || edit_=="null")
  219. {
  220. window.alert("禁止操作");
  221. return("" );
  222. }
  223. //$(window.parent.document).find('#iframe-form').attr("src",edit_+"?id="+id);
  224. popup(edit_+"?id="+id);
  225. // location.href=edit_+"?id="+id;
  226. }
  227. function homePage()
  228. {
  229. engineName=document.ViewForm.engineName.value;
  230. catKey=document.ViewForm.catKeyName.value;
  231. findKey=document.ViewForm.findKey.value;
  232. p=Number(document.ViewForm.iNowPage.value);
  233. if (p==1) {return false};
  234. var url=engineName+"?p=1&c="+catKey+"&k="+findKey;
  235. document.ViewForm.action=url;
  236. document.ViewForm.submit();
  237. }
  238. function lastPage()
  239. {
  240. engineName=$('[name=engineName]').val();
  241. catKey=$('[name=catKeyName]').val();
  242. findKey=$('[name=findKey]').val();
  243. iNowPage=$('[name=iNowPage]').val();
  244. p=Number(iNowPage);
  245. if (p==1) {return false};
  246. p--;
  247. var url= engineName+"?p="+p+"&c="+catKey+"&k="+findKey;
  248. document.ViewForm.action=url;
  249. document.ViewForm.submit();
  250. }
  251. function nextPage()
  252. {
  253. engineName=$('[name=engineName]').val();
  254. catKey=$('[name=catKeyName]').val();
  255. findKey=$('[name=findKey]').val();
  256. iNowPage=$('[name=iNowPage]').val();
  257. pages=Number($('[name=pages]').val());
  258. iStart=$('[name=iStart]').val();
  259. p=Number(iNowPage);
  260. if (p==pages)
  261. {
  262. return("");
  263. }
  264. p++;
  265. var url=engineName+"?p="+p+"&c="+catKey+"&k="+findKey;
  266. document.ViewForm.action=url;
  267. document.ViewForm.submit();
  268. }
  269. function endPage()
  270. {
  271. engineName=document.ViewForm.engineName.value;
  272. catKey=document.ViewForm.catKeyName.value;
  273. findKey=document.ViewForm.findKey.value;
  274. p=Number(document.ViewForm.iNowPage.value);
  275. pages=Number(document.ViewForm.pages.value);
  276. if (p==pages)
  277. {
  278. return("");
  279. }
  280. var url= engineName+"?p="+pages+"&c="+catKey;
  281. document.ViewForm.action=url;
  282. document.ViewForm.submit();
  283. }
  284. function jumpPage()
  285. {
  286. jump=document.ViewForm.jump.value;
  287. var patrn=/^\d+$/;
  288. if(!patrn.test(jump)) {
  289. alert("请输入数字");
  290. return false;
  291. }
  292. engineName=document.ViewForm.engineName.value;
  293. p=Number(jump);
  294. pages=Number(document.ViewForm.pages.value);
  295. if(p==0) p=1;
  296. if (p>pages) p=pages;
  297. url="?p="+p;
  298. location.href=url;
  299. }
  300. function selectCat()
  301. {
  302. engineName=document.ViewForm.engineName.value;
  303. appName=document.ViewForm.appName.value;
  304. rows=document.ViewForm.rows.value;
  305. var tmp=$('[name=CatKey]').val();
  306. //alert(tmp)
  307. if (tmp=="")
  308. {
  309. window.alert('没有分类');
  310. return;
  311. }
  312. var url= engineName+"?v="+appName;
  313. url=url+"&c="+tmp;
  314. url=url+"&rows="+rows;
  315. location.href=url;
  316. }
  317. function selectRow()
  318. {
  319. engineName=document.ViewForm.engineName.value;
  320. appName=document.ViewForm.appName.value;
  321. var url= engineName+"?v="+appName;
  322. var rows =$('[name=Rows]').val();
  323. url=url+"&rows="+rows;
  324. document.ViewForm.action=url;
  325. document.ViewForm.submit();
  326. }
  327. function expandAction(code)
  328. {
  329. if (isSelected())
  330. {
  331. var tmp=code+"?ids="+getSelectIds();
  332. //location.href=tmp;
  333. $(window.parent.document).find('#iframe-form').attr("src",tmp);
  334. }
  335. }
  336. function search()
  337. {
  338. appName=ViewForm.appName.value;
  339. sending.style.visibility="visible";
  340. location.href=
  341. ("list.do?v="+appName+"&FindKey="+ViewForm.SearchInput.value)
  342. }
  343. function tr1(o1,num){
  344. o=document.all("tmpDelete"+num);
  345. if (!o.checked) o1.className="tr2";
  346. }
  347. function tr2(o1,num){
  348. o=document.all("tmpDelete"+num);
  349. if (!o.checked) o1.className="tr1";
  350. }
  351. function selectCheck(o1,num){
  352. recNums=ViewForm.recNums.value;
  353. iCount=ViewForm.iCount.value;
  354. selectSingleCheckBox(o1,num);
  355. refreshButton(recNums,iCount);
  356. }
  357. function find(){
  358. //alert("============");
  359. appName=document.ViewForm.appName.value;
  360. url="li.do?v="+appName+"&k="+$("#keyWord").val();
  361. location.href=url;
  362. }
  363. function find_(){
  364. appName=ViewForm.appName.value;
  365. //sending.style.visibility="visible";
  366. location.href="content/searchframe.jsp?v="+appName;
  367. }
  368. function popup(url)
  369. {
  370. var width = 700;
  371. var height = 510;
  372. var left = (screen.width - width)/2;
  373. var top = (screen.height - height)/2;
  374. var params = 'width='+width+', height='+height;
  375. params += ', top='+top+', left='+left;
  376. params += ', directories=no';
  377. params += ', location=no';
  378. params += ', menubar=no';
  379. params += ', resizable=yes';
  380. params += ', scrollbars=no';
  381. params += ', status=no';
  382. params += ', toolbar=no';
  383. newwin=window.open(url,'window123', params);
  384. if (window.focus) {newwin.focus()}
  385. return false;
  386. }