3158a426d9e725d6791fd99143da1439486fcf19.svn-base 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>基本表格模板</title>
  6. <!--框架必需start-->
  7. <script type="text/javascript" src="../../libs/js/jquery.js"></script>
  8. <script type="text/javascript" src="../../libs/js/language/cn.js"></script>
  9. <script type="text/javascript" src="../../libs/js/framework.js"></script>
  10. <link href="../../libs/css/import_basic.css" rel="stylesheet" type="text/css"/>
  11. <link rel="stylesheet" type="text/css" id="skin" prePath="../../"/>
  12. <link rel="stylesheet" type="text/css" id="customSkin"/>
  13. <!--框架必需end-->
  14. <!--数据表格start-->
  15. <script src="../../libs/js/table/quiGrid.js" type="text/javascript"></script>
  16. <!--数据表格end-->
  17. <!--表单异步提交start-->
  18. <script src="../../libs/js/form/form.js" type="text/javascript"></script>
  19. <!--表单异步提交end-->
  20. </head>
  21. <body>
  22. <div class="box2" panelTitle="查询用户" id="searchPanel">
  23. <form action="../../getUsersOfPager.action" id="queryForm" method="post">
  24. <input type="hidden" id="parentId" name="parentId" value="1"/>
  25. <table>
  26. <tr>
  27. <td>姓名:</td>
  28. <td>
  29. <input type="text" id="searchInput" name="userinfor.userName" />
  30. <input type="text" style="width:2px;display:none;"/>
  31. </td>
  32. <td><button type="button" onclick="searchHandler()"><span class="icon_find">查询</span></button></td>
  33. <td><button type="button" onclick="resetSearch()"><span class="icon_reload">重置</span></button></td>
  34. <td><div class="red">此示例由后台支持</div></td>
  35. </tr>
  36. </table>
  37. </form>
  38. </div>
  39. <div class="padding_right5">
  40. <div id="dataBasic"></div>
  41. </div>
  42. <script type="text/javascript">
  43. //设定不可编辑的节点id
  44. var noeditArray = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19"];
  45. //grid
  46. var grid = null;
  47. function initComplete(){
  48. //当提交表单刷新本页面时关闭弹窗
  49. top.Dialog.close();
  50. /*
  51. grid = $("#dataBasic").quiGrid({
  52. columns:[
  53. { display: '姓名', name: 'userName', align: 'left', width: "20%"},
  54. { display: '所属部门', name: 'orgName', align: 'left', width: "20%"},
  55. { display: '性别', name: 'userSex', align: 'left', width: "20%"},
  56. { display: '入职时间', name: 'userEmployTime', align: 'left', width:"20%"} ,
  57. { display: '学历', name: 'userEducation', align: 'left', width:"20%"} ,
  58. { display: '操作', isAllowHide: false, align: 'left', width:100,
  59. render: function (rowdata, rowindex, value, column){
  60. return '<div class="padding_top4 padding_left5">'
  61. + '<span class="img_list hand" title="查看" onclick="onView(' + rowdata.userId + ')"></span>'
  62. + '<span class="img_edit hand" title="修改" onclick="onEdit(' + rowdata.userId + ')"></span>'
  63. + '<span class="img_delete hand" title="删除" onclick="onDelete(' + rowdata.userId+','+rowindex + ')"></span>'
  64. + '</div>';
  65. }
  66. }
  67. ],
  68. url: '../../userAction.do?method=getUsers', sortName: 'userId',rownumbers:true,checkbox:true,
  69. height: '100%', width:"100%",pageSize:10,percentWidthMode:true,
  70. toolbar:{
  71. items:[
  72. {text: '新增', click: addUnit, iconClass: 'icon_add'},
  73. { line : true },
  74. {text: '批量删除', click: deleteUnit, iconClass: 'icon_delete'},
  75. { line : true },
  76. {text: '导入', click: showImportDialog, iconClass: 'icon_import'},
  77. { line : true },
  78. {text: '导出当前页', click: exportPageData, iconClass: 'icon_export'},
  79. { line : true },
  80. {text: '导出全部', click: exportTotalData, iconClass: 'icon_export'}
  81. ]
  82. }
  83. });
  84. */
  85. //监听查询框的回车事件
  86. $("#searchInput").keydown(function(event){
  87. if(event.keyCode==13){
  88. searchHandler();
  89. }
  90. })
  91. $("#searchPanel").bind("stateChange",function(e,state){
  92. grid.resetHeight();
  93. });
  94. }
  95. //新增
  96. function addUnit() {
  97. top.Dialog.open({
  98. URL:"../../sample_html/unit/user-management-content.html",
  99. Title:"添加",Width:500,Height:350});
  100. }
  101. //查看
  102. function onView(rowid){
  103. top.Dialog.open({
  104. URL:"../../userAction.do?method=getUserDetail&userinfor.userId=" + rowid,
  105. Title:"查看",Width:500,Height:350});
  106. }
  107. //修改
  108. function onEdit(rowid){
  109. if (getPosition(rowid, noeditArray) != -1) {
  110. top.Dialog.alert("为保证数据的完整性,由管理员添加的数据无法修改或删除。可以为新添加的数据来修改和删除。");
  111. return false;
  112. }
  113. top.Dialog.open({
  114. URL:"../../userAction.do?method=preUpdate&userinfor.userId=" + rowid,
  115. Title:"修改",Width:500,Height:350});
  116. }
  117. //删除
  118. function onDelete(rowid,rowidx){
  119. if (getPosition(rowid, noeditArray) != -1) {
  120. top.Dialog.alert("为保证数据的完整性,由管理员添加的数据无法修改或删除。可以为新添加的数据来修改和删除。");
  121. return false;
  122. }
  123. top.Dialog.confirm("确定要删除该记录吗?",function(){
  124. //删除记录
  125. $.post("../../userAction.do?method=deleteUser",
  126. {"ids":rowid},
  127. function(result){
  128. handleResult(result.status);
  129. },"json");
  130. //刷新表格
  131. grid.loadData();
  132. });
  133. }
  134. //批量删除
  135. function deleteUnit() {
  136. top.Dialog.alert("为保证数据的完整性,演示版中禁用了批量删除。");
  137. return;
  138. var rows = grid.getSelectedRows();
  139. var rowsLength = rows.length;
  140. if(rowsLength == 0) {
  141. top.Dialog.alert("请选中要删除的记录!");
  142. return;
  143. }
  144. top.Dialog.confirm("确定要删除吗?",function(){
  145. $.post("../../userAction.do?method=deleteUser",
  146. //获取所有选中行
  147. getSelectIds(grid),
  148. function(result){
  149. handleResult(result);
  150. },
  151. "json");
  152. });
  153. }
  154. //删除后的提示
  155. function handleResult(result){
  156. if(result == 1){
  157. top.Dialog.alert("删除成功!",null,null,null,1);
  158. grid.loadData();
  159. }else{
  160. top.Dialog.alert("删除失败!");
  161. }
  162. }
  163. //获取所有选中行获取选中行的id 格式为 ids=1&ids=2
  164. function getSelectId(grid) {
  165. var selectedRows = grid.getSelectedRows();
  166. var selectedRowsLength = selectedRows.length;
  167. var ids = "";
  168. for(var i = 0;i<selectedRowsLength;i++) {
  169. ids += selectedRows[i].userId + ",";
  170. }
  171. return {"ids":ids};
  172. }
  173. //导入
  174. function showImportDialog(){
  175. top.Dialog.open({Title:"导入用户信息", Message:"请上传excel文件", URL:"../../sample_html/unit/uploadFile.html?type=3",Width:350,Height:130});
  176. }
  177. //导出本页
  178. function exportPageData(){
  179. exportData(true);
  180. }
  181. //导出全部
  182. function exportTotalData(){
  183. exportData(false);
  184. }
  185. //导出处理
  186. function exportData(isPage){
  187. var pageNo = grid.options.page;
  188. var pagerSize = grid.options.pageSize;;
  189. var sort = grid.options.sortName;
  190. var direction = grid.options.sortOrder;
  191. var parentid = $("#parentId").val();
  192. var userName = $("#userName").val();
  193. var url = "../../userAction.do?method=exportData";
  194. if(isPage){
  195. url += "&pager.pageSize=" + pagerSize;
  196. url += "&pager.pageNo=" + pageNo;
  197. url += "&sort=" + sort;
  198. url += "&direction=" + direction;
  199. url += "&isPage=1";
  200. }else{
  201. url += "&isPage=0";
  202. }
  203. url += "&parentId=" + parentid;
  204. url += "&userinfor.userName" + userName;
  205. window.location = url;
  206. }
  207. //查询
  208. function searchHandler(){
  209. var query = $("#queryForm").formToArray();
  210. grid.setOptions({ params : query});
  211. //页号重置为1
  212. grid.setNewPage(1);
  213. grid.loadData();//加载数据
  214. }
  215. //重置查询
  216. function resetSearch(){
  217. $("#queryForm")[0].reset();
  218. $('#search').click();
  219. }
  220. //刷新表格数据并重置排序和页数
  221. function refresh(isUpdate){
  222. if(!isUpdate){
  223. //重置排序
  224. grid.options.sortName='userId';
  225. grid.options.sortOrder="desc";
  226. //页号重置为1
  227. grid.setNewPage(1);
  228. }
  229. grid.loadData();
  230. }
  231. </script>
  232. </body>
  233. </html>