one

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<meta charset="UTF-8">
<meta name="Generator" content="EditPlus®">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<title>排课登记</title>
</head>
<link rel="stylesheet" type="text/css" href="${StaticResourceContextPath}/lib/bootstrap/3.3.6/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css"
href="${StaticResourceContextPath}/lib/jstree/3.2.1/dist/themes/default/style.min.css">
<link rel="stylesheet" type="text/css" href="${StaticResourceContextPath}/school/attendance/css/index.css">
<link rel="stylesheet" type="text/css" href="${StaticResourceContextPath}/school/attendance/css/course.css">
<body>
<%--start right_pannel--%>
<div class="course-right-pannel">
<%--start right-pannel-header--%>
<div class="right-pannel-header">
<input type="button" value="添加" id="add_submit" class="add_submit">
<label style="margin-left: 20px;">选择校历</label>
<select id="school_calender"></select>
</div>
<%--end right-pannel-header--%>
<div class="right-pannel-body" style="background: #fff !important;">
<div class="course_info">
<label style="clear: both;">选择班级</label><select id="choose_class" style="clear: both;"></select><br><br>
<label style="float: left;">上课地点</label>
<select id="building" style="float: left;"></select>
<select id="story" class="none" style="float: left;"></select>
<select id="classRoom" class="none" style="float: left;"></select>
<br><br><br>
<div>
<label>选择周数:</label>
<div class="weekend-value-area"></div>
<div class="weekend-choose" style="float:left;">
<input type="button" name="single" class="single" id="single" value="单周">
<input type="button" name="double" class="double" id="double" value="双周">
<input type="button" name="checkall" class="checkall" id="checkall" value="全选">
<input type="button" name="cancel" class="cancel" id="cancel" value="取消">
<input type="button" name="ok" class="ok" id="ok" value="选择">
<br><br>
<table border="1" cellpadding="0" cellspacing="0" id="weekend-chooses" class="weekend-chooses">
</table>
</div>
<table id="scheduling_choose" cellpadding="0" cellspacing="0" border="1"
style="float:left;margin-left: 20px;">
</table>
</div>
</div>
</div>
</div>
<%--end right_pannel--%>
<%--存放pk--%>
<div class="classRoom_pk_area none"></div>
<div class="class_pk_area none"></div>
<div class="pk_calenders none"></div>
<div class="class_pk_area none"></div>
<div class="class_pk_area none"></div>
</body>
<script type="text/javascript" src="${StaticResourceContextPath}/lib/jquery/2.1.1/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="${StaticResourceContextPath}/lib/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<script type="text/javascript" src="${StaticResourceContextPath}/lib/jstree/3.2.1/dist/jstree.min.js"></script>
<script type="text/javascript" src="${StaticResourceContextPath}/school/attendance/js/public.js"></script>
<script>
$(function () {
/*定义body-pannel高度*/
var body_pannel = window.screen.availHeight - 120;
var right_pannel = window.screen.availWidth - 200;
$('.second-trees').css({height: body_pannel});
$('.course-right-pannel').css({ right_pannel});

/*对周数选择进行操作*/
$(".single").click(function () {
$(".weekend-chooses").find('td').each(function (i) {
if ((i + 1) % 2 == 1) {
$(this).removeClass('td-bg-white');
$(this).addClass('td-bg-blue');
}
else {
$(this).removeClass('td-bg-blue');
$(this).addClass('td-bg-white');
}
});
});

$(".double").click(function () {
$(".weekend-chooses").find('td').each(function (i) {
if ((i + 1) % 2 == 0) {
$(this).removeClass('td-bg-white');
$(this).addClass('td-bg-blue');
}
else {
$(this).removeClass('td-bg-blue');
$(this).addClass('td-bg-white');
}
});
});

$(".cancel").click(function () {
$(".weekend-chooses").find('td').each(function (i) {
$(this).removeClass('td-bg-blue');
$(this).addClass('td-bg-white');
$('.weekend-value-area').empty();
});
});

$(".checkall").click(function () {
$(".weekend-chooses").find('td').each(function (i) {
$(this).removeClass('td-bg-white');
$(this).addClass('td-bg-blue');
});
});

$('.boxs').each(function () {
$(this).bind('click', function () {
// alert($(this).val());
});
});
/*楼层*/
loadBuilding();

});
var ip = '<%=request.getServerName()%>';
var port = '<%=request.getServerPort()%>';
var url = "http://" + ip + ":" + port;
//存放各类pk
var classRoom_pk_areas = $('.classRoom_pk_area').html();
;//获取的教室pk值
var class_pk_area = $('.class_pk_area').html();//获取班级pk值
var pk_calenders = $('.pk_calenders').html();//校历pk

