Browse Source

202508120 删除训练接口

贾小兵 2 weeks ago
parent
commit
9b84a572d4

+ 40 - 32
application/admin/controller/teacher/Practice.php

@@ -270,45 +270,53 @@ class Practice extends Backend
 
     public function del($ids = null)
     {
-        if (false === $this->request->isPost()) {
-            $this->error(__("Invalid parameters"));
-        }
-        $ids = $ids ?: $this->request->post("ids");
-        if (empty($ids)) {
-            $this->error(__('Parameter %s can not be empty', 'ids'));
-        }
-        $pk = $this->model->getPk();
-        $adminIds = $this->getDataLimitAdminIds();
-        if (is_array($adminIds)) {
-            $this->model->where($this->dataLimitField, 'in', $adminIds);
-        }
-        $list = $this->model->where($pk, 'in', $ids)->select();
-
+//        if (false === $this->request->isPost()) {
+//            $this->error(__("Invalid parameters"));
+//        }
+//        $ids = $ids ?: $this->request->post("ids");
+//        if (empty($ids)) {
+//            $this->error(__('Parameter %s can not be empty', 'ids'));
+//        }
+//        $pk = $this->model->getPk();
+//        $adminIds = $this->getDataLimitAdminIds();
+//        if (is_array($adminIds)) {
+//            $this->model->where($this->dataLimitField, 'in', $adminIds);
+//        }
+//        $list = $this->model->where($pk, 'in', $ids)->select();
         $count = 0;
         Db::startTrans();
         try {
-            //删除考试集合  real_exam_collection
-            foreach ($list as $item) {
-//                if($item['yikao_count']>0){
-//                    $this->error('已有学员参加训练,无法删除');
-//                }
-                $count += $item->delete();
-            }
-            //删除学员考试 mx_real_exam
-            $exam_list = $this->exam_model->where('exam_collection_id',$ids)->select();
-            if(!empty($exam_list)){
-                foreach ($exam_list as $k=>$it)
-                {
-                    //删除学员考试故障表 mx_real_exam_fault
-                    Db::name('real_exam_fault')->where('exam_id',$it['exam_id'])->delete();
-                    $it->delete();
+            if(Env::get('app.is_fault')){
+                $url = config('site.url_type').'/sim/real-exam-collection/teacher/ref/'.$ids;
+                $ret = json_decode(send_post($url),true);
+                if($ret['code']!=200){
+                    $this->error($ret['msg']);
+                }else{
+                    $count = 1;
                 }
-
+            }else{
+                $count =1;
             }
+            //删除考试集合  real_exam_collection
+//            foreach ($list as $item) {
+////                if($item['yikao_count']>0){
+////                    $this->error('已有学员参加训练,无法删除');
+////                }
+//                $count += $item->delete();
+//            }
+//            //删除学员考试 mx_real_exam
+//            $exam_list = $this->exam_model->where('exam_collection_id',$ids)->select();
+//            if(!empty($exam_list)){
+//                foreach ($exam_list as $k=>$it)
+//                {
+//                    //删除学员考试故障表 mx_real_exam_fault
+//                    Db::name('real_exam_fault')->where('exam_id',$it['exam_id'])->delete();
+//                    $it->delete();
+//                }
+//
+//            }
             //删除考试关联区队表 mx_real_exam_collection_dept
             // Db::name('real_exam_collection_dept')->where('exam_collection_id',$ids)->delete();
-
-
             Db::commit();
         } catch (PDOException|Exception $e) {
             Db::rollback();

+ 1 - 0
public/assets/js/backend/teacher/practice.js

@@ -27,6 +27,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form','editable'], function
                 sortName: 'exam_collection_id',
                 fixedColumns: true,
                 fixedRightNumber: 1,
+                singleSelect : true,
                 searchFormVisible:true,
                 search:false,
                 showExport:false,