123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>转财务订单</title>
- <link href="/css/ims/base.css" rel="stylesheet">
- <link href="/css/ims/ims.css" rel="stylesheet">
- <link rel="stylesheet" type="text/css" href="/css/ims/bootstrap.min.css" />
- <link rel="stylesheet" type="text/css" href="/css/ims/ace.min.css" />
- <link rel="stylesheet" type="text/css" href="/css/ims/jquery.datetimepicker.css" />
- <style>
- .ims-add-student-box {
- margin: 20px;
- }
- .ims-add-student-box p{
- margin: 0;
- }
- .ims-add-student-box .ims-title{
- font-size: 20px;
- font-weight: bold;
- }
- .ims-add-student-box .ims-title span{
- margin-right: 20px;
- }
- .ims-add-student-box .add-student-box {
- margin-top: 20px;
- font-size: 0;
- overflow: hidden;
- }
- .ims-add-student-box .add-student-box>div{
- display: inline-block;
- height: 530px;
- font-size: 14px;
- vertical-align: top;
- }
- .ims-add-student-box .add-student-box .add-student-title{
- padding: 0 8px;
- line-height: 30px;
- color: #fff;
- background-color: #2977ff;
- }
- .ims-add-student-box .add-student-box .add-student-title label{
- font-size: 14px;
- font-weight: normal;
- cursor: pointer;
- margin-bottom: 0;
- }
- .ims-add-student-box .add-student-box .add-student-title input{
- vertical-align: middle;
- margin: 0;
- }
- #input-search-student{
- width: 120px;
- height: 20px;
- border: 0;
- color:#000;
- }
- .ims-add-student-box .add-student-box{
- line-height: 30px;
- min-width: 938px;
- }
- .ims-add-student-box .add-student-box .class-box {
- width: 180px;
- text-align: center;
- border: 1px solid #ccc;
- }
- .ims-add-student-box .student-list div{
- font-size: 14px;
- font-weight: normal;
- }
- .ims-add-student-box .add-student-box .class-list{
- height: 500px;
- overflow: auto;
- }
- .ims-add-student-box .add-student-box .class-list li{
- border-bottom: 1px solid #ccc;
- cursor: pointer;
- }
- .ims-add-student-box .class-list .active{
- color: #619aff;
- }
- .ims-add-student-box .add-student-box .student-list{
- margin: 0;
- width: 34%;
- min-width: 326px;
- border: 1px solid #ccc;
- border-left: 0;
- }
- .ims-add-student-box .student-list-content,.selected-list-content{
- padding: 8px;
- height: 500px;
- overflow: auto;
- }
- .ims-add-student-box .student-list-content label,.selected-list-content label{
- display: inline-block;
- width: 150px;
- cursor: pointer;
- font-size: 14px;
- font-weight: normal;
- }
- .ims-add-student-box .btn-search-student{
- height: 20px;
- line-height: 20px;
- padding: 0 5px;
- border-radius: 3px;
- color: #619aff;
- background-color: #fff;
- border: none;
- outline: none;
- cursor: pointer;
- }
- .ims-add-student-box .btns-box {
- width: 100px;
- text-align: center;
- }
- .ims-add-student-box .btn-left,.ims-add-student-box .btn-right{
- margin: 150px auto 0;
- width: 40px;
- height: 40px;border: 1px solid #ccc;
- border-radius: 50%;
- background-color: #fff;
- text-align: center;
- line-height: 40px;
- cursor: pointer;
- }
- .ims-add-student-box .selected-list{
- width: 34%;
- min-width: 326px;
- border: 1px solid #ccc;
- }
- .ims-add-student-box .btn-confirm_purchase {
- display: block;
- margin: 0 auto;
- margin-top: 10px;
- margin-bottom: 10px;
- width: 200px;
- line-height: 54px;
- color: #fff;
- font-family: PingFangSC-Regular, "PingFang SC";
- font-weight: 400;
- font-style: normal;
- font-size: 20px;
- text-align: center;
- background-color: #2977ff;
- cursor: pointer;
- }
- .yiiPager li{display: inline}
- </style>
- </head>
- <body>
- <h3 class="sale-title">转财务订单申请</h3>
- <input type="hidden" name="itemName">
- <input type="hidden" name="itemSpec">
- <input type="hidden" name="itemCode">
- <input type="hidden" name="unitId">
- <div class="sale-table">
- <table width="100%">
- <tr>
- <th><em class="red">*</em>销售订单号</th>
- <td >
- <?php echo $orderNo?>
- </td>
- <th><em class="red">*</em>剩余名额</th>
- <td >
- <?php echo $surplus < 0 ? 0 : $surplus; ?>
- <input type="hidden" id="surplus" value="<?php echo $surplus;?>" />
- </td>
- </tr>
- <tr>
- <th><em class="red">*</em>年级</th>
- <td >
- <?php echo $gradeText?>
- </td>
- <th><em class="red">*</em>商品</th>
- <td >
- <?php echo $goodsName?>
- </td>
- </tr>
- <tr>
- <th><em class="red">*</em>申请人数</th>
- <td colspan="3" class="apply_people">
- </td>
- </tr>
- </table>
- <button type="button" class="label-primary-s bth-s create-allocation">添加学生</button>
- <table width="100%" class="table table-striped table-bordered table-hover dataTable no-footer DTTT_selectable" id="P_list">
- <tr>
- <td>序号</td>
- <td>姓名</td>
- <td>班级</td>
- <td>操作</td>
- </tr>
- </table>
- </div>
- <div class="sale-submit" style="margin-top: 25px;">
- <button type="button" class=" label-primary-s bth-s" id="savebutton">提交</button>
- </div>
- <!-- 编辑名单弹层 -->
- <div class="layer-edit">
- <div class="ims-add-student-box">
- <h2 class="ims-title"><span>添加学生</span><span>使用年级:<?php echo $useGrade?></span><span>入学级别:<?php echo $schoolYear?></span><span>当前年级:<?php echo $gradeText?></span></h2>
- <div class="add-student-box">
- <div class="class-box">
- <div class="add-student-title">
- <p>班级</p>
- </div>
- <ul class="class-list">
- <li class="active">一班</li>
- <li>二班</li>
- <li>三班</li>
- </ul>
- </div>
- <div class="student-list">
- <div class="add-student-title clearfix">
- <span class="fl">
- <label>
- <input type="checkbox" name="select-all" value="1" />全选
- </label>
- <span></span>
- </span>
- <span class="fr">
- <input type="text" id="input-search-student" name="search-student-name" placeholder="学生姓名" />
- <button type="button" class="btn-search-student">搜索</button>
- </span>
- </div>
- <div class="student-list-content" id="studentListContent">
- </div>
- </div>
- <div class="btns-box">
- <p class="btn-left" id="btnRemoveStudent"><</p>
- <p class="btn-right" id="btnAddStudent" >></p>
- </div>
- <div class="selected-list">
- <div class="add-student-title">
- <p>已选(<span id="studentSelectedLength">0</span>人)</p>
- </div>
- <div class="selected-list-content" id="selectedListContent">
- </div>
- </div>
- </div>
- <a class="btn-confirm_purchase">完成</a>
- </div>
- </div>
- <script src="/js/jquery-2.2.2.min.js" ></script>
- <script src="/js/jquery.datetimepicker.js"></script>
- <script src="/js/layer/layer.js"></script>
- <script src="/js/xsgl.js"></script>
- <script>
- $(document).ready(function() {
- var maxNumber=<?php echo $surplus?>;
- var orderId='<?php echo $orderId?>';
- var selectedDataAll=[];
- var selectedDataValue =[];
- var selectedClassId=0;
- var selectedClassName='';
- //班级切换
- $(".class-list").on("click", "li", function(event) {
- if(!$(this).hasClass('subjectObj')){
- $(".class-list li").removeClass("active");
- $(this).addClass("active");
- $("input[name='select-all']").prop("checked",false);
- //console.log($(this).attr('classId'));
- selectedClassId=classId=$(this).attr('classId');
- selectedClassName=className=$(this).html();
- getStudent(classId,className,'');
- }
- });
- //搜索学生
- $('.btn-search-student').click(function(){
- studentName=$('input[name=search-student-name]').val();
- if(studentName!=''){
- getStudent(selectedClassId,selectedClassName,studentName);
- }
- });
- function getStudent(classId,className,studentName){
- console.log(selectedDataValue);
- $.ajax({
- url:'<?php echo $this->createUrl('imsSale/getFilterStudent')?>',
- type:'POST',
- dataType:'json',
- data:{'classId':classId,'orderId':orderId,'studentName':studentName},
- success:function(res){
- if(res.status==1){
- var studentHtml='';
- for(var i=0;i<res.data.list.length;i++){
- if($.inArray(res.data.list[i]['student_id'],res.data.student)!=-1){
- //continue;
- 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>';
- }else{
- if($.inArray(res.data.list[i]['student_id'],selectedDataValue)!=-1){
- 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>';
- }else{
- 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>';
- }
- }
- }
- $('.student-list-content').html(studentHtml);
- }else{
- $('.student-list-content').html('');
- }
- }
- });
- }
- // 全选按钮
- $("input[name='select-all']").change(function() {
- var type = $("input[name='select-all']").prop("checked")
- if(type){
- obj=$("#studentListContent").find("input");
- for(var i=0;i<obj.length;i++){
- if(obj.eq(i).attr('disabled')==undefined){
- obj.eq(i).prop("checked", true);
- }
- }
- }else{
- $("#studentListContent").find("input").prop("checked", false);
- }
- });
- // 添加学生
- $("#btnAddStudent").on("click", function() {
- getStudentSelected();
- });
- // 移出学生
- $("#btnRemoveStudent").on("click", function() {
- removeStudentSelected();
- });
- $('.create-allocation').click(function(){
- $.ajax({
- url:'<?php echo $this->createUrl('imsSale/getClassListForClassifed')?>',
- type:'POST',
- dataType:'json',
- data:{'grade':<?php echo $grade;?>},
- success:function(res){
- if(res.status==1){
- var html='';
- console.log(res.data['subjects'].length);
- for(var i=0;i<res.data['classList'].length;i++){
- html+='<li classId="'+res.data['classList'][i]['class_id']+'">'+res.data['classList'][i]['class_name']+'</li>';
- }
- if(res.data.subjects.length>0){
- html+='<li class="subjectObj">教学班<select class="chooseSubject"><option value="0">选择学科</option>';
- for(var i=0;i<res.data.subjects.length;i++){
- html+='<option value="'+res.data.subjects[i]['id']+'">'+res.data.subjects[i]['name']+'</option>';
- }
- html+='</select></li>';
- }
- $('.class-list').html(html);
- var selectStudentIndex=layer.open({
- title: false,
- closeBtn: 1,
- type: 1,
- offset: '20px',
- area: ['65%', '600px'],
- content: $(".layer-edit")
- });
- }
- }
- });
- });
- $('.class-box').on('change','.chooseSubject',function(){
- var subjectId=$(this).val();
- $('.classified').remove();
- $.ajax({
- url:'<?php echo $this->createUrl('imsSale/getClassListForClassifed')?>',
- type:'POST',
- dataType:'json',
- data:{'grade':<?php echo $grade;?>,'subject':subjectId},
- success:function(res){
- if(res.status==1){
- var html='';
- for(var i=0;i<res.data.length;i++){
- html+='<li class="classified" classId="'+res.data[i]['class_id']+'">'+res.data[i]['class_name']+'</li>';
- }
- $('.class-list').append(html);
- }
- }
- });
- });
- function getStudentSelected() {
- var selectedData = $("#studentListContent input[name='studentName']:checked"); //获取所以选中学生
- var studentName = '';
- for (var i = 0; i < selectedData.length; i++) {
- if (!isSelected(selectedData[i].value)) {
- studentName = $(selectedData[i]).parent().text();
- var student ={
- name:studentName,
- value:selectedData[i].value,
- class:$(selectedData[i]).attr('className'),
- classId:$(selectedData[i]).attr('classId'),
- };
- selectedDataAll.push(student);
- selectedDataValue.push(selectedData[i].value);
- }else{
- //console.log(selectedData[i].value)
- }
- showSelectedStudent();
- }
- };
- function isSelected(val){
- return selectedDataValue.indexOf(val) > -1
- };
- function removeStudentSelected() {
- var selectedStudent = $("#selectedListContent input[name='selectedStudent']:checked"); //获取所有选中学生
- var selectedData = $("#studentListContent input[name='studentName']:checked"); //获取所以选中学生
- for (var i = 0; i < selectedStudent.length; i++) {
- $(selectedStudent[i]).parent().remove();
- for (var j = 0; j < selectedData.length; j++) {
- if(selectedData[j].value===selectedStudent[i].value){
- $(selectedData[j]).prop("checked", false);
- if(selectedDataValue.length>0){
- for(var k=0;k<selectedDataValue.length;k++){
- if(selectedDataValue[k]===selectedStudent[i].value){
- selectedDataValue.splice(k,1);
- selectedDataAll.splice(k,1);
- }
- }
- }
- }
- }
- }
- $('#studentSelectedLength').text(selectedDataAll.length);
- };
- function showSelectedStudent() {
- var selectedDataList = [];
- for (var i = 0; i < selectedDataAll.length; i++) {
- selectedDataList.push('<label><input type="checkbox" name="selectedStudent" value="'+ selectedDataAll[i].value +'" />'+selectedDataAll[i].name+'</label>');
- }
- $('#selectedListContent').html(selectedDataList);
- $('#studentSelectedLength').text(selectedDataAll.length);
- };
- //确认选择学生
- var page=1;
- var pageLimit=10;
- var totalPage=0;
- $('.btn-confirm_purchase').click(function(){
- //console.log(selectedDataAll);
- /*if(maxNumber<selectedDataAll.length){
- layer.msg('选择学生数量不能超过剩余名额');
- }else{
- showStudentList();
- layer.closeAll();
- }*/
- showStudentList();
- layer.closeAll();
- });
- function showStudentList(){
- var listLength=selectedDataAll.length;
- totalPage=Math.ceil(listLength/pageLimit);
- start=(page-1)*pageLimit;
- $('.apply_people').html(listLength+'人');
- var studentList=selectedDataAll.slice(start,(start+pageLimit));
- console.log(studentList);
- console.log(start);
- html=' <tr>\n' +
- ' <th>序号</th>\n' +
- ' <th>姓名</th>\n' +
- ' <th>班级</th>\n' +
- ' <th>操作</th>\n' +
- ' </tr>';
- for(var i=0;i<studentList.length;i++){
- html+='<tr>';
- html+='<td>'+(i+1)+'</td>';
- html+='<td>'+studentList[i].name+'</td>';
- html+='<td>'+studentList[i].class+'</td>';
- html+='<td><a href="#" studentId="'+studentList[i].value+'" class="remove">移除</a></td>';
- html+='</tr>';
- }
- html+='<tr>';
- html+='<td colspan=4 class="page">';
- html+=' <div class="row" style="padding-top:10px;">\n' +
- ' <div class="col-xs-7">\n' +
- ' 共'+(listLength)+'条记录,第'+page+'页,共'+totalPage+'页\n' +
- ' </div>\n' +
- ' <div class="col-xs-5" style="font-size: 16px">\n' +
- ' <div class="dataTables_paginate paging_simple_numbers" style="vertical-align:sub;">\n' +
- ' <ul id="yw0" class="yiiPager">';
- if(page>1){
- html+='<li class="previous"><a href="#">上一页</a></li>';
- }
- for(var j=1;j<=totalPage;j++){
- if(j==page){
- html+='<li class="page selected"><a href="#">'+j+'</a></li>';
- }else{
- html+='<li class="page gotoPage" rel="'+j+'"><a href="#">'+j+'</a></li>';
- }
- }
- if(page<totalPage){
- html+='<li class="next"><a href="#">下一页</a></li>';
- }
- html+='</ul></div></div></div></tr>';
- $('#P_list').html(html);
- }
- //提交申请
- $('#savebutton').click(function(){
- $(this).attr('disabled',true);
- var obj=$(this);
- var suplus = $('#surplus') .val();
- $.ajax({
- url:'<?php echo $this->createUrl('imsSale/turnOrder')?>',
- type:'POST',
- data:{'orderId':orderId,'officialNum':selectedDataAll.length,'studentInfo':JSON.stringify(selectedDataAll),'suplus':suplus},
- dataType:'json',
- success:function(res){
- if(res.status==1){
- layer.msg('申请成功');
- window.location.href='<?php echo $this->createUrl('imsSale/purposeTable')?>';
- }else{
- if(res.msg!=undefined){
- layer.msg(res.msg);
- }else{
- layer.msg("申请失败");
- }
- obj.removeAttr('disabled');
- }
- }
- });
- });
- $(document)
- .on('change','.num',function(){
- $(this).val($(this).val().replace(/[^\d+|\.]/g,"1"));
- var num=parseInt($(this).val());
- console.log(num);
- if(num<1 ){
- $(this).val(1);
- }
- })
- .on('click','.remove',function(){
- studentId=$(this).attr('studentId');
- for (var j = 0; j < selectedDataAll.length; j++) {
- if(selectedDataAll[j].value===studentId){
- selectedDataAll.splice(j,1);
- selectedDataValue.splice(j,1);
- }
- }
- $('.apply_people').html(selectedDataAll.length+'人');
- var selectedStudent = $("#selectedListContent input[name='selectedStudent']"); //获取所有选中学生
- var selectedData = $("#studentListContent input[name='studentName']:checked"); //获取待选学生
- for (var i = 0; i < selectedData.length; i++) {
- if(selectedData[i].value===studentId){
- $(selectedData[i]).prop("checked", false);
- }
- }
- for (var i = 0; i < selectedStudent.length; i++) {
- if(selectedStudent[i].value===studentId){
- $(selectedStudent[i]).parent().remove();
- }
- }
- $('#studentSelectedLength').text(selectedDataAll.length);
- $(this).closest('tr').remove();
- var tr=$('#P_list').find('tr');
- if(tr.length<3 && selectedDataAll.length>0){
- showStudentList();
- }
- })
- .on('click','.next',function(){
- page++;
- showStudentList();
- })
- .on('click','.previous',function(){
- if(page>1){
- page--;
- showStudentList();
- }
- })
- .on('click','.gotoPage',function(){
- page=parseInt($(this).attr('rel'));
- showStudentList();
- })
- });
- </script>
- </body>
- </html>
|