/*获取校历*/
var school_calender = document.getElementById('school_calender');
$.get(url + "/root/api/calendar", {}, function (data) {
if (data.success) {
var school_calendar = document.getElementById('school_calender');
for (var i = 0; i < data.resultData.length; i++) {
school_calendar_value = data.resultData[i].calendar_name;
school_calendar.options.add(new Option(school_calendar_value));
}
$('#school_calender').change(function () {
$('#weekend-chooses').empty();
$('#school_calender option:selected').each(function () {
var index = school_calender.selectedIndex;
var pk_calenders = data.resultData[index].pk_calender;//获得选择校历的pk值
$('.pk_calenders').html(pk_calenders);
/*start 作息时间表*/
$.get(url + '/root/api/workRest',
{pk_calender: $('.pk_calenders').html()},
function (d) {
var str;
str += '<tr><td></td><td>周一</td><td>周二</td><td>周三</td><td>周四</td><td>周五</td><td>周六</td><td>周七</td></tr>';
str += '<tr><td>' + d.resultData[0].class_name + '</td><td>' + '<input type="checkbox" class="check" pk="' + d.resultData[0].pk_work_rest + '" week="1"></td><td>' + '<input type="checkbox" class="check" pk="' + d.resultData[0].pk_work_rest + '" week="2"></td><td>' + '<input type="checkbox" class="check" pk="' + d.resultData[0].pk_work_rest + '" week="3"></td><td>' + '<input type="checkbox" class="check" pk="' + d.resultData[0].pk_work_rest + '" week="4"></td><td>' + '<input type="checkbox" class="check" pk="' + d.resultData[0].pk_work_rest + '" week="5"></td><td>' + '<input type="checkbox" class="check" pk="' + d.resultData[0].pk_work_rest + '" week="6"></td><td>' + '<input type="checkbox" class="check" pk="' + d.resultData[0].pk_work_rest + '" week="7"></td></tr>';
str += '<tr><td>' + d.resultData[1].class_name + '</td><td>' + '<input type="checkbox" class="check" pk="' + d.resultData[1].pk_work_rest + '" week="1"></td><td>' + '<input type="checkbox" class="check" pk="' + d.resultData[1].pk_work_rest + '" week="2"></td><td>' + '<input type="checkbox" class="check" pk="' + d.resultData[1].pk_work_rest + '" week="3"></td><td>' + '<input type="checkbox" class="check" pk="' + d.resultData[1].pk_work_rest + '" week="4"></td><td>' + '<input type="checkbox" class="check" pk="' + d.resultData[1].pk_work_rest + '" week="5"></td><td>' + '<input type="checkbox" class="check" pk="' + d.resultData[1].pk_work_rest + '" week="6"></td><td>' + '<input type="checkbox" class="check" pk="' + d.resultData[1].pk_work_rest + '" week="7"></td></tr>';
str += '<tr><td>' + d.resultData[2].class_name + '</td><td>' + '<input type="checkbox" class="check" pk="' + d.resultData[2].pk_work_rest + '" week="1"></td><td>' + '<input type="checkbox" class="check" pk="' + d.resultData[2].pk_work_rest + '" week="2"></td><td>' + '<input type="checkbox" class="check" pk="' + d.resultData[2].pk_work_rest + '" week="3"></td><td>' + '<input type="checkbox" class="check" pk="' + d.resultData[2].pk_work_rest + '" week="4"></td><td>' + '<input type="checkbox" class="check" pk="' + d.resultData[2].pk_work_rest + '" week="5"></td><td>' + '<input type="checkbox" class="check" pk="' + d.resultData[2].pk_work_rest + '" week="6"></td><td>' + '<input type="checkbox" class="check" pk="' + d.resultData[2].pk_work_rest + '" week="7"></td></tr>';
str += '<tr><td>' + d.resultData[3].class_name + '</td><td>' + '<input type="checkbox" class="check" pk="' + d.resultData[3].pk_work_rest + '" week="1"></td><td>' + '<input type="checkbox" class="check" pk="' + d.resultData[3].pk_work_rest + '" week="2"></td><td>' + '<input type="checkbox" class="check" pk="' + d.resultData[3].pk_work_rest + '" week="3"></td><td>' + '<input type="checkbox" class="check" pk="' + d.resultData[3].pk_work_rest + '" week="4"></td><td>' + '<input type="checkbox" class="check" pk="' + d.resultData[3].pk_work_rest + '" week="5"></td><td>' + '<input type="checkbox" class="check" pk="' + d.resultData[3].pk_work_rest + '" week="6"></td><td>' + '<input type="checkbox" class="check" pk="' + d.resultData[3].pk_work_rest + '" week="7"></td></tr>';
str += '<tr><td>' + d.resultData[4].class_name + '</td><td>' + '<input type="checkbox" class="check" pk="' + d.resultData[4].pk_work_rest + '" week="1"></td><td>' + '<input type="checkbox" class="check" pk="' + d.resultData[4].pk_work_rest + '" week="2"></td><td>' + '<input type="checkbox" class="check" pk="' + d.resultData[4].pk_work_rest + '" week="3"></td><td>' + '<input type="checkbox" class="check" pk="' + d.resultData[4].pk_work_rest + '" week="4"></td><td>' + '<input type="checkbox" class="check" pk="' + d.resultData[4].pk_work_rest + '" week="5"></td><td>' + '<input type="checkbox" class="check" pk="' + d.resultData[4].pk_work_rest + '" week="6"></td><td>' + '<input type="checkbox" class="check" pk="' + d.resultData[4].pk_work_rest + '" week="7"></td></tr>';
str += '<tr><td>' + d.resultData[5].class_name + '</td><td>' + '<input type="checkbox" class="check" pk="' + d.resultData[5].pk_work_rest + '" week="1"></td><td>' + '<input type="checkbox" class="check" pk="' + d.resultData[5].pk_work_rest + '" week="2"></td><td>' + '<input type="checkbox" class="check" pk="' + d.resultData[5].pk_work_rest + '" week="3"></td><td>' + '<input type="checkbox" class="check" pk="' + d.resultData[5].pk_work_rest + '" week="4"></td><td>' + '<input type="checkbox" class="check" pk="' + d.resultData[5].pk_work_rest + '" week="5"></td><td>' + '<input type="checkbox" class="check" pk="' + d.resultData[5].pk_work_rest + '" week="6"></td><td>' + '<input type="checkbox" class="check" pk="' + d.resultData[5].pk_work_rest + '" week="7"></td></tr>';
str += '<tr><td>' + d.resultData[6].class_name + '</td><td>' + '<input type="checkbox" class="check" pk="' + d.resultData[6].pk_work_rest + '" week="1"></td><td>' + '<input type="checkbox" class="check" pk="' + d.resultData[6].pk_work_rest + '" week="2"></td><td>' + '<input type="checkbox" class="check" pk="' + d.resultData[6].pk_work_rest + '" week="3"></td><td>' + '<input type="checkbox" class="check" pk="' + d.resultData[6].pk_work_rest + '" week="4"></td><td>' + '<input type="checkbox" class="check" pk="' + d.resultData[6].pk_work_rest + '" week="5"></td><td>' + '<input type="checkbox" class="check" pk="' + d.resultData[6].pk_work_rest + '" week="6"></td><td>' + '<input type="checkbox" class="check" pk="' + d.resultData[6].pk_work_rest + '" week="7"></td></tr>';
str += '<tr><td>' + d.resultData[7].class_name + '</td><td>' + '<input type="checkbox" class="check" pk="' + d.resultData[7].pk_work_rest + '" week="1"></td><td>' + '<input type="checkbox" class="check" pk="' + d.resultData[7].pk_work_rest + '" week="2"></td><td>' + '<input type="checkbox" class="check" pk="' + d.resultData[7].pk_work_rest + '" week="3"></td><td>' + '<input type="checkbox" class="check" pk="' + d.resultData[7].pk_work_rest + '" week="4"></td><td>' + '<input type="checkbox" class="check" pk="' + d.resultData[7].pk_work_rest + '" week="5"></td><td>' + '<input type="checkbox" class="check" pk="' + d.resultData[7].pk_work_rest + '" week="6"></td><td>' + '<input type="checkbox" class="check" pk="' + d.resultData[7].pk_work_rest + '" week="7"></td></tr>';
str += '<tr><td>' + d.resultData[8].class_name + '</td><td>' + '<input type="checkbox" class="check" pk="' + d.resultData[8].pk_work_rest + '" week="1"></td><td>' + '<input type="checkbox" class="check" pk="' + d.resultData[8].pk_work_rest + '" week="2"></td><td>' + '<input type="checkbox" class="check" pk="' + d.resultData[8].pk_work_rest + '" week="3"></td><td>' + '<input type="checkbox" class="check" pk="' + d.resultData[8].pk_work_rest + '" week="4"></td><td>' + '<input type="checkbox" class="check" pk="' + d.resultData[8].pk_work_rest + '" week="5"></td><td>' + '<input type="checkbox" class="check" pk="' + d.resultData[8].pk_work_rest + '" week="6"></td><td>' + '<input type="checkbox" class="check" pk="' + d.resultData[8].pk_work_rest + '" week="7"></td></tr>';
str += '<tr><td>' + d.resultData[9].class_name + '</td><td>' + '<input type="checkbox" class="check" pk="' + d.resultData[9].pk_work_rest + '" week="1"></td><td>' + '<input type="checkbox" class="check" pk="' + d.resultData[9].pk_work_rest + '" week="2"></td><td>' + '<input type="checkbox" class="check" pk="' + d.resultData[9].pk_work_rest + '" week="3"></td><td>' + '<input type="checkbox" class="check" pk="' + d.resultData[9].pk_work_rest + '" week="4"></td><td>' + '<input type="checkbox" class="check" pk="' + d.resultData[9].pk_work_rest + '" week="5"></td><td>' + '<input type="checkbox" class="check" pk="' + d.resultData[9].pk_work_rest + '" week="6"></td><td>' + '<input type="checkbox" class="check" pk="' + d.resultData[9].pk_work_rest + '" week="7"></td></tr>';
$('#scheduling_choose').html(str);

/*对获取的checkbox进行操作*/
var checkPk;
var checkWeek;

$('.add_submit').click(function() {

$(":checkbox:checked").each(function (i) {
checkPk = $(this).attr('pk');
checkWeek = $(this).attr('week');
var saveDataPk = [];
saveDataPk.push(checkPk);
var saveDataWeek = [];
saveDataWeek.push(checkWeek);
});

});

$(".ok").click(function () {
var allTd = document.querySelectorAll('.td-bg-blue');
for (var i = 0; i < allTd.length; i++) {
var td_value = allTd[i].innerHTML;
$('.weekend-value-area').append(td_value + '&nbsp;');
}
});



});
/*end 作息时间表*/
/*start 排周数*/
var start_time = data.resultData[index].action_date;
var end_time = data.resultData[index].end_date;
totalDay = calculateDay(end_time, start_time);
currentWeekday = new Date(start_time).getDay();
switch (currentWeekday) {
case 1:
if (totalDay % 7 == 0) {
totalWeeks = parseInt(totalDay / 7);
}
else {
totalWeeks = parseInt(totalDay / 7) + 1;
}
break;
case 2:
if ((totalDay - 6) % 7 == 0) {
totalWeeks = parseInt((totalDay - 6) / 7) + 1;
}
else {
totalWeeks = parseInt((totalDay - 6) / 7) + 2;
}
break;
case 3:
if ((totalDay - 5) % 7 == 0) {
totalWeeks = parseInt((totalDay - 5) / 7) + 1;
}
else {
totalWeeks = parseInt((totalDay - 5) / 7) + 2;
}
break;
case 4:
if ((totalDay - 4) % 7 == 0) {
totalWeeks = parseInt((totalDay - 4) / 7) + 1;
}
else {
totalWeeks = parseInt((totalDay - 4) / 7) + 2;
}
break;
case 5:
if ((totalDay - 3) % 7 == 0) {
totalWeeks = parseInt((totalDay - 3) / 7) + 1;
}
else {
totalWeeks = parseInt((totalDay - 3) / 7) + 2;
}
break;
case 6:
if ((totalDay - 2) % 7 == 0) {
totalWeeks = parseInt((totalDay - 2) / 7) + 1;
}
else {
totalWeeks = parseInt((totalDay - 2) / 7) + 2;
}
break;
case 7:
if ((totalDay - 1) % 7 == 0) {
totalWeeks = parseInt((totalDay - 1) / 7) + 1;
}
else {
totalWeeks = parseInt((totalDay - 1) / 7) + 2;
}
break;
}
var rows = parseInt(totalWeeks / 6);
var count = 1;
if (totalWeeks % 6 == 0) {
var str;
for (var j = 0; j < rows; j++) {
str += "<tr>";
for (var k = 0; k < 6; k++) {
str += "<td>";
str += count;
str += "</td>";
count++;
}
str += "</tr>";
}
$(".weekend-chooses tr td").bind('click', function () {
$(this).removeClass('td-bg-white');
$(this).addClass('td-bg-blue');
});
$(".weekend-chooses tr td").bind('dblclick', function () {
$(this).removeClass('td-bg-blue');
$(this).addClass('td-bg-white');
});
} else {
var str;
for (var j = 0; j < rows+1; j++) {
str += "<tr>";
for (var k = 0; k < 6; k++) {
str += "<td>";
str += count;
str += "</td>";
count++;
}
str += "</tr>";
}
$('#weekend-chooses').append(str);
$(".weekend-chooses tr td").bind('click', function () {
$(this).removeClass('td-bg-white');
$(this).addClass('td-bg-blue');
});
$(".weekend-chooses tr td").bind('dblclick', function () {
$(this).removeClass('td-bg-blue');
$(this).addClass('td-bg-white');
});
}
/*end 排周数*/
});
});
}
});

