1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260
| <script type="text/javascript"> $(function(){ initTable(); $("#saveExamPaper").bind("click",function(){ var rows = $('#tableOne').bootstrapTable('getData',false); for(i=0;i<rows.length;i++){ if(rows[i].qubankId == null){ dialog("请先选择题库!"); return; } if(rows[i].radioCount <= 0 || rows[i].multiCount <= 0 || rows[i].judgeCount <= 0 || rows[i].saqCount <= 0){ dialog("题目数量不能为零!"); return; } } $("#form").ajaxSubmit({ type: "POST", dataType: 'json', url: "<%=basePath%>examPaperWeb/addOrEdit.so", async: true, success: function (result) { if(result.success){ $.each(rows, function(index, e){ e.paperId = result.data; }); $.ajax({ type: "POST", dataType: 'json', url: "<%=basePath%>examRepoWeb/addOrEdit.so", data: {lists: rows}, async: true, success: function (result) { if(result.success){ url = "<%=basePath%>examPaperWeb/listPage.so"; dialogUrl(result.message, url); }else{ dialog(result.message); } }, error : function() { dialog("系统异常,请联系管理员!"); } }); }else{ dialog(result.message); } }, error : function() { dialog("系统异常,请联系管理员!"); } }); if(rowList && rowList.length>0){ $.ajax({ type: "POST", dataType: 'json', url: "<%=basePath%>examRepoWeb/delByIds.so", data: "rowList="+rowList, async: true, success: function (result) { if(!result.success){ dialog(result.message); } }, error : function() { dialog("系统异常,请联系管理员!"); } }); } });
$("#return").click(function(){ window.location.href="<%=basePath%>examPaperWeb/listPage.so"; }); });
function choiceQU(index, qubankId, id){ var obj = {}; obj.choiceNum = qubankId; var url = "<%=basePath%>examPaperWeb/quBankPage.so"; var win = showModalDialog(url,obj,"scroll:yes;status:no;dialogWidth:800px;dialogHeight:450px"); if (win != null) { $("#tableOne").bootstrapTable('updateRow', {index: index, replace:true, row:{ id: id, qubankId: win[0], qubankTitle: win[1], radioCount: 0, radioScore: 0, multiCount: 0, multiScore: 0, judgeCount: 0, judgeScore: 0, saqCount: 0, saqScore: 0 }}); } }
function queryParams(params) { var quarP={ pageSize : params.pageSize, pageNo : params.pageNumber, paperId : $('#id').val() } return quarP; }
function initTable(){ $('#tableOne').bootstrapTable('destroy'); $('#tableOne').bootstrapTable({ method: 'post', contentType:'application/x-www-form-urlencoded; charset=UTF-8', url: '<%=basePath%>examRepoWeb/listByPaperId.so', striped: true, pagination: true, sortable:true, sortOrder: "asc", clickEdit: true, pageSize: 5, pageList: customPageList, paginationShowPageGo: true, sidePagination: "server", search: false, showColumns: false, minimunCountColumns: 2, showColumns: false, showRefresh: false, silent : true, singleSelect: false, queryParams: queryParams, queryParamsType: "", columns:[ {title: '序号',field: 'index',align: 'center',width:'50px',formatter:function(value, row, index){ var pageSize = $('#tableOne').bootstrapTable('getOptions').pageSize; var pageNumber = $('#tableOne').bootstrapTable('getOptions').pageNumber; return pageSize * (pageNumber - 1) + index + 1; }}, {field: 'id',title: "考试题库id",valign:"middle",align:"center",visible:false}, {field: 'qubankId',title: "题库id",valign:"middle",align:"center",visible:false}, {field: 'qubankTitle',title: "题库",valign:"middle",align:"center",isTip:false,formatter:function(value,row,index){ return '<div style="cursor:pointer;" onclick="choiceQU('+index+','+row.qubankId+','+row.id+')">'+value+'</div>'; }}, {field: 'radioCount',title: "单选题数量",valign:"middle",align:"center",isTip:false,formatter:function(value){ return '<div contentEditable="true">' + value + '</div>'}}, {field: 'radioScore',title: "单选题分数",valign:"middle",align:"center",isTip:false,formatter:function(value){ return '<div contentEditable="true">' + value + '</div>'}}, {field: 'multiCount',title: "多选题数量",valign:"middle",align:"center",isTip:false,formatter:function(value){ return '<div contentEditable="true">' + value + '</div>'}}, {field: 'multiScore',title: "多选题分数",valign:"middle",align:"center",isTip:false,formatter:function(value){ return '<div contentEditable="true">' + value + '</div>'}}, {field: 'judgeCount',title: "判断题数量",valign:"middle",align:"center",isTip:false,formatter:function(value){ return '<div contentEditable="true">' + value + '</div>'}}, {field: 'judgeScore',title: "判断题分数",valign:"middle",align:"center",isTip:false,formatter:function(value){ return '<div contentEditable="true">' + value + '</div>'}}, {field: 'saqCount',title: "简答题数量",valign:"middle",align:"center",isTip:false,formatter:function(value){ return '<div contentEditable="true">' + value + '</div>'}}, {field: 'saqScore',title: "简答题分数",valign:"middle",align:"center",isTip:false,formatter:function(value){ return '<div contentEditable="true">' + value + '</div>'}}, {field: 'index',title: "操作",valign:"middle",align:"center",isTip:false,formatter: function (value, row, index){ var url = '<a href="javascript:void(0)" style="color:blue" onclick="removeRow('+value+','+row.id+')"><img src="skin/meteringTS/custom/images/deletes.png" /></a>'; return url; }} ], onClickCell: function(field, value, row, $element){ if(field=='qubankTitle' || field=='index') return; if(!row.qubankId || row.qubankId == null || row.qubankId == ''){ dialog("请先选择题库!"); return; } $element.children().blur(function(){ var index = $element.parent().data('index'); var tdValue = $element.children().html(); var reg = new RegExp(/^\+?[1-9][0-9]*$/); if (!reg.test(tdValue)) { tdValue = value; } if(field=='radioCount' || field=='multiCount' || field=='judgeCount' || field=='saqCount'){ $.ajax({ type: "POST", dataType: 'json', url: "<%=basePath%>examQuesWeb/list.so", data: {qubankId: row.qubankId}, async: true, success: function (result) { console.log(result); if(result.total < tdValue){ dialog("题库题目数量不足!"); $("#tableOne").bootstrapTable('updateCell', {index: index, field: field,value: value}); } }, error : function() { dialog("系统异常,请联系管理员!"); } }); } $("#tableOne").bootstrapTable('updateCell', {index: index, field: field,value: tdValue}); calcTotal(); }); } }); }
function insertRow(){ var obj=$('#tableOne'); var count = obj.bootstrapTable('getData').length; obj.bootstrapTable('insertRow', { index: count, row: { index: count, id: null, qubankId: null, qubankTitle: '请选择', radioCount: 0, radioScore: 0, multiCount: 0, multiScore: 0, judgeCount: 0, judgeScore: 0, saqCount: 0, saqScore: 0 } }); $(".pagination-info").html("总记录"+(count+1)+" 条"); }
var rowList = []; function removeRow(index, id){ var count = $("#tableOne").bootstrapTable('getData').length; if(id){ rowList.push(id); $("#tableOne").bootstrapTable('remove', {field: 'id',values: [parseInt(id)] }); }else{ $("#tableOne").bootstrapTable('remove', {field: 'index',values: [parseInt(index)] }); } $(".pagination-info").html("总记录"+(count-1<0?0:count-1)+" 条"); calcTotal(); } </script>
|