贾小兵 1 неделя назад
Родитель
Сommit
b280433184

+ 10 - 9
application/admin/controller/student/Exercise.php

@@ -52,7 +52,7 @@ class Exercise extends Backend
             return $this->view->fetch();
         }
         if ($this->request->isPost()) {
-            $params = $this->request->post('row/a');
+            $params = $this->request->post();
             $count = 0;
             Db::startTrans();
             try {
@@ -63,6 +63,7 @@ class Exercise extends Backend
                 $params['limit_duration'] = 30;
                 $params['start_time'] = date('Y-m-d');
                 $params['end_time'] = date('Y-m-d');
+
                 $exam_id = $this->model->insertGetId($params);
                 
                 $sim = Db::name('sim')->where('sim_type',$params['sim_type'])->where('seat_id',$this->auth->seat_id)->find();
@@ -127,6 +128,14 @@ class Exercise extends Backend
                 $this->error($e->getMessage());
             }
             if ($count) {
+                //先请求接口判断,再进行处理
+                if(Env::get('app.is_fault')){
+                    $url = config('site.url_type').'/sim/real-exam/student/self-exercise/start/'.$count;
+                    $ret = json_decode(send_get($url),true);
+                    if($ret['code']!=200){
+                        $this->error($ret['msg']);
+                    }
+                }
                 $this->success('开始成功','/admin/student/exercise/examing/ids/'.$count);
             }
             $this->error(__('No rows were updated'));
@@ -139,14 +148,6 @@ class Exercise extends Backend
         if(!$row){
             $this->error('未找到记录');
         }
-        //先请求接口判断,再进行处理
-        if(Env::get('app.is_fault') && $row->exam_status==0){
-            $url = config('site.url_type').'/sim/real-exam/student/self-exercise/start/'.$ids;
-            $ret = json_decode(send_get($url),true);
-            if($ret['code']!=200){
-                $this->error($ret['msg']);
-            }
-        }
                 
         if ($this->request->isPost()) {
 

+ 5 - 2
application/admin/view/student/exercise/index.html

@@ -37,6 +37,9 @@
         opacity: 0;
     }
     .panel-heading{font-size: 18px}
+    #layui-layer1{width: 200px !important}
+    .layui-layer-loading2{width: 300px !important;padding-left:40px;line-height:35px}
+
 </style>
 <div class="row animated fadeInRight">
     <div class="col-md-12">
@@ -52,7 +55,7 @@
                         <div class="row">
                             <div class="form-group col-sm-12">
                                 <label class="control-label">{:__('模拟器类型')}:</label>
-                                <select class="form-control" name="row[sim_type]" data-rule="required" style="width: 80%">
+                                <select class="form-control sim_type" name="row[sim_type]" data-rule="required" style="width: 80%">
                                     <option value="">请选择</option>
                                     {volist name="sim_sim_type" id="vo"}
                                     <option value="{$key}">{$vo}</option>
@@ -69,7 +72,7 @@
                         <div style="color: rgb(192, 74, 84)">2.合理安排时间</div>
                     </div>
                     <div class="form-group" style="text-align: center">
-                        <button type="submit" class="btn btn-info">{:__('开始练习')}</button>
+                        <button type="button" class="btn btn-info btn-startexam">{:__('开始练习')}</button>
                         <!--                            <button type="reset" class="btn btn-default">{:__('Reset')}</button>-->
                     </div>
                 </form>

+ 38 - 3
public/assets/js/backend/student/exercise.js

@@ -2,10 +2,45 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
 
     var Controller = {
         index: function () {
-            Form.api.bindevent($("form[role=form]"), function(data, ret) {
-                if(ret.code==1){
-                    Backend.api.addtabs( ret.url,'正在练习');
+            // Form.api.bindevent($("form[role=form]"), function(data, ret) {
+            //     var index =  Layer.load(2, {
+            //         shade: [0.5,'#393D49'],
+            //         content: '正在检查模拟器并下发故障,请稍后...', // 这里是加载的文字
+            //     }); 
+            //     Layer.close(index);
+            //     if(ret.code==1){
+            //         // Backend.api.addtabs( ret.url,'正在练习');
+            //     }
+            // });
+            $(document).on('click', '.btn-startexam', function () {
+                var sim_type = $(".sim_type").val();
+                if(!sim_type){
+                    Layer.alert('请先选择模拟器');
+                    return;
                 }
+                var index =  Layer.load(2, {
+                    shade: [0.5,'#393D49'],
+                    content: '正在检查模拟器并下发故障,请稍后...', // 这里是加载的文字
+                });
+                $(this).removeClass('btn-info');
+                $(this).addClass('btn-primary');
+                $.ajax({
+                    url: "student/exercise/index",
+                    type: 'post',
+                    data: {
+                        sim_type: $(".sim_type").val(),
+                    },
+                    success: function (ret) {
+                        if(ret.code==1){
+                            window.location.href = ret.url;
+                        }else{
+                            Layer.alert(ret.msg);
+                            Layer.close(index);
+                            return;
+                        }
+                    }
+                });
+                
             });
         },
         examing: function () {