'+(i+1)+' | '+data.data[i].TITLE+' | '+getClassName(data.data[i].CLASS_ID)+' | '+getSubjectName(data.data[i].SUBJECT_ID)+' | '+data.data[i].EXAM_TIME+'分钟 | '+data.data[i].CREATE_DATE+' | 查看 |  | ';
}
$("#tab_body").html(tab_html);
window.top.loading.remove();
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
// wrong massage
alert("Status code:"+XMLHttpRequest.status+"Status"+XMLHttpRequest.readyState+"wrong massage:"+textStatus+"");
window.top.loading.remove();
}
});
}
$('#ids').on('click', function(){
var th_checked = $("#ids").prop('checked');//checkbox inside "TH" table header
$(".table_box .table").find('tbody > tr').each(function(){
var row = this;
if(th_checked) $(row).find('input[type=checkbox]').eq(0).prop('checked', true);
else $(row).find('input[type=checkbox]').eq(0).prop('checked', false);
});
});
function jump(obj){ //预览试卷
window.top.loading.show();
var id=obj.closest("tr").attr("data-id");
var classid=obj.closest("tr").attr("data-classid");
location.href="paper_view2.do?PAPER_ID="+id+"&classID="+classid+"&userid="+user_id;
}
$(".classList").on("click","li",function(){
$(this).siblings().removeClass("active");
$(this).addClass("active");
});
$("#creatPaper").click(function(){ //新建试卷
$('#myModal').modal('show');
});
function setQUestion(){ //新建试卷-选择班级
if($(".classList .active").length>0){
class_id=$(".classList .active").attr("data-classid");
location.href="set_question.do?subject_id="+subject_id+"&class_id="+class_id+"&user_id="+user_id;
}else{
alert("Please select class first");
}
window.top.loading.show();
console.log($(".classList .active").length);
//location.href="";
}
function getSubjectName(id){ //获取科目中文名
var subjectName="";
$.ajax({
url:url+"/api/v1/subjectcname",
async:false,
type:"post",
data:{id:id},
success:function(data){
subjectName=data.data;
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
// wrong massage
alert("Status code:"+XMLHttpRequest.status+"Status"+XMLHttpRequest.readyState+"wrong massage:"+textStatus+"");
window.top.loading.remove();
}
})
return subjectName;
}
function getClassName(id){ //获取班级中文名
var className="";
$.ajax({
url:url+"/api/v1/classname",
async:false,
type:"post",
data:{id:id},
success:function(data){
className=data.data;
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
// wrong massage
alert("Status code:"+XMLHttpRequest.status+"Status:"+XMLHttpRequest.readyState+"wrong massage:"+textStatus+"");
window.top.loading.remove();
}
})
return className;
}
function getday(month){ //获取日期
var time=[];
var d= new Date();
d.setMonth(month-1);
d.setDate(1);
var day=d.getDate();
var month=d.getMonth()+1;
if((d.getMonth()+1)<10){
var month="0"+(d.getMonth()+1);
}
var year=d.getFullYear();
var startTime=year+"-"+month+"-"+day;
d.setMonth(month);
var end_day=d.getDate();
var end_month=d.getMonth()+1;
if((d.getMonth()+1)<10){
var end_month="0"+(d.getMonth()+1);
}
var end_year=d.getFullYear();
var endTime=end_year+"-"+end_month+"-"+end_day;
time[0]=startTime;
time[1]=endTime;
return time;
}
function timeList(){ //渲染时间列表
var time = new Date();
var now_month=time.getMonth()+1;
time.setMonth(now_month-1)
if(time.getMonth()!= 0 ){
var preceding_month = time.getMonth();
}else
var preceding_month = 12;
time.setMonth(now_month-2)
if(time.getMonth()!= 0 ){
var last_month = time.getMonth();
}else
var last_month = 12;
var option_html="";
option_html += '';
$("#dealer_id_1").html(option_html);
}
function tosearch(){ //搜索
//var timeBox=getday($("#dealer_id_1").val());
var start_date=$("#lastStart").val();
var end_date=$("#lastEnd").val();
var class_id=$("#dealer_id_2").val();
getList(start_date,end_date,class_id);
}
function del(obj){ //删除
//var remove = new remove();
var id=obj.closest("tr").attr("data-id");
window.top.remove.init({"title":"Delete","func":function(success){
if(success){
var url1 = url+ "/paper/delete.do?PAPER_ID="+id+"&tm="+new Date().getTime();
window.top.loading.show();
$.get(url1,function(data){
tosearch();
});
}
else{
console.log("false");
}
}});
window.top.remove.show();
}
function deleteAll(){ //批量删除
window.top.remove.init({"title":"Delete","func":function(success){
if(success){
var str = '';
for(var i=0;i < document.getElementsByName('ids').length;i++){
if(document.getElementsByName('ids')[i].checked){
if(str=='') str += document.getElementsByName('ids')[i].value;
else str += ',' + document.getElementsByName('ids')[i].value;
}
}
if(str==''){
}else{
$.ajax({
type: "POST",
url:url+ '/paper/deleteAll.do?tm='+new Date().getTime(),
data: {DATA_IDS:str},
dataType:'json',
//beforeSend: validateData,
cache: false,
success: function(data){
$.each(data.list, function(i, list){
tosearch();
});
}
});
}
}
else{
console.log("false");
}
}});
window.top.remove.show();
}