appInfoList.js 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. <%@ page contentType="text/html;charset=UTF-8" %>
  2. <script>
  3. $(document).ready(function() {
  4. $('#appInfoTable').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: false,
  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}/app/info/appInfo/data",
  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. edit(row.id);
  58. }else if($el.data("item") == "view"){
  59. view(row.id);
  60. } else if($el.data("item") == "delete"){
  61. jp.confirm('确认要删除该信息发布厅记录吗?', function(){
  62. jp.loading();
  63. jp.get("${ctx}/app/info/appInfo/delete?id="+row.id, function(data){
  64. if(data.success){
  65. $('#appInfoTable').bootstrapTable('refresh');
  66. jp.success(data.msg);
  67. }else{
  68. jp.error(data.msg);
  69. }
  70. })
  71. });
  72. }
  73. },
  74. onClickRow: function(row, $el){
  75. },
  76. onShowSearch: function () {
  77. $("#search-collapse").slideToggle();
  78. },
  79. columns: [{
  80. checkbox: true
  81. }
  82. ,{
  83. field: 'title',
  84. title: '标题',
  85. sortable: true,
  86. sortName: 'title',
  87. formatter:function(value, row , index){
  88. value = jp.unescapeHTML(value);
  89. <c:choose>
  90. <c:when test="${fns:hasPermission('app:info:appInfo:edit')}">
  91. return "<a href='javascript:edit(\""+row.id+"\")'>"+value+"</a>";
  92. </c:when>
  93. <c:when test="${fns:hasPermission('app:info:appInfo:view')}">
  94. return "<a href='javascript:view(\""+row.id+"\")'>"+value+"</a>";
  95. </c:when>
  96. <c:otherwise>
  97. return value;
  98. </c:otherwise>
  99. </c:choose>
  100. }
  101. }
  102. ,{
  103. field: 'type',
  104. title: '类型',
  105. sortable: true,
  106. sortName: 'type',
  107. formatter:function(value, row , index){
  108. return jp.getDictLabel(${fns:toJson(fns:getDictList('announce_info_type'))}, value, "-");
  109. }
  110. }
  111. ,{
  112. field: 'createBy.name',
  113. title: '创建人',
  114. sortable: true,
  115. sortName: 'createBy.id'
  116. }
  117. ,{
  118. field: 'createDate',
  119. title: '创建时间',
  120. sortable: true,
  121. sortName: 'createDate'
  122. }
  123. ]
  124. });
  125. if(navigator.userAgent.match(/(iPhone|iPod|Android|ios)/i)){//如果是移动端
  126. $('#appInfoTable').bootstrapTable("toggleView");
  127. }
  128. $('#appInfoTable').on('check.bs.table uncheck.bs.table load-success.bs.table ' +
  129. 'check-all.bs.table uncheck-all.bs.table', function () {
  130. $('#remove').prop('disabled', ! $('#appInfoTable').bootstrapTable('getSelections').length);
  131. $('#view,#edit').prop('disabled', $('#appInfoTable').bootstrapTable('getSelections').length!=1);
  132. });
  133. $("#btnImport").click(function(){
  134. jp.open({
  135. type: 2,
  136. area: [500, 200],
  137. auto: true,
  138. title:"导入数据",
  139. content: "${ctx}/tag/importExcel" ,
  140. btn: ['下载模板','确定', '关闭'],
  141. btn1: function(index, layero){
  142. jp.downloadFile('${ctx}/app/info/appInfo/import/template');
  143. },
  144. btn2: function(index, layero){
  145. var iframeWin = layero.find('iframe')[0]; //得到iframe页的窗口对象,执行iframe页的方法:iframeWin.method();
  146. iframeWin.contentWindow.importExcel('${ctx}/app/info/appInfo/import', function (data) {
  147. if(data.success){
  148. jp.success(data.msg);
  149. refresh();
  150. }else{
  151. jp.error(data.msg);
  152. }
  153. });//调用保存事件
  154. jp.close(index);
  155. },
  156. btn3: function(index){
  157. jp.close(index);
  158. }
  159. });
  160. });
  161. $("#export").click(function(){//导出Excel文件
  162. jp.downloadFile('${ctx}/app/info/appInfo/export');
  163. });
  164. $("#search").click("click", function() {// 绑定查询按扭
  165. $('#appInfoTable').bootstrapTable('refresh');
  166. });
  167. $("#reset").click("click", function() {// 绑定查询按扭
  168. $("#searchForm input").val("");
  169. $("#searchForm select").val("");
  170. $("#searchForm .select-item").html("");
  171. $('#appInfoTable').bootstrapTable('refresh');
  172. });
  173. });
  174. function getIdSelections() {
  175. return $.map($("#appInfoTable").bootstrapTable('getSelections'), function (row) {
  176. return row.id
  177. });
  178. }
  179. function deleteAll(){
  180. jp.confirm('确认要删除该信息发布厅记录吗?', function(){
  181. jp.loading();
  182. jp.get("${ctx}/app/info/appInfo/deleteAll?ids=" + getIdSelections(), function(data){
  183. if(data.success){
  184. $('#appInfoTable').bootstrapTable('refresh');
  185. jp.success(data.msg);
  186. }else{
  187. jp.error(data.msg);
  188. }
  189. })
  190. })
  191. }
  192. function refresh(){
  193. $('#appInfoTable').bootstrapTable('refresh');
  194. }
  195. function add(){
  196. jp.go("${ctx}/app/info/appInfo/form/add");
  197. }
  198. function edit(id){
  199. if(id == undefined){
  200. id = getIdSelections();
  201. }
  202. jp.go("${ctx}/app/info/appInfo/form/edit?id=" + id);
  203. }
  204. function view(id) {
  205. if(id == undefined){
  206. id = getIdSelections();
  207. }
  208. jp.go("${ctx}/app/info/appInfo/form/view?id=" + id);
  209. }
  210. </script>