Procházet zdrojové kódy

20250227 添加考试集合,追加学员

贾小兵 před 2 měsíci
rodič
revize
8fc1f3eb75

+ 34 - 0
application/admin/controller/auth/Admin.php

@@ -28,6 +28,8 @@ class Admin extends Backend
     protected $childrenGroupIds = [];
     protected $childrenAdminIds = [];
 
+    protected $noNeedRight = ['admintotal'];
+
     public function _initialize()
     {
         parent::_initialize();
@@ -114,6 +116,38 @@ class Admin extends Backend
         return $this->view->fetch();
     }
 
+
+    /**
+     * 查看
+     */
+    public function admintotal()
+    {
+        //设置过滤方法
+        $this->request->filter(['strip_tags', 'trim']);
+        if ($this->request->isAjax()) {
+            //如果发送的来源是Selectpage,则转发到Selectpage
+            if ($this->request->request('keyField')) {
+                return $this->selectpage();
+            }
+            list($where, $sort, $order, $offset, $limit) = $this->buildparams();
+            $list = $this->model
+                ->where($where)
+                ->where('depart_id', '>', 0)
+                ->order($sort, $order)
+                ->paginate($limit);
+            // foreach ($list as $k => &$v) {
+            //     $v->department_name = Db::name('department')->where(['id'=>$v['depart_id']])->value('name');
+            // }
+            unset($v);
+            $result = array("total" => $list->total(), "rows" => $list->items());
+
+            return json($result);
+        }
+        return $this->view->fetch();
+    }
+
+
+
     /**
      * 添加
      */

+ 113 - 151
application/admin/controller/teacher/Collection.php

@@ -29,6 +29,8 @@ class Collection extends Backend
     protected $exam_model = null;
     protected $whereExtend = null;
 
