123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392 |
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
- <title>订购</title>
- <meta name="description" content="">
- <meta name="keywords" content="">
- <link href="/css/ims/base.css" rel="stylesheet">
- <style>
- .ims-box {
- margin: 20px;
- }
- .screen {
- padding-left: 20px;
- height: 44px;
- line-height: 44px;
- background-color: #eff4fa;
- }
- .screen li {
- float: left;
- margin-right: 30px;
- }
- .bg-d9bf6e {
- margin-left: 5px;
- padding: 0 20px;
- color: #fff;
- background-color: #d9bf6e;
- }
- .list {
- margin-top: 40px;
- overflow: hidden;
- }
- .list h2 {
- line-height: 30px;
- }
- .list .student-list_box {
- width: 300px;
- }
- .list .student-list_box>ul{
- height: 360px;
- overflow: auto;
- padding: 20px;
- background-color: #eef3ff;
- }
- .list .student-list_box li {
- line-height: 30px;
- cursor: pointer;
- }
- .list .student-selected_box {
- margin-left: 60px;
- width: 60%;
- overflow-x: scroll;
- }
- .list .student-list {
- display: none;
- margin-left: 20px;
- }
- .list .student-list li.active .btn-select_all {
- display: inline-block;
- }
- .list .student-list span {
- cursor: pointer;
- }
- .list .btn-select_all {
- margin-left: 84px;
- color: #008000;
- }
- .student-name_box li {
- position: relative;
- margin-left: 28px;
- line-height: 30px;
- }
- .student-name_box input {
- position: absolute;
- left: 155px;
- top: 8px;
- }
- .btn-select_all,
- .student-name_box {
- display: none;
- }
- .student-selected {
- height: 400px;
- overflow: auto;
- }
- .student-selected li {
- float: left;
- margin-right: 24px;
- margin-bottom: 12px;
- width: 280px;
- height: 26px;
- line-height: 26px;
- text-indent: 20px;
- background-color: #f2f2f2;
- }
- .student-selected .btn-delete {
- float: right;
- margin-right: 20px;
- color: red;
- cursor: pointer;
- }
- .btn-confirm_purchase {
- display: block;
- margin: 0 auto;
- margin-top: 100px;
- margin-bottom: 50px;
- width: 430px;
- 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: rgba(0, 153, 102, 1);
- cursor: pointer;
- }
- .more-show{
- width: 40%;overflow: hidden; text-overflow:ellipsis; white-space: nowrap;
- }
- .layui-layer-btn .layui-layer-btn0 {
- border-color: #15ae68 !important;
- background-color: #15ae68 !important;
- color: #fff;
- }
- .stop-layer-box, .resubmit-layer-box, .delete-layer-box {
- line-height: 140px;
- text-align: center;
- }
- </style>
- </head>
- <body>
- <input type="hidden" value="<?php echo $orderId?>" name="orderId" id="orderId">
- <div class="ims-box">
- <div class="screen">
- <ul>
- <li><span class="product">订购商品</span><span class="product-name bg-d9bf6e"><?php echo $goodDetail['goodName'];?></span></li>
- <li><span class="package">套餐</span><span class="grade-name bg-d9bf6e"><?php echo $goodDetail['packageName'];?></span></li>
- <li class="more-show"><span class="date">使用月份</span><span class="date-name bg-d9bf6e"><?php echo $goodDetail['useDate'];?></span></li>
- </ul>
- </div>
- <div class="list">
- <div class="student-list_box fl">
- <input type="hidden" name="grade" value="1">
- <h2>学生名单</h2>
- <ul>
- <?php if ($goodDetail['grade']=='1'):?>
- <li class="grade">❖<span grade="1">高一</span>
- <ul class="student-list grade_1"></ul>
- </li>
- <?php elseif ($goodDetail['grade']=='2'):?>
- <li class="grade">❖<span grade="2">高二</span>
- <ul class="student-list grade_2"></ul>
- </li>
- <?php else:?>
- <li class="grade">❖<span grade="3">高三</span>
- <ul class="student-list grade_3"></ul>
- </li>
- <?php endif;?>
- </div>
- <div class="student-selected_box fl">
- <h2>已选(<span id="studentSelectedLength">0</span>)</h2>
- <ul class="student-selected">
- </ul>
- </div>
- </div>
- <a class="btn-confirm_purchase">确认订购</a>
- </div>
- <script src="/js/productset/jquery.min.js"></script>
- <script src="/js/layer/layer.js"></script>
- <script>
- $(document).ready(function() {
- $(".grade>span").on("click", function(event) {
- $(this).parent().children(".student-list").toggle();
- event.isDefaultPrevented();
- event.stopPropagation();
- getClass($(this).attr('grade'));
- return false;
- });
- $(".student-list").on("click", "span", function(event) {
- var classId = $(this).attr('class-id');
- var obj = $(this);
- var objLen = obj.parent().children('.student-name_box').find('li').length;
- var orderId = "<?php echo $_GET['orderId']?>";
- if(objLen<=0){
- $.ajax({
- type: 'post',
- url: "<?php echo Yii::app()->createUrl('imsSale/getOfficialStudent');?>",
- data: {'classId': classId, 'orderId': orderId},
- dataType: 'json',
- success: function (data) {
- console.log(data);
- if (data.status) {
- var html = '';
- var list = data.data.list;
- var students = data.data.student;
- for (var i = 0; i < list.length; i++) {
- var item = list[i];
- if (item['student_id']) {
- var index = $.inArray(item['student_id'], students);
- if (index>=0) {
- html += '<li><label>';
- html += item['realname'];
- html += '<input type="checkbox" checked disabled name="studentId" value="'+item['student_id']+'" />';
- html += '</label></li>';
- }else{
- html += '<li><label>';
- html += item['realname'];
- html += '<input type="checkbox" name="studentId" value="'+item['student_id']+'" />';
- html += '</label></li>';
- }
- }
- }
- } else {
- var html = '<li>暂无学生数据</li>';
- }
- obj.parent().children('.student-name_box').html(html);
- },
- error: function () {
- return false;
- }
- });
- }
- obj.parent().toggleClass("active");
- obj.parent().children(".student-name_box").toggle();
- event.stopPropagation();
- return false;
- });
- // 单选按钮
- $('body').on('change', "input[name='studentId']", function () {
- getsStudentSelected();
- });
- // 全选按钮
- $('body').on('click', ".btn-select_all", function () {
- var obj = $(this).parent().find("input");
- if($(this).hasClass('isSelected')){
- obj.each(function () {
- if(!$(this).is(':disabled')){
- $(this).prop("checked", false);
- }
- })
- $(this).removeClass("isSelected");
- }else{
- obj.each(function () {
- if(!$(this).is(':disabled')){
- $(this).prop("checked", true);
- }
- })
- $(this).addClass("isSelected");
- }
- getsStudentSelected();
- });
- //删除学生
- $(".student-selected").on("click", ".btn-delete", function() {
- $(this).parent().remove();
- var studentValue = $(this).attr('value');
- $("input[value='" + studentValue + "']").prop("checked", false);
- getsStudentSelected();
- });
- // 提交
- var flag = true;
- $(".btn-confirm_purchase").on("click", function() {
- var selectedStudentAll = [];
- var selectedStudent = $(".student-selected>li");
- selectedStudent.each(function () {
- var cc = $(this).attr('student-info');
- selectedStudentAll.push(cc);
- });
- if (selectedStudentAll.length != 0) {
- var orderId = $("input[name='orderId']").val();
- var data = {
- orderId: orderId,
- studentList: selectedStudentAll
- };
- if (flag){
- flag = false;
- $.ajax({
- type: 'post',
- url: "<?php echo Yii::app()->createUrl('imsSale/saveOfficial')?>",
- dataType: 'json',
- data: data,
- success: function (data) {
- console.log(data);
- if (data.status){
- layer.alert("提交成功!", {icon:1,closeBtn:0},function () {
- location.href="<?php echo Yii::app()->createUrl('imsSale/officialTable')?>"
- });
- }else{
- flag = true;
- layer.alert(data.msg, {icon:2});
- }
- },
- error: function () {
- flag = true;
- layer.alert("提交失败!", {icon:2});
- }
- });
- }else{
- layer.msg("稍安勿躁,正在处理中...");
- }
- } else {
- layer.alert("请选择至少一个学生", {'icon':7});
- }
- });
- //获取班级
- function getClass(grade) {
- $('.student-list').empty();
- $.ajax({
- type: 'post',
- url: "<?php echo Yii::app()->createUrl('imsSale/getClassList');?>",
- data: {grade: grade},
- dataType: 'json',
- success: function (data) {
- if (data.status) {
- var html = '';
- for (var i = 0; i < data.data.length; i++) {
- var item = data.data[i];
- if (item['class_id']) {
- html += '<li>▾<span class="student" class-id="'+item['class_id']+'"> ';
- html += item['class_name'];
- html += '</span><a type="button" class="btn-select_all">全选</a>';
- html += '<ul class="student-name_box"></ul>';
- html += '</li>'
- }
- }
- } else {
- var html = '<li>暂无班级数据</li>';
- }
- $('.grade_'+grade).html(html);
- }
- })
- }
- //选择学生
- function getsStudentSelected() {
- var selectedData = $("input[name='studentId']:checked"); //获取所以选中学生
- var selectedDataList = [];
- var studentName, studentClass, studentClassId = '';
- var disabled = 0;
- for (var i = 0; i < selectedData.length; i++) {
- if(!$(selectedData[i]).is(':disabled')){
- var dd = '';
- studentName = $(selectedData[i]).parent().text();
- studentClass = $(selectedData[i]).parents('li').children('span.student').text();
- studentClassId = $(selectedData[i]).parents('li').children('span.student').attr('class-id');
- dd = studentName+'#'+selectedData[i].value+'#'+studentClass+'#'+studentClassId;
- selectedDataList.push('<li student-info="'+dd+'">' + studentName + '--' + studentClass + '<i class="btn-delete" value="' + selectedData[i].value + '">X</i></li>');
- }else{
- disabled++;
- }
- }
- $('.student-selected').html(selectedDataList);
- $('#studentSelectedLength').text(selectedData.length-disabled);
- };
- });
- </script>
- </body>
- </html>
|