jacksenma 7 роки тому
батько
коміт
8d50275237

+ 1 - 0
.gitignore

@@ -15,6 +15,7 @@
 *.iws
 *.iml
 *.ipr
+*.xml
 
 ### NetBeans ###
 /nbproject/private/

+ 37 - 50
.idea/workspace.xml

@@ -2,7 +2,7 @@
 <project version="4">
   <component name="ChangeListManager">
     <list default="true" id="6ab6cf33-62bd-48c1-935e-834777603958" name="Default Changelist" comment="">
-      <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/.gitignore" beforeDir="false" afterPath="$PROJECT_DIR$/.gitignore" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/src/main/java/com/example/cinema/bl/ScheduleServiceImpl.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/example/cinema/bl/ScheduleServiceImpl.java" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/src/main/java/com/example/cinema/vo/ScheduleItem.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/example/cinema/vo/ScheduleItem.java" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/src/main/resources/application.yml" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/application.yml" afterDir="false" />
@@ -68,6 +68,7 @@
       </usages-collector>
       <usages-collector id="statistics.file.extensions.open">
         <counts>
+          <entry key="gitignore" value="1" />
           <entry key="hall" value="2" />
           <entry key="java" value="101" />
           <entry key="movie" value="5" />
@@ -83,6 +84,7 @@
         <counts>
           <entry key="Database Element" value="16" />
           <entry key="JAVA" value="101" />
+          <entry key="PLAIN_TEXT" value="1" />
           <entry key="Scratch" value="5" />
           <entry key="XML" value="14" />
           <entry key="YAML" value="5" />
@@ -91,6 +93,7 @@
       <usages-collector id="statistics.file.extensions.edit">
         <counts>
           <entry key="cell" value="98" />
+          <entry key="gitignore" value="6" />
           <entry key="java" value="2240" />
           <entry key="sql" value="436" />
           <entry key="txt" value="6" />
@@ -101,7 +104,7 @@
       <usages-collector id="statistics.file.types.edit">
         <counts>
           <entry key="JAVA" value="2240" />
-          <entry key="PLAIN_TEXT" value="6" />
+          <entry key="PLAIN_TEXT" value="12" />
           <entry key="SQL" value="23" />
           <entry key="Scratch" value="534" />
           <entry key="XML" value="265" />
@@ -130,11 +133,11 @@
           </provider>
         </entry>
       </file>
-      <file pinned="false" current-in-tab="true">
+      <file pinned="false" current-in-tab="false">
         <entry file="file://$PROJECT_DIR$/src/main/java/com/example/cinema/bl/ScheduleServiceImpl.java">
           <provider selected="true" editor-type-id="text-editor">
-            <state relative-caret-position="70">
-              <caret line="53" column="100" selection-start-line="53" selection-start-column="100" selection-end-line="53" selection-end-column="100" />
+            <state relative-caret-position="144">
+              <caret line="22" column="27" selection-start-line="22" selection-start-column="27" selection-end-line="22" selection-end-column="27" />
               <folding>
                 <element signature="imports" expanded="true" />
               </folding>
@@ -142,6 +145,20 @@
           </provider>
         </entry>
       </file>
+      <file pinned="false" current-in-tab="false">
+        <entry file="file://$PROJECT_DIR$/.idea/workspace.xml">
+          <provider selected="true" editor-type-id="text-editor" />
+        </entry>
+      </file>
+      <file pinned="false" current-in-tab="true">
+        <entry file="file://$PROJECT_DIR$/.gitignore">
+          <provider selected="true" editor-type-id="text-editor">
+            <state relative-caret-position="255">
+              <caret line="17" column="5" selection-start-line="17" selection-start-column="5" selection-end-line="17" selection-end-column="5" />
+            </state>
+          </provider>
+        </entry>
+      </file>
       <file pinned="false" current-in-tab="false">
         <entry file="file://$PROJECT_DIR$/src/main/resources/application.yml">
           <provider selected="true" editor-type-id="text-editor">