+    protected $noNeedRight = ['adduser','edituser', 'viewuser'];
+
     public function _initialize()
     {
         parent::_initialize();
@@ -49,7 +51,7 @@ class Collection extends Backend
      * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
      */
 
-    public function add()
+    public function adduser($ids = null)
     {
         if (false === $this->request->isPost()) {
             return $this->view->fetch();
@@ -59,7 +61,7 @@ class Collection extends Backend
             $this->error(__('Parameter %s can not be empty', ''));
         }
         if(empty($params['depart_ids'])){
-            $this->error('请选择区队名称');
+            $this->error('请选择学员名称');
         }
         if(!empty($params['question_setting_method'])){
             if($params['question_setting_method']==2 && empty($params['question_ids'])){
@@ -69,174 +71,56 @@ class Collection extends Backend
                 $this->error('出题方式为任务自选,请选择任务');
             }
         }
-        $params = $this->preExcludeFields($params);
-        $result = false;
-        Db::startTrans();
-        try {
-            $depart_ids = $params['depart_ids'];
-            if($params['question_setting_method']==3 && !empty($params['fault_name'])){
-                $params['question_name'] = $params['fault_name'];
-                unset($params['fault_name']);
-            }
-            $result = $this->model->allowField(true)->save($params);
-            foreach(explode(',',$depart_ids) as $item){
-                if(!empty($item)){
-                    $arr = [
-                        'exam_collection_id' => $this->model->exam_collection_id,
-                        'dept_id' => $item,
-                        'update_time' => date('Y-m-d H:i:s'),
-                    ];
-                    Db::name('real_exam_collection_dept')->insert($arr);
-                }
-            }
-
-            //匹配的学员自动加入  mx_real_exam 考试表  总分
-            $admin_list = Db::name('admin')->where('depart_id','in',$depart_ids)->select();
-            foreach ($admin_list as $it){
-                $arr1 = [
-                    'exam_collection_id' => $this->model->exam_collection_id,
-                    'exam_collection_name' => $params['exam_collection_name'],
-                    'exam_collection_type' => $params['exam_collection_type'],
-                    'sim_type' => $params['sim_type'],
-                    'user_username' => $it['username'],
-                    'user_nickname' => $it['nickname'],
-                    'user_id' => $it['id'],
-                    'user_depart_id' => $it['depart_id'],
-                    'create_time'=>date('Y-m-d H:i:s'),
-                    'update_time' => date('Y-m-d H:i:s'),
-                ];
-                $examid = Db::name('real_exam')->insertGetId($arr1);
-                //匹配的学员自动加入  mx_real_exam_fault 考试故障关联表
-                $fault_list = Fault::where(['sim_type' => $params['sim_type'], 'fault_state' => 0,'fault_type'=>3])->select();
-                if($params['question_setting_method']==1){ //系统随机
-                    // $fault_key = $this->rand_fault($fault_list);
-                    if($params['sim_type']=='0002'){
-                        $fault_key1 = rand(0, 1);
-                        $fault_key2 = 4;
-                        $fault_key3 = rand(10,11);
-                    }else{
-                        $fault_key1 = rand(0, 1);
-                        $fault_key2 = rand(2, 3);
-                        $fault_key3 = rand(4, 5);
-                    }
-                    $fault_key = [$fault_key1,$fault_key2,$fault_key3];
-                }else if($params['question_setting_method']==2){//教师自选
-                    $question_ids = $params['question_ids'];
-                }else if($params['question_setting_method']==3){ //任务自选
-                    $task_ids = Db::name('task_fault')->where(['task_id'=>['in',$params['task_id']]])->column('fault_id');
-                }
-                foreach ($fault_list as $key=> $item1){
-                    $flag = 0;
-                    if(!empty($fault_key) && in_array($key,$fault_key)){
-                        $flag = 1;
-                    }
-                    if(!empty($question_ids) && in_array($item1['fault_id'],explode(',',$question_ids))){
-                        $flag = 1;
-                    }
-                    if(!empty($task_ids) && in_array($item1['fault_id'],$task_ids)){
-                        $flag = 1;
-                    }
-                    $add= [
-                        'exam_id'=>$examid,
-                        'fault_id'=>$item1['fault_id'],
-                        'ref_type'=>2,
-                        'flag'=>$flag,
-                        'ref_state'=>0,
-                        'createtime'=>time(),
-                        'updatetime'=>time(),
-                        'create_time'=>date('Y-m-d H:i:s'),
-                        'update_time'=>date('Y-m-d H:i:s'),
-                    ];
-                    Db::name('real_exam_fault')->insert($add);
-                }
-                unset($item1);
-
-            }
-
-            Db::commit();
-        } catch (ValidateException|PDOException|Exception $e) {
-            Db::rollback();
-            $this->error($e->getMessage());
-        }
-        if ($result === false) {
-            $this->error(__('No rows were inserted'));
+        $depart_ids = $params['depart_ids'];
+        //先判断是否已经存在
+        $isset_exam = $this->exam_model->where(['user_id'=>['in',$depart_ids],'exam_collection_id'=>$ids])->find();
+        if(!empty($isset_exam)){
+            $this->error('添加的人员已存在该考试中,请重新选择');
         }
-        $this->success();
-    }
-
-    public function edit($ids = null)
-    {
         $row = $this->model->get($ids);
-        if (!$row) {
-            $this->error(__('No Results were found'));
-        }
-        if (false === $this->request->isPost()) {
-//            $examing_count = $this->exam_model->where(['exam_collection_id'=>$ids,'exam_status'=>4])->count();
-//            if($examing_count>0){
-//                $this->error('有学员考试中,无法修改');
-//            }
-            $this->view->assign('row', $row);
-            $this->assignConfig('row_info', $row);
-            return $this->view->fetch();
-        }
-        $params = $this->request->post('row/a');
-        if (empty($params)) {
-            $this->error(__('Parameter %s can not be empty', ''));
-        }
-        if(!empty($params['question_setting_method'])){
-            if($params['question_setting_method']==2 && empty($params['question_ids'])){
-                $this->error('出题方式为考题自选,请选择考题');
-            }
-            if($params['question_setting_method']==3 && empty($params['task_id'])){
-                $this->error('出题方式为任务自选,请选择任务');
-            }
-        }
         $params = $this->preExcludeFields($params);
         $result = false;
         Db::startTrans();
         try {
-            $depart_ids = $params['depart_ids'];
+            
             if($params['question_setting_method']==3 && !empty($params['fault_name'])){
                 $params['question_name'] = $params['fault_name'];
                 unset($params['fault_name']);
             }
-            $result = $row->allowField(true)->save($params);
+            // $result = $this->model->allowField(true)->save($params);
+            
+            $row->xueyuan_count = $row->xueyuan_count+$params['xueyuan_count'];
+            $row->save();
 
-            Db::name('real_exam_collection_dept')->where(['exam_collection_id'=>$row->exam_collection_id])->delete();
             foreach(explode(',',$depart_ids) as $item){
                 if(!empty($item)){
+                    $admin = Db::name('admin')->where('id',$item)->find();
                     $arr = [
-                        'exam_collection_id' => $row->exam_collection_id,
-                        'dept_id' => $item,
-                        'update_time' => date('Y-m-d H:i:s'),
-                    ];
-                    Db::name('real_exam_collection_dept')->insert($arr);
-                }
-            }
-
-            Db::name('real_exam')->where(['exam_collection_id'=>$row->exam_collection_id,'starttime'=>0])->delete();
-            //匹配的学员自动加入  mx_real_exam 考试表  总分
-            $admin_list = Db::name('admin')->where('depart_id','in',$depart_ids)->select();
-            foreach ($admin_list as $it){
-                $real_exam = Db::name('real_exam')->where(['exam_collection_id'=>$row->exam_collection_id,'user_id'=>$it['id']])->find();
-                if(empty($real_exam)){
-                    $arr1 = [
-                        'exam_collection_id' => $row->exam_collection_id,
-                        'exam_collection_name' => $params['exam_collection_name'],
+                        'exam_collection_id' => $ids,
+                        'exam_collection_name' => $row->exam_collection_name,
+                        'question_setting_method' => $params['question_setting_method'],
                         'exam_collection_type' => $row['exam_collection_type'],
                         'sim_type' => $params['sim_type'],
-                        'user_username' => $it['username'],
-                        'user_nickname' => $it['nickname'],
-                        'user_id' => $it['id'],
-                        'user_depart_id' => $it['depart_id'],
-                        'create_time'=>date('Y-m-d H:i:s'),
+                        'user_username' => $admin['username'],
+                        'user_nickname' => $admin['nickname'],
+                        'user_id' => $item,
+                        'seat_id'=>0,
+                        'task_id'=>$params['task_id'],
+                        'question_ids'=>$params['question_ids'],
+                        'question_name'=>$params['question_name'],
+                        'user_depart_id' => $admin['depart_id'],
+                        'createtime'=>time(),
+                        'updatetime'=>time(),
+                        'create_time' => date('Y-m-d H:i:s'),
                         'update_time' => date('Y-m-d H:i:s'),
                     ];
-                    $examid = Db::name('real_exam')->insertGetId($arr1);
+                    $examid = $this->exam_model->insertGetId($arr);
+
+                    
+
                     //匹配的学员自动加入  mx_real_exam_fault 考试故障关联表
                     $fault_list = Fault::where(['sim_type' => $params['sim_type'], 'fault_state' => 0,'fault_type'=>3])->select();
                     if($params['question_setting_method']==1){ //系统随机
-                        // $fault_key = $this->rand_fault($fault_list);
                         if($params['sim_type']=='0002'){
                             $fault_key1 = rand(0, 1);
                             $fault_key2 = 4;
@@ -252,8 +136,6 @@ class Collection extends Backend
                     }else if($params['question_setting_method']==3){ //任务自选
                         $task_ids = Db::name('task_fault')->where(['task_id'=>['in',$params['task_id']]])->column('fault_id');
                     }
-                    Db::name('real_exam_fault')->where(['exam_id'=>$examid])->delete();
-
                     foreach ($fault_list as $key=> $item1){
                         $flag = 0;
                         if(!empty($fault_key) && in_array($key,$fault_key)){
@@ -281,6 +163,64 @@ class Collection extends Backend
                     unset($item1);
                 }
             }
+            $result = true;
+            Db::commit();
+        } catch (ValidateException|PDOException|Exception $e) {
+            Db::rollback();
+            $this->error($e->getMessage());
+        }
+        if ($result === false) {
+            $this->error(__('No rows were inserted'));
+        }
+        $this->success();
+    }
+
+    public function edituser($ids = null)
+    {
+        $row = $this->model->get($ids);
+        if (!$row) {
+            $this->error(__('No Results were found'));
+        }
+        //获取当前考试的全部用户id
+        $user_ids = $this->exam_model->where(['exam_collection_id'=>$ids])->column('user_id');
+        if (false === $this->request->isPost()) {
+            $this->view->assign('row', $row);
+            $this->view->assign('user_ids',implode(',', $user_ids));
+            $this->assignConfig('user_ids', $user_ids);
+            return $this->view->fetch();
+        }
+        $params = $this->request->post('row/a');
+        if (empty($params)) {
+            $this->error(__('Parameter %s can not be empty', ''));
+        }
+        $params = $this->preExcludeFields($params);
+        $depart_id = $params['depart_id'];
+        unset($params['depart_id']);
+
+        //判断是否有已经开始考试的人员
+        $isset_exam = $this->exam_model->where(['user_id'=>['in',$depart_id],'exam_collection_id'=>$ids,'exam_status'=>4])->find();
+        if(!empty($isset_exam)){
+            $this->error('删除的人员已再考试中,请重新选择');
+        }
+        $depart_count = count(explode(',', $depart_id));
+        $result = false;
+        Db::startTrans();
+        try {
+            if(!empty($depart_id)){ 
+                $params['xueyuan_count'] = $row->xueyuan_count-$depart_count??0;
+                $result = $row->allowField(true)->save($params);
+
+                foreach(explode(',',$depart_id) as $item){
+                    if(!empty($item)){
+                        $exam =  $this->exam_model->where(['exam_collection_id'=>$ids,'user_id'=>$item])->find();
+                        //删除real_exam 的人员
+                        $this->exam_model->where(['exam_collection_id'=>$ids,'user_id'=>$item])->delete();
+                        //删除real_exam_fault 的故障内容
+                        Db::name('real_exam_fault')->where(['exam_id'=>$exam['exam_id']])->delete();
+                    }
+                }
+            }
+            $result = true; 
             Db::commit();
         } catch (ValidateException|PDOException|Exception $e) {
             Db::rollback();
@@ -292,6 +232,28 @@ class Collection extends Backend
         $this->success();
     }
 
+    //查看学员
+    public function viewuser($ids= null)
+    {
+        //设置过滤方法
+        $this->request->filter(['strip_tags', 'trim']);
+        if (false === $this->request->isAjax()) {
+            $this->assignConfig('ids', $ids);
+            return $this->view->fetch();
+        }
+        //如果发送的来源是 Selectpage,则转发到 Selectpage
+        if ($this->request->request('keyField')) {
+            return $this->selectpage();
+        }
+        [$where, $sort, $order, $offset, $limit] = $this->buildparams();
+        $list = $this->exam_model->where($where)->where('exam_collection_id',$ids)
+            ->order($sort, $order)
+            ->paginate($limit);
+        unset($v);
+        $result = ['total' => $list->total(), 'rows' => $list->items()];
+        return json($result);
+    }
+
 
     public function multi($ids = null)
     {

+ 30 - 1
application/admin/model/Admin.php

@@ -5,6 +5,7 @@ namespace app\admin\model;
 use think\Model;
 use think\Session;
 use traits\model\SoftDelete;
+use app\admin\model\department\Department;
 
 class Admin extends Model
 {
@@ -18,7 +19,12 @@ class Admin extends Model
     protected $deleteTime = 'deletetime';
     protected $hidden = [
         'password',
-        'salt'
+        'salt',
+    ];
+
+    // 追加属性
+    protected $append = [
+        'department_text'
     ];
 
     public static function init()
@@ -32,4 +38,27 @@ class Admin extends Model
         });
     }
 
+    public function getDepartmentTextAttr($value, $data){
+        $text = '';
+        if(!empty($data['depart_id'])){
+            $qudui = Department::where(['id'=>$data['depart_id']])->find();
+            if(!empty($qudui['parent_id'])){
+                $dui= Department::where(['id'=>$qudui['parent_id']])->find();
+                if(!empty($dui['parent_id'])){
+                    $ji = Department::where(['id'=>$dui['parent_id']])->find();
+                    if(!empty($ji['parent_id'])){
+                        $zhuanye = Department::where(['id'=>$ji['parent_id']])->find();
+                        if(!empty($zhuanye['parent_id'])){
+                            $parent = Department::where(['id'=>$zhuanye['parent_id']])->find();
+
+                            $text = $parent['name'].">>>".$zhuanye['name'].">>>".$ji['name'].">>>".$dui['name'].">>>".$qudui['name'];
+                        }
+                    }
+                }
+            }
+        }
+        return $text;
+    }
+
+
 }

+ 3 - 68
application/admin/view/teacher/collection/add.html

@@ -4,29 +4,15 @@
         <input class="form-control" name="row[exam_collection_type]" type="hidden" value="3">
         <input class="form-control" name="row[create_user_id]" type="hidden" value="{$auth->id}">
         <input class="form-control" name="row[create_by]" type="hidden" value="{$auth->nickname}">
-        <input class="form-control depart_ids" name="row[depart_ids]" type="hidden" value="">
-        <input class="form-control question_ids" name="row[question_ids]" type="hidden" value="0">
-        <input class="form-control task_id" name="row[task_id]" type="hidden" value="0">
 
-        <div class="form-group col-sm-6">
+        <div class="form-group col-sm-12">
             <label class="control-label col-xs-12 col-sm-3 addRedStar">{:__('Exam_collection_name')}:</label>
             <div class="col-xs-12 col-sm-7">
                 <input id="c-exam_collection_name" data-rule="required" class="form-control" name="row[exam_collection_name]" type="text">
             </div>
         </div>
-        <div class="form-group col-sm-6">
-            <label class="control-label col-xs-12 col-sm-3 addRedStar">{:__('Sim_type')}:</label>
-            <div class="col-xs-12 col-sm-7">
-                <select id="c-sim_type" data-rule="required" class="form-control" name="row[sim_type]">
-                    <option value="">请选择</option>
-                    {foreach name="sim_sim_type" item="vo"}
-                    <option value="{$key}" >{$vo}</option>
-                    {/foreach}
-                </select>
-            </div>
-        </div>
 
-        <div class="form-group col-sm-6">
+        <div class="form-group col-sm-12">
             <label class="control-label col-xs-12 col-sm-3 addRedStar">{:__('Limit_duration')}:</label>
             <div class="col-xs-12 col-sm-7">
                 <div class="input-group input-groupp-sm">
@@ -36,60 +22,9 @@
             </div>
         </div>
 
-        <div class="form-group col-sm-6">
-            <label class="control-label col-xs-12 col-sm-3 addRedStar">{:__('Question_setting_method')}:</label>
-            <div class="col-xs-12 col-sm-7">
-                <select id="c-question_setting_method" data-rule="required" class="form-control" name="row[question_setting_method]">
-                    <option value="">请选择</option>
-                    {foreach name="sim_question_setting_method" item="vo"}
-                    <option value="{$key}" >{$vo}</option>
-                    {/foreach}
-                </select>
-            </div>
-            <div class="btn btn-info btn-sm" style="display: none">自选考题编辑</div>
-            <div class="btn btn-info btn-task" style="display: none">自选任务编辑</div>
-        </div>
-
-        <div class="form-group col-sm-6 tasks" style="display:none;left: 48%">
-            <label class="control-label col-xs-12 col-sm-3 addRedStar">{:__('故障题目')}:</label>
-            <div class="col-xs-12 col-sm-7">
-                <input id="c-task_name" readonly class="form-control" name="row[task_name]" type="hidden">
-                <input id="c-fault_name" readonly class="form-control" name="row[fault_name]" type="text">
-            </div>
-        </div>
-
-        <div class="form-group col-sm-6 questions" style="display:none;left: 48%">
-            <label class="control-label col-xs-12 col-sm-3 addRedStar">{:__('故障名称')}:</label>
-            <div class="col-xs-12 col-sm-7">
-                <input id="c-question_name" readonly  class="form-control" name="row[question_name]" type="text">
-            </div>
-        </div>
-
-    </div>
-    <div class="panel panel-default panel-intro">
-        <div class="panel-body">
-            <div class="tableTitle success" style="font-size: 16px;margin: 10px 0">统计情况</div>
-            <div class="panel-success">
-                <div>本次考试区队数量:<span class="qudui_total">0</span><input type="hidden" name="row[qudui_count]" value="0" class="qudui_input" />‌</div>
-                <div>计划参加考试学员数量:<span class="xueyuan_total">0</span><input type="hidden" name="row[xueyuan_count]" value="0" class="xueyuan_input" /></div>
-            </div>
-            <div id="myTabContent" class="tab-content">
-                <div class="tab-pane fade active in" id="one">
-                    <div class="widget-body no-padding">
-                        <div id="toolbar" class="toolbar">
-                            {:build_toolbar('refresh')}
-                        </div>
-                        <table id="table1" class="table table-striped table-bordered table-hover table-nowrap"
-                               data-operate-edit="{:$auth->check('category/edit')}"
-                               data-operate-del="{:$auth->check('category/del')}" data-show-export="false" data-search="false"
-                               width="100%">
-                        </table>
-                    </div>
-                </div>
-            </div>
-        </div>
     </div>
 
+
     <div class="form-group layer-footer">
         <label class="control-label col-xs-12 col-sm-2"></label>
         <div class="col-xs-12 col-sm-8">

+ 81 - 0
application/admin/view/teacher/collection/adduser.html

@@ -0,0 +1,81 @@
+<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
+    <div class="row">
+
+        <input class="form-control depart_ids" name="row[depart_ids]" type="hidden" value="">
+        <input class="form-control question_ids" name="row[question_ids]" type="hidden" value="0">
+        <input class="form-control task_id" name="row[task_id]" type="hidden" value="0">
+
+        <div class="form-group col-sm-6">
+            <label class="control-label col-xs-12 col-sm-3 addRedStar">{:__('Sim_type')}:</label>
+            <div class="col-xs-12 col-sm-7">
+                <select id="c-sim_type" data-rule="required" class="form-control" name="row[sim_type]">
+                    <option value="">请选择</option>
+                    {foreach name="sim_sim_type" item="vo"}
+                    <option value="{$key}" >{$vo}</option>
+                    {/foreach}
+                </select>
+            </div>
+        </div>
+
+        <div class="form-group col-sm-6">
+            <label class="control-label col-xs-12 col-sm-3 addRedStar">{:__('Question_setting_method')}:</label>
+            <div class="col-xs-12 col-sm-7">
+                <select id="c-question_setting_method" data-rule="required" class="form-control" name="row[question_setting_method]">
+                    <option value="">请选择</option>
+                    {foreach name="sim_question_setting_method" item="vo"}
+                    <option value="{$key}" >{$vo}</option>
+                    {/foreach}
+                </select>
+            </div>
+            <div class="btn btn-info btn-sm" style="display: none">自选考题编辑</div>
+            <div class="btn btn-info btn-task" style="display: none">自选任务编辑</div>
+        </div>
+
+        <div class="form-group col-sm-6 tasks" style="display:none;left: 48%">
+            <label class="control-label col-xs-12 col-sm-3 addRedStar">{:__('故障题目')}:</label>
+            <div class="col-xs-12 col-sm-7">
+                <input id="c-task_name" readonly class="form-control" name="row[task_name]" type="hidden">
+                <input id="c-fault_name" readonly class="form-control" name="row[fault_name]" type="text">
+            </div>
+        </div>
+
+        <div class="form-group col-sm-6 questions" style="display:none;left: 48%">
+            <label class="control-label col-xs-12 col-sm-3 addRedStar">{:__('故障名称')}:</label>
+            <div class="col-xs-12 col-sm-7">
+                <input id="c-question_name" readonly  class="form-control" name="row[question_name]" type="text">
+            </div>
+        </div>
+
+    </div>
+    <div class="panel panel-default panel-intro">
+        <div class="panel-body">
+            <div class="tableTitle success" style="font-size: 16px;margin: 10px 0">统计情况</div>
+            <div class="panel-success">
+                <div>计划参加考试学员数量:<span class="xueyuan_total">0</span>
+                    <input type="hidden" name="row[xueyuan_count]" value="0" class="xueyuan_input" />
+                </div>
+            </div>
+            <div id="myTabContent" class="tab-content">
+                <div class="tab-pane fade active in" id="one">
+                    <div class="widget-body no-padding">
+                        <div id="toolbar" class="toolbar">
+                            {:build_toolbar('refresh')}
+                        </div>
+                        <table id="table1" class="table table-striped table-bordered table-hover table-nowrap"
+                               data-operate-edit="{:$auth->check('category/edit')}"
+                               data-operate-del="{:$auth->check('category/del')}" data-show-export="false" data-search="false"
+                               width="100%">
+                        </table>
+                    </div>
+                </div>
+            </div>
+        </div>
+    </div>
+
+    <div class="form-group layer-footer">
+        <label class="control-label col-xs-12 col-sm-2"></label>
+        <div class="col-xs-12 col-sm-8">
+            <button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
+        </div>
+    </div>
+</form>

+ 3 - 69
application/admin/view/teacher/collection/edit.html

@@ -1,27 +1,14 @@
 <form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
     <div class="row">
-        <input class="form-control depart_ids" name="row[depart_ids]" type="hidden" value="{$row.depart_ids|htmlentities}">
-        <input class="form-control question_ids" name="row[question_ids]" type="hidden" value="{$row.question_ids|htmlentities}">
-        <input class="form-control task_id" name="row[task_id]" type="hidden" value="{$row.task_id|htmlentities}">
-        <div class="form-group col-sm-6">
+        <div class="form-group col-sm-12">
             <label class="control-label col-xs-12 col-sm-3 addRedStar">{:__('Exam_collection_name')}:</label>
             <div class="col-xs-12 col-sm-7">
                 <input id="c-exam_collection_name" {if $row.starttime>0} readonly {/if} data-rule="required" class="form-control" name="row[exam_collection_name]" value="{$row.exam_collection_name|htmlentities}" type="text">
             </div>
         </div>
-        <div class="form-group col-sm-6">
-            <label class="control-label col-xs-12 col-sm-3 addRedStar">{:__('Sim_type')}:</label>
-            <div class="col-xs-12 col-sm-7">
-                <select id="c-sim_type" data-rule="required" class="form-control" name="row[sim_type]" {if $row.starttime>0} readonly {/if}>
-                    <option value="">请选择</option>
-                    {foreach name="sim_sim_type" item="vo"}
-                    <option value="{$key}" {if $row.sim_type eq $key} selected {/if} >{$vo}</option>
-                    {/foreach}
-                </select>
-            </div>
-        </div>
 
-        <div class="form-group col-sm-6">
+
+        <div class="form-group col-sm-12">
             <label class="control-label col-xs-12 col-sm-3 addRedStar">{:__('Limit_duration')}:</label>
             <div class="col-xs-12 col-sm-7">
                 <div class="input-group input-groupp-sm">
@@ -31,59 +18,6 @@
             </div>
         </div>
 
-        <div class="form-group col-sm-6">
-            <label class="control-label col-xs-12 col-sm-3 addRedStar">{:__('Question_setting_method')}:</label>
-            <div class="col-xs-12 col-sm-7">
-                <select id="c-question_setting_method" data-rule="required" class="form-control" name="row[question_setting_method]" {if $row.starttime>0} readonly {/if}>
-                    <option value="">请选择</option>
-                    {foreach name="sim_question_setting_method" item="vo"}
-                    <option value="{$key}" {if $row.question_setting_method eq $key} selected {/if}>{$vo}</option>
-                    {/foreach}
-                </select>
-            </div>
-            <div class="btn btn-info btn-sm" {if $row.question_setting_method neq 2}style="display: none"{/if} >自选考题编辑</div>
-            <div class="btn btn-info btn-task" {if $row.question_setting_method neq 3}style="display: none"{/if} >自选任务编辑</div>
-        </div>
-
-        <div class="form-group col-sm-6 questions" {if $row.question_setting_method neq 2}style="display: none" {else} style="left: 48%" {/if}>
-            <label class="control-label col-xs-12 col-sm-3 addRedStar">{:__('故障名称')}:</label>
-            <div class="col-xs-12 col-sm-7">
-                <input id="c-question_name" readonly  class="form-control" name="row[question_name]" type="text" value="{$row.question_name|htmlentities}">
-            </div>
-        </div>
-
-        <div class="form-group col-sm-6 tasks" {if $row.question_setting_method neq 3}style="display:none;" {else} style="left: 48%"  {/if}>
-            <label class="control-label col-xs-12 col-sm-3 addRedStar">{:__('故障题目')}:</label>
-            <div class="col-xs-12 col-sm-7">
-                <input id="c-task_name" readonly class="form-control" name="row[task_name]" type="hidden"  value="{$row.task_name|htmlentities}">
-                <input id="c-fault_name" readonly class="form-control" name="row[fault_name]" type="text"  value="{$row.question_name|htmlentities}">
-            </div>
-        </div>
-
-    </div>
-    <div class="panel panel-default panel-intro">
-        <div class="panel-body">
-            <div class="tableTitle success" style="font-size: 16px;margin: 10px 0">统计情况</div>
-            <div class="panel-success">
-                <div>本次考试区队数量:<span class="qudui_total">0</span><input type="hidden" name="row[qudui_count]" value="0" class="qudui_input" />‌</div>
-                <div>计划参加考试学员数量:<span class="xueyuan_total">0</span><input type="hidden" name="row[xueyuan_count]" value="0" class="xueyuan_input" /></div>
-            </div>
-            <div id="myTabContent" class="tab-content">
-                <div class="tab-pane fade active in" id="one">
-                    <div class="widget-body no-padding">
-                        <div id="toolbar" class="toolbar">
-                            {:build_toolbar('refresh')}
-                        </div>
-                        <table id="table1" class="table table-striped table-bordered table-hover table-nowrap"
-                               data-operate-edit="{:$auth->check('category/edit')}"
-                               data-operate-del="{:$auth->check('category/del')}" data-show-export="false" data-search="false"
-                               width="100%">
-                        </table>
-                    </div>
-                </div>
-
-            </div>
-        </div>
     </div>
 
     <div class="form-group layer-footer">

+ 37 - 0
application/admin/view/teacher/collection/edituser.html

@@ -0,0 +1,37 @@
+<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
+    <div class="panel panel-default panel-intro">
+        <div class="panel-body">
+            <input class="form-control depart_id" name="row[depart_id]" type="hidden" value="">
+
+            <div class="tableTitle success" style="font-size: 16px;margin: 10px 0">情况说明</div>
+            <div class="panel-danger">
+                <span class="text text-danger">将需要删除的学员直接去掉选中,这里仅支持删除学员</span><br/>
+                <span class="text text-danger"></span>
+            </div>
+            <div class="panel-success">
+                <div>计划参加考试学员数量:<span class="xueyuan_total">{$row.xueyuan_count}</span></div>
+            </div>
+            <div id="myTabContent" class="tab-content">
+                <div class="tab-pane fade active in" id="one">
+                    <div class="widget-body no-padding">
+                        <div id="toolbar" class="toolbar">
+                            {:build_toolbar('refresh')}
+                        </div>
+                        <table id="table1" class="table table-striped table-bordered table-hover table-nowrap"
+                               data-operate-edit="{:$auth->check('category/edit')}"
+                               data-operate-del="{:$auth->check('category/del')}" data-show-export="false" data-search="false"
+                               width="100%">
+                        </table>
+                    </div>
+                </div>
+            </div>
+        </div>
+    </div>
+
+    <div class="form-group layer-footer">
+        <label class="control-label col-xs-12 col-sm-2"></label>
+        <div class="col-xs-12 col-sm-8">
+            <button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
+        </div>
+    </div>
+</form>

+ 22 - 0
application/admin/view/teacher/collection/viewuser.html

@@ -0,0 +1,22 @@
+<div class="panel panel-default panel-intro">
+    {:build_heading()}
+
+    <div class="panel-body">
+        <div id="myTabContent" class="tab-content">
+            <div class="tab-pane fade active in" id="one">
+                <div class="widget-body no-padding">
+                    <div id="toolbar" class="toolbar">
+                        <a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
+
+                    </div>
+                    <table id="table" class="table table-striped table-bordered table-hover table-nowrap"
+                           data-operate-edit="{:$auth->check('teacher/collection/edit')}"
+                           data-operate-del="{:$auth->check('teacher/collection/del')}"
+                           width="100%">
+                    </table>
+                </div>
+            </div>
+
+        </div>
+    </div>
+</div>

+ 167 - 68
public/assets/js/backend/teacher/collection.js

@@ -1,8 +1,6 @@
 define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
     var Controller = {
         index: function () {
-            $('.btn-add').data('area',['85%','85%']);
-            $('.btn-edit').data('area',['85%','85%']);
             // 初始化表格参数配置
             Table.api.init({
                 extend: {
@@ -32,8 +30,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                         {checkbox: true},
                         {field: 'exam_collection_id', title: __('编号'),operate: false},
                         {field: 'exam_collection_name', title: __('Exam_collection_name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
-                        {field: 'sim_type', title: __('Sim_type'),searchList:{"0001":"FZD04B型侦毒器","0002":"FZB006型毒剂报警器","0003":"防化兵用毒剂报警器"},formatter: Table.api.formatter.simtype},
-                        {field: 'question_setting_method', title: __('Question_setting_method'),searchList:{"1":"系统随机","2":"教师自选","3":"任务自选"},formatter: Table.api.formatter.simmethod},
+                        // {field: 'sim_type', title: __('Sim_type'),searchList:{"0001":"FZD04B型侦毒器","0002":"FZB006型毒剂报警器","0003":"防化兵用毒剂报警器"},formatter: Table.api.formatter.simtype},
+                        // {field: 'question_setting_method', title: __('Question_setting_method'),searchList:{"1":"系统随机","2":"教师自选","3":"任务自选"},formatter: Table.api.formatter.simmethod},
                         {
                             field: 'exam_collection_state',searchList:{"2":"打开","3":"关闭"},
                             title: __('Exam_collection_state'),
@@ -48,7 +46,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                         // {field: 'end_time', title: __('End_time'), operate:false, addclass:'datetimerange', autocomplete:false},
                         // {field: 'create_user_id', title: __('Create_user_id')},
                         {field: 'create_by', title: __('Create_by'), operate: 'LIKE'},
-                        {field: 'qudui_count', title: __('区队数量'), operate: false},
+                        // {field: 'qudui_count', title: __('区队数量'), operate: false},
                         {field: 'xueyuan_count', title: __('应考人数'), operate: false},
                         {field: 'yikao_count', title: __('已考人数'), operate: false},
                         {field: 'createtime', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false,formatter: Table.api.formatter.datetime},
@@ -65,7 +63,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                                     icon: 'fa fa-pencil',
                                     title: '编辑',
                                     classname: 'btn btn-success btn-xs btn-magic btn-dialog',
-                                    extend: 'data-area=\'["85%","85%"]\'',
+                                    // extend: 'data-area=\'["85%","85%"]\'',
                                     url: 'teacher/collection/edit',
                                 },
                                 {
@@ -84,6 +82,33 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                                 },
                                 {
                                     name: 'dispatch',
+                                    text: '查看学员',
+                                    icon: 'fa fa-eye',
+                                    title: '查看学员',
+                                    classname: 'btn btn-warning btn-xs btn-magic btn-dialog',
+                                    extend: 'data-area=\'["85%","85%"]\'',
+                                    url: 'teacher/collection/viewuser',
+                                },
+                                {
+                                    name: 'dispatch',
+                                    text: '添加学员',
+                                    icon: 'fa fa-plus',
+                                    title: '添加学员',
+                                    classname: 'btn btn-success btn-xs btn-magic btn-dialog',
+                                    extend: 'data-area=\'["85%","85%"]\'',
+                                    url: 'teacher/collection/adduser',
+                                },
+                                {
+                                    name: 'dispatch',
+                                    text: '删除学员',
+                                    icon: 'fa fa-pencil',
+                                    title: '删除学员',
+                                    classname: 'btn btn-info btn-xs btn-magic btn-dialog',
+                                    extend: 'data-area=\'["75%","75%"]\'',
+                                    url: 'teacher/collection/edituser',
+                                },
+                                {
+                                    name: 'dispatch',
                                     text: '删除',
                                     icon: 'fa fa-trash',
                                     title: '删除',
@@ -119,6 +144,54 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                 });
             });
         },
+
+        viewuser: function () {
+            // 初始化表格参数配置
+            Table.api.init({
+                extend: {
+                    index_url: 'teacher/collection/viewuser/ids/' +Config.ids+ location.search,
+                }
+            });
+
+            var table = $("#table");
+            var multiple = true;
+            // 初始化表格
+            table.bootstrapTable({
+                url: $.fn.bootstrapTable.defaults.extend.index_url,
+                pk: 'task_id',
+                sortName: 'task_id',
+                fixedColumns: true,
+                fixedRightNumber: 1,
+                singleSelect : true,
+                searchFormVisible:true,
+                search: false,
+                columns: [
+                    [
+                        // {checkbox: true},
+                        // {field: 'task_id', title: __('Task_id'),operate: false},
+                        {field: 'user_nickname', title: __('学员'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
+                        {field: 'sim_type', title: __('Sim_type'),searchList:{"0001":"FZD04B型侦毒器","0002":"FZB006型毒剂报警器","0003":"防化兵用毒剂报警器"},formatter: Table.api.formatter.simtype},
+                        {field: 'question_setting_method', title: __('Question_setting_method'),searchList:{"1":"系统随机","2":"教师自选","3":"任务自选"},formatter: Table.api.formatter.simmethod},
+                        {field: 'fault_names', title: __('故障内容'),formatter: Table.api.formatter.faultname,operate: false},
+                        {field: 'createtime', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false,formatter: Table.api.formatter.datetime},
+                        // {
+                        //     field: 'operate', title: __('Operate'), width: 85, events: {
+                        //         'click .btn-chooseone': function (e, value, row, index) {
+                        //             Fast.api.close({url: row.url, multiple: multiple,task_id:row.task_id,task_name:row.name,fault_name:row.fault_name});
+                        //         },
+                        //     }, formatter: function () {
+                        //         return '<a href="javascript:;" class="btn btn-danger btn-chooseone btn-xs"><i class="fa fa-check"></i> ' + __('Choose') + '</a>';
+                        //     }
+                        // }
+                    ]
+                ]
+            });
+            // 为表格绑定事件
+            Table.api.bindevent(table);
+        },
+
+
+
         task: function () {
             // 初始化表格参数配置
             Table.api.init({
@@ -245,19 +318,29 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
             $("button[name=commonSearch]").css('display','none');
         },
         add: function () {
+            Controller.api.bindevent1();
+        },
+        adduser: function () {
+            Controller.api.bindevent2();
+        },
+        edituser: function () {
             Controller.api.bindevent();
         },
         edit: function () {
-            Controller.api.bindevent();
+            Controller.api.bindevent1();
         },
         api: {
-            bindevent: function () {
+            bindevent1: function () {
+                Form.api.bindevent($("form[role=form]"));
+            },
+            bindevent2: function () {
                 var rel_Ids = [];
                 var qudui_total = 0;
                 var xueyuan_total = 0;
                 Table.api.init({
                     extend: {
-                        index_url: 'department/admin/departadmintotal' + location.search,
+                        // index_url: 'department/admin/departadmintotal' + location.search,
+                        index_url: 'auth/admin/admintotal' + location.search,
                     }
                 });
                 var table = $("#table1");
@@ -269,47 +352,40 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                     fixedColumns: true,
                     fixedRightNumber: 1,
                     searchFormVisible:false,
-                    pagination:false,
+                    // pagination:false,
                     Search:false,
                     columns: [
                         [
                             {checkbox: true,
                                 formatter: function(value,row,index){
-                                    // console.log(row.id+'####'+Config.row_info.depart_ids)
-                                    if(Config.row_info != undefined && Config.row_info.depart_ids.indexOf(row.id)>-1){
+                                    if(Config.user_ids != undefined && Config.user_ids.indexOf(row.id)>-1){
                                         rel_Ids.push(row.id);
                                         return true;
                                     }
                                     return false;
                                 }
                             },
-                            {field: 'department_name', title: __('区队名称'), operate: false,width: '400px', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
-                            {field: 'department_admin_count', title: __('全部人员数量'),operate: false},
+                            {field: 'department_text', title: __('区队名称'), operate: false,width: '400px', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
+                            {field: 'nickname', title: __('姓名'),operate: false},
                         ]
                     ],
                     onLoadSuccess: function(data) {
                         $.each(data.rows, function(index, row) {
-                            if(Config.row_info != undefined && Config.row_info.depart_ids.indexOf(row.id)>-1){
-                                qudui_total = qudui_total+1;
-                                xueyuan_total = xueyuan_total+row.department_admin_count;
+                            if(Config.user_ids != undefined && Config.user_ids.indexOf(row.id)>-1){
+                                xueyuan_total = xueyuan_total+1;
                             }
 
                         });
-                        $(".qudui_total").html(qudui_total);
                         $(".xueyuan_total").html(xueyuan_total);
-                        $(".qudui_input").val(qudui_total);
                         $(".xueyuan_input").val(xueyuan_total);
                     },
                     // 点击每一个单选框时触发的操作
                     onCheck:function(row){
                         rel_Ids.push(row.id);
-                        qudui_total = qudui_total+1;
-                        xueyuan_total = xueyuan_total+row.department_admin_count;
+                        xueyuan_total = xueyuan_total+1;
 
                         $(".depart_ids").val(rel_Ids.join());
-                        $(".qudui_total").html(qudui_total);
                         $(".xueyuan_total").html(xueyuan_total);
-                        $(".qudui_input").val(qudui_total);
                         $(".xueyuan_input").val(xueyuan_total);
                     },
                     // 取消每一个单选框时对应的操作;
@@ -318,13 +394,10 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                         if(index > -1) {
                             rel_Ids.splice(index, 1);
                         }
-                        qudui_total = qudui_total-1;
-                        xueyuan_total = xueyuan_total-row.department_admin_count;
+                        xueyuan_total = xueyuan_total-1;
 
                         $(".depart_ids").val(rel_Ids.join());
-                        $(".qudui_total").html(qudui_total);
                         $(".xueyuan_total").html(xueyuan_total);
-                        $(".qudui_input").val(qudui_total);
                         $(".xueyuan_input").val(xueyuan_total);
                     }
                 });
@@ -332,47 +405,6 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                 // 为表格绑定事件
                 Table.api.bindevent(table);
 
-                //点击每一行
-                // table.on('click-row.bs.table', function (e, row, element) {
-                //     console.log(rel_Ids)
-                //     // console.log('row')
-                //     if(!$.inArray(row.id,rel_Ids)){
-                //         if(Config.row_info.starttime>0){
-                //             Layer.alert('考试正在进行中,只可增加区队不可取消区队');
-                //             return false;
-                //         }
-                //         arr = $.grep(rel_Ids, function(value) {
-                //             return value != row["id"];
-                //         });
-                //         rel_Ids = arr;
-                //         qudui_total = qudui_total-1;
-                //         xueyuan_total = xueyuan_total-row.department_admin_count;
-                //     }else if(rel_Ids.indexOf(row.id)>-1){
-                //         if(Config.row_info.starttime>0){
-                //             Layer.alert('考试正在进行中,只可增加区队不可取消区队');
-                //             return false;
-                //         }
-                //         var index = rel_Ids.indexOf(row.id);
-                //         if(index > -1) {
-                //             rel_Ids.splice(index, 1);
-                //         }
-                //         qudui_total = qudui_total-1;
-                //         xueyuan_total = xueyuan_total-row.department_admin_count;
-                //     }else{
-                //         qudui_total = qudui_total+1;
-                //         xueyuan_total = xueyuan_total+row.department_admin_count;
-                //         rel_Ids.push(row.id);
-                //     }
-                //     console.log(qudui_total);
-                //     console.log(xueyuan_total);
-                //     $(".depart_ids").val(rel_Ids.join());
-                //     $(".qudui_total").html(qudui_total);
-                //     $(".xueyuan_total").html(xueyuan_total);
-                //     $(".qudui_input").val(qudui_total);
-                //     $(".xueyuan_input").val(xueyuan_total);
-                // });
-
-
                 $(document).on('change', '#c-question_setting_method', function () {
                     if($(this).val()==1){
                         $(".btn-sm,.btn-task").css('display','none');
@@ -447,7 +479,74 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                 $("button[name=commonSearch]").css('display','none');
                 $("input[name='btSelectAll']").css('display','none');
                 Form.api.bindevent($("form[role=form]"));
+            },
+            bindevent: function () {
+                var rel_Ids = [];
+                Table.api.init({
+                    extend: {
+                        // index_url: 'department/admin/departadmintotal' + location.search,
+                        index_url: 'auth/admin/admintotal' + location.search,
+                    }
+                });
+                var table = $("#table1");
+
+                // 初始化表格
+                table.bootstrapTable({
+                    url: $.fn.bootstrapTable.defaults.extend.index_url,
+                    pk: 'id',
+                    sortName: 'id',
+                    fixedColumns: true,
+                    fixedRightNumber: 1,
+                    searchFormVisible:false,
+                    // pagination:false,
+                    Search:false,
+                    columns: [
+                        [
+                            {checkbox: true,
+                                formatter: function(value,row,index){
+                                    if(Config.user_ids != undefined && Config.user_ids.indexOf(row.id)>-1){
+                                        // rel_Ids.push(row.id);
+                                        return true;
+                                    }else{
+                                        return {disabled : true}
+                                    }
+                                }
+                            },
+                            // {field: 'id', title: __('ID'),operate: false},
+                            {field: 'department_text', title: __('区队名称'), operate: false,width: '400px', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
+                            {field: 'nickname', title: __('姓名'),operate: false},
+                        ]
+                    ],
+                    onLoadSuccess: function(data) {
+                        // $.each(data.rows, function(index, row) {
+                        //     if(Config.user_ids != undefined && Config.user_ids.indexOf(row.id)>-1){
+                        //         xueyuan_total = xueyuan_total+1;
+                        //     }
+                        // });
+                    },
+                    // 点击每一个单选框时触发的操作
+                    onCheck:function(row){
+                        var index = rel_Ids.indexOf(row.id);
+                        if(index > -1) {
+                            rel_Ids.splice(index, 1);
+                        };
+                        $(".depart_id").val(rel_Ids.join());
+                    },
+                    // 取消每一个单选框时对应的操作;
+                    onUncheck:function(row){
+                        rel_Ids.push(row.id);
+                        $(".depart_id").val(rel_Ids.join());
+                    }
+                });
+
+                // 为表格绑定事件
+                Table.api.bindevent(table);
+
+                $("button[name=commonSearch]").css('display','none');
+                $("input[name='btSelectAll']").css('display','none');
+                Form.api.bindevent($("form[role=form]"));
             }
+
         }
     };
     return Controller;