passRateList.js 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. <%@ page contentType="text/html;charset=UTF-8" %>
  2. <script>
  3. $(document).ready(function() {
  4. $('#passRateTable').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}/exam/eduUserTests/passRateData",
  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. }
  61. },
  62. onShowSearch: function () {
  63. $("#search-collapse").slideToggle();
  64. },
  65. columns: [{
  66. checkbox: true
  67. }
  68. ,{
  69. field: 'paperName',
  70. title: '试卷名称',
  71. sortable: true,
  72. sortName: 'paperName'
  73. ,formatter:function(value, row , index){
  74. value = jp.unescapeHTML(value);
  75. return "<a href='javascript:view(\""+row.paperId+"\")'>"+value+"</a>";
  76. }
  77. },{
  78. field: 'score',
  79. title: '总分数',
  80. sortable: true,
  81. sortName: 'score'
  82. }
  83. ,{
  84. field: 'jg',
  85. title: '及格人数',
  86. sortable: true,
  87. sortName: 'jg'
  88. ,formatter:function(value, row , index){
  89. value = jp.unescapeHTML(value);
  90. return "<a href='javascript:pass(\""+row.paperId+"\")'>"+value+"</a>";
  91. }
  92. }
  93. ,{
  94. field: 'bjg',
  95. title: '不及格人数',
  96. sortable: true,
  97. sortName: 'bjg'
  98. ,formatter:function(value, row , index){
  99. value = jp.unescapeHTML(value);
  100. return "<a href='javascript:fail(\""+row.paperId+"\")'>"+value+"</a>";
  101. }
  102. },{
  103. field: 'jgl',
  104. title: '及格率(%)',
  105. sortable: true,
  106. sortName: 'jgl'
  107. }
  108. ]
  109. });
  110. if(navigator.userAgent.match(/(iPhone|iPod|Android|ios)/i)){//如果是移动端
  111. $('#passRateTable').bootstrapTable("toggleView");
  112. }
  113. $('#passRateTable').on('check.bs.table uncheck.bs.table load-success.bs.table ' +
  114. 'check-all.bs.table uncheck-all.bs.table', function () {
  115. $('#remove').prop('disabled', ! $('#passRateTable').bootstrapTable('getSelections').length);
  116. $('#view,#edit').prop('disabled', $('#passRateTable').bootstrapTable('getSelections').length!=1);
  117. });
  118. $("#export").click(function(){//导出Excel文件
  119. jp.downloadFile('${ctx}/exam/passRate/export');
  120. });
  121. $("#search").click("click", function() {// 绑定查询按扭
  122. $('#passRateTable').bootstrapTable('refresh');
  123. });
  124. $("#reset").click("click", function() {// 绑定查询按扭
  125. $("#searchForm input").val("");
  126. $("#searchForm select").val("");
  127. $("#searchForm .select-item").html("");
  128. $('#passRateTable').bootstrapTable('refresh');
  129. });
  130. });
  131. function getIdSelections() {
  132. return $.map($("#passRateTable").bootstrapTable('getSelections'), function (row) {
  133. return row.paperId
  134. });
  135. }
  136. function deleteAll(){
  137. jp.confirm('确认要删除该试卷记录吗?', function(){
  138. jp.loading();
  139. jp.get("${ctx}/exam/passRate/deleteAll?ids=" + getIdSelections(), function(data){
  140. if(data.success){
  141. $('#passRateTable').bootstrapTable('refresh');
  142. jp.success(data.msg);
  143. }else{
  144. jp.error(data.msg);
  145. }
  146. })
  147. })
  148. }
  149. //刷新列表
  150. function refresh(){
  151. $('#passRateTable').bootstrapTable('refresh');
  152. }
  153. function add(){
  154. jp.go("${ctx}/exam/passRate/form/add?isFix=0");
  155. }
  156. function addFix(){
  157. jp.go("${ctx}/exam/passRate/form/add?isFix=1");
  158. }
  159. function edit(id){
  160. if(id == undefined){
  161. id = getIdSelections();
  162. }
  163. jp.go("${ctx}/exam/passRate/form/edit?id=" + id);
  164. }
  165. function view(id){//没有权限时,不显示确定按钮
  166. if(id == undefined){
  167. id = getIdSelections();
  168. }
  169. jp.go("${ctx}/exam/eduPaper/passRateForm?id=" + id);
  170. }
  171. function pass(paperId){//没有权限时,不显示确定按钮
  172. if(paperId == undefined){
  173. paperId = getIdSelections();
  174. }
  175. jp.go("${ctx}/exam/eduUserTests/pass?paperId=" + paperId);
  176. }
  177. function fail(paperId){//没有权限时,不显示确定按钮
  178. if(paperId == undefined){
  179. paperId = getIdSelections();
  180. }
  181. jp.go("${ctx}/exam/eduUserTests/fail?paperId=" + paperId);
  182. }
  183. </script>