add.php 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. <div class="main-content-inner">
  2. <div class="breadcrumbs" id="breadcrumbs">
  3. <ul class="breadcrumb">
  4. <li>
  5. <i class="ace-icon fa fa-home home-icon"></i>
  6. <a>首页</a>
  7. </li>
  8. <li>
  9. <a>教学管理</a>
  10. </li>
  11. <li class="active">添加教学进度</li>
  12. </ul>
  13. </div>
  14. <div class="page-content">
  15. <div class="row">
  16. <div class="col-xs-12">
  17. <!-- PAGE CONTENT BEGINS -->
  18. <form class="form-horizontal" action="<?php echo $this->createUrl('syllabus/add');?>" method="post" id="userInfoSubmit">
  19. <div class="form-group">
  20. <label class="control-label col-xs-12 col-sm-3 no-padding-right">选择年级:</label>
  21. <div class="col-xs-12 col-sm-9">
  22. <div class="clearfix">
  23. <select class="input-medium" onchange="changeYears(this.value);" name="years_id" id="years_id">
  24. <option value="">请选择年级</option>
  25. <?php if(!empty($yearsInfo)):foreach($yearsInfo as $loop):?>
  26. <option value="<?php echo $loop->years_id;?>"><?php echo $loop->years_name;?></option>
  27. <?php endforeach;endif;?>
  28. </select>
  29. </div>
  30. </div>
  31. <div class="col-xs-12 col-sm-9" id="classDiv" style="display:none;">
  32. <div class="clearfix">
  33. <select class="input-medium" id="class_id" name="class_id">
  34. </select>
  35. </div>
  36. </div>
  37. </div>
  38. <div class="form-group">
  39. <label class="control-label col-xs-12 col-sm-3 no-padding-right">选择教材:</label>
  40. <div class="col-xs-12 col-sm-9">
  41. <div class="clearfix">
  42. <select class="input-medium" onchange="getMaterial(this.value);" name="tm_id" id="tm_id">
  43. <option value="">请选择教材</option>
  44. <?php if(!empty($material)):foreach($material as $mt):?>
  45. <option value="<?php echo $mt->tm_id;?>"><?php echo $mt->teach_name;?></option>
  46. <?php endforeach;endif;?>
  47. </select>
  48. </div>
  49. </div>
  50. <div class="col-xs-12 col-sm-9" id="subjectDiv" style="display:none;">
  51. <div class="clearfix">
  52. <select onchange="getUnit(this.value);" class="input-medium" id="subject_id" name="subject_id">
  53. </select>
  54. </div>
  55. </div>
  56. <div class="col-xs-12 col-sm-9" id="unitDiv" style="display:none;">
  57. <div class="clearfix">
  58. <select onchange="getSection(this.value);" class="input-medium" id="unit_id" name="unit_id">
  59. </select>
  60. </div>
  61. </div>
  62. <div class="col-xs-12 col-sm-9" id="secDiv" style="display:none;">
  63. <div class="clearfix">
  64. <select class="input-medium" id="sec_id" name="sec_id">
  65. </select>
  66. </div>
  67. </div>
  68. </div>
  69. <div class="clearfix form-actions">
  70. <div class="col-md-offset-3 col-md-9">
  71. <button class="btn btn-info" type="submit" id="schoolSubmit">
  72. <i class="ace-icon fa fa-check bigger-110"></i>
  73. 提交
  74. </button>
  75. &nbsp; &nbsp; &nbsp;
  76. <button class="btn" type="reset">
  77. <i class="ace-icon fa fa-undo bigger-110"></i>
  78. 重填
  79. </button>
  80. </div>
  81. </div>
  82. </form>
  83. <!-- PAGE CONTENT ENDS -->
  84. </div>
  85. </div>
  86. </div>
  87. </div>
  88. <script src="/js/jquery.validate.min.js"></script>
  89. <script type="text/javascript">
  90. jQuery(function($) {
  91. $('#userInfoSubmit').validate({
  92. //debug:true,// 表单不会提交
  93. //errorElement: 'font', // 错误信息div
  94. errorClass: 'errorMessage', //错误样式
  95. ignore: "", //忽略提交字段
  96. rules: {
  97. years_id: {
  98. required: true,
  99. },
  100. class_id: {
  101. required: true,
  102. },
  103. tm_id: {
  104. required: true,
  105. },
  106. subject_id: {
  107. required: true,
  108. },
  109. unit_id: {
  110. required: true,
  111. },
  112. sec_id: {
  113. required: true,
  114. }
  115. },
  116. messages: {
  117. years_id: {
  118. required: "请选择年级!",
  119. },
  120. class_id: {
  121. required: "请选择班级!",
  122. },
  123. tm_id: {
  124. required: "请选择教材!",
  125. },
  126. subject_id: {
  127. required: "请选择科目!",
  128. },
  129. unit_id: {
  130. required: "请选择章!",
  131. },
  132. sec_id: {
  133. required: "请选择节!",
  134. }
  135. }
  136. })
  137. });
  138. // ajax获取班级
  139. function changeYears(num) {
  140. if (!num) return;
  141. $.post("<?php echo $this->createUrl('classes/ajaxclass');?>",{yid:num},function(data){
  142. var p = eval("("+data+")");
  143. if (p.flag) {
  144. $("#classDiv").show();
  145. var html;
  146. var cityObj = $("#class_id");
  147. cityObj.empty();
  148. if (p.classList.length > 0){
  149. html = "<option value=''>请选择班级</option>";
  150. $.each(p.classList,function(i,n){
  151. html += "<option value='"+n.class_id+"'>" + n.class_name + "</option>";
  152. });
  153. } else {
  154. html = "<option value=''>暂无班级</option>";
  155. }
  156. cityObj.append(html);
  157. } else {
  158. alert("获取数据失败!");
  159. }
  160. });
  161. }
  162. // 获取教材信息
  163. function getMaterial(id) {
  164. if (!id){ alert('页面错误!');return;}
  165. $.post("<?php echo $this->createUrl('syllabus/material');?>",{tmid:id},function(data){
  166. var p = eval("("+data+")");
  167. if (p.flag) {
  168. $("#subjectDiv").show();
  169. var html;
  170. var subObj = $("#subject_id");
  171. subObj.empty();
  172. if (p.subList.length > 0){
  173. html = "<option value=''>请选择科目</option>";
  174. $.each(p.subList,function(i,n){
  175. html += "<option value='"+n.tms_id+"'>" + n.subject_name + "</option>";
  176. });
  177. } else {
  178. html = "<option value=''>暂无科目</option>";
  179. }
  180. subObj.append(html);
  181. } else {
  182. alert("获取数据失败!");
  183. }
  184. });
  185. }
  186. // 获取章
  187. function getUnit(num) {
  188. if (!num) return;
  189. $.post("<?php echo $this->createUrl('syllabus/unit');?>",{unid:num},function(data){
  190. var p = eval("("+data+")");
  191. if (p.flag) {
  192. $("#unitDiv").show();
  193. var hm;
  194. var unitObj = $("#unit_id");
  195. unitObj.empty();
  196. if (p.unitArr.length > 0){
  197. hm = "<option value=''>请选择章</option>";
  198. $.each(p.unitArr,function(i,n){
  199. hm += "<option value='"+n.unit_id+"'>" + n.unit_name + "</option>";
  200. });
  201. } else {
  202. hm = "<option value=''>暂无章可选</option>";
  203. }
  204. unitObj.append(hm);
  205. } else {
  206. alert("获取数据失败!");
  207. }
  208. });
  209. }
  210. // 获取节
  211. function getSection(num) {
  212. if (!num) return;
  213. $.post("<?php echo $this->createUrl('syllabus/section');?>",{seid:num},function(data){
  214. var p = eval("("+data+")");
  215. if (p.flag) {
  216. $("#secDiv").show();
  217. var hm;
  218. var secObj = $("#sec_id");
  219. secObj.empty();
  220. if (p.secList.length > 0){
  221. hm = "<option value=''>请选择节</option>";
  222. $.each(p.secList,function(i,n){
  223. hm += "<option value='"+n.unit_id+"'>" + n.unit_name + "</option>";
  224. });
  225. } else {
  226. hm = "<option value=''>暂无节可选</option>";
  227. }
  228. secObj.append(hm);
  229. } else {
  230. alert("获取数据失败!");
  231. }
  232. });
  233. }
  234. </script>