messages-list.html 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  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. <div class="container mb-10">
  22. <form>
  23. <div class="row mb-10">
  24. <select class="select" style="width:250px" id="selSendMes" name="selSendMes"></select>
  25. <select class="select" style="width:250px" id="selReceiveMes" name="selReceiveMes"></select>
  26. <input type="text" class="input-text" style="width: 250px" placeholder="输入消息标题" id="selTitle">
  27. <button type="submit" class="btn btn-success" id="btnSearch">
  28. <i class="Hui-iconfont">&#xe665;</i> 查询
  29. </button>
  30. <button type="reset" class="btn btn-success" id="btnReset">
  31. <i class="Hui-iconfont">&#xe665;</i> 重置
  32. </button>
  33. </div>
  34. </form>
  35. </div>
  36. <div class="cl pd-5 bg-1 bk-gray">
  37. <span class="l">
  38. <a href="javascript:batch_del();" class="btn btn-danger radius"><i class="Hui-iconfont">&#xe6e2;</i>批量删除</a>
  39. <a href="javascript:item_add();" class="btn btn-primary radius"><i class="Hui-iconfont">&#xe600;</i>添加</a>
  40. </span>
  41. </div>
  42. <div class="mt-20">
  43. <table id="grid1" class="table table-border table-bordered table-bg">
  44. <thead>
  45. <tr class="text-c">
  46. <th width="25"><input id="checkAll" type="checkbox" value=""></th>
  47. <th width="100">接收信息用户</th>
  48. <th width="100">消息标题</th>
  49. <th width="100">消息详情</th>
  50. <th width="100">创建人</th>
  51. <th width="100">创建时间</th>
  52. <th width="100">更新人</th>
  53. <th width="100">更新时间</th>
  54. <th width="100">操作</th>
  55. </tr>
  56. </thead>
  57. <tbody>
  58. </tbody>
  59. </table>
  60. </div>
  61. </div>
  62. <!--_footer 作为公共模版分离出去-->
  63. <!--#include file="common/_footer.html"-->
  64. <!--/_footer 作为公共模版分离出去-->
  65. <!--请在下方写此页面业务相关的脚本-->
  66. <script type="text/javascript" src="lib/My97DatePicker/4.8/WdatePicker.js"></script>
  67. <script type="text/javascript" src="lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
  68. <script type="text/javascript" src="lib/laypage/1.2/laypage.js"></script>
  69. <script id="rowTmpl" type="text/template">
  70. <a href="javascript:item_edit('{{id}}')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6df;</i>编辑</a>
  71. <a href="javascript:item_del('{{id}}','{{name}}')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6e2;</i>删除</a>
  72. </script>
  73. <script type="text/javascript" src="lib/laypage/1.2/laypage.js"></script>
  74. <script type="text/javascript" src="scripts/global.js"></script>
  75. <!-- select2 start-->
  76. <link rel="stylesheet" type="text/css" href="lib/select2/select2.min.css" />
  77. <script src="lib/select2/select2.full.js" type="text/javascript"></script>
  78. <script src="lib/select2/select2.zh-CN.js" type="text/javascript"></script>
  79. <!-- select2 end -->
  80. <script type="text/javascript">
  81. var path = global_backend_url;
  82. $(document).ready(function(){
  83. $('#grid1').dataTable({
  84. ajax: {
  85. url: path + "/messages/list",
  86. type: 'post',
  87. dataFilter: function(responseText){
  88. var jsonData = JSON.parse(responseText);
  89. // 处理返回json
  90. if(jsonData.result){
  91. return JSON.stringify(jsonData.data);
  92. }
  93. else{
  94. processError(jsonData);
  95. return null;
  96. }
  97. },
  98. data: function(searchParams){
  99. // 查询json
  100. searchParams["selSendMes"] = $("#selSendMes").val();
  101. searchParams["selReceiveMes"] = $("#selReceiveMes").val();
  102. searchParams["selTitle"] = $("#selTitle").val();
  103. }
  104. },
  105. serverSide: true,
  106. searching : false,
  107. ordering: false,
  108. columns: [
  109. {data:'id'},
  110. {data:'jpAdmin.realName'},
  111. {data:'title'},
  112. {data:'detail'},
  113. {data:null},
  114. {data:'createDate'},
  115. {data:null},
  116. {data:'updateDate'},
  117. {"data":null}
  118. ],
  119. columnDefs: [
  120. {
  121. targets:0,
  122. sClass:'center',
  123. bSortable:false,
  124. render: function (data, type, row) {
  125. return '<input type="checkbox" name="checkItems" value="'+ data + '">';
  126. }
  127. },
  128. {
  129. targets:4,
  130. sClass:'center',
  131. bSortable:false,
  132. render: function (data, type, row) {
  133. return row.createByAdmin!=null ? row.createByAdmin.realName : "";
  134. }
  135. }, {
  136. targets:6,
  137. sClass:'center',
  138. bSortable:false,
  139. render: function (data, type, row) {
  140. return row.updateByAdmin!=null ? row.updateByAdmin.realName : "";
  141. }
  142. },
  143. {
  144. targets:8,
  145. sClass:'center',
  146. bSortable:false,
  147. render: function (data, type, row) {
  148. return template("rowTmpl",{
  149. id: row.id
  150. });
  151. }
  152. }
  153. ]
  154. });
  155. $("#checkAll").change(function(){
  156. var checked = $(this).is(':checked');
  157. $("input[name='checkItems']").each(function(){
  158. $(this).attr("checked",checked);
  159. });
  160. });
  161. $("#btnSearch").click(function(){
  162. event.preventDefault();
  163. var table = $('#grid1').DataTable();
  164. table.ajax.reload();
  165. });
  166. $("#btnReset").click(function(){
  167. $("#selSendMes").empty();
  168. $("#selReceiveMes").empty();
  169. });
  170. strTitle = "输入发送信息用户";
  171. getSelect("selSendMes",null);
  172. strTitle = "输入接收信息用户";
  173. getSelect("selReceiveMes",null);
  174. });
  175. var strTitle = "";
  176. function getSelect(id,value){
  177. if(value != null){
  178. var Html = "<option value='"+value.id+"' selected>" + value.realName + "</option>";
  179. $('#' + id).append(Html);
  180. $('#' + id).select2();
  181. }
  182. $("#" + id).select2({
  183. language: "zh-CN",
  184. placeholder:strTitle,//文本框的提示信息
  185. minimumInputLength:0, //至少输入n个字符,才去加载数据
  186. allowClear: true, //是否允许用户清除文本信息
  187. ajax:{
  188. url:path + "/jpAdmin/selectUser", //地址
  189. type: "POST",
  190. dataType:'json', //接收的数据类型
  191. delay:250,
  192. cache: true,
  193. processResults: function (data) {
  194. var results = data.map(function(item){
  195. return {
  196. id : item.userId,
  197. text : item.realName,
  198. userName: item.userName,
  199. orgName : item.orgName
  200. }
  201. });
  202. return {
  203. results: results
  204. }
  205. }
  206. },
  207. language: "zh-CN",
  208. templateResult: function (state) {
  209. var html = "<div>";
  210. html += "<strong>姓名:" + state.text + "</strong>(" + state.userName + ")<br/>";
  211. html += "单位:" + state.orgName;
  212. html += "</div>";
  213. return $(html);
  214. }
  215. });
  216. }
  217. function item_add(){
  218. layer_show("添加","messages-detail.html",800,600);
  219. }
  220. function item_edit(id){
  221. layer_show("编辑","messages-detail.html?id=" + id,800,600);
  222. }
  223. function item_del(id){
  224. layer.confirm("是否删除?",{
  225. btns:["是","否"]
  226. },function(){
  227. $.post(path + "/messages/forgedDelete/" + id,null,function(json){
  228. if(json.result){
  229. layer.msg("删除成功!",{icon:1,time:2000});
  230. reloadList();
  231. }
  232. else{
  233. layer.msg("删除失败!" + json.message);
  234. }
  235. });
  236. });
  237. }
  238. function reloadList(){
  239. $('#grid1').DataTable().ajax.reload(null,false);
  240. }
  241. function batch_del(){
  242. layer.confirm("是否删除选中项?",{
  243. btns:["是","否"]
  244. },function(){
  245. var arr = $("input[name='checkItems']:checked").map(function(){
  246. return $(this).val();
  247. }).get();
  248. $.post(path + "/messages/batchDelete",{
  249. ids:arr.join(",")
  250. },function(json){
  251. if(json.result){
  252. layer.msg("删除成功!",{icon:1,time:2000});
  253. reloadList();
  254. }
  255. else{
  256. layer.msg("删除失败!" + json.message);
  257. }
  258. });
  259. })
  260. }
  261. </script>
  262. </body>
  263. </html>