소스 검색

20250227 考试追加删除学员,上下级

贾小兵 2 달 전
부모
커밋
ef81f34623

+ 2 - 2
application/admin/controller/teacher/Collection.php

@@ -54,6 +54,7 @@ class Collection extends Backend
     public function adduser($ids = null)
     {
         if (false === $this->request->isPost()) {
+            $this->assignConfig('user_ids',[]);
             return $this->view->fetch();
         }
         $params = $this->request->post('row/a');
@@ -444,8 +445,7 @@ class Collection extends Backend
 
             }
             //删除考试关联区队表 mx_real_exam_collection_dept
-            Db::name('real_exam_collection_dept')->where('exam_collection_id',$ids)->delete();
-
+            // Db::name('real_exam_collection_dept')->where('exam_collection_id',$ids)->delete();
 
             Db::commit();
         } catch (PDOException|Exception $e) {

+ 6 - 1
application/admin/model/teacher/Collection.php

@@ -27,7 +27,8 @@ class Collection extends Model
     // 追加属性
     protected $append = [
         'sim_type_text',
-        'yikao_count'
+        'yikao_count',
+        'user_count'
     ];
 
     protected static function init()
@@ -69,6 +70,10 @@ class Collection extends Model
         return Exams::where(['exam_collection_id'=>$data['exam_collection_id'],'exam_collection_type'=>3,'starttime'=>['>',0]])->count();
     }
 
+    public function getUserCountAttr($value, $data)
+    {
+        return Exams::where(['exam_collection_id'=>$data['exam_collection_id']])->count();
+    }
 
     public  function allexam()
     {

+ 20 - 2
public/assets/js/backend/teacher/collection.js

@@ -85,6 +85,12 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                                     text: '查看学员',
                                     icon: 'fa fa-eye',
                                     title: '查看学员',
+                                    visible: function (rr) {
+                                        if(rr.user_count > 0){
+                                            return true;
+                                        }
+                                        return false;
+                                    },
                                     classname: 'btn btn-warning btn-xs btn-magic btn-dialog',
                                     extend: 'data-area=\'["85%","85%"]\'',
                                     url: 'teacher/collection/viewuser',
@@ -103,6 +109,12 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                                     text: '删除学员',
                                     icon: 'fa fa-pencil',
                                     title: '删除学员',
+                                    visible: function (rr) {
+                                        if(rr.user_count > 0){
+                                            return true;
+                                        }
+                                        return false;
+                                    },
                                     classname: 'btn btn-info btn-xs btn-magic btn-dialog',
                                     extend: 'data-area=\'["75%","75%"]\'',
                                     url: 'teacher/collection/edituser',
@@ -350,8 +362,12 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                     checkboxHeader: false,
                     columns: [
                         {checkbox: true,
-                            formatter: function(value,row,index){
-                                if(Config.user_ids != undefined && Config.user_ids.indexOf(row.id)>-1){
+                            formatter: function(value,rows,index){
+                                console.log('Config.user_ids');
+                                console.log(Config.user_ids);
+                                if(Config.user_ids.length==0){
+                                    return false;
+                                }else if(Config.user_ids.indexOf(rows.id)>-1){
                                     return true;
                                 }else{
                                     return {disabled : true}
@@ -368,6 +384,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                 sub_table.on("check.bs.table uncheck.bs.table check-all.bs.table uncheck-all.bs.table post-body.bs.table", function (e) {
                     var selectedIds = Table.api.selectedids(sub_table);
                     console.log(selectedIds);
+                    $(".xueyuan_input").val(selectedIds.length);
+                    $(".xueyuan_total").html(selectedIds.length);
                     $(".depart_ids").val(selectedIds.join());
                 })
             },