wechatMessages-list.html 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  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">
  23. <input type="text" class="input-text" style="width: 250px" placeholder="输入标题" id="title" name="title">
  24. <button type="submit" class="btn btn-success" id="btnSearch">
  25. <i class="Hui-iconfont">&#xe665;</i> 查询
  26. </button>
  27. <button type="reset" class="btn btn-default" id="btnReset" >
  28. <i class="Hui-iconfont">&#xe68f;</i> 重置
  29. </button>
  30. </div>
  31. </form>
  32. <div class="cl pd-5 bg-1 bk-gray">
  33. <span class="l">
  34. <a href="javascript:item_add();" class="btn btn-primary radius"><i class="Hui-iconfont">&#xe600;</i>发消息</a>
  35. </span>
  36. </div>
  37. <div class="mt-20">
  38. <table id="grid1" class="table table-border table-bordered table-bg">
  39. <thead>
  40. <tr class="text-c">
  41. <th width="25"><input id="checkAll" type="checkbox" value="">选择</th>
  42. <th width="100">标题</th>
  43. <th width="100">内容</th>
  44. <th width="100">发送时间</th>
  45. <th width="100">发送人</th>
  46. <th width="100">发送对象</th>
  47. </tr>
  48. </thead>
  49. <tbody>
  50. </tbody>
  51. </table>
  52. </div>
  53. </div>
  54. <!--_footer 作为公共模版分离出去-->
  55. <!--#include file="common/_footer.html"-->
  56. <!--/_footer 作为公共模版分离出去-->
  57. <!--请在下方写此页面业务相关的脚本-->
  58. <script type="text/javascript" src="lib/My97DatePicker/4.8/WdatePicker.js"></script>
  59. <script type="text/javascript" src="lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
  60. <script type="text/javascript" src="lib/laypage/1.2/laypage.js"></script>
  61. <script id="rowTmpl" type="text/template">
  62. <a href="javascript:item_edit('{{id}}')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6df;</i>编辑</a>
  63. <a href="javascript:item_del('{{id}}','{{name}}')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6e2;</i>删除</a>
  64. </script>
  65. <script id="rowTmpl2" type="text/template">
  66. <a href="javascript:item_sendItem('{{id}}')" class="ml-5" style="text-decoration:none">发送对象</a>
  67. </script>
  68. <script type="text/javascript" src="lib/laypage/1.2/laypage.js"></script>
  69. <script type="text/javascript" src="scripts/global.js"></script>
  70. <script type="text/javascript">
  71. var path = global_backend_url;
  72. $(document).ready(function(){
  73. $('#grid1').dataTable({
  74. ajax: {
  75. url: path + "/wechatMessage/list",
  76. type: 'post',
  77. dataFilter: function(responseText){
  78. var jsonData = JSON.parse(responseText);
  79. // 处理返回json
  80. if(jsonData.result){
  81. return JSON.stringify(jsonData.data);
  82. }
  83. else{
  84. processError(jsonData);
  85. return null;
  86. }
  87. },
  88. data: function(searchParams){
  89. // 查询json
  90. searchParams["title"] = $("#title").val();
  91. }
  92. },
  93. serverSide: true,
  94. searching : false,
  95. ordering: false,
  96. columns: [
  97. {data:'id'},
  98. {data:'title'},
  99. {data:'content'},
  100. {data:'createDate'},
  101. {data:'createBy'},
  102. ],
  103. columnDefs: [
  104. {
  105. targets:0,
  106. sClass:'center',
  107. bSortable:false,
  108. render: function (data, type, row) {
  109. return '<input type="checkbox" name="checkItems" value="'+ data + '">';
  110. }
  111. },{
  112. targets:5,
  113. sClass:'center',
  114. bSortable:false,
  115. render: function (data, type, row) {
  116. return template("rowTmpl2",{
  117. id: row.id
  118. });
  119. }
  120. }
  121. ]
  122. });
  123. $("#checkAll").change(function(){
  124. var checked = $(this).is(':checked');
  125. $("input[name='checkItems']").each(function(){
  126. $(this).attr("checked",checked);
  127. });
  128. });
  129. $("#btnSearch").click(function(){
  130. event.preventDefault();
  131. var table = $('#grid1').DataTable();
  132. table.ajax.reload();
  133. });
  134. });
  135. function item_add(){
  136. layer_show("发送消息","wechatMessages-detail.html",1000,600);
  137. }
  138. function item_edit(id){
  139. layer_show("编辑","wechatMessages-detail.html?id=" + id,1000,600);
  140. }
  141. function item_sendItem(id){
  142. layer_show("发送对象","wechatMessages-view.html?id=" + id,600,600);
  143. }
  144. function item_del(id){
  145. layer.confirm("是否删除?",{
  146. btns:["是","否"]
  147. },function(){
  148. $.post(path + "/wechatMessage/delete/" + id,null,function(json){
  149. if(json.result){
  150. layer.msg("删除成功!",{icon:1,time:2000});
  151. reloadList();
  152. }
  153. else{
  154. layer.msg("删除失败!" + json.message);
  155. }
  156. });
  157. });
  158. }
  159. function reloadList(){
  160. $('#grid1').DataTable().ajax.reload();
  161. }
  162. function batch_del(){
  163. layer.confirm("是否删除选中项?",{
  164. btns:["是","否"]
  165. },function(){
  166. var arr = $("input[name='checkItems']:checked").map(function(){
  167. return $(this).val();
  168. }).get();
  169. $.post(path + "/wechatMessage/batchDelete",{
  170. ids:arr.join(",")
  171. },function(json){
  172. if(json.result){
  173. layer.msg("删除成功!",{icon:1,time:2000});
  174. reloadList();
  175. }
  176. else{
  177. layer.msg("删除失败!" + json.message);
  178. }
  179. });
  180. })
  181. }
  182. </script>
  183. </body>
  184. </html>