@@ -222,6 +239,7 @@
         <option value="$PROJECT_DIR$/src/main/java/com/example/cinema/vo/ScheduleSearchForm.java" />
         <option value="$PROJECT_DIR$/src/main/resources/application.yml" />
         <option value="$PROJECT_DIR$/src/main/java/com/example/cinema/bl/ScheduleServiceImpl.java" />
+        <option value="$PROJECT_DIR$/.gitignore" />
       </list>
     </option>
   </component>
@@ -259,53 +277,12 @@
             <path>
               <item name="cinema" type="b2602c69:ProjectViewProjectNode" />
               <item name="CinemaDemo" type="462c0819:PsiDirectoryNode" />
-              <item name="src" type="462c0819:PsiDirectoryNode" />
-            </path>
-            <path>
-              <item name="cinema" type="b2602c69:ProjectViewProjectNode" />
-              <item name="CinemaDemo" type="462c0819:PsiDirectoryNode" />
-              <item name="src" type="462c0819:PsiDirectoryNode" />
-              <item name="main" type="462c0819:PsiDirectoryNode" />
-            </path>
-            <path>
-              <item name="cinema" type="b2602c69:ProjectViewProjectNode" />
-              <item name="CinemaDemo" type="462c0819:PsiDirectoryNode" />
-              <item name="src" type="462c0819:PsiDirectoryNode" />
-              <item name="main" type="462c0819:PsiDirectoryNode" />
-              <item name="java" type="462c0819:PsiDirectoryNode" />
-            </path>
-            <path>
-              <item name="cinema" type="b2602c69:ProjectViewProjectNode" />
-              <item name="CinemaDemo" type="462c0819:PsiDirectoryNode" />
-              <item name="src" type="462c0819:PsiDirectoryNode" />
-              <item name="main" type="462c0819:PsiDirectoryNode" />
-              <item name="java" type="462c0819:PsiDirectoryNode" />
-              <item name="cinema" type="462c0819:PsiDirectoryNode" />
-            </path>
-            <path>
-              <item name="cinema" type="b2602c69:ProjectViewProjectNode" />
-              <item name="CinemaDemo" type="462c0819:PsiDirectoryNode" />
-              <item name="src" type="462c0819:PsiDirectoryNode" />
-              <item name="main" type="462c0819:PsiDirectoryNode" />
-              <item name="java" type="462c0819:PsiDirectoryNode" />
-              <item name="cinema" type="462c0819:PsiDirectoryNode" />
-              <item name="bl" type="462c0819:PsiDirectoryNode" />
-            </path>
-            <path>
-              <item name="cinema" type="b2602c69:ProjectViewProjectNode" />
-              <item name="CinemaDemo" type="462c0819:PsiDirectoryNode" />
-              <item name="src" type="462c0819:PsiDirectoryNode" />
-              <item name="main" type="462c0819:PsiDirectoryNode" />
-              <item name="java" type="462c0819:PsiDirectoryNode" />
-              <item name="cinema" type="462c0819:PsiDirectoryNode" />
-              <item name="controller" type="462c0819:PsiDirectoryNode" />
+              <item name=".idea" type="462c0819:PsiDirectoryNode" />
             </path>
             <path>
               <item name="cinema" type="b2602c69:ProjectViewProjectNode" />
               <item name="CinemaDemo" type="462c0819:PsiDirectoryNode" />
               <item name="src" type="462c0819:PsiDirectoryNode" />
-              <item name="main" type="462c0819:PsiDirectoryNode" />
-              <item name="resources" type="462c0819:PsiDirectoryNode" />
             </path>
             <path>
               <item name="cinema" type="b2602c69:ProjectViewProjectNode" />
@@ -502,7 +479,7 @@
     </history-entry>
   </component>
   <component name="TimeTrackingManager">
-    <option name="totallyTimeSpent" value="20530000" />
+    <option name="totallyTimeSpent" value="20551000" />
   </component>
   <component name="TodoView">
     <todo-panel id="selected-file">
