newGoodsChange.php 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768
  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: #2977ff;
  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: #2977ff;
  126. cursor: pointer;
  127. }
  128. .layui-layer-btn .layui-layer-btn0 {
  129. border-color: #2977ff !important;
  130. background-color: #2977ff !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: #2977ff;
  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: #619aff;
  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: #2977ff;
  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: #2977ff;
  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. echo '<option value="'.$value['schoolYearId'].'">'.$value['schoolYearName'].'</option>';
  292. }
  293. }
  294. ?>
  295. </select>
  296. </th>
  297. <th class="title">选择新销售订单</th>
  298. <th>
  299. <select name="sellOrder" id="sellOrder">
  300. <option value="0">选择新销售订单</option>
  301. </select>
  302. </th>
  303. </tr>
  304. <tr>
  305. <th class="title">售价</th>
  306. <th >
  307. <span class="sellingPrice">
  308. </span>
  309. </th >
  310. <th class="title" style="width:10%">商品</th>
  311. <th>
  312. <span class="goodsName">
  313. </span>
  314. </th>
  315. </tr>
  316. <tr>
  317. <th class="title">年级</th>
  318. <th >
  319. <span class="gradeName">
  320. </span>
  321. </th >
  322. <th class="title" style="width:10%">商品变更类型</th>
  323. <th>
  324. <span class="goodsChangeName" data-goods-change="">
  325. </span>
  326. </th>
  327. </tr>
  328. </table>
  329. 需变更财务订单
  330. <table id="formalOrderTable"
  331. class="table table-bordered table-hover dataTable no-footer DTTT_selectable"
  332. style="font-size:12px">
  333. <tr>
  334. <th class="title">财务订单号</th>
  335. <th style="width:38%">
  336. <select name="financeOrder" id="financeOrder">
  337. <option value="0">财务订单号</option>
  338. </select>
  339. </th>
  340. <th class="title">商品</th>
  341. <th>
  342. <span class="financeGoodsName">
  343. </span>
  344. </th>
  345. </tr>
  346. <tr>
  347. <th class="title">售价</th>
  348. <th >
  349. <span class="financeSellingPrice">
  350. </span>
  351. </th >
  352. <th class="title" style="width:10%">可变更人数</th>
  353. <th>
  354. <span class="canChangeNum">
  355. </span>
  356. </th>
  357. </tr>
  358. </table>
  359. </div>
  360. <div class="ims-add-student-box">
  361. <h2 class="ims-title"><span>添加学生</span></h2>
  362. <div class="add-student-box">
  363. <div class="class-box">
  364. <div class="add-student-title">
  365. <p>班级</p>
  366. </div>
  367. <ul class="class-list">
  368. </ul>
  369. </div>
  370. <div class="student-list">
  371. <div class="add-student-title clearfix">
  372. <span class="fl">
  373. <label>
  374. <input type="checkbox" name="select-all" value="1" />全选
  375. </label>
  376. <span></span>
  377. </span>
  378. </div>
  379. <div class="student-list-content" id="studentListContent">
  380. </div>
  381. </div>
  382. <div class="btns-box">
  383. <p class="btn-left" id="btnRemoveStudent"><</p>
  384. <p class="btn-right" id="btnAddStudent" >></p>
  385. </div>
  386. <div class="selected-list">
  387. <div class="add-student-title">
  388. <p>已选(<span id="studentSelectedLength">0</span>人)</p>
  389. </div>
  390. <div class="selected-list-content" id="selectedListContent">
  391. </div>
  392. </div>
  393. </div>
  394. </div>
  395. <a class="btn-trial">确定</a>
  396. </div>
  397. <script src="/js/productset/jquery.min.js"></script>
  398. <script src="/js/ims/jquery.datetimepicker.js"></script>
  399. <script src="/js/layer/layer.js"></script>
  400. </body>
  401. </html>
  402. <script>
  403. $(function(){
  404. var sellOrderArr=[],financeOrderArr=[];
  405. var classStudentArr={};
  406. $("#schoolYear").change(function(){
  407. var schoolYear=$(this).val();
  408. $('.sellingPrice').html('');
  409. $('.goodsName').html('');
  410. $('.gradeName').html('');
  411. $('.goodsChangeName').html('');
  412. $('.goodsChangeName').attr('data-goods-change','');
  413. $('.financeSellingPrice').html('');
  414. $('.financeGoodsName').html('');
  415. $('.canChangeNum').html('');
  416. $('.class-list').html('<li>暂无班级数据</li>');
  417. $('.student-list-content').html('');
  418. $('.selected-list-content').html('');
  419. $('#financeOrder').html('<option value="0">选择财务订单</option>');
  420. if(schoolYear!=0){
  421. sellOrderArr=[];
  422. $('#sellOrder').html('<option value="0">选择新销售订单</option>');
  423. $.ajax({
  424. url:'<?php echo $this->createUrl('imsSale/canChangeOrder')?>',
  425. type:'POST',
  426. dataType:'json',
  427. data:{'schoolYearId':schoolYear},
  428. success:function(res){
  429. if(res.status==1){
  430. html='<option value="0">选择新销售订单</option>';
  431. for(var i=0;i<res.data.length;i++){
  432. html+='<option value="'+res.data[i]['orderId']+'">'+res.data[i]['orderNo']+'</option>';
  433. sellOrderArr.push(res.data[i]);
  434. }
  435. $('#sellOrder').html(html);
  436. }
  437. }
  438. })
  439. }
  440. })
  441. $("#sellOrder").change(function(){
  442. var orderId=$(this).val();
  443. $('.sellingPrice').html('');
  444. $('.goodsName').html('');
  445. $('.gradeName').html('');
  446. $('.goodsChangeName').html('');
  447. $('.goodsChangeName').attr('data-goods-change','');
  448. $('.financeSellingPrice').html('');
  449. $('.financeGoodsName').html('');
  450. $('.canChangeNum').html('');
  451. $('.class-list').html('<li>暂无班级数据</li>');
  452. $('.student-list-content').html('');
  453. $('.selected-list-content').html('');
  454. if(orderId!=0){
  455. if(sellOrderArr.length>0){
  456. $.each(sellOrderArr,function(i,v){
  457. if(v.orderId==orderId){
  458. $('.sellingPrice').html(v.sellingPrice);
  459. $('.goodsName').html(v.goodsName);
  460. $('.gradeName').html(v.gradeName);
  461. $('.goodsChangeName').html(v.goodsChangeName);
  462. $('.goodsChangeName').attr('data-goods-change',v.goodsChange);
  463. }
  464. })
  465. }
  466. financeOrderArr=[]
  467. $('#financeOrder').html('<option value="0">选择财务订单</option>');
  468. $.ajax({
  469. url:'<?php echo $this->createUrl('imsSale/needChangeOrder')?>',
  470. type:'POST',
  471. dataType:'json',
  472. data:{'orderId':orderId},
  473. success:function(res){
  474. if(res.status==1){
  475. html='<option value="0">选择财务订单</option>';
  476. for(var i=0;i<res.data.length;i++){
  477. html+='<option value="'+res.data[i]['orderId']+'">'+res.data[i]['orderNo']+'</option>';
  478. financeOrderArr.push(res.data[i]);
  479. }
  480. $('#financeOrder').html(html);
  481. }
  482. }
  483. })
  484. }
  485. })
  486. $('#financeOrder').change(function(){
  487. var orderId=$(this).val();
  488. $('.canChangeNum').html('');
  489. $('.financeGoodsName').html('');
  490. $('.financeSellingPrice').html('');
  491. $('.class-list').html('<li>暂无班级数据</li>');
  492. $('.student-list-content').html('');
  493. $('.selected-list-content').html('');
  494. selectedDataAll=[];
  495. selectedDataValue=[];
  496. if(orderId!=0) {
  497. if (financeOrderArr.length > 0) {
  498. $.each(financeOrderArr, function (i, v) {
  499. if (v.orderId == orderId) {
  500. // $('.canChangeNum').html(v.canChangeNum);
  501. $('.financeGoodsName').html(v.goodsName);
  502. $('.financeSellingPrice').html(v.sellingPrice);
  503. }
  504. })
  505. }
  506. //查询可变理人数
  507. $.ajax({
  508. url:'<?php echo $this->createUrl('imsSale/searchChangeNum')?>',
  509. type:'POST',
  510. dataType:'json',
  511. data:{'orderId':$('#sellOrder').val(),financeOrderId:orderId},
  512. success:function(res){
  513. if(res.status==1){
  514. $('.canChangeNum').html(res.data['canChangeNum']);
  515. }else{
  516. $('.canChangeNum').html('');
  517. }
  518. }
  519. })
  520. //查询学生
  521. $.ajax({
  522. url:'<?php echo $this->createUrl('imsSale/orderStudentList')?>',
  523. type:'POST',
  524. dataType:'json',
  525. data:{'orderId':orderId},
  526. success:function(res){
  527. if(res.status==1){
  528. if(res.data.length>0){
  529. classStudentArr=res.data
  530. var html = '';
  531. $.each(res.data,function(i,v){
  532. html+='<li class="classified" classId="'+v['clazzId']+'">'+v['clazzName']+'</li>';
  533. })
  534. $('.class-list').html(html);
  535. }else{
  536. $('.class-list').html('<li>暂无班级数据</li>');
  537. }
  538. }
  539. }
  540. })
  541. }
  542. })
  543. //班级切换
  544. $(".class-list").on("click", "li", function(event) {
  545. $(".class-list li").removeClass("active");
  546. $(this).addClass("active");
  547. selectedClassId=classId=$(this).attr('classId');
  548. selectedClassName=className=$(this).html();
  549. getStudent(classId);
  550. });
  551. function getStudent(classId){
  552. var studentHtml='';
  553. if(classStudentArr.length>0){
  554. $.each(classStudentArr,function(i,v){
  555. if(v.clazzId==classId && v.studentInfoList.length>0){
  556. $.each(v.studentInfoList,function(k,value){
  557. studentHtml+='<label><input type="checkbox" name="studentName" classId="'+classId+'" className="'+v.clazzName+'" value="'+value.studentId+'" />'+value.studentName+'</label>';
  558. })
  559. }
  560. })
  561. }
  562. $('.student-list-content').html(studentHtml);
  563. }
  564. // 添加学生
  565. $("#btnAddStudent").on("click", function() {
  566. getStudentSelected();
  567. });
  568. // 移出学生
  569. $("#btnRemoveStudent").on("click", function() {
  570. removeStudentSelected();
  571. });
  572. // 全选按钮
  573. $("input[name='select-all']").change(function() {
  574. var type = $("input[name='select-all']").prop("checked")
  575. if(type){
  576. obj=$("#studentListContent").find("input");
  577. for(var i=0;i<obj.length;i++){
  578. if(obj.eq(i).attr('disabled')==undefined){
  579. obj.eq(i).prop("checked", true);
  580. }
  581. }
  582. }else{
  583. $("#studentListContent").find("input").prop("checked", false);
  584. }
  585. });
  586. function getStudentSelected() {
  587. var selectedData = $("#studentListContent input[name='studentName']:checked"); //获取所以选中学生
  588. var studentName = '';
  589. for (var i = 0; i < selectedData.length; i++) {
  590. if (!isSelected(selectedData[i].value)) {
  591. studentName = $(selectedData[i]).parent().text();
  592. var student ={
  593. name:studentName,
  594. value:selectedData[i].value,
  595. class:$(selectedData[i]).attr('className'),
  596. classId:$(selectedData[i]).attr('classId'),
  597. };
  598. selectedDataAll.push(student);
  599. selectedDataValue.push(selectedData[i].value);
  600. }else{
  601. //console.log(selectedData[i].value)
  602. }
  603. showSelectedStudent();
  604. }
  605. }
  606. function removeStudentSelected() {
  607. var selectedStudent = $("#selectedListContent input[name='selectedStudent']:checked"); //获取所有选中学生
  608. var selectedData = $("#studentListContent input[name='studentName']:checked"); //获取所以选中学生
  609. for (var i = 0; i < selectedStudent.length; i++) {
  610. $(selectedStudent[i]).parent().remove();
  611. if(selectedDataValue.length>0){
  612. for(var k=0;k<selectedDataValue.length;k++){
  613. if(selectedDataValue[k]===selectedStudent[i].value){
  614. selectedDataValue.splice(k,1);
  615. selectedDataAll.splice(k,1);
  616. }
  617. }
  618. }
  619. for (var j = 0; j < selectedData.length; j++) {
  620. if(selectedData[j].value===selectedStudent[i].value){
  621. $(selectedData[j]).prop("checked", false);
  622. }
  623. }
  624. }
  625. $('#studentSelectedLength').text(selectedDataAll.length);
  626. }
  627. function showSelectedStudent() {
  628. var selectedDataList = [];
  629. for (var i = 0; i < selectedDataAll.length; i++) {
  630. selectedDataList.push('<label><input type="checkbox" name="selectedStudent" value="'+ selectedDataAll[i].value +'" />'+selectedDataAll[i].name+'</label>');
  631. }
  632. $('#selectedListContent').html(selectedDataList);
  633. $('#studentSelectedLength').text(selectedDataAll.length);
  634. }
  635. function isSelected(val){
  636. return selectedDataValue.indexOf(val) > -1
  637. }
  638. // 提交
  639. var flag = true;
  640. $(".btn-trial").on("click", function () {
  641. if (selectedDataAll.length >0) {
  642. var oldOrderId=$('#financeOrder').val();
  643. var purposeOrderId=$('#sellOrder').val();
  644. var goodsChange= $('.goodsChangeName').attr('data-goods-change');
  645. var data = {
  646. oldOrderId: oldOrderId,
  647. purposeOrderId: purposeOrderId,
  648. studentList:JSON.stringify(selectedDataAll),
  649. goodsChange: goodsChange,
  650. };
  651. if (flag){
  652. flag = false;
  653. $.ajax({
  654. type: 'post',
  655. url: "<?php echo Yii::app()->createUrl('imsSale/saveGoodsChange')?>",
  656. dataType: 'json',
  657. data: data,
  658. success: function (data) {
  659. if (data.status){
  660. layer.alert(data.msg, {icon:1,closeBtn:0},function () {
  661. location.href="<?php echo Yii::app()->createUrl('imsSale/goodsChange')?>"
  662. });
  663. }else{
  664. flag = true;
  665. layer.alert(data.msg, {icon:2});
  666. }
  667. },
  668. error: function () {
  669. flag = true;
  670. layer.alert("提交失败!", {icon:2});
  671. }
  672. });
  673. }else{
  674. layer.msg("稍安勿躁,正在处理中...");
  675. }
  676. } else {
  677. layer.alert("请选择至少一个学生", {'icon':7});
  678. }
  679. });
  680. })
  681. </script>