Browse Source

20250207 考试添加和编辑,系统随机和考题自选,同一个故障现象只允许一个故障部位

贾小兵 2 tháng trước cách đây
mục cha
commit
c85439f85a

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

@@ -110,7 +110,8 @@ class Collection extends Backend
                 //匹配的学员自动加入  mx_real_exam_fault 考试故障关联表
                 //匹配的学员自动加入  mx_real_exam_fault 考试故障关联表
                 $fault_list = Fault::where(['sim_type' => $params['sim_type'], 'fault_state' => 0,'fault_type'=>3])->select();
                 $fault_list = Fault::where(['sim_type' => $params['sim_type'], 'fault_state' => 0,'fault_type'=>3])->select();
                 if($params['question_setting_method']==1){ //系统随机
                 if($params['question_setting_method']==1){ //系统随机
-                    $fault_key = array_rand($fault_list, 3);
+                    $faultlist = Fault::where(['sim_type' => $params['sim_type'], 'fault_state' => 0,'fault_type'=>3])->group('parent_fault_id')->select();
+                    $fault_key = array_rand($faultlist, 3);
                 }else if($params['question_setting_method']==2){//教师自选
                 }else if($params['question_setting_method']==2){//教师自选
                     $question_ids = $params['question_ids'];
                     $question_ids = $params['question_ids'];
                 }else if($params['question_setting_method']==3){ //任务自选
                 }else if($params['question_setting_method']==3){ //任务自选

+ 13 - 1
public/assets/js/backend/teacher/collection.js

@@ -187,7 +187,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                     [
                     [
                         {checkbox: true},
                         {checkbox: true},
                         {field: 'sim_type', title: __('模拟器类型'),operate:false,searchList:{"0001":"FZD04B型侦毒器","0002":"FZB006型毒剂报警器","0003":"防化兵用毒剂报警器"},formatter: Table.api.formatter.simtype},
                         {field: 'sim_type', title: __('模拟器类型'),operate:false,searchList:{"0001":"FZD04B型侦毒器","0002":"FZB006型毒剂报警器","0003":"防化兵用毒剂报警器"},formatter: Table.api.formatter.simtype},
-                        // {field: 'parent_name', title: __('故障现象'), operate: false, table: table, class: 'autocontent', formatter: Table.api.formatter.content},
+                        {field: 'parent_name', title: __('故障现象'), operate: false, table: table, class: 'autocontent',},
                         {field: 'name', title: __('故障内容'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                         {field: 'name', title: __('故障内容'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                         // {
                         // {
                         //     field: 'operate', title: __('Operate'), width: 85, events: {
                         //     field: 'operate', title: __('Operate'), width: 85, events: {
@@ -211,11 +211,23 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                     Layer.alert('故障内容只允许选择3个');
                     Layer.alert('故障内容只允许选择3个');
                     return false
                     return false
                 }
                 }
+                console.log(ids)
+
                 var taskname = [];
                 var taskname = [];
+                var ptaskids = [];
                 var datas = $("#table").bootstrapTable('getSelections');
                 var datas = $("#table").bootstrapTable('getSelections');
                 $.each(datas,function (index,val) {
                 $.each(datas,function (index,val) {
                     taskname.push(val.name)
                     taskname.push(val.name)
+                    var index = ptaskids.indexOf(val.parent_fault_id);
+                    if (index > -1) {
+                         Layer.alert('一个故障现象下只允许申请一个故障部位');
+                         return false
+                    }
+                    ptaskids.push(val.parent_fault_id)
                 })
                 })
+                console.log(taskname)
+                console.log(ptaskids)
+                return;
                 Fast.api.close({url: '', multiple: multiple, task_id:ids,task_name:taskname});
                 Fast.api.close({url: '', multiple: multiple, task_id:ids,task_name:taskname});
             });
             });