@@ -881,14 +858,24 @@
     </entry>
     <entry file="file://$PROJECT_DIR$/src/main/java/com/example/cinema/bl/ScheduleServiceImpl.java">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="70">
-          <caret line="53" column="100" selection-start-line="53" selection-start-column="100" selection-end-line="53" selection-end-column="100" />
+        <state relative-caret-position="144">
+          <caret line="22" column="27" selection-start-line="22" selection-start-column="27" selection-end-line="22" selection-end-column="27" />
           <folding>
             <element signature="imports" expanded="true" />
           </folding>
         </state>
       </provider>
     </entry>
+    <entry file="file://$PROJECT_DIR$/.idea/workspace.xml">
+      <provider selected="true" editor-type-id="text-editor" />
+    </entry>
+    <entry file="file://$PROJECT_DIR$/.gitignore">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="255">
+          <caret line="17" column="5" selection-start-line="17" selection-start-column="5" selection-end-line="17" selection-end-column="5" />
+        </state>
+      </provider>
+    </entry>
   </component>
   <component name="masterDetails">
     <states>

+ 6 - 6
src/main/resources/static/css/adminSchedule.css

@@ -5,33 +5,33 @@
 
 .schedule-time-line {
     width: 80px;
-    height: 720px;
     display: flex;
     flex-direction: column;
     justify-content: space-between;
 }
 
 .schedule-item-line {
-    height: 720px;
+    height: 960px;
     width: 150px;
     border-left: 1px solid #ccc;
     position: relative;
 }
 
 .schedule-item {
-    background: #1caaaa;
-    height:80px;
+    width: 100%;
     display: flex;
     flex-direction: column;
-    justify-content: center;
     align-items: center;
     color: #fff;
+    position: absolute;
+    overflow-y: scroll;
 }
 
 .schedule-date-container {
     padding-left: 100px;
-    height: 30px;
+    height: 40px;
     line-height: 30px;
+    display: flex;
 }
 
 .schedule-date {

+ 13 - 12
src/main/resources/static/js/adminCinemaManage.js

@@ -3,18 +3,20 @@ $(document).ready(function() {
     getCinemaHalls();
 
     function getCinemaHalls() {
-        var halls = [
-            {
-                name: '1号厅',
-                column: 10,
-                row: 5
+        var halls = [];
+        getRequest(
+            '/hall/all',
+            function (res) {
+                halls = res.content;
+                renderHall(halls);
             },
-            {
-                name: '2号厅',
-                column: 12,
-                row: 8
-            },
-        ];
+            function (error) {
+                alert(JSON.stringify(error));
+            }
+        );
+    }
+
+    function renderHall(halls){
         $('#hall-card').empty();
         var hallDomStr = "";
         halls.forEach(function (hall) {
@@ -39,5 +41,4 @@ $(document).ready(function() {
         })
         $('#hall-card').append(hallDomStr);
     }
-
 });

+ 149 - 5
src/main/resources/static/js/adminScheduleManage.js

@@ -1,10 +1,154 @@
 var colors = [
-    '#66cccc',
-    '#0099cc',
+    '#FF6666',
+    '#FFFF33',
     '#FF9933',
+    '#66cccc',
     '#FFCCCC',
     '#3399FF',
-    '#FFFF33',
+
     '#9966FF',
-    '#FF6666',
-]
+
+];
+
+function formatDate(date){
+    var year = date.getFullYear();
+    var month = date.getMonth()+1+'';
+    var day = date.getDate()+'';
+    month.length===1 && (month = '0'+month)
+    day.length===1 && (day = '0'+day)
+    return year+'-'+month+'-'+day;
+}
+
+function formatTime(date){
+    return date.getHours()+":"+date.getMinutes();
+}
+
+$(document).ready(function() {
+    var hallId,
+        scheduleDate = formatDate(new Date());
+
+    initSelectAndDate();
+
+    function getSchedules() {
+        var schedules = [];
+        postRequest(
+            '/schedule/search',
+            {
+                hallId: hallId,
+                startDate: scheduleDate
+             },
+            function (res) {
+                schedules = res.content;
+                console.log(schedules);
+                renderScheduleTable(schedules);
+             },
+            function (error) {
+                alert(JSON.stringify(error));
+             }
+        );
+    }
+
+    function renderScheduleTable(schedules){
+        $('.schedule-date-container').empty();
+        $(".schedule-time-line").siblings().remove();
+        schedules.forEach(function (scheduleOfDate) {
+            $('.schedule-date-container').append("<div class='schedule-date'>"+formatDate(new Date(scheduleOfDate.date))+"</div>");
+            var scheduleDateDom = $(" <ul class='schedule-item-line'></ul>");
+            $(".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+"'>"+
+                    "<span>"+schedule.movieName+"</span>"+
+                    "<span class='error-text'>¥"+schedule.fare+"</span>"+
+                    "<span>"+formatTime(new Date(schedule.startTime))+"-"+formatTime(new Date(schedule.endTime))+"</span>"+
+                    "</li>");
+            })
+        })
+    }
+
+    function mapScheduleStyle(schedule) {
+        var start = new Date(schedule.startTime).getHours()+new Date(schedule.startTime).getMinutes()/60,
+            end = new Date(schedule.endTime).getHours()+new Date(schedule.endTime).getMinutes()/60 ;
+        return {
+            color: colors[schedule.movieId%colors.length],
+            top: 40*start+'px',
+            height: 40*(end-start)+'px'
+        }
+    }
+
+    function initSelectAndDate() {
+        $('#schedule-date-input').val(scheduleDate);
+        getCinemaHalls();
+        getAllMovies();
+        
+        // 过滤条件变化后重新查询
+        $('#hall-select').change (function () {
+            hallId=$(this).children('option:selected').val();
+            getSchedules();
+        });
+        $('#schedule-date-input').change(function () {
+            scheduleDate = $('#schedule-date-input').val();
+            getSchedules();
+        });
+    }
+
+    function getCinemaHalls() {
+        var halls = [];
+        getRequest(
+            '/hall/all',
+            function (res) {
+                halls = res.content;
+                hallId = halls[0].id;
+                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>");
+                });
+                getSchedules();
+            },
+            function (error) {
+                alert(JSON.stringify(error));
+            }
+        );
+    }
+
+    function getAllMovies() {
+        getRequest(
+            '/movie/all',
+            function (res) {
+                var movieList = res.content;
+                movieList.forEach(function (movie) {
+                    $('#schedule-movie-input').append("<option value="+ movie.id +">"+movie.name+"</option>");
+                });
+            },
+            function (error) {
+                alert(error);
+            }
+        );
+    }
+    
+    $('#schedule-form-btn').click(function () {
+        var form = {
+            hallId: $("#schedule-hall-input").children('option:selected').val(),
+            movieId : $("#schedule-movie-input").children('option:selected').val(),
+            startTime: $("#schedule-start-date-input").val(),
+            endTime: $("#schedule-end-date-input").val(),
+            fare: $("#schedule-price-input").val()
+        };
+        //todo 需要做一下表单验证?
+
+        postRequest(
+            '/schedule/add',
+            form,
+            function (res) {
+                getSchedules();
+                $("#scheduleModal").modal('hide');
+            },
+            function (error) {
+                alert(JSON.stringify(error));
+            }
+        );
+    })
+
+});
+

