eduVideoNewsList.js 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. <%@ page contentType="text/html;charset=UTF-8" %>
  2. <script>
  3. var typeId = '';
  4. var typeName = '';
  5. $(document).ready(function() {
  6. $('#eduVideoNewsTable').bootstrapTable({
  7. //请求方法
  8. method: 'post',
  9. //类型json
  10. dataType: "json",
  11. contentType: "application/x-www-form-urlencoded",
  12. //显示检索按钮
  13. showSearch: true,
  14. //显示刷新按钮
  15. showRefresh: true,
  16. //显示切换手机试图按钮
  17. showToggle: true,
  18. //显示 内容列下拉框
  19. showColumns: true,
  20. //显示到处按钮
  21. showExport: false,
  22. //显示切换分页按钮
  23. showPaginationSwitch: true,
  24. //最低显示2行
  25. minimumCountColumns: 2,
  26. //是否显示行间隔色
  27. striped: true,
  28. //是否使用缓存,默认为true,所以一般情况下需要设置一下这个属性(*)
  29. cache: false,
  30. //是否显示分页(*)
  31. pagination: true,
  32. //排序方式
  33. sortOrder: "asc",
  34. //初始化加载第一页,默认第一页
  35. pageNumber:1,
  36. //每页的记录行数(*)
  37. pageSize: 10,
  38. //可供选择的每页的行数(*)
  39. pageList: [10, 25, 50, 100],
  40. //这个接口需要处理bootstrap table传递的固定参数,并返回特定格式的json数据
  41. url: "${ctx}/base/eduVideoNews/data",
  42. //默认值为 'limit',传给服务端的参数为:limit, offset, search, sort, order Else
  43. //queryParamsType:'',
  44. ////查询参数,每次调用是会带上这个参数,可自定义
  45. queryParams : function(params) {
  46. var searchParam = $("#searchForm").serializeJSON();
  47. searchParam.pageNo = params.limit === undefined? "1" :params.offset/params.limit+1;
  48. searchParam.pageSize = params.limit === undefined? -1 : params.limit;
  49. searchParam.orderBy = params.sort === undefined? "" : params.sort+ " "+ params.order;
  50. return searchParam;
  51. },
  52. //分页方式:client客户端分页,server服务端分页(*)
  53. sidePagination: "server",
  54. onClickRow: function(row, $el){
  55. },
  56. onShowSearch: function () {
  57. $("#search-collapse").slideToggle();
  58. },
  59. columns: [{
  60. checkbox: true
  61. }
  62. ,{
  63. field: 'title',
  64. title: '标题',
  65. sortable: true,
  66. sortName: 'title'
  67. ,formatter:function(value, row , index){
  68. value = jp.unescapeHTML(value);
  69. <c:choose>
  70. <c:when test="${fns:hasPermission('base:eduVideoNews:edit')}">
  71. return "<a href='javascript:edit(\""+row.id+"\")'>"+value+"</a>";
  72. </c:when>
  73. <c:when test="${fns:hasPermission('base:eduVideoNews:view')}">
  74. return "<a href='javascript:view(\""+row.id+"\")'>"+value+"</a>";
  75. </c:when>
  76. <c:otherwise>
  77. return value;
  78. </c:otherwise>
  79. </c:choose>
  80. }
  81. }
  82. ,{
  83. field: 'source',
  84. title: '来源',
  85. sortable: true,
  86. sortName: 'source'
  87. }
  88. ,{
  89. field: 'createDate',
  90. title: '创建时间',
  91. sortable: true,
  92. sortName: 'createDate'
  93. }
  94. ,{
  95. field: 'score',
  96. title: '积分',
  97. sortable: true,
  98. sortName: 'score'
  99. }
  100. ,{
  101. field: 'scoreType',
  102. title: '积分类型',
  103. sortable: true,
  104. sortName: 'scoreType',
  105. formatter:function(value, row , index){
  106. if(value === "1"){
  107. return "进入得分"
  108. }else {
  109. return "观看得分"
  110. }
  111. }
  112. }
  113. ]
  114. });
  115. if(navigator.userAgent.match(/(iPhone|iPod|Android|ios)/i)){//如果是移动端
  116. $('#eduVideoNewsTable').bootstrapTable("toggleView");
  117. }
  118. $('#eduVideoNewsTable').on('check.bs.table uncheck.bs.table load-success.bs.table ' +
  119. 'check-all.bs.table uncheck-all.bs.table', function () {
  120. $('#remove').prop('disabled', ! $('#eduVideoNewsTable').bootstrapTable('getSelections').length);
  121. $('#view,#edit').prop('disabled', $('#eduVideoNewsTable').bootstrapTable('getSelections').length!=1);
  122. });
  123. $("#search").click("click", function() {// 绑定查询按扭
  124. $('#eduVideoNewsTable').bootstrapTable('refresh');
  125. });
  126. $("#reset").click("click", function() {// 绑定查询按扭
  127. $('#title').val("");
  128. $('#eduVideoNewsTable').bootstrapTable('refresh');
  129. });
  130. });
  131. function getIdSelections() {
  132. return $.map($("#eduVideoNewsTable").bootstrapTable('getSelections'), function (row) {
  133. return row.id
  134. });
  135. }
  136. function deleteAll(){
  137. typeId = $('#typeId').val();
  138. typeName = $('#typeName').val();
  139. jp.confirm('确认要删除该'+typeName+'记录吗?', function(){
  140. jp.loading();
  141. jp.get("${ctx}/base/eduVideoNews/deleteAll?typeId="+typeId+"&ids=" + getIdSelections(), function(data){
  142. if(data.success){
  143. $('#eduVideoNewsTable').bootstrapTable('refresh');
  144. jp.success(data.msg);
  145. }else{
  146. jp.error(data.msg);
  147. }
  148. })
  149. })
  150. }
  151. //刷新列表
  152. function refresh(){
  153. $('#eduVideoNewsTable').bootstrapTable('refresh');
  154. }
  155. function add(){
  156. typeId = $('#typeId').val();
  157. typeName = $('#typeName').val();
  158. jp.openSaveDialog('新增'+typeName, "${ctx}/base/eduVideoNews/form?typeId="+typeId,'1100px', '700px');
  159. }
  160. function edit(id){//没有权限时,不显示确定按钮
  161. if(id == undefined){
  162. id = getIdSelections();
  163. }
  164. typeId = $('#typeId').val();
  165. typeName = $('#typeName').val();
  166. jp.openSaveDialog('编辑'+typeName, "${ctx}/base/eduVideoNews/form?id=" + id+"&typeId="+typeId, '1100px', '700px');
  167. }
  168. function view(id){//没有权限时,不显示确定按钮
  169. if(id == undefined){
  170. id = getIdSelections();
  171. }
  172. typeId = $('#typeId').val();
  173. typeName = $('#typeName').val();
  174. jp.openViewDialog('查看'+typeName, "${ctx}/base/eduVideoNews/form?oprType=view&id=" + id+"&typeId="+typeId, '1100px', '700px');
  175. }
  176. </script>