orderOfficial.php 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  6. <title>订购</title>
  7. <meta name="description" content="">
  8. <meta name="keywords" content="">
  9. <link href="/css/ims/base.css" rel="stylesheet">
  10. <style>
  11. .ims-box {
  12. margin: 20px;
  13. }
  14. .screen {
  15. padding-left: 20px;
  16. height: 44px;
  17. line-height: 44px;
  18. background-color: #eff4fa;
  19. }
  20. .screen li {
  21. float: left;
  22. margin-right: 30px;
  23. }
  24. .bg-d9bf6e {
  25. margin-left: 5px;
  26. padding: 0 20px;
  27. color: #fff;
  28. background-color: #d9bf6e;
  29. }
  30. .list {
  31. margin-top: 40px;
  32. overflow: hidden;
  33. }
  34. .list h2 {
  35. line-height: 30px;
  36. }
  37. .list .student-list_box {
  38. width: 300px;
  39. }
  40. .list .student-list_box>ul{
  41. height: 360px;
  42. overflow: auto;
  43. padding: 20px;
  44. background-color: #eef3ff;
  45. }
  46. .list .student-list_box li {
  47. line-height: 30px;
  48. cursor: pointer;
  49. }
  50. .list .student-selected_box {
  51. margin-left: 60px;
  52. width: 60%;
  53. overflow-x: scroll;
  54. }
  55. .list .student-list {
  56. display: none;
  57. margin-left: 20px;
  58. }
  59. .list .student-list li.active .btn-select_all {
  60. display: inline-block;
  61. }
  62. .list .student-list span {
  63. cursor: pointer;
  64. }
  65. .list .btn-select_all {
  66. margin-left: 84px;
  67. color: #008000;
  68. }
  69. .student-name_box li {
  70. position: relative;
  71. margin-left: 28px;
  72. line-height: 30px;
  73. }
  74. .student-name_box input {
  75. position: absolute;
  76. left: 155px;
  77. top: 8px;
  78. }
  79. .btn-select_all,
  80. .student-name_box {
  81. display: none;
  82. }
  83. .student-selected {
  84. height: 400px;
  85. overflow: auto;
  86. }
  87. .student-selected li {
  88. float: left;
  89. margin-right: 24px;
  90. margin-bottom: 12px;
  91. width: 280px;
  92. height: 26px;
  93. line-height: 26px;
  94. text-indent: 20px;
  95. background-color: #f2f2f2;
  96. }
  97. .student-selected .btn-delete {
  98. float: right;
  99. margin-right: 20px;
  100. color: red;
  101. cursor: pointer;
  102. }
  103. .btn-confirm_purchase {
  104. display: block;
  105. margin: 0 auto;
  106. margin-top: 100px;
  107. margin-bottom: 50px;
  108. width: 430px;
  109. line-height: 54px;
  110. color: #fff;
  111. font-family: PingFangSC-Regular, "PingFang SC";
  112. font-weight: 400;
  113. font-style: normal;
  114. font-size: 20px;
  115. text-align: center;
  116. background-color: rgba(0, 153, 102, 1);
  117. cursor: pointer;
  118. }
  119. .more-show{
  120. width: 40%;overflow: hidden; text-overflow:ellipsis; white-space: nowrap;
  121. }
  122. .layui-layer-btn .layui-layer-btn0 {
  123. border-color: #15ae68 !important;
  124. background-color: #15ae68 !important;
  125. color: #fff;
  126. }
  127. .stop-layer-box, .resubmit-layer-box, .delete-layer-box {
  128. line-height: 140px;
  129. text-align: center;
  130. }
  131. </style>
  132. </head>
  133. <body>
  134. <input type="hidden" value="<?php echo $orderId?>" name="orderId" id="orderId">
  135. <div class="ims-box">
  136. <div class="screen">
  137. <ul>
  138. <li><span class="product">订购商品</span><span class="product-name bg-d9bf6e"><?php echo $goodDetail['goodName'];?></span></li>
  139. <li><span class="package">套餐</span><span class="grade-name bg-d9bf6e"><?php echo $goodDetail['packageName'];?></span></li>
  140. <li class="more-show"><span class="date">使用月份</span><span class="date-name bg-d9bf6e"><?php echo $goodDetail['useDate'];?></span></li>
  141. </ul>
  142. </div>
  143. <div class="list">
  144. <div class="student-list_box fl">
  145. <input type="hidden" name="grade" value="1">
  146. <h2>学生名单</h2>
  147. <ul>
  148. <?php if ($goodDetail['grade']=='1'):?>
  149. <li class="grade">❖<span grade="1">高一</span>
  150. <ul class="student-list grade_1"></ul>
  151. </li>
  152. <?php elseif ($goodDetail['grade']=='2'):?>
  153. <li class="grade">❖<span grade="2">高二</span>
  154. <ul class="student-list grade_2"></ul>
  155. </li>
  156. <?php else:?>
  157. <li class="grade">❖<span grade="3">高三</span>
  158. <ul class="student-list grade_3"></ul>
  159. </li>
  160. <?php endif;?>
  161. </div>
  162. <div class="student-selected_box fl">
  163. <h2>已选(<span id="studentSelectedLength">0</span>)</h2>
  164. <ul class="student-selected">
  165. </ul>
  166. </div>
  167. </div>
  168. <a class="btn-confirm_purchase">确认订购</a>
  169. </div>
  170. <script src="/js/productset/jquery.min.js"></script>
  171. <script src="/js/layer/layer.js"></script>
  172. <script>
  173. $(document).ready(function() {
  174. $(".grade>span").on("click", function(event) {
  175. $(this).parent().children(".student-list").toggle();
  176. event.isDefaultPrevented();
  177. event.stopPropagation();
  178. getClass($(this).attr('grade'));
  179. return false;
  180. });
  181. $(".student-list").on("click", "span", function(event) {
  182. var classId = $(this).attr('class-id');
  183. var obj = $(this);
  184. var objLen = obj.parent().children('.student-name_box').find('li').length;
  185. var orderId = "<?php echo $_GET['orderId']?>";
  186. if(objLen<=0){
  187. $.ajax({
  188. type: 'post',
  189. url: "<?php echo Yii::app()->createUrl('imsSale/getOfficialStudent');?>",
  190. data: {'classId': classId, 'orderId': orderId},
  191. dataType: 'json',
  192. success: function (data) {
  193. console.log(data);
  194. if (data.status) {
  195. var html = '';
  196. var list = data.data.list;
  197. var students = data.data.student;
  198. for (var i = 0; i < list.length; i++) {
  199. var item = list[i];
  200. if (item['student_id']) {
  201. var index = $.inArray(item['student_id'], students);
  202. if (index>=0) {
  203. html += '<li><label>';
  204. html += item['realname'];
  205. html += '<input type="checkbox" checked disabled name="studentId" value="'+item['student_id']+'" />';
  206. html += '</label></li>';
  207. }else{
  208. html += '<li><label>';
  209. html += item['realname'];
  210. html += '<input type="checkbox" name="studentId" value="'+item['student_id']+'" />';
  211. html += '</label></li>';
  212. }
  213. }
  214. }
  215. } else {
  216. var html = '<li>暂无学生数据</li>';
  217. }
  218. obj.parent().children('.student-name_box').html(html);
  219. },
  220. error: function () {
  221. return false;
  222. }
  223. });
  224. }
  225. obj.parent().toggleClass("active");
  226. obj.parent().children(".student-name_box").toggle();
  227. event.stopPropagation();
  228. return false;
  229. });
  230. // 单选按钮
  231. $('body').on('change', "input[name='studentId']", function () {
  232. getsStudentSelected();
  233. });
  234. // 全选按钮
  235. $('body').on('click', ".btn-select_all", function () {
  236. var obj = $(this).parent().find("input");
  237. if($(this).hasClass('isSelected')){
  238. obj.each(function () {
  239. if(!$(this).is(':disabled')){
  240. $(this).prop("checked", false);
  241. }
  242. })
  243. $(this).removeClass("isSelected");
  244. }else{
  245. obj.each(function () {
  246. if(!$(this).is(':disabled')){
  247. $(this).prop("checked", true);
  248. }
  249. })
  250. $(this).addClass("isSelected");
  251. }
  252. getsStudentSelected();
  253. });
  254. //删除学生
  255. $(".student-selected").on("click", ".btn-delete", function() {
  256. $(this).parent().remove();
  257. var studentValue = $(this).attr('value');
  258. $("input[value='" + studentValue + "']").prop("checked", false);
  259. getsStudentSelected();
  260. });
  261. // 提交
  262. var flag = true;
  263. $(".btn-confirm_purchase").on("click", function() {
  264. var selectedStudentAll = [];
  265. var selectedStudent = $(".student-selected>li");
  266. selectedStudent.each(function () {
  267. var cc = $(this).attr('student-info');
  268. selectedStudentAll.push(cc);
  269. });
  270. if (selectedStudentAll.length != 0) {
  271. var orderId = $("input[name='orderId']").val();
  272. var data = {
  273. orderId: orderId,
  274. studentList: selectedStudentAll
  275. };
  276. if (flag){
  277. flag = false;
  278. $.ajax({
  279. type: 'post',
  280. url: "<?php echo Yii::app()->createUrl('imsSale/saveOfficial')?>",
  281. dataType: 'json',
  282. data: data,
  283. success: function (data) {
  284. console.log(data);
  285. if (data.status){
  286. layer.alert("提交成功!", {icon:1,closeBtn:0},function () {
  287. location.href="<?php echo Yii::app()->createUrl('imsSale/officialTable')?>"
  288. });
  289. }else{
  290. flag = true;
  291. layer.alert(data.msg, {icon:2});
  292. }
  293. },
  294. error: function () {
  295. flag = true;
  296. layer.alert("提交失败!", {icon:2});
  297. }
  298. });
  299. }else{
  300. layer.msg("稍安勿躁,正在处理中...");
  301. }
  302. } else {
  303. layer.alert("请选择至少一个学生", {'icon':7});
  304. }
  305. });
  306. //获取班级
  307. function getClass(grade) {
  308. $('.student-list').empty();
  309. $.ajax({
  310. type: 'post',
  311. url: "<?php echo Yii::app()->createUrl('imsSale/getClassList');?>",
  312. data: {grade: grade},
  313. dataType: 'json',
  314. success: function (data) {
  315. if (data.status) {
  316. var html = '';
  317. for (var i = 0; i < data.data.length; i++) {
  318. var item = data.data[i];
  319. if (item['class_id']) {
  320. html += '<li>▾<span class="student" class-id="'+item['class_id']+'"> ';
  321. html += item['class_name'];
  322. html += '</span><a type="button" class="btn-select_all">全选</a>';
  323. html += '<ul class="student-name_box"></ul>';
  324. html += '</li>'
  325. }
  326. }
  327. } else {
  328. var html = '<li>暂无班级数据</li>';
  329. }
  330. $('.grade_'+grade).html(html);
  331. }
  332. })
  333. }
  334. //选择学生
  335. function getsStudentSelected() {
  336. var selectedData = $("input[name='studentId']:checked"); //获取所以选中学生
  337. var selectedDataList = [];
  338. var studentName, studentClass, studentClassId = '';
  339. var disabled = 0;
  340. for (var i = 0; i < selectedData.length; i++) {
  341. if(!$(selectedData[i]).is(':disabled')){
  342. var dd = '';
  343. studentName = $(selectedData[i]).parent().text();
  344. studentClass = $(selectedData[i]).parents('li').children('span.student').text();
  345. studentClassId = $(selectedData[i]).parents('li').children('span.student').attr('class-id');
  346. dd = studentName+'#'+selectedData[i].value+'#'+studentClass+'#'+studentClassId;
  347. selectedDataList.push('<li student-info="'+dd+'">' + studentName + '--' + studentClass + '<i class="btn-delete" value="' + selectedData[i].value + '">X</i></li>');
  348. }else{
  349. disabled++;
  350. }
  351. }
  352. $('.student-selected').html(selectedDataList);
  353. $('#studentSelectedLength').text(selectedData.length-disabled);
  354. };
  355. });
  356. </script>
  357. </body>
  358. </html>