46557852c591e82cbb4efb078d7e230803bcac40.svn-base 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
  2. <%
  3. String path = request.getContextPath();
  4. %>
  5. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  6. <html xmlns="http://www.w3.org/1999/xhtml">
  7. <head>
  8. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  9. <title>锁定列</title>
  10. <!--框架必需start-->
  11. <script type="text/javascript" src="<%=path%>/libs/js/jquery.js"></script>
  12. <script type="text/javascript" src="<%=path%>/libs/js/language/cn.js"></script>
  13. <script type="text/javascript" src="<%=path%>/libs/js/framework.js"></script>
  14. <link href="<%=path%>/libs/css/import_basic.css" rel="stylesheet" type="text/css"/>
  15. <link rel="stylesheet" type="text/css" id="skin" prePath="<%=path%>/"/>
  16. <link rel="stylesheet" type="text/css" id="customSkin"/>
  17. <!--框架必需end-->
  18. <!--数据表格start-->
  19. <script src="<%=path%>/libs/js/table/quiGrid.js" type="text/javascript"></script>
  20. <!--数据表格end-->
  21. </head>
  22. <body>
  23. <fieldset style="width:815px;">
  24. <legend>注意</legend>
  25. 左右排列的表格双选器适合列数较少的情况;上下排列的表格双选器适合行数较少的情况。<br/>
  26. 如果有必要,可以在表格上方加上查询条件,这样筛选更加方便。<br/>
  27. 按照本例的做法,也可以实现树形的表格双选器。<br/>
  28. </fieldset>
  29. <div class="height_15"></div>
  30. <div class="red">此示例由后台支持</div>
  31. <div class="box1" panelWidth="835">
  32. <table>
  33. <tr>
  34. <td id="leftCon"><div id="maingrid"></div></td>
  35. <td>
  36. <input type="button" value="选择选中行>>" onclick="selectAll()"/>
  37. <div class="height_15"></div>
  38. <input type="button" value="<<返回选中行" onclick="deSelectAll()"/>
  39. </td>
  40. <td id="rightCon"><div id="maingrid2"></div></td>
  41. </tr>
  42. </table>
  43. </div>
  44. <script type="text/javascript">
  45. //数据表格使用
  46. var g;
  47. var g2;
  48. var sexData={"list":[{"value":"1","key":"男"},{"value":"0","key":"女"}]};
  49. var educationData={"list":[{"value":"1","key":"专科"},{"value":"2","key":"本科"},{"value":"3","key":"硕士"},{"value":"4","key":"博士"}]};
  50. function initComplete(){
  51. g = $("#maingrid").quiGrid({
  52. columns: [
  53. { display: '姓名', name: 'userName', align: 'center', width: "60%",isSort:false},
  54. { display: '性别', name: 'userSex', align: 'center' , width: "40%",isSort:false,render:function (item){
  55. for (var i = 0; i < sexData["list"].length; i++)
  56. {
  57. if (sexData["list"][i]['value'] == item.userSex)
  58. return sexData["list"][i]['key']
  59. }
  60. return item.userSex;
  61. }},
  62. { display: '选择', isAllowHide: false, align: 'left', width:50,isSort:false,
  63. render: function (rowdata, rowindex, value, column){
  64. return '<div class="padding_top4 padding_left5">'
  65. + '<span class="img_btn_right hand" title="选择" onclick="selectItem(' + rowdata.userId + ','+rowindex + ')"></span>'
  66. + '</div>';
  67. }
  68. }
  69. ], url: '<%=path%>/getUserdbs.action', pageSize: 10, rownumbers:true, checkbox:true,percentWidthMode:true,sortName:"userId",sortOrder:"desc",
  70. height: '420', width:"350",showPageInfo:false,showPageSize:false,title:"未选择列表"
  71. });
  72. g2 = $("#maingrid2").quiGrid({
  73. columns: [
  74. { display: '反选', isAllowHide: false, align: 'left', width:50,isSort:false,
  75. render: function (rowdata, rowindex, value, column){
  76. return '<div class="padding_top4 padding_left5">'
  77. + '<span class="img_btn_left hand" title="反选" onclick="deSelectItem(' + rowdata.userId + ','+rowindex + ')"></span>'
  78. + '</div>';
  79. }
  80. },
  81. { display: '姓名', name: 'userName', align: 'center', width: "60%",isSort:false},
  82. { display: '性别', name: 'userSex', align: 'center' , width: "40%",isSort:false}
  83. ], url: '<%=path%>/getUsersOfPager.action?parentId=15', pageSize: 10, rownumbers:true, checkbox:true,percentWidthMode:true,sortName:"userId",sortOrder:"desc",
  84. height: '420', width:"350",showPageInfo:false,showPageSize:false,title:"已选择列表"
  85. });
  86. }
  87. function selectItem(rowid,rowindex){
  88. var rowData=g.getRow(rowindex);
  89. selectHandler(rowData,rowid,rowindex)
  90. }
  91. function deSelectItem(rowid,rowindex){
  92. var rowData=g2.getRow(rowindex);
  93. deSelectHandler(rowData,rowid)
  94. }
  95. function selectHandler(rowData,rowid){
  96. //alert(rowData.userName)
  97. g.deleteRow(rowData);
  98. $.ajax({
  99. url:"<%=path%>/saveUser.action",
  100. type:"POST",
  101. data:{
  102. "userinfor.organization.orgId":15,
  103. "userinfor.userId":rowData.userId,
  104. "userinfor.userName":rowData.userName,
  105. "userinfor.userLoginName":rowData.userLoginName,
  106. "userinfor.userPassword":rowData.userPassword,
  107. "userinfor.userSex":rowData.userSex,
  108. "userinfor.userEducation":rowData.userEducation
  109. },
  110. error:function(){
  111. },
  112. success: function(data){
  113. //页号重置为1
  114. g2.setNewPage(1);
  115. g2.loadData();
  116. $.post("<%=path%>/deleteUserdb.action",
  117. {"ids":rowid},
  118. function(result){
  119. //刷新表格
  120. g.loadData();
  121. },"json");
  122. }
  123. });
  124. var $hi = $('<div class="itemMinEffect"></div>');
  125. $hi.css({
  126. "width":$("#leftCon").width(),
  127. "height":32,
  128. "left":currentMouseX-$("#leftCon").width()+"px",
  129. top:currentMouseY-10+"px",
  130. opacity:0.1
  131. }).animate({
  132. width:$("#leftCon").width(),
  133. height:0,
  134. left:currentMouseX+100+$("#leftCon").width()+"px",
  135. top:currentMouseY-10+"px",
  136. opacity:0
  137. },200,function(){
  138. $hi.remove();
  139. })
  140. $("body").append($hi);
  141. }
  142. function deSelectHandler(rowData,rowid){
  143. var userSex;
  144. for (var i = 0; i < sexData["list"].length; i++)
  145. {
  146. if (sexData["list"][i]['key'] == rowData.userSex)
  147. userSex= sexData["list"][i]['value']
  148. }
  149. var userEducation;
  150. for (var j = 0; j < educationData["list"].length; j++)
  151. {
  152. if (educationData["list"][j]['key'] == rowData.userEducation)
  153. userEducation= educationData["list"][j]['value']
  154. }
  155. var postData={
  156. userName:rowData.userName,
  157. userLoginName:rowData.userLoginName,
  158. userPassword:rowData.userPassword,
  159. userSex:userSex,
  160. userAge:18,
  161. userId:rowData.userId,
  162. userEducation:userEducation
  163. }
  164. $.post("<%=path%>/saveUserdb.action",rowToBO(postData),function(result){
  165. //页号重置为1
  166. g.setNewPage(1);
  167. g.loadData();
  168. $.post("<%=path%>/deleteUser.action",
  169. {"ids":rowid},
  170. function(result){
  171. g2.loadData();
  172. },"json");
  173. },"json");
  174. g2.deleteRow(rowData);
  175. var $hi = $('<div class="itemMinEffect"></div>');
  176. $hi.css({
  177. "width":$("#rightCon").width(),
  178. "height":32,
  179. "left":currentMouseX+"px",
  180. top:currentMouseY-10+"px",
  181. opacity:0.1
  182. }).animate({
  183. width:$("#leftCon").width(),
  184. height:0,
  185. left:currentMouseX-100-$("#leftCon").width()+"px",
  186. top:currentMouseY-10+"px",
  187. opacity:0
  188. },200,function(){
  189. $hi.remove();
  190. })
  191. $("body").append($hi);
  192. }
  193. //将row JSON对象转化为bo对象
  194. function rowToBO(row) {
  195. var params = 'userinfor.userName='+row.userName+'&userinfor.userSex='+row.userSex+'&userinfor.userAge='+Math.ceil(row.userAge)+'&userinfor.userDepartment='+row.userDepartment+'&userinfor.userAssistance='+row.userAssistance+'&userinfor.userDuty='+row.userDuty+'&userinfor.userEmployTime='+row.userEmployTime+'&userinfor.userPassword='+row.userPassword+'&userinfor.userEducation='+row.userEducation+'&userinfor.userLoginName='+row.userLoginName;
  196. return params;
  197. }
  198. function selectAll(){
  199. var rows = g.getSelectedRows();
  200. for(var i=0;i<rows.length;i++){
  201. selectHandler(rows[i],rows[i].userId);
  202. }
  203. }
  204. function deSelectAll(){
  205. var rows = g2.getSelectedRows();
  206. for(var i=0;i<rows.length;i++){
  207. deSelectHandler(rows[i],rows[i].userId);
  208. }
  209. }
  210. </script>
  211. </body>
  212. </html>