oaNotifyList.js 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. <%@ page contentType="text/html;charset=UTF-8" %>
  2. <script>
  3. $(document).ready(function() {
  4. $('#table').bootstrapTable({
  5. //请求方法
  6. method: 'post',
  7. //类型json
  8. dataType: "json",
  9. contentType: "application/x-www-form-urlencoded",
  10. //显示检索按钮
  11. showSearch: true,
  12. //显示刷新按钮
  13. showRefresh: true,
  14. //显示切换手机试图按钮
  15. showToggle: true,
  16. //显示 内容列下拉框
  17. showColumns: true,
  18. //显示到处按钮
  19. showExport: true,
  20. //显示切换分页按钮
  21. showPaginationSwitch: true,
  22. //最低显示2行
  23. minimumCountColumns: 2,
  24. //是否显示行间隔色
  25. striped: true,
  26. //是否使用缓存,默认为true,所以一般情况下需要设置一下这个属性(*)
  27. cache: false,
  28. //是否显示分页(*)
  29. pagination: true,
  30. //排序方式
  31. sortOrder: "asc",
  32. //初始化加载第一页,默认第一页
  33. pageNumber:1,
  34. //每页的记录行数(*)
  35. pageSize: 10,
  36. //可供选择的每页的行数(*)
  37. pageList: [10, 25, 50, 100],
  38. //这个接口需要处理bootstrap table传递的固定参数,并返回特定格式的json数据
  39. url: "${ctx}/oa/oaNotify/data?isSelf=${isSelf}",
  40. //默认值为 'limit',传给服务端的参数为:limit, offset, search, sort, order Else
  41. //queryParamsType:'',
  42. ////查询参数,每次调用是会带上这个参数,可自定义
  43. queryParams : function(params) {
  44. var searchParam = $("#searchForm").serializeJSON();
  45. searchParam.pageNo = params.limit === undefined? "1" :params.offset/params.limit+1;
  46. searchParam.pageSize = params.limit === undefined? -1 : params.limit;
  47. searchParam.orderBy = params.sort === undefined? "" : params.sort+ " "+ params.order;
  48. return searchParam;
  49. },
  50. //分页方式:client客户端分页,server服务端分页(*)
  51. sidePagination: "server",
  52. contextMenuTrigger:"right",//pc端 按右键弹出菜单
  53. contextMenuTriggerMobile:"press",//手机端 弹出菜单,click:单击, press:长按。
  54. contextMenu: '#context-menu',
  55. onContextMenuItem: function(row, $el){
  56. if($el.data("item") == "edit"){
  57. jp.go("${ctx}/oa/oaNotify/form?id=" + row.id);
  58. } else if($el.data("item") == "delete"){
  59. jp.confirm('确认要删除该通知记录吗?', function(){
  60. jp.loading();
  61. jp.get("${ctx}/oa/oaNotify/delete?id="+row.id, function(data){
  62. if(data.success){
  63. $('#table').bootstrapTable('refresh');
  64. jp.success(data.msg);
  65. }else{
  66. jp.error(data.msg);
  67. }
  68. })
  69. });
  70. }
  71. },
  72. onShowSearch: function () {
  73. $("#search-collapse").slideToggle();
  74. },
  75. columns: [{
  76. checkbox: true
  77. }
  78. ,{
  79. field: 'title',
  80. title: '标题',
  81. sortable: true,
  82. formatter:function(value, row , index){
  83. return "<a href='${ctx}/oa/oaNotify/form?isSelf=${isSelf}&id="+row.id+"'>"+value+"</a>";
  84. }
  85. }
  86. ,{
  87. field: 'type',
  88. title: '类型',
  89. sortable: true,
  90. formatter:function(value, row , index){
  91. return jp.getDictLabel(${fns:toJson(fns:getDictList('oa_notify_type'))}, value, "-");
  92. }
  93. },{
  94. field: 'content',
  95. title: '内容',
  96. sortable: true
  97. }
  98. ,{
  99. field: 'status',
  100. title: '状态',
  101. sortable: true,
  102. formatter:function(value, row , index){
  103. if(value == '0'){
  104. return '<font color="red">'+jp.getDictLabel(${fns:toJson(fns:getDictList('oa_notify_status'))}, value, "-")+'</font>';
  105. }else{
  106. return '<font color="green">'+jp.getDictLabel(${fns:toJson(fns:getDictList('oa_notify_status'))}, value, "-")+'</font>';
  107. }
  108. }
  109. },{
  110. field: 'readFlag',
  111. title: '查阅状态',
  112. sortable: true,
  113. formatter:function(value, row , index){
  114. <c:if test="${isSelf}">
  115. if(value == '0'){
  116. return '<font color="red">'+jp.getDictLabel(${fns:toJson(fns:getDictList('oa_notify_read'))}, value, "-")+'</font>';
  117. }else{
  118. return '<font color="green">'+jp.getDictLabel(${fns:toJson(fns:getDictList('oa_notify_read'))}, value, "-")+'</font>';
  119. }
  120. </c:if>
  121. <c:if test="${!isSelf}">
  122. return row.readNum + "/" + row.unReadNum;
  123. </c:if>
  124. }
  125. },{
  126. field: 'updateDate',
  127. title: '发布时间',
  128. sortable: true
  129. }
  130. ]
  131. });
  132. if(navigator.userAgent.match(/(iPhone|iPod|Android|ios)/i)){//如果是移动端
  133. $('#table').bootstrapTable("toggleView");
  134. }
  135. $('#table').on('check.bs.table uncheck.bs.table load-success.bs.table ' +
  136. 'check-all.bs.table uncheck-all.bs.table', function () {
  137. $('#remove').prop('disabled', ! $('#table').bootstrapTable('getSelections').length);
  138. $('#edit').prop('disabled', $('#table').bootstrapTable('getSelections').length!=1);
  139. });
  140. $("#btnImport").click(function(){
  141. jp.open({
  142. type: 1,
  143. area: [500, 300],
  144. title:"导入数据",
  145. content:$("#importBox").html() ,
  146. btn: ['下载模板','确定', '关闭'],
  147. btn1: function(index, layero){
  148. window.location='${ctx}/oa/oaNotify/import/template';
  149. },
  150. btn2: function(index, layero){
  151. var inputForm =top.$("#importForm");
  152. var top_iframe = top.getActiveTab().attr("name");//获取当前active的tab的iframe
  153. inputForm.attr("target",top_iframe);//表单提交成功后,从服务器返回的url在当前tab中展示
  154. inputForm.onsubmit = function(){
  155. jp.loading(' 正在导入,请稍等...');
  156. }
  157. inputForm.submit();
  158. jp.close(index);
  159. },
  160. btn3: function(index){
  161. jp.close(index);
  162. }
  163. });
  164. });
  165. $("#search").click("click", function() {// 绑定查询按扭
  166. $('#table').bootstrapTable('refresh');
  167. });
  168. $("#reset").click("click", function() {// 绑定查询按扭
  169. $("#searchForm input").val("");
  170. $("#searchForm select").val("");
  171. $('#table').bootstrapTable('refresh');
  172. });
  173. });
  174. function getIdSelections() {
  175. return $.map($("#table").bootstrapTable('getSelections'), function (row) {
  176. return row.id
  177. });
  178. }
  179. function deleteAll(){
  180. jp.confirm('确认要删除通知吗?', function(){
  181. jp.loading();
  182. jp.get("${ctx}/oa/oaNotify/deleteAll?ids=" + getIdSelections(), function(data){
  183. if(data.success){
  184. $('#table').bootstrapTable('refresh');
  185. jp.success(data.msg);
  186. }else{
  187. jp.error(data.msg);
  188. }
  189. })
  190. })
  191. }
  192. function edit(){
  193. jp.go("${ctx}/oa/oaNotify/form?id=" + getIdSelections());
  194. }
  195. </script>