editGoodsChange.php 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858
  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. <link rel="stylesheet" type="text/css" href="/css/ims/jquery.datetimepicker.css"/>
  11. <link rel="stylesheet" type="text/css" href="/css/ims/bootstrap.min.css"/>
  12. <link rel="stylesheet" type="text/css" href="/css/ims/ace.min.css"/>
  13. <link href="/css/ims/ims.css" rel="stylesheet">
  14. <style>
  15. .ims-box {
  16. padding: 30px 50px;
  17. }
  18. .ims-box > h1 {
  19. font-size: 28px;
  20. }
  21. .screen {
  22. width:100%;
  23. }
  24. .screen li {
  25. height: 30px;
  26. line-height: 30px;
  27. border: 1px solid #DBDBDB;
  28. font-size: 0;
  29. }
  30. .screen span {
  31. display: inline-block;
  32. font-size: 13px;
  33. }
  34. .screen .title {
  35. width: 100px;
  36. background-color: #EAEAEA;
  37. text-align: center;
  38. }
  39. /*.screen .type {*/
  40. /*width: 400px;*/
  41. /*}*/
  42. .screen .type label {
  43. margin: 0 20px;
  44. }
  45. .list {
  46. overflow: hidden;
  47. }
  48. .list h2 {
  49. line-height: 30px;
  50. }
  51. .list .student-list_box {
  52. width: 30%;
  53. }
  54. .list .student-selected_box {
  55. margin-left: 60px;
  56. width: 60%;
  57. overflow-x: scroll;
  58. }
  59. .list .student-list {
  60. height: 360px;
  61. overflow: auto;
  62. padding: 20px;
  63. background-color: #eef3ff;
  64. }
  65. .list .student-list li {
  66. line-height: 30px;
  67. cursor: pointer;
  68. }
  69. .list .student-list li.active .btn-select_all {
  70. display: inline-block;
  71. }
  72. .list .student-list span {
  73. cursor: pointer;
  74. }
  75. .list .btn-select_all {
  76. margin-left: 84px;
  77. color: #008000;
  78. }
  79. .student-name_box li {
  80. position: relative;
  81. margin-left: 28px;
  82. line-height: 30px;
  83. }
  84. .student-name_box input {
  85. position: absolute;
  86. left: 140px;
  87. top: 8px;
  88. }
  89. .btn-select_all, .student-name_box {
  90. display: none;
  91. }
  92. .student-selected {
  93. height: 400px;
  94. overflow: auto;
  95. }
  96. .student-selected li {
  97. float: left;
  98. margin-right: 24px;
  99. margin-bottom: 12px;
  100. width: 280px;
  101. height: 26px;
  102. line-height: 26px;
  103. text-indent: 20px;
  104. background-color: #f2f2f2;
  105. }
  106. .student-selected .btn-delete {
  107. float: right;
  108. margin-right: 20px;
  109. color: red;
  110. cursor: pointer;
  111. }
  112. .btn-trial {
  113. display: block;
  114. margin: 0 auto;
  115. margin-top: 100px;
  116. margin-bottom: 50px;
  117. width: 430px;
  118. line-height: 54px;
  119. color: #fff;
  120. font-family: PingFangSC-Regular, "PingFang SC";
  121. font-weight: 400;
  122. font-style: normal;
  123. font-size: 20px;
  124. text-align: center;
  125. background-color: rgba(0, 153, 102, 1);
  126. cursor: pointer;
  127. }
  128. .layui-layer-btn .layui-layer-btn0 {
  129. border-color: #15ae68 !important;
  130. background-color: #15ae68 !important;
  131. color: #fff;
  132. }
  133. .stop-layer-box, .resubmit-layer-box, .delete-layer-box {
  134. line-height: 140px;
  135. text-align: center;
  136. }
  137. .ims-add-student-box {
  138. margin: 20px;
  139. }
  140. .ims-add-student-box p{
  141. margin: 0;
  142. }
  143. .ims-add-student-box .ims-title{
  144. font-size: 20px;
  145. font-weight: bold;
  146. }
  147. .ims-add-student-box .ims-title span{
  148. margin-right: 20px;
  149. }
  150. .ims-add-student-box .add-student-box {
  151. margin-top: 20px;
  152. font-size: 0;
  153. overflow: hidden;
  154. }
  155. .ims-add-student-box .add-student-box>div{
  156. display: inline-block;
  157. height: 530px;
  158. font-size: 14px;
  159. vertical-align: top;
  160. }
  161. .ims-add-student-box .add-student-box .add-student-title{
  162. padding: 0 8px;
  163. line-height: 30px;
  164. color: #fff;
  165. background-color: #058000;
  166. }
  167. .ims-add-student-box .add-student-box .add-student-title label{
  168. font-size: 14px;
  169. font-weight: normal;
  170. cursor: pointer;
  171. margin-bottom: 0;
  172. }
  173. .ims-add-student-box .add-student-box .add-student-title input{
  174. vertical-align: middle;
  175. margin: 0;
  176. }
  177. #input-search-student{
  178. width: 120px;
  179. height: 20px;
  180. border: 0;
  181. color:#000;
  182. }
  183. .ims-add-student-box .add-student-box{
  184. line-height: 30px;
  185. min-width: 938px;
  186. }
  187. .ims-add-student-box .add-student-box .class-box {
  188. width: 180px;
  189. text-align: center;
  190. border: 1px solid #ccc;
  191. }
  192. .ims-add-student-box .student-list div{
  193. font-size: 14px;
  194. font-weight: normal;
  195. }
  196. .ims-add-student-box .add-student-box .class-list{
  197. height: 500px;
  198. overflow: auto;
  199. }
  200. .ims-add-student-box .add-student-box .class-list li{
  201. border-bottom: 1px solid #ccc;
  202. cursor: pointer;
  203. }
  204. .ims-add-student-box .class-list .active{
  205. color: #058000;
  206. }
  207. .ims-add-student-box .add-student-box .student-list{
  208. margin: 0;
  209. width: 34%;
  210. min-width: 326px;
  211. border: 1px solid #ccc;
  212. border-left: 0;
  213. }
  214. .ims-add-student-box .student-list-content,.selected-list-content{
  215. padding: 8px;
  216. height: 500px;
  217. overflow: auto;
  218. }
  219. .ims-add-student-box .student-list-content label,.selected-list-content label{
  220. display: inline-block;
  221. width: 150px;
  222. cursor: pointer;
  223. font-size: 14px;
  224. font-weight: normal;
  225. }
  226. .ims-add-student-box .btn-search-student{
  227. height: 20px;
  228. line-height: 20px;
  229. padding: 0 5px;
  230. border-radius: 3px;
  231. color: #058000;
  232. background-color: #fff;
  233. border: none;
  234. outline: none;
  235. cursor: pointer;
  236. }
  237. .ims-add-student-box .btns-box {
  238. width: 100px;
  239. text-align: center;
  240. }
  241. .ims-add-student-box .btn-left,.ims-add-student-box .btn-right{
  242. margin: 150px auto 0;
  243. width: 40px;
  244. height: 40px;border: 1px solid #ccc;
  245. border-radius: 50%;
  246. background-color: #fff;
  247. text-align: center;
  248. line-height: 40px;
  249. cursor: pointer;
  250. }
  251. .ims-add-student-box .selected-list{
  252. width: 34%;
  253. min-width: 326px;
  254. border: 1px solid #ccc;
  255. }
  256. .ims-add-student-box .btn-confirm_purchase {
  257. display: block;
  258. margin: 0 auto;
  259. margin-top: 100px;
  260. margin-bottom: 50px;
  261. width: 200px;
  262. line-height: 54px;
  263. color: #fff;
  264. font-family: PingFangSC-Regular, "PingFang SC";
  265. font-weight: 400;
  266. font-style: normal;
  267. font-size: 20px;
  268. text-align: center;
  269. background-color: rgba(0, 153, 102, 1);
  270. cursor: pointer;
  271. }
  272. .yiiPager li{display: inline}
  273. </style>
  274. </head>
  275. <body>
  276. <div class="ims-box">
  277. <h1 class="title">商品变更申请</h1>
  278. <div class="screen">
  279. 选择变更新销售订单
  280. <table id="formalOrderTable"
  281. class="table table-bordered table-hover dataTable no-footer DTTT_selectable"
  282. style="font-size:12px">
  283. <tr>
  284. <th class="title">选择学年</th>
  285. <th style="width:38%">
  286. <select name="schoolYear" id="schoolYear">
  287. <option value="0">选择学年</option>
  288. <?php
  289. if($schoolYear){
  290. foreach ($schoolYear as $value){
  291. if($schoolYearName && $schoolYearName==$value['schoolYearName']){
  292. echo '<option value="'.$value['schoolYearId'].'" selected>'.$value['schoolYearName'].'</option>';
  293. }else{
  294. echo '<option value="'.$value['schoolYearId'].'">'.$value['schoolYearName'].'</option>';
  295. }
  296. }
  297. }
  298. ?>
  299. </select>
  300. </th>
  301. <th class="title">选择新销售订单</th>
  302. <th>
  303. <select name="sellOrder" id="sellOrder">
  304. <option value="0">选择新销售订单</option>
  305. </select>
  306. </th>
  307. </tr>
  308. <tr>
  309. <th class="title">售价</th>
  310. <th >
  311. <span class="sellingPrice">
  312. </span>
  313. </th >
  314. <th class="title" style="width:10%">商品</th>
  315. <th>
  316. <span class="goodsName">
  317. </span>
  318. </th>
  319. </tr>
  320. <tr>
  321. <th class="title">年级</th>
  322. <th >
  323. <span class="gradeName">
  324. </span>
  325. </th >
  326. <th class="title" style="width:10%"></th>
  327. <th>
  328. </th>
  329. </tr>
  330. </table>
  331. 需变更财务订单
  332. <table id="formalOrderTable"
  333. class="table table-bordered table-hover dataTable no-footer DTTT_selectable"
  334. style="font-size:12px">
  335. <tr>
  336. <th class="title">财务订单号</th>
  337. <th style="width:38%">
  338. <select name="financeOrder" id="financeOrder">
  339. <option value="0">财务订单号</option>
  340. </select>
  341. </th>
  342. <th class="title">商品</th>
  343. <th>
  344. <span class="financeGoodsName">
  345. </span>
  346. </th>
  347. </tr>
  348. <tr>
  349. <th class="title">售价</th>
  350. <th >
  351. <span class="financeSellingPrice">
  352. </span>
  353. </th >
  354. <th class="title" style="width:10%">可变更人数</th>
  355. <th>
  356. <span class="canChangeNum">
  357. </span>
  358. </th>
  359. </tr>
  360. </table>
  361. </div>
  362. <div class="ims-add-student-box">
  363. <h2 class="ims-title"><span>添加学生</span></h2>
  364. <div class="add-student-box">
  365. <div class="class-box">
  366. <div class="add-student-title">
  367. <p>班级</p>
  368. </div>
  369. <ul class="class-list">
  370. </ul>
  371. </div>
  372. <div class="student-list">
  373. <div class="add-student-title clearfix">
  374. <span class="fl">
  375. <label>
  376. <input type="checkbox" name="select-all" value="1" />全选
  377. </label>
  378. <span></span>
  379. </span>
  380. </div>
  381. <div class="student-list-content" id="studentListContent">
  382. </div>
  383. </div>
  384. <div class="btns-box">
  385. <p class="btn-left" id="btnRemoveStudent"><</p>
  386. <p class="btn-right" id="btnAddStudent" >></p>
  387. </div>
  388. <div class="selected-list">
  389. <div class="add-student-title">
  390. <p>已选(<span id="studentSelectedLength">0</span>人)</p>
  391. </div>
  392. <div class="selected-list-content" id="selectedListContent">
  393. </div>
  394. </div>
  395. </div>
  396. </div>
  397. <input type="hidden" name="ogcId" value="<?php echo $ogcId?>">
  398. <a class="btn-trial">确定</a>
  399. </div>
  400. <script src="/js/productset/jquery.min.js"></script>
  401. <script src="/js/ims/jquery.datetimepicker.js"></script>
  402. <script src="/js/layer/layer.js"></script>
  403. </body>
  404. </html>
  405. <script>
  406. $(function(){
  407. var editSchoolYearId='<?php echo $schoolYearId;?>';
  408. var editPurposeOrderId='<?php echo $purposeOrderId;?>';
  409. var editOldOrderId='<?php echo $oldOrderId;?>';
  410. var editSchoolYearFirst=true,editOrderFirst=true;
  411. //原订单学生
  412. var studentIds=[];
  413. selectedDataAll=[];
  414. selectedDataValue=[];
  415. <?php
  416. if(isset($students) && $students){
  417. foreach ($students as $v){
  418. //echo "studentIds.push('".$v."');";
  419. ?>
  420. var student ={
  421. name:'<?php echo $v['studentName']?>',
  422. value:'<?php echo $v['studentId']?>',
  423. class:'<?php echo $v['clazzId']?>',
  424. classId:'<?php echo $v['clazzName']?>',
  425. };
  426. selectedDataAll.push(student);
  427. selectedDataValue.push('<?php echo $v['studentId']?>');
  428. <?php
  429. }
  430. }
  431. ?>
  432. getOder(editSchoolYearId);
  433. var sellOrderArr=[],financeOrderArr=[];
  434. var classStudentArr={};
  435. $("#schoolYear").change(function(){
  436. var schoolYear=$(this).val();
  437. getOder(schoolYear);
  438. })
  439. function getOder(schoolYear){
  440. $('.sellingPrice').html('');
  441. $('.goodsName').html('');
  442. $('.gradeName').html('');
  443. $('.financeSellingPrice').html('');
  444. $('.financeGoodsName').html('');
  445. $('.canChangeNum').html('');
  446. $('.class-list').html('<li>暂无班级数据</li>');
  447. $('.student-list-content').html('');
  448. $('.selected-list-content').html('');
  449. $('#financeOrder').html('<option value="0">选择财务订单</option>');
  450. if(schoolYear!=0){
  451. sellOrderArr=[];
  452. $('#sellOrder').html('<option value="0">选择新销售订单</option>');
  453. $.ajax({
  454. url:'<?php echo $this->createUrl('imsSale/canChangeOrder')?>',
  455. type:'POST',
  456. dataType:'json',
  457. data:{'schoolYearId':schoolYear},
  458. success:function(res){
  459. if(res.status==1){
  460. html='<option value="0">选择新销售订单</option>';
  461. for(var i=0;i<res.data.length;i++){
  462. if(res.data[i]['orderId']==editPurposeOrderId && editSchoolYearFirst){
  463. html+='<option value="'+res.data[i]['orderId']+'" selected>'+res.data[i]['orderNo']+'</option>';
  464. getFinanceOrder(editPurposeOrderId);
  465. $('.sellingPrice').html(res.data[i].sellingPrice);
  466. $('.goodsName').html(res.data[i].goodsName);
  467. $('.gradeName').html(res.data[i].gradeName);
  468. editSchoolYearFirst=false;
  469. }else{
  470. html+='<option value="'+res.data[i]['orderId']+'">'+res.data[i]['orderNo']+'</option>';
  471. }
  472. sellOrderArr.push(res.data[i]);
  473. }
  474. $('#sellOrder').html(html);
  475. }
  476. }
  477. })
  478. }
  479. }
  480. function getFinanceOrder(orderId){
  481. $('.sellingPrice').html('');
  482. $('.goodsName').html('');
  483. $('.gradeName').html('');
  484. $('.financeSellingPrice').html('');
  485. $('.financeGoodsName').html('');
  486. $('.canChangeNum').html('');
  487. $('.class-list').html('<li>暂无班级数据</li>');
  488. $('.student-list-content').html('');
  489. $('.selected-list-content').html('');
  490. if(orderId!=0){
  491. if(sellOrderArr.length>0){
  492. $.each(sellOrderArr,function(i,v){
  493. if(v.orderId==orderId){
  494. $('.sellingPrice').html(v.sellingPrice);
  495. $('.goodsName').html(v.goodsName);
  496. $('.gradeName').html(v.gradeName);
  497. }
  498. })
  499. }
  500. financeOrderArr=[]
  501. $('#financeOrder').html('<option value="0">选择财务订单</option>');
  502. $.ajax({
  503. url:'<?php echo $this->createUrl('imsSale/needChangeOrder')?>',
  504. type:'POST',
  505. dataType:'json',
  506. data:{'orderId':orderId},
  507. success:function(res){
  508. if(res.status==1){
  509. html='<option value="0">选择财务订单</option>';
  510. for(var i=0;i<res.data.length;i++){
  511. if(editOldOrderId==res.data[i]['orderId'] && editOrderFirst){
  512. html+='<option value="'+res.data[i]['orderId']+'" selected>'+res.data[i]['orderNo']+'</option>';
  513. $('.canChangeNum').html(res.data[i].canChangeNum);
  514. $('.financeSellingPrice').html(res.data[i].sellingPrice);
  515. $('.financeGoodsName').html(res.data[i].goodsName);
  516. editOrderFirst=false;
  517. //查询学生
  518. $.ajax({
  519. url:'<?php echo $this->createUrl('imsSale/orderStudentList')?>',
  520. type:'POST',
  521. dataType:'json',
  522. data:{'orderId':editOldOrderId},
  523. success:function(res){
  524. if(res.status==1){
  525. if(res.data.length>0){
  526. classStudentArr=res.data
  527. var html = '';
  528. var firstClassId=0
  529. $.each(res.data,function(i,v){
  530. if(firstClassId==0){
  531. firstClassId=v['clazzId'];
  532. html+='<li class="classified active" classId="'+v['clazzId']+'">'+v['clazzName']+'</li>';
  533. }else{
  534. html+='<li class="classified" classId="'+v['clazzId']+'">'+v['clazzName']+'</li>';
  535. }
  536. getStudent(firstClassId);
  537. })
  538. $('.class-list').html(html);
  539. }else{
  540. $('.class-list').html('<li>暂无班级数据</li>');
  541. }
  542. }
  543. }
  544. })
  545. showSelectedStudent();
  546. }else{
  547. html+='<option value="'+res.data[i]['orderId']+'">'+res.data[i]['orderNo']+'</option>';
  548. }
  549. financeOrderArr.push(res.data[i]);
  550. }
  551. $('#financeOrder').html(html);
  552. }
  553. }
  554. })
  555. }
  556. }
  557. $("#sellOrder").change(function(){
  558. var orderId=$(this).val();
  559. getFinanceOrder(orderId);
  560. })
  561. $('#financeOrder').change(function(){
  562. var orderId=$(this).val();
  563. $('.canChangeNum').html('');
  564. $('.financeGoodsName').html('');
  565. $('.financeGradeName').html('');
  566. $('.class-list').html('<li>暂无班级数据</li>');
  567. $('.student-list-content').html('');
  568. $('.selected-list-content').html('');
  569. selectedDataAll=[];
  570. selectedDataValue=[];
  571. if(orderId!=0) {
  572. if (financeOrderArr.length > 0) {
  573. $.each(financeOrderArr, function (i, v) {
  574. if (v.orderId == orderId) {
  575. // $('.canChangeNum').html(v.canChangeNum);
  576. $('.financeGoodsName').html(v.goodsName);
  577. $('.financeGradeName').html(v.gradeName);
  578. }
  579. })
  580. }
  581. //查询可变理人数
  582. $.ajax({
  583. url:'<?php echo $this->createUrl('imsSale/searchChangeNum')?>',
  584. type:'POST',
  585. dataType:'json',
  586. data:{'orderId':$('#sellOrder').val(),financeOrderId:orderId},
  587. success:function(res){
  588. if(res.status==1){
  589. $('.canChangeNum').html(res.data['canChangeNum']);
  590. }else{
  591. $('.canChangeNum').html('');
  592. }
  593. }
  594. })
  595. //查询学生
  596. $.ajax({
  597. url:'<?php echo $this->createUrl('imsSale/orderStudentList')?>',
  598. type:'POST',
  599. dataType:'json',
  600. data:{'orderId':orderId},
  601. success:function(res){
  602. if(res.status==1){
  603. if(res.data.length>0){
  604. classStudentArr=res.data
  605. var html = '';
  606. $.each(res.data,function(i,v){
  607. html+='<li class="classified" classId="'+v['clazzId']+'">'+v['clazzName']+'</li>';
  608. })
  609. $('.class-list').html(html);
  610. }else{
  611. $('.class-list').html('<li>暂无班级数据</li>');
  612. }
  613. }
  614. }
  615. })
  616. }
  617. })
  618. //班级切换
  619. $(".class-list").on("click", "li", function(event) {
  620. $(".class-list li").removeClass("active");
  621. $(this).addClass("active");
  622. selectedClassId=classId=$(this).attr('classId');
  623. selectedClassName=className=$(this).html();
  624. getStudent(classId);
  625. });
  626. function getStudent(classId){
  627. var studentHtml='';
  628. if(classStudentArr.length>0){
  629. $.each(classStudentArr,function(i,v){
  630. if(v.clazzId==classId && v.studentInfoList.length>0){
  631. console.log(selectedDataValue)
  632. $.each(v.studentInfoList,function(k,value){
  633. if (!isSelected(value.studentId)) {
  634. studentHtml+='<label><input type="checkbox" name="studentName" classId="'+classId+'" className="'+v.clazzName+'" value="'+value.studentId+'" />'+value.studentName+'</label>';
  635. }else{
  636. studentHtml+='<label><input type="checkbox" checked disabled name="studentName" classId="'+classId+'" className="'+v.clazzName+'" value="'+value.studentId+'" />'+value.studentName+'</label>';
  637. }
  638. })
  639. }
  640. })
  641. }
  642. $('.student-list-content').html(studentHtml);
  643. }
  644. // 添加学生
  645. $("#btnAddStudent").on("click", function() {
  646. getStudentSelected();
  647. });
  648. // 移出学生
  649. $("#btnRemoveStudent").on("click", function() {
  650. removeStudentSelected();
  651. });
  652. // 全选按钮
  653. $("input[name='select-all']").change(function() {
  654. var type = $("input[name='select-all']").prop("checked")
  655. if(type){
  656. obj=$("#studentListContent").find("input");
  657. for(var i=0;i<obj.length;i++){
  658. if(obj.eq(i).attr('disabled')==undefined){
  659. obj.eq(i).prop("checked", true);
  660. }
  661. }
  662. }else{
  663. $("#studentListContent").find("input").prop("checked", false);
  664. }
  665. });
  666. function getStudentSelected() {
  667. var selectedData = $("#studentListContent input[name='studentName']:checked"); //获取所以选中学生
  668. var studentName = '';
  669. for (var i = 0; i < selectedData.length; i++) {
  670. if (!isSelected(selectedData[i].value)) {
  671. studentName = $(selectedData[i]).parent().text();
  672. var student ={
  673. name:studentName,
  674. value:selectedData[i].value,
  675. class:$(selectedData[i]).attr('className'),
  676. classId:$(selectedData[i]).attr('classId'),
  677. };
  678. selectedDataAll.push(student);
  679. selectedDataValue.push(selectedData[i].value);
  680. }else{
  681. //console.log(selectedData[i].value)
  682. }
  683. showSelectedStudent();
  684. }
  685. }
  686. function removeStudentSelected() {
  687. var selectedStudent = $("#selectedListContent input[name='selectedStudent']:checked"); //获取所有选中学生
  688. var selectedData = $("#studentListContent input[name='studentName']:checked"); //获取所以选中学生
  689. for (var i = 0; i < selectedStudent.length; i++) {
  690. $(selectedStudent[i]).parent().remove();
  691. if(selectedDataValue.length>0){
  692. for(var k=0;k<selectedDataValue.length;k++){
  693. if(selectedDataValue[k]===selectedStudent[i].value){
  694. selectedDataValue.splice(k,1);
  695. selectedDataAll.splice(k,1);
  696. }
  697. }
  698. }
  699. for (var j = 0; j < selectedData.length; j++) {
  700. if(selectedData[j].value===selectedStudent[i].value){
  701. $(selectedData[j]).prop("checked", false);
  702. }
  703. }
  704. }
  705. $('#studentSelectedLength').text(selectedDataAll.length);
  706. }
  707. function showSelectedStudent() {
  708. var selectedDataList = [];
  709. for (var i = 0; i < selectedDataAll.length; i++) {
  710. selectedDataList.push('<label><input type="checkbox" name="selectedStudent" value="'+ selectedDataAll[i].value +'" />'+selectedDataAll[i].name+'</label>');
  711. }
  712. $('#selectedListContent').html(selectedDataList);
  713. $('#studentSelectedLength').text(selectedDataAll.length);
  714. }
  715. function isSelected(val){
  716. return selectedDataValue.indexOf(val) > -1
  717. }
  718. // 提交
  719. var flag = true;
  720. $(".btn-trial").on("click", function () {
  721. if (selectedDataAll.length >0) {
  722. var oldOrderId=$('#financeOrder').val();
  723. var purposeOrderId=$('#sellOrder').val();
  724. var ogcId=$('input[name=ogcId]').val();
  725. var data = {
  726. ogcId:ogcId,
  727. oldOrderId: oldOrderId,
  728. purposeOrderId: purposeOrderId,
  729. studentList:JSON.stringify(selectedDataAll),
  730. };
  731. if (flag){
  732. flag = false;
  733. $.ajax({
  734. type: 'post',
  735. url: "<?php echo Yii::app()->createUrl('imsSale/saveGoodsChange')?>",
  736. dataType: 'json',
  737. data: data,
  738. success: function (data) {
  739. if (data.status){
  740. layer.alert(data.msg, {icon:1,closeBtn:0},function () {
  741. location.href="<?php echo Yii::app()->createUrl('imsSale/goodsChange')?>"
  742. });
  743. }else{
  744. flag = true;
  745. layer.alert(data.msg, {icon:2});
  746. }
  747. },
  748. error: function () {
  749. flag = true;
  750. layer.alert("提交失败!", {icon:2});
  751. }
  752. });
  753. }else{
  754. layer.msg("稍安勿躁,正在处理中...");
  755. }
  756. } else {
  757. layer.alert("请选择至少一个学生", {'icon':7});
  758. }
  759. });
  760. })
  761. </script>