+ 26 - 10
src/main/resources/templates/adminScheduleManage.html

@@ -13,6 +13,8 @@
     <script src="/js/jquery.js"></script>
     <script src="/js/bootstrap.js"></script>
     <script src="/js/request.js"></script>
+    <script src="/js/adminScheduleManage.js"></script>
+
 </head>
 <body>
 <div class="main-container">
@@ -38,8 +40,6 @@
                 <div>
                 <span>选择影厅  </span>
                 <select id="hall-select" class="form-control" style="display: inline-block;width: 180px;">
-                    <option>1</option>
-                    <option>2</option>
                 </select>
                 </div>
                 <div>
@@ -63,10 +63,6 @@
                     <li class="schedule-time-item">24:00</li>
                 </ul>
                 <ul class="schedule-item-line">
-                    <li class="schedule-item">
-                        <span>电影1</span>
-                        <span>00:00-02:00</span>
-                    </li>
                 </ul>
             </div>
         </div>
@@ -82,15 +78,35 @@
             <div class="modal-body">
                 <form class="form-horizontal" role="form">
                     <div class="form-group">
-                        <label class="col-sm-2 control-label" for="movie-name-input"><span class="error-text">*</span>电影名称</label>
+                        <label class="col-sm-2 control-label" for="schedule-movie-input"><span class="error-text">*</span>电影名称</label>
+                        <div class="col-sm-10">
+                            <select id="schedule-movie-input" class="form-control">
+                            </select>
+                        </div>
+                    </div>
+                    <div class="form-group">
+                        <label class="col-sm-2 control-label" for="schedule-hall-input"><span class="error-text">*</span>放映影厅</label>
+                        <div class="col-sm-10">
+                            <select id="schedule-hall-input" class="form-control">
+                            </select>
+                        </div>
+                    </div>
+                    <div class="form-group">
+                        <label class="col-sm-2 control-label" for="schedule-start-date-input"><span class="error-text">*</span>开始时间</label>
+                        <div class="col-sm-10">
+                            <input type="datetime-local" class="form-control" id="schedule-start-date-input" placeholder="请选择开始时间">
+                        </div>
+                    </div>
+                    <div class="form-group">
+                        <label class="col-sm-2 control-label" for="schedule-end-date-input"><span class="error-text">*</span>结束时间</label>
                         <div class="col-sm-10">