/*加载班级*/
$.get(url + "/root/api/class",
{user_code: $("#teachercode", window.parent.document).html()},
function (d) {
if (d.success = true) {
for (var m = 0; m < d.length; m++) {
var choose_class = document.getElementById('choose_class');
var choose_class_value = d[m].deptname;
choose_class.options.add(new Option(choose_class_value));
}
$('#choose_class').change(function () {
$('#choose_class option:selected').each(function () {
var choose_classes = document.getElementById('choose_class');
var classIndex = choose_classes.selectedIndex;
var class_pk_area = d[classIndex].pk_deptdoc;
$('.class_pk_area').html(class_pk_area);
});
});
}
});
/*班级获取*/

/*加载楼*/
function loadBuilding() {
$.get(url + '/root/api/build', {},
function (data) {
if (data.success) {
var building = document.getElementById('building');
var story = document.getElementById('story');
var classRoom = document.getElementById('classRoom');
building.options.length = 0;
story.options.length = 0;
classRoom.options.length = 0;
for (var i = 0; i < data.resultData.length; i++) {
var buildind_value = data.resultData[i].area_name;
building.options.add(new Option(buildind_value));//创造option
}
$('#building').change(function () {
story.options.length = 0;
classRoom.options.length = 0;
$('#building option:selected').each(function () {
var index = building.selectedIndex;
var building_selected_text = $(this).val();
var building_pk_area = data.resultData[index].pk_area;
/*加载层*/
$('#story').removeClass('none').addClass('block');
$.get(url + '/root/api/story', {pk_area: building_pk_area},
function (data) {
if (data.success) {
for (var j = 0; j < data.resultData.length; j++) {
var story_value = data.resultData[j].area_name;
story.options.add(new Option(story_value));//创造option
}
$('#story').change(function () {
classRoom.options.length = 0;
$('#story option:selected').each(function () {
var indexTwo = story.selectedIndex;
var story_pk_area = data.resultData[indexTwo].pk_area;
/*加载教室*/
$('#classRoom').removeClass('none').addClass('block');
$.get(url + '/root/api/classroom', {pk_area: story_pk_area},
function (data) {
if (data.success) {
for (var k = 0; k < data.resultData.length; k++) {
var classRoom_value = data.resultData[k].area_name;
classRoom.options.add(new Option(classRoom_value));//创造option
}
$('#classRoom').change(function () {
$('#classRoom option:selected').each(function () {
var classRoomIndex = classRoom.selectedIndex;
var classRoom_pk_area = data.resultData[classRoomIndex].pk_area;
$('.classRoom_pk_area').html(classRoom_pk_area);
});
});
}
else {
alert(data.msg);
}
}
);
/*加载教室*/
});
});
}
else {
alert(data.msg);
}
}
);
/*加载层*/
});
});
}
else {
alert(data.msg);
}

}
);
}

/*计算天数*/
function calculateDay($endTime, $startTime) {
var endTime = arguments[0], startTime = arguments[1];
endTime = Date.parse(endTime) / 1000;
startTime = Date.parse(startTime) / 1000;
var time = endTime - startTime;
return (time / (24 * 60 * 60));
}


</script>
</html>




原文地址:https://www.cnblogs.com/qiuchunxia/p/6282448.html