jpAdmin-list.html 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <title>列表页面</title>
  5. <!--#include file="common/_header.html"-->
  6. <style>
  7. .table .center{
  8. text-align:center;
  9. }
  10. </style>
  11. </head>
  12. <body>
  13. <nav class="breadcrumb">
  14. <i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 列表
  15. <a class="btn btn-success radius r"
  16. style="line-height: 1.6em; margin-top: 3px"
  17. href="javascript:location.replace(location.href);" title="刷新">
  18. <i class="Hui-iconfont">&#xe68f;</i></a>
  19. </nav>
  20. <div class="page-container">
  21. <form>
  22. <div class="text-c mb-10" style="text-align:left;">
  23. <input type="text" class="input-text" style="width: 200px" id="userName" name="userName" placeholder="用户名">
  24. <input type="text" class="input-text" style="width: 200px" id="realName" name="realName" placeholder="真实姓名">
  25. <input type="text" class="input-text" style="width: 200px" id="roleName" name="roleName" placeholder="角色类别">
  26. <input type="text" class="input-text" style="width: 200px" id="orgName" name="orgName" placeholder="所属单位">
  27. <select class="select-box" style="width: 200px;" name="isDel" id="isDel">
  28. <option class="select" value="0">未删除</option>
  29. <option value="1">已删除</option>
  30. </select>
  31. <button type="submit" class="btn btn-success" id="btnSearch">
  32. <i class="Hui-iconfont">&#xe665;</i> 查询
  33. </button>
  34. <button type="reset" class="btn btn-default" id="btnReset" >
  35. <i class="Hui-iconfont">&#xe68f;</i> 重置
  36. </button>
  37. </div>
  38. </form>
  39. <div class="cl pd-5 bg-1 bk-gray">
  40. <span class="l">
  41. <a href="javascript:batch_del();" class="btn btn-danger radius"><i class="Hui-iconfont">&#xe6e2;</i>批量删除</a>
  42. <a href="javascript:item_add();" class="btn btn-primary radius"><i class="Hui-iconfont">&#xe600;</i>添加</a>
  43. </span>
  44. </div>
  45. <div class="mt-20">
  46. <table id="grid1" class="table table-border table-bordered table-bg">
  47. <thead>
  48. <tr class="text-c">
  49. <th width="25"><input id="checkAll" type="checkbox" value="">选择</th>
  50. <th width="100">角色类别</th>
  51. <th width="100">用户名</th>
  52. <th width="100">真实姓名</th>
  53. <th width="100">密码</th>
  54. <th width="50">性别</th>
  55. <th width="100">所属单位</th>
  56. <th width="100">所属部门</th>
  57. <th width="100">所属科室</th>
  58. <th width="100">职务</th>
  59. <th width="100">联系电话</th>
  60. <th width="50">是否删除</th>
  61. <th width="150">操作</th>
  62. </tr>
  63. </thead>
  64. <tbody>
  65. </tbody>
  66. </table>
  67. </div>
  68. </div>
  69. <!--_footer 作为公共模版分离出去-->
  70. <!--#include file="common/_footer.html"-->
  71. <!--/_footer 作为公共模版分离出去-->
  72. <!--请在下方写此页面业务相关的脚本-->
  73. <script type="text/javascript" src="lib/My97DatePicker/4.8/WdatePicker.js"></script>
  74. <script type="text/javascript" src="lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
  75. <script type="text/javascript" src="lib/laypage/1.2/laypage.js"></script>
  76. <script id="rowTmpl" type="text/template">
  77. <a href="javascript:item_edit('{{id}}')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6df;</i>编辑</a>
  78. {{if !delFlag}}
  79. <a href="javascript:item_del('{{id}}','{{name}}')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6e2;</i>删除</a>
  80. {{else}}
  81. <a href="javascript:recovery_del('{{id}}')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe66b;</i>恢复</a>
  82. {{/if}}
  83. </script>
  84. <script type="text/javascript" src="lib/laypage/1.2/laypage.js"></script>
  85. <script type="text/javascript" src="scripts/global.js"></script>
  86. <script type="text/javascript">
  87. var path = global_backend_url;
  88. var filePath = file_upload_url;
  89. $(document).ready(function(){
  90. $('#grid1').dataTable({
  91. ajax: {
  92. url: path + "/jpAdmin/list",
  93. type: 'post',
  94. dataFilter: function(responseText){
  95. var jsonData = JSON.parse(responseText);
  96. // 处理返回json
  97. if(jsonData.result){
  98. return JSON.stringify(jsonData.data);
  99. }
  100. else{
  101. processError(jsonData);
  102. return null;
  103. }
  104. },
  105. data: function(searchParams){
  106. // 查询json
  107. searchParams["userName"] = $("#userName").val();
  108. searchParams["realName"] = $("#realName").val();
  109. searchParams["roleName"] = $("#roleName").val();
  110. searchParams["orgName"] = $("#orgName").val();
  111. searchParams["isDel"] = $('#isDel option:selected').val();
  112. }
  113. },
  114. serverSide: true,
  115. searching : false,
  116. ordering: false,
  117. columns: [
  118. {data:'id'},
  119. {"title":"角色类别","render":function(data, type, row, meta){
  120. var json = row.adminRoleList;
  121. var result = "";
  122. $.each(json,function(index,obj){
  123. if(json.length-1 == index){
  124. result = result + obj.roleDescription;
  125. }
  126. else{
  127. result = result + obj.roleDescription+",";
  128. }
  129. })
  130. return result;
  131. }},
  132. {data:'userName'},
  133. {data:'realName'},
  134. {data:'pwd'},
  135. {
  136. "title": "性别", "render": function (data, type, row, meta) {
  137. var result = "";
  138. if (row.gender == "1") {
  139. result = "女";
  140. }
  141. else {
  142. result = "男";
  143. }
  144. return result;
  145. }
  146. },
  147. {data:'org.orgName'},
  148. {data:'department'},
  149. {data:'office'},
  150. {data:'post'},
  151. {data:'tel'},
  152. {
  153. "title": "是否删除", "render": function (data, type, row, meta) {
  154. var result = "";
  155. if (row.delFlag) {
  156. result = "是";
  157. }
  158. else {
  159. result = "否";
  160. }
  161. return result;
  162. }
  163. },
  164. {"data":null}
  165. ],
  166. columnDefs: [
  167. {
  168. targets:0,
  169. sClass:'center',
  170. bSortable:false,
  171. render: function (data, type, row) {
  172. return '<input type="checkbox" name="checkItems" value="'+ data + '">';
  173. }
  174. },
  175. /* {
  176. targets:5,
  177. sClass:'center',
  178. bSortable:false,
  179. render: function (data, type, row) {
  180. var url = "";
  181. if(row.pictureUrl==""||row.pictureUrl==null){
  182. url = row.pictureUrlN;
  183. }
  184. else{
  185. url = filePath + row.pictureUrl;
  186. }
  187. return '<img src="' + url + '?x-oss-process=image/resize,m_lfit,h_70,w_50">';
  188. }
  189. }, */
  190. {
  191. targets:12,
  192. sClass:'center',
  193. bSortable:false,
  194. render: function (data, type, row) {
  195. return template("rowTmpl",{
  196. id: row.id,
  197. delFlag: row.delFlag
  198. });
  199. }
  200. }
  201. ]
  202. });
  203. $("#checkAll").change(function(){
  204. var checked = $(this).is(':checked');
  205. $("input[name='checkItems']").each(function(){
  206. $(this).attr("checked",checked);
  207. });
  208. });
  209. $("#btnSearch").click(function(){
  210. event.preventDefault();
  211. var table = $('#grid1').DataTable();
  212. table.ajax.reload();
  213. });
  214. });
  215. function item_add(){
  216. layer_show("添加","jpAdmin-detail.html",550,600);
  217. }
  218. function item_edit(id){
  219. layer_show("编辑","jpAdmin-detail.html?id=" + id,550,600);
  220. }
  221. function item_del(id){
  222. layer.confirm("是否删除?",{
  223. btns:["是","否"]
  224. },function(){
  225. $.post(path + "/jpAdmin/delete/" + id,null,function(json){
  226. if(json.result){
  227. layer.msg("删除成功!",{icon:1,time:2000});
  228. reloadList();
  229. }
  230. else{
  231. layer.msg("删除失败!" + json.message);
  232. }
  233. });
  234. });
  235. }
  236. function recovery_del(id){
  237. layer.confirm("是否恢复删除用户?",{
  238. btns:["是","否"]
  239. },function(){
  240. $.post(path + "/jpAdmin/recoveryDel/" + id,null,function(json){
  241. if(json.result){
  242. layer.msg("恢复删除用户成功!",{icon:1,time:2000});
  243. reloadList();
  244. }
  245. else{
  246. layer.msg("恢复删除用户失败!" + json.message);
  247. }
  248. });
  249. });
  250. }
  251. function reloadList(){
  252. $('#grid1').DataTable().ajax.reload(null,false);
  253. }
  254. function batch_del(){
  255. var arr = $("input[name='checkItems']:checked").map(function(){
  256. return $(this).val();
  257. }).get();
  258. if(arr.length>0){
  259. layer.confirm("是否删除选中项?",{
  260. btns:["是","否"]
  261. },function(){
  262. $.post(path + "/jpAdmin/batchDelete",{
  263. ids:arr.join(",")
  264. },function(json){
  265. if(json.result){
  266. layer.msg("删除成功!",{icon:1,time:2000});
  267. reloadList();
  268. }
  269. else{
  270. layer.msg("删除失败!" + json.message);
  271. }
  272. });
  273. })
  274. }
  275. else{
  276. layer.msg("请先选择一条记录!");
  277. }
  278. }
  279. function addUser(name) {
  280. var tag = name;
  281. $('#tags').addTag(tag);
  282. }
  283. </script>
  284. </body>
  285. </html>