-                            <input type="text" class="form-control" id="movie-name-input" placeholder="请输入电影名称">
+                            <input type="datetime-local" class="form-control" id="schedule-end-date-input" placeholder="请选择结束时间">
                         </div>
                     </div>
                     <div class="form-group">
-                        <label class="col-sm-2 control-label" for="movie-date-input"><span class="error-text">*</span>上映时间</label>
+                        <label class="col-sm-2 control-label" for="schedule-price-input"><span class="error-text">*</span>场次票价</label>
                         <div class="col-sm-10">
-                            <input type="date" class="form-control" id="movie-date-input" placeholder="请输入电影上映时间">
+                            <input type="text" class="form-control" id="schedule-price-input" placeholder="请输入票价">
                         </div>
                     </div>
                 </form>

+ 6 - 6
target/classes/static/css/adminSchedule.css

@@ -5,33 +5,33 @@
 
 .schedule-time-line {
     width: 80px;
-    height: 720px;
     display: flex;
     flex-direction: column;
     justify-content: space-between;
 }
 
 .schedule-item-line {
-    height: 720px;
+    height: 960px;
     width: 150px;
     border-left: 1px solid #ccc;
     position: relative;
 }
 
 .schedule-item {
-    background: #1caaaa;
-    height:80px;
+    width: 100%;
     display: flex;
     flex-direction: column;
-    justify-content: center;
     align-items: center;
     color: #fff;
+    position: absolute;
+    overflow-y: scroll;
 }
 
 .schedule-date-container {
     padding-left: 100px;
-    height: 30px;
+    height: 40px;
     line-height: 30px;
+    display: flex;
 }
 
 .schedule-date {

+ 13 - 12
target/classes/static/js/adminCinemaManage.js

@@ -3,18 +3,20 @@ $(document).ready(function() {
     getCinemaHalls();
 
     function getCinemaHalls() {
-        var halls = [
-            {
-                name: '1号厅',
-                column: 10,
-                row: 5
+        var halls = [];
+        getRequest(
+            '/hall/all',
+            function (res) {
+                halls = res.content;
+                renderHall(halls);
             },
-            {
-                name: '2号厅',
-                column: 12,
-                row: 8
-            },
-        ];
+            function (error) {
+                alert(JSON.stringify(error));
+            }
+        );
+    }
+
+    function renderHall(halls){
         $('#hall-card').empty();
         var hallDomStr = "";
         halls.forEach(function (hall) {
@@ -39,5 +41,4 @@ $(document).ready(function() {
         })
         $('#hall-card').append(hallDomStr);
     }
-
 });

+ 149 - 5
target/classes/static/js/adminScheduleManage.js

@@ -1,10 +1,154 @@
 var colors = [
-    '#66cccc',
-    '#0099cc',
+    '#FF6666',
+    '#FFFF33',
     '#FF9933',
+    '#66cccc',
     '#FFCCCC',
     '#3399FF',
-    '#FFFF33',
+
     '#9966FF',
-    '#FF6666',
-]
+
+];
+
+function formatDate(date){
+    var year = date.getFullYear();
+    var month = date.getMonth()+1+'';
+    var day = date.getDate()+'';
+    month.length===1 && (month = '0'+month)
+    day.length===1 && (day = '0'+day)
+    return year+'-'+month+'-'+day;
+}
+
+function formatTime(date){
+    return date.getHours()+":"+date.getMinutes();
+}
+
+$(document).ready(function() {
+    var hallId,
+        scheduleDate = formatDate(new Date());
+
+    initSelectAndDate();
+
+    function getSchedules() {
+        var schedules = [];
+        postRequest(
+            '/schedule/search',
+            {
+                hallId: hallId,
+                startDate: scheduleDate
+             },
+            function (res) {
+                schedules = res.content;
+                console.log(schedules);
+                renderScheduleTable(schedules);
+             },
+            function (error) {
+                alert(JSON.stringify(error));
+             }
+        );
+    }
+
+    function renderScheduleTable(schedules){
+        $('.schedule-date-container').empty();
+        $(".schedule-time-line").siblings().remove();
+        schedules.forEach(function (scheduleOfDate) {
+            $('.schedule-date-container').append("<div class='schedule-date'>"+formatDate(new Date(scheduleOfDate.date))+"</div>");
+            var scheduleDateDom = $(" <ul class='schedule-item-line'></ul>");
+            $(".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+"'>"+
+                    "<span>"+schedule.movieName+"</span>"+
+                    "<span class='error-text'>¥"+schedule.fare+"</span>"+
+                    "<span>"+formatTime(new Date(schedule.startTime))+"-"+formatTime(new Date(schedule.endTime))+"</span>"+
+                    "</li>");
+            })
+        })
+    }
+
+    function mapScheduleStyle(schedule) {
+        var start = new Date(schedule.startTime).getHours()+new Date(schedule.startTime).getMinutes()/60,
+            end = new Date(schedule.endTime).getHours()+new Date(schedule.endTime).getMinutes()/60 ;
+        return {
+            color: colors[schedule.movieId%colors.length],
+            top: 40*start+'px',
+            height: 40*(end-start)+'px'
+        }
+    }
+
+    function initSelectAndDate() {
+        $('#schedule-date-input').val(scheduleDate);
+        getCinemaHalls();
+        getAllMovies();
+        
+        // 过滤条件变化后重新查询
+        $('#hall-select').change (function () {
+            hallId=$(this).children('option:selected').val();
+            getSchedules();
+        });
+        $('#schedule-date-input').change(function () {
+            scheduleDate = $('#schedule-date-input').val();
+            getSchedules();
+        });
+    }
+
+    function getCinemaHalls() {
+        var halls = [];
+        getRequest(
+            '/hall/all',
+            function (res) {
+                halls = res.content;
+                hallId = halls[0].id;
+                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>");
+                });
+                getSchedules();
+            },
+            function (error) {
+                alert(JSON.stringify(error));
+            }
+        );
+    }
+
+    function getAllMovies() {
+        getRequest(
+            '/movie/all',
+            function (res) {
+                var movieList = res.content;
+                movieList.forEach(function (movie) {
+                    $('#schedule-movie-input').append("<option value="+ movie.id +">"+movie.name+"</option>");
+                });
+            },
+            function (error) {
+                alert(error);
+            }
+        );
+    }
+    
+    $('#schedule-form-btn').click(function () {
+        var form = {
+            hallId: $("#schedule-hall-input").children('option:selected').val(),
+            movieId : $("#schedule-movie-input").children('option:selected').val(),
+            startTime: $("#schedule-start-date-input").val(),
+            endTime: $("#schedule-end-date-input").val(),
+            fare: $("#schedule-price-input").val()
+        };
+        //todo 需要做一下表单验证?
+
+        postRequest(
+            '/schedule/add',
+            form,
+            function (res) {
+                getSchedules();
+                $("#scheduleModal").modal('hide');
+            },
+            function (error) {
+                alert(JSON.stringify(error));
+            }
+        );
+    })
+
+});
+

