|
|
@@ -5,7 +5,6 @@ var colors = [
|
|
|
'#66cccc',
|
|
|
'#FFCCCC',
|
|
|
'#3399FF',
|
|
|
-
|
|
|
'#9966FF',
|
|
|
|
|
|
];
|
|
|
@@ -20,17 +19,22 @@ function formatDate(date){
|
|
|
}
|
|
|
|
|
|
function formatTime(date){
|
|
|
- return date.getHours()+":"+date.getMinutes();
|
|
|
+ var hour = date.getHours()+'';
|
|
|
+ var minutes = date.getMinutes()+'';
|
|
|
+ hour.length===1 && (hour = '0'+hour)
|
|
|
+ minutes.length===1 && (minutes = '0'+minutes)
|
|
|
+ return hour+":"+minutes;
|
|
|
}
|
|
|
|
|
|
$(document).ready(function() {
|
|
|
var hallId,
|
|
|
- scheduleDate = formatDate(new Date());
|
|
|
+ scheduleDate = formatDate(new Date()),
|
|
|
+ schedules = [];
|
|
|
|
|
|
initSelectAndDate();
|
|
|
|
|
|
function getSchedules() {
|
|
|
- var schedules = [];
|
|
|
+
|
|
|
getRequest(
|
|
|
'/schedule/search?hallId='+hallId+'&startDate='+scheduleDate.replace(/-/g,'/'),
|
|
|
function (res) {
|
|
|
@@ -52,13 +56,14 @@ $(document).ready(function() {
|
|
|
$(".schedule-container").append(scheduleDateDom);
|
|
|
scheduleOfDate.scheduleItemList.forEach(function (schedule,index) {
|
|
|
var scheduleStyle = mapScheduleStyle(schedule);
|
|
|
- scheduleDateDom.append(
|
|
|
- "<li class='schedule-item' style='background:"+scheduleStyle.color+";top:"+scheduleStyle.top+";height:"+scheduleStyle.height+"'>"+
|
|
|
+ var scheduleItemDom =$(
|
|
|
+ "<li id='schedule-"+ schedule.id +"' class='schedule-item' data-schedule='"+JSON.stringify(schedule)+"' style='background:"+scheduleStyle.color+";top:"+scheduleStyle.top+";height:"+scheduleStyle.height+"'>"+
|
|
|
"<span>"+schedule.movieName+"</span>"+
|
|
|
"<span class='error-text'>¥"+schedule.fare+"</span>"+
|
|
|
"<span>"+formatTime(new Date(schedule.startTime))+"-"+formatTime(new Date(schedule.endTime))+"</span>"+
|
|
|
"</li>");
|
|
|
- })
|
|
|
+ scheduleDateDom.append(scheduleItemDom);
|
|
|
+ });
|
|
|
})
|
|
|
}
|
|
|
|
|
|
@@ -98,6 +103,7 @@ $(document).ready(function() {
|
|
|
halls.forEach(function (hall) {
|
|
|
$('#hall-select').append("<option value="+ hall.id +">"+hall.name+"</option>");
|
|
|
$('#schedule-hall-input').append("<option value="+ hall.id +">"+hall.name+"</option>");
|
|
|
+ $('#schedule-edit-hall-input').append("<option value="+ hall.id +">"+hall.name+"</option>");
|
|
|
});
|
|
|
getSchedules();
|
|
|
},
|
|
|
@@ -114,6 +120,7 @@ $(document).ready(function() {
|
|
|
var movieList = res.content;
|
|
|
movieList.forEach(function (movie) {
|
|
|
$('#schedule-movie-input').append("<option value="+ movie.id +">"+movie.name+"</option>");
|
|
|
+ $("#schedule-edit-movie-input").append("<option value="+ movie.id +">"+movie.name+"</option>");
|
|
|
});
|
|
|
},
|
|
|
function (error) {
|
|
|
@@ -121,6 +128,18 @@ $(document).ready(function() {
|
|
|
}
|
|
|
);
|
|
|
}
|
|
|
+
|
|
|
+ $(document).on('click','.schedule-item',function (e) {
|
|
|
+ var schedule = JSON.parse(e.target.dataset.schedule);
|
|
|
+ $("#schedule-edit-hall-input").children('option[value='+schedule.hallId+']').attr('selected',true);
|
|
|
+ $("#schedule-edit-movie-input").children('option[value='+schedule.movieId+']').attr('selected',true);
|
|
|
+ $("#schedule-edit-start-date-input").val(schedule.startTime.slice(0,16));
|
|
|
+ $("#schedule-edit-end-date-input").val(schedule.endTime.slice(0,16));
|
|
|
+ $("#schedule-edit-price-input").val(schedule.fare);
|
|
|
+ $('#scheduleEditModal').modal('show');
|
|
|
+ $('#scheduleEditModal')[0].dataset.scheduleId = schedule.id;
|
|
|
+ console.log(schedule);
|
|
|
+ });
|
|
|
|
|
|
$('#schedule-form-btn').click(function () {
|
|
|
var form = {
|
|
|
@@ -143,6 +162,55 @@ $(document).ready(function() {
|
|
|
alert(JSON.stringify(error));
|
|
|
}
|
|
|
);
|
|
|
+ });
|
|
|
+
|
|
|
+ $('#schedule-edit-form-btn').click(function () {
|
|
|
+ var form = {
|
|
|
+ id: Number($('#scheduleEditModal')[0].dataset.scheduleId),
|
|
|
+ hallId: $("#schedule-edit-hall-input").children('option:selected').val(),
|
|
|
+ movieId : $("#schedule-edit-movie-input").children('option:selected').val(),
|
|
|
+ startTime: $("#schedule-edit-start-date-input").val(),
|
|
|
+ endTime: $("#schedule-edit-end-date-input").val(),
|
|
|
+ fare: $("#schedule-edit-price-input").val()
|
|
|
+ };
|
|
|
+ //todo 需要做一下表单验证?
|
|
|
+
|
|
|
+ postRequest(
|
|
|
+ '/schedule/update',
|
|
|
+ form,
|
|
|
+ function (res) {
|
|
|
+ if(res.success){
|
|
|
+ getSchedules();
|
|
|
+ $("#scheduleEditModal").modal('hide');
|
|
|
+ } else{
|
|
|
+ alert(res.message);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ function (error) {
|
|
|
+ alert(JSON.stringify(error));
|
|
|
+ }
|
|
|
+ );
|
|
|
+ });
|
|
|
+
|
|
|
+ $("#schedule-edit-remove-btn").click(function () {
|
|
|
+ var r=confirm("确认要删除该排片信息吗")
|
|
|
+ if (r) {
|
|
|
+ deleteRequest(
|
|
|
+ '/schedule/delete/batch',
|
|
|
+ {scheduleIdList:[Number($('#scheduleEditModal')[0].dataset.scheduleId)]},
|
|
|
+ function (res) {
|
|
|
+ if(res.success){
|
|
|
+ getSchedules();
|
|
|
+ $("#scheduleEditModal").modal('hide');
|
|
|
+ } else{
|
|
|
+ alert(res.message);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ function (error) {
|
|
|
+ alert(JSON.stringify(error));
|
|
|
+ }
|
|
|
+ );
|
|
|
+ }
|
|
|
})
|
|
|
|
|
|
});
|