formalOrder.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>转财务订单</title>
  6. <link href="/css/ims/base.css" rel="stylesheet">
  7. <link href="/css/ims/ims.css" rel="stylesheet">
  8. <link rel="stylesheet" type="text/css" href="/css/ims/bootstrap.min.css" />
  9. <link rel="stylesheet" type="text/css" href="/css/ims/ace.min.css" />
  10. <link rel="stylesheet" type="text/css" href="/css/ims/jquery.datetimepicker.css" />
  11. <style>
  12. .ims-add-student-box {
  13. margin: 20px;
  14. }
  15. .ims-add-student-box p{
  16. margin: 0;
  17. }
  18. .ims-add-student-box .ims-title{
  19. font-size: 20px;
  20. font-weight: bold;
  21. }
  22. .ims-add-student-box .ims-title span{
  23. margin-right: 20px;
  24. }
  25. .ims-add-student-box .add-student-box {
  26. margin-top: 20px;
  27. font-size: 0;
  28. overflow: hidden;
  29. }
  30. .ims-add-student-box .add-student-box>div{
  31. display: inline-block;
  32. height: 530px;
  33. font-size: 14px;
  34. vertical-align: top;
  35. }
  36. .ims-add-student-box .add-student-box .add-student-title{
  37. padding: 0 8px;
  38. line-height: 30px;
  39. color: #fff;
  40. background-color: #2977ff;
  41. }
  42. .ims-add-student-box .add-student-box .add-student-title label{
  43. font-size: 14px;
  44. font-weight: normal;
  45. cursor: pointer;
  46. margin-bottom: 0;
  47. }
  48. .ims-add-student-box .add-student-box .add-student-title input{
  49. vertical-align: middle;
  50. margin: 0;
  51. }
  52. #input-search-student{
  53. width: 120px;
  54. height: 20px;
  55. border: 0;
  56. color:#000;
  57. }
  58. .ims-add-student-box .add-student-box{
  59. line-height: 30px;
  60. min-width: 938px;
  61. }
  62. .ims-add-student-box .add-student-box .class-box {
  63. width: 180px;
  64. text-align: center;
  65. border: 1px solid #ccc;
  66. }
  67. .ims-add-student-box .student-list div{
  68. font-size: 14px;
  69. font-weight: normal;
  70. }
  71. .ims-add-student-box .add-student-box .class-list{
  72. height: 500px;
  73. overflow: auto;
  74. }
  75. .ims-add-student-box .add-student-box .class-list li{
  76. border-bottom: 1px solid #ccc;
  77. cursor: pointer;
  78. }
  79. .ims-add-student-box .class-list .active{
  80. color: #619aff;
  81. }
  82. .ims-add-student-box .add-student-box .student-list{
  83. margin: 0;
  84. width: 34%;
  85. min-width: 326px;
  86. border: 1px solid #ccc;
  87. border-left: 0;
  88. }
  89. .ims-add-student-box .student-list-content,.selected-list-content{
  90. padding: 8px;
  91. height: 500px;
  92. overflow: auto;
  93. }
  94. .ims-add-student-box .student-list-content label,.selected-list-content label{
  95. display: inline-block;
  96. width: 150px;
  97. cursor: pointer;
  98. font-size: 14px;
  99. font-weight: normal;
  100. }
  101. .ims-add-student-box .btn-search-student{
  102. height: 20px;
  103. line-height: 20px;
  104. padding: 0 5px;
  105. border-radius: 3px;
  106. color: #619aff;
  107. background-color: #fff;
  108. border: none;
  109. outline: none;
  110. cursor: pointer;
  111. }
  112. .ims-add-student-box .btns-box {
  113. width: 100px;
  114. text-align: center;
  115. }
  116. .ims-add-student-box .btn-left,.ims-add-student-box .btn-right{
  117. margin: 150px auto 0;
  118. width: 40px;
  119. height: 40px;border: 1px solid #ccc;
  120. border-radius: 50%;
  121. background-color: #fff;
  122. text-align: center;
  123. line-height: 40px;
  124. cursor: pointer;
  125. }
  126. .ims-add-student-box .selected-list{
  127. width: 34%;
  128. min-width: 326px;
  129. border: 1px solid #ccc;
  130. }
  131. .ims-add-student-box .btn-confirm_purchase {
  132. display: block;
  133. margin: 0 auto;
  134. margin-top: 10px;
  135. margin-bottom: 10px;
  136. width: 200px;
  137. line-height: 54px;
  138. color: #fff;
  139. font-family: PingFangSC-Regular, "PingFang SC";
  140. font-weight: 400;
  141. font-style: normal;
  142. font-size: 20px;
  143. text-align: center;
  144. background-color: #2977ff;
  145. cursor: pointer;
  146. }
  147. .yiiPager li{display: inline}
  148. </style>
  149. </head>
  150. <body>
  151. <h3 class="sale-title">转财务订单申请</h3>
  152. <input type="hidden" name="itemName">
  153. <input type="hidden" name="itemSpec">
  154. <input type="hidden" name="itemCode">
  155. <input type="hidden" name="unitId">
  156. <div class="sale-table">
  157. <table width="100%">
  158. <tr>
  159. <th><em class="red">*</em>销售订单号</th>
  160. <td >
  161. <?php echo $orderNo?>
  162. </td>
  163. <th><em class="red">*</em>剩余名额</th>
  164. <td >
  165. <?php echo $surplus < 0 ? 0 : $surplus; ?>
  166. <input type="hidden" id="surplus" value="<?php echo $surplus;?>" />
  167. </td>
  168. </tr>
  169. <tr>
  170. <th><em class="red">*</em>年级</th>
  171. <td >
  172. <?php echo $gradeText?>
  173. </td>
  174. <th><em class="red">*</em>商品</th>
  175. <td >
  176. <?php echo $goodsName?>
  177. </td>
  178. </tr>
  179. <tr>
  180. <th><em class="red">*</em>申请人数</th>
  181. <td colspan="3" class="apply_people">
  182. </td>
  183. </tr>
  184. </table>
  185. <button type="button" class="label-primary-s bth-s create-allocation">添加学生</button>
  186. <table width="100%" class="table table-striped table-bordered table-hover dataTable no-footer DTTT_selectable" id="P_list">
  187. <tr>
  188. <td>序号</td>
  189. <td>姓名</td>
  190. <td>班级</td>
  191. <td>操作</td>
  192. </tr>
  193. </table>
  194. </div>
  195. <div class="sale-submit" style="margin-top: 25px;">
  196. <button type="button" class=" label-primary-s bth-s" id="savebutton">提交</button>
  197. </div>
  198. <!-- 编辑名单弹层 -->
  199. <div class="layer-edit">
  200. <div class="ims-add-student-box">
  201. <h2 class="ims-title"><span>添加学生</span><span>使用年级:<?php echo $useGrade?></span><span>入学级别:<?php echo $schoolYear?></span><span>当前年级:<?php echo $gradeText?></span></h2>
  202. <div class="add-student-box">
  203. <div class="class-box">
  204. <div class="add-student-title">
  205. <p>班级</p>
  206. </div>
  207. <ul class="class-list">
  208. <li class="active">一班</li>
  209. <li>二班</li>
  210. <li>三班</li>
  211. </ul>
  212. </div>
  213. <div class="student-list">
  214. <div class="add-student-title clearfix">
  215. <span class="fl">
  216. <label>
  217. <input type="checkbox" name="select-all" value="1" />全选
  218. </label>
  219. <span></span>
  220. </span>
  221. <span class="fr">
  222. <input type="text" id="input-search-student" name="search-student-name" placeholder="学生姓名" />
  223. <button type="button" class="btn-search-student">搜索</button>
  224. </span>
  225. </div>
  226. <div class="student-list-content" id="studentListContent">
  227. </div>
  228. </div>
  229. <div class="btns-box">
  230. <p class="btn-left" id="btnRemoveStudent"><</p>
  231. <p class="btn-right" id="btnAddStudent" >></p>
  232. </div>
  233. <div class="selected-list">
  234. <div class="add-student-title">
  235. <p>已选(<span id="studentSelectedLength">0</span>人)</p>
  236. </div>
  237. <div class="selected-list-content" id="selectedListContent">
  238. </div>
  239. </div>
  240. </div>
  241. <a class="btn-confirm_purchase">完成</a>
  242. </div>
  243. </div>
  244. <script src="/js/jquery-2.2.2.min.js" ></script>
  245. <script src="/js/jquery.datetimepicker.js"></script>
  246. <script src="/js/layer/layer.js"></script>
  247. <script src="/js/xsgl.js"></script>
  248. <script>
  249. $(document).ready(function() {
  250. var maxNumber=<?php echo $surplus?>;
  251. var orderId='<?php echo $orderId?>';
  252. var selectedDataAll=[];
  253. var selectedDataValue =[];
  254. var selectedClassId=0;
  255. var selectedClassName='';
  256. //班级切换
  257. $(".class-list").on("click", "li", function(event) {
  258. if(!$(this).hasClass('subjectObj')){
  259. $(".class-list li").removeClass("active");
  260. $(this).addClass("active");
  261. $("input[name='select-all']").prop("checked",false);
  262. //console.log($(this).attr('classId'));
  263. selectedClassId=classId=$(this).attr('classId');
  264. selectedClassName=className=$(this).html();
  265. getStudent(classId,className,'');
  266. }
  267. });
  268. //搜索学生
  269. $('.btn-search-student').click(function(){
  270. studentName=$('input[name=search-student-name]').val();
  271. if(studentName!=''){
  272. getStudent(selectedClassId,selectedClassName,studentName);
  273. }
  274. });
  275. function getStudent(classId,className,studentName){
  276. console.log(selectedDataValue);
  277. $.ajax({
  278. url:'<?php echo $this->createUrl('imsSale/getFilterStudent')?>',
  279. type:'POST',
  280. dataType:'json',
  281. data:{'classId':classId,'orderId':orderId,'studentName':studentName},
  282. success:function(res){
  283. if(res.status==1){
  284. var studentHtml='';
  285. for(var i=0;i<res.data.list.length;i++){
  286. if($.inArray(res.data.list[i]['student_id'],res.data.student)!=-1){
  287. //continue;
  288. studentHtml+='<label><input type="checkbox" disabled name="studentName" classId="'+classId+'" className="'+className+'" value="'+res.data.list[i]['student_id']+'" />'+res.data.list[i]['realname']+'('+res.data.list[i]['serial_number']+')</label>';
  289. }else{
  290. if($.inArray(res.data.list[i]['student_id'],selectedDataValue)!=-1){
  291. studentHtml+='<label><input type="checkbox" checked name="studentName" classId="'+classId+'" className="'+className+'" value="'+res.data.list[i]['student_id']+'" />'+res.data.list[i]['realname']+'('+res.data.list[i]['serial_number']+')</label>';
  292. }else{
  293. studentHtml+='<label><input type="checkbox" name="studentName" classId="'+classId+'" className="'+className+'" value="'+res.data.list[i]['student_id']+'" />'+res.data.list[i]['realname']+'('+res.data.list[i]['serial_number']+')</label>';
  294. }
  295. }
  296. }
  297. $('.student-list-content').html(studentHtml);
  298. }else{
  299. $('.student-list-content').html('');
  300. }
  301. }
  302. });
  303. }
  304. // 全选按钮
  305. $("input[name='select-all']").change(function() {
  306. var type = $("input[name='select-all']").prop("checked")
  307. if(type){
  308. obj=$("#studentListContent").find("input");
  309. for(var i=0;i<obj.length;i++){
  310. if(obj.eq(i).attr('disabled')==undefined){
  311. obj.eq(i).prop("checked", true);
  312. }
  313. }
  314. }else{
  315. $("#studentListContent").find("input").prop("checked", false);
  316. }
  317. });
  318. // 添加学生
  319. $("#btnAddStudent").on("click", function() {
  320. getStudentSelected();
  321. });
  322. // 移出学生
  323. $("#btnRemoveStudent").on("click", function() {
  324. removeStudentSelected();
  325. });
  326. $('.create-allocation').click(function(){
  327. $.ajax({
  328. url:'<?php echo $this->createUrl('imsSale/getClassListForClassifed')?>',
  329. type:'POST',
  330. dataType:'json',
  331. data:{'grade':<?php echo $grade;?>},
  332. success:function(res){
  333. if(res.status==1){
  334. var html='';
  335. console.log(res.data['subjects'].length);
  336. for(var i=0;i<res.data['classList'].length;i++){
  337. html+='<li classId="'+res.data['classList'][i]['class_id']+'">'+res.data['classList'][i]['class_name']+'</li>';
  338. }
  339. if(res.data.subjects.length>0){
  340. html+='<li class="subjectObj">教学班<select class="chooseSubject"><option value="0">选择学科</option>';
  341. for(var i=0;i<res.data.subjects.length;i++){
  342. html+='<option value="'+res.data.subjects[i]['id']+'">'+res.data.subjects[i]['name']+'</option>';
  343. }
  344. html+='</select></li>';
  345. }
  346. $('.class-list').html(html);
  347. var selectStudentIndex=layer.open({
  348. title: false,
  349. closeBtn: 1,
  350. type: 1,
  351. offset: '20px',
  352. area: ['65%', '600px'],
  353. content: $(".layer-edit")
  354. });
  355. }
  356. }
  357. });
  358. });
  359. $('.class-box').on('change','.chooseSubject',function(){
  360. var subjectId=$(this).val();
  361. $('.classified').remove();
  362. $.ajax({
  363. url:'<?php echo $this->createUrl('imsSale/getClassListForClassifed')?>',
  364. type:'POST',
  365. dataType:'json',
  366. data:{'grade':<?php echo $grade;?>,'subject':subjectId},
  367. success:function(res){
  368. if(res.status==1){
  369. var html='';
  370. for(var i=0;i<res.data.length;i++){
  371. html+='<li class="classified" classId="'+res.data[i]['class_id']+'">'+res.data[i]['class_name']+'</li>';
  372. }
  373. $('.class-list').append(html);
  374. }
  375. }
  376. });
  377. });
  378. function getStudentSelected() {
  379. var selectedData = $("#studentListContent input[name='studentName']:checked"); //获取所以选中学生
  380. var studentName = '';
  381. for (var i = 0; i < selectedData.length; i++) {
  382. if (!isSelected(selectedData[i].value)) {
  383. studentName = $(selectedData[i]).parent().text();
  384. var student ={
  385. name:studentName,
  386. value:selectedData[i].value,
  387. class:$(selectedData[i]).attr('className'),
  388. classId:$(selectedData[i]).attr('classId'),
  389. };
  390. selectedDataAll.push(student);
  391. selectedDataValue.push(selectedData[i].value);
  392. }else{
  393. //console.log(selectedData[i].value)
  394. }
  395. showSelectedStudent();
  396. }
  397. };
  398. function isSelected(val){
  399. return selectedDataValue.indexOf(val) > -1
  400. };
  401. function removeStudentSelected() {
  402. var selectedStudent = $("#selectedListContent input[name='selectedStudent']:checked"); //获取所有选中学生
  403. var selectedData = $("#studentListContent input[name='studentName']:checked"); //获取所以选中学生
  404. for (var i = 0; i < selectedStudent.length; i++) {
  405. $(selectedStudent[i]).parent().remove();
  406. for (var j = 0; j < selectedData.length; j++) {
  407. if(selectedData[j].value===selectedStudent[i].value){
  408. $(selectedData[j]).prop("checked", false);
  409. if(selectedDataValue.length>0){
  410. for(var k=0;k<selectedDataValue.length;k++){
  411. if(selectedDataValue[k]===selectedStudent[i].value){
  412. selectedDataValue.splice(k,1);
  413. selectedDataAll.splice(k,1);
  414. }
  415. }
  416. }
  417. }
  418. }
  419. }
  420. $('#studentSelectedLength').text(selectedDataAll.length);
  421. };
  422. function showSelectedStudent() {
  423. var selectedDataList = [];
  424. for (var i = 0; i < selectedDataAll.length; i++) {
  425. selectedDataList.push('<label><input type="checkbox" name="selectedStudent" value="'+ selectedDataAll[i].value +'" />'+selectedDataAll[i].name+'</label>');
  426. }
  427. $('#selectedListContent').html(selectedDataList);
  428. $('#studentSelectedLength').text(selectedDataAll.length);
  429. };
  430. //确认选择学生
  431. var page=1;
  432. var pageLimit=10;
  433. var totalPage=0;
  434. $('.btn-confirm_purchase').click(function(){
  435. //console.log(selectedDataAll);
  436. /*if(maxNumber<selectedDataAll.length){
  437. layer.msg('选择学生数量不能超过剩余名额');
  438. }else{
  439. showStudentList();
  440. layer.closeAll();
  441. }*/
  442. showStudentList();
  443. layer.closeAll();
  444. });
  445. function showStudentList(){
  446. var listLength=selectedDataAll.length;
  447. totalPage=Math.ceil(listLength/pageLimit);
  448. start=(page-1)*pageLimit;
  449. $('.apply_people').html(listLength+'人');
  450. var studentList=selectedDataAll.slice(start,(start+pageLimit));
  451. console.log(studentList);
  452. console.log(start);
  453. html=' <tr>\n' +
  454. ' <th>序号</th>\n' +
  455. ' <th>姓名</th>\n' +
  456. ' <th>班级</th>\n' +
  457. ' <th>操作</th>\n' +
  458. ' </tr>';
  459. for(var i=0;i<studentList.length;i++){
  460. html+='<tr>';
  461. html+='<td>'+(i+1)+'</td>';
  462. html+='<td>'+studentList[i].name+'</td>';
  463. html+='<td>'+studentList[i].class+'</td>';
  464. html+='<td><a href="#" studentId="'+studentList[i].value+'" class="remove">移除</a></td>';
  465. html+='</tr>';
  466. }
  467. html+='<tr>';
  468. html+='<td colspan=4 class="page">';
  469. html+=' <div class="row" style="padding-top:10px;">\n' +
  470. ' <div class="col-xs-7">\n' +
  471. ' 共'+(listLength)+'条记录,第'+page+'页,共'+totalPage+'页\n' +
  472. ' </div>\n' +
  473. ' <div class="col-xs-5" style="font-size: 16px">\n' +
  474. ' <div class="dataTables_paginate paging_simple_numbers" style="vertical-align:sub;">\n' +
  475. ' <ul id="yw0" class="yiiPager">';
  476. if(page>1){
  477. html+='<li class="previous"><a href="#">上一页</a></li>';
  478. }
  479. for(var j=1;j<=totalPage;j++){
  480. if(j==page){
  481. html+='<li class="page selected"><a href="#">'+j+'</a></li>';
  482. }else{
  483. html+='<li class="page gotoPage" rel="'+j+'"><a href="#">'+j+'</a></li>';
  484. }
  485. }
  486. if(page<totalPage){
  487. html+='<li class="next"><a href="#">下一页</a></li>';
  488. }
  489. html+='</ul></div></div></div></tr>';
  490. $('#P_list').html(html);
  491. }
  492. //提交申请
  493. $('#savebutton').click(function(){
  494. $(this).attr('disabled',true);
  495. var obj=$(this);
  496. var suplus = $('#surplus') .val();
  497. $.ajax({
  498. url:'<?php echo $this->createUrl('imsSale/turnOrder')?>',
  499. type:'POST',
  500. data:{'orderId':orderId,'officialNum':selectedDataAll.length,'studentInfo':JSON.stringify(selectedDataAll),'suplus':suplus},
  501. dataType:'json',
  502. success:function(res){
  503. if(res.status==1){
  504. layer.msg('申请成功');
  505. window.location.href='<?php echo $this->createUrl('imsSale/purposeTable')?>';
  506. }else{
  507. if(res.msg!=undefined){
  508. layer.msg(res.msg);
  509. }else{
  510. layer.msg("申请失败");
  511. }
  512. obj.removeAttr('disabled');
  513. }
  514. }
  515. });
  516. });
  517. $(document)
  518. .on('change','.num',function(){
  519. $(this).val($(this).val().replace(/[^\d+|\.]/g,"1"));
  520. var num=parseInt($(this).val());
  521. console.log(num);
  522. if(num<1 ){
  523. $(this).val(1);
  524. }
  525. })
  526. .on('click','.remove',function(){
  527. studentId=$(this).attr('studentId');
  528. for (var j = 0; j < selectedDataAll.length; j++) {
  529. if(selectedDataAll[j].value===studentId){
  530. selectedDataAll.splice(j,1);
  531. selectedDataValue.splice(j,1);
  532. }
  533. }
  534. $('.apply_people').html(selectedDataAll.length+'人');
  535. var selectedStudent = $("#selectedListContent input[name='selectedStudent']"); //获取所有选中学生
  536. var selectedData = $("#studentListContent input[name='studentName']:checked"); //获取待选学生
  537. for (var i = 0; i < selectedData.length; i++) {
  538. if(selectedData[i].value===studentId){
  539. $(selectedData[i]).prop("checked", false);
  540. }
  541. }
  542. for (var i = 0; i < selectedStudent.length; i++) {
  543. if(selectedStudent[i].value===studentId){
  544. $(selectedStudent[i]).parent().remove();
  545. }
  546. }
  547. $('#studentSelectedLength').text(selectedDataAll.length);
  548. $(this).closest('tr').remove();
  549. var tr=$('#P_list').find('tr');
  550. if(tr.length<3 && selectedDataAll.length>0){
  551. showStudentList();
  552. }
  553. })
  554. .on('click','.next',function(){
  555. page++;
  556. showStudentList();
  557. })
  558. .on('click','.previous',function(){
  559. if(page>1){
  560. page--;
  561. showStudentList();
  562. }
  563. })
  564. .on('click','.gotoPage',function(){
  565. page=parseInt($(this).attr('rel'));
  566. showStudentList();
  567. })
  568. });
  569. </script>
  570. </body>
  571. </html>