+ 26 - 10
target/classes/templates/adminScheduleManage.html

@@ -13,6 +13,8 @@
     <script src="/js/jquery.js"></script>
     <script src="/js/bootstrap.js"></script>
     <script src="/js/request.js"></script>
+    <script src="/js/adminScheduleManage.js"></script>
+
 </head>
 <body>
 <div class="main-container">
@@ -38,8 +40,6 @@
                 <div>
                 <span>选择影厅  </span>
                 <select id="hall-select" class="form-control" style="display: inline-block;width: 180px;">
-                    <option>1</option>
-                    <option>2</option>
                 </select>
                 </div>
                 <div>
@@ -63,10 +63,6 @@
                     <li class="schedule-time-item">24:00</li>
                 </ul>
                 <ul class="schedule-item-line">
-                    <li class="schedule-item">
-                        <span>电影1</span>
-                        <span>00:00-02:00</span>
-                    </li>
                 </ul>
             </div>
         </div>
@@ -82,15 +78,35 @@
             <div class="modal-body">
                 <form class="form-horizontal" role="form">
                     <div class="form-group">
-                        <label class="col-sm-2 control-label" for="movie-name-input"><span class="error-text">*</span>电影名称</label>
+                        <label class="col-sm-2 control-label" for="schedule-movie-input"><span class="error-text">*</span>电影名称</label>
+                        <div class="col-sm-10">
+                            <select id="schedule-movie-input" class="form-control">
+                            </select>
+                        </div>
+                    </div>
+                    <div class="form-group">
+                        <label class="col-sm-2 control-label" for="schedule-hall-input"><span class="error-text">*</span>放映影厅</label>
+                        <div class="col-sm-10">
+                            <select id="schedule-hall-input" class="form-control">
+                            </select>
+                        </div>
+                    </div>
+                    <div class="form-group">
+                        <label class="col-sm-2 control-label" for="schedule-start-date-input"><span class="error-text">*</span>开始时间</label>
+                        <div class="col-sm-10">
+                            <input type="datetime-local" class="form-control" id="schedule-start-date-input" placeholder="请选择开始时间">
+                        </div>
+                    </div>
+                    <div class="form-group">
+                        <label class="col-sm-2 control-label" for="schedule-end-date-input"><span class="error-text">*</span>结束时间</label>
                         <div class="col-sm-10">
-                            <input type="text" class="form-control" id="movie-name-input" placeholder="请输入电影名称">
+                            <input type="datetime-local" class="form-control" id="schedule-end-date-input" placeholder="请选择结束时间">
                         </div>
                     </div>
                     <div class="form-group">
-                        <label class="col-sm-2 control-label" for="movie-date-input"><span class="error-text">*</span>上映时间</label>
+                        <label class="col-sm-2 control-label" for="schedule-price-input"><span class="error-text">*</span>场次票价</label>
                         <div class="col-sm-10">
-                            <input type="date" class="form-control" id="movie-date-input" placeholder="请输入电影上映时间">
+                            <input type="text" class="form-control" id="schedule-price-input" placeholder="请输入票价">
                         </div>
                     </div>
                 </form>