123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488 |
- 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: {
- index_url: 'teacher/practice/index' + location.search,
- add_url: 'teacher/practice/add',
- edit_url: 'teacher/practice/edit',
- del_url: 'teacher/practice/del',
- multi_url: 'teacher/practice/multi',
- import_url: 'teacher/practice/import',
- table: 'teacher_collection',
- }
- });
- var table = $("#table");
- // 初始化表格
- table.bootstrapTable({
- url: $.fn.bootstrapTable.defaults.extend.index_url,
- pk: 'exam_collection_id',
- sortName: 'exam_collection_id',
- fixedColumns: true,
- fixedRightNumber: 1,
- searchFormVisible:true,
- search:false,
- columns: [
- [
- {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: 'exam_collection_type', title: __('Exam_collection_type'),operate: false,formatter: function (value, row, index) {
- // return '练习';
- // }
- // },
- {
- field: 'exam_collection_state',searchList:{"2":"打开","3":"关闭"},
- title: __('是否开启练习'),
- align: 'center',
- table: table,
- formatter: Table.api.formatter.collectonstate
- },
- // {field: 'task_id', title: __('Task_id')},
- {field: 'limit_duration', title: __('Limit_duration')},
- // {field: 'start_time', title: __('Start_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
- // {field: 'end_time', title: __('End_time'), operate:'RANGE', 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: '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},
- // {field: 'update_by', title: __('Update_by'), operate: 'LIKE'},
- // {field: 'update_time', title: __('Update_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
- // {field: 'remark', title: __('Remark'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
- {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate,
- // formatter: Table.api.formatter.operate
- formatter: Table.api.formatter.buttons,
- buttons: [
- {
- name: 'dispatch',
- text: '编辑',
- icon: 'fa fa-pencil',
- title: '编辑',
- classname: 'btn btn-success btn-xs btn-magic btn-dialog',
- extend: 'data-area=\'["85%","85%"]\'',
- url: 'teacher/practice/edit',
- },
- {
- name: 'dispatch',
- text: '进入练习',
- icon: 'fa fa-hand-pointer-o',
- title: '进入练习',
- visible: function (rr) {
- if(rr.exam_collection_state == 2){
- return true;
- }
- return false;
- },
- classname: 'btn btn-info btn-xs btn-magic btn-addtabs',
- url: 'teacher/practice/persent',
- },
- {
- name: 'dispatch',
- text: '删除',
- icon: 'fa fa-trash',
- title: '删除',
- classname: 'btn btn-danger btn-xs btn-magic btn-ajax',
- url: 'teacher/practice/del',
- confirm: '确定要删除吗?',
- success: function (data, ret) {
- $(".btn-refresh").trigger("click");
- },
- error: function (data, ret) {
- Layer.alert(ret.msg);
- return false;
- }
- }
- ],
- }
- ]
- ]
- });
- // 为表格绑定事件
- Table.api.bindevent(table);
- $(document).on('click', '.btn-start', function () {
- var ids = Table.api.selectedids(table);
- Fast.api.ajax({
- url: "teacher/practice/start/ids/"+ids,
- type: "post",
- }, function () {
- table.bootstrapTable('refresh');
- Layer.close(index);
- });
- });
- },
- persent: function () {
- Table.api.init({
- extend: {
- index_url: 'teacher/practice/persent/ids/'+Config.ids + location.search,
- indexed_url: 'teacher/practice/examing/ids/'+ Config.ids+ location.search,
- table: 'teacher_exams',
- }
- });
- var table = $("#table");
- // 初始化表格
- table.bootstrapTable({
- url: $.fn.bootstrapTable.defaults.extend.index_url,
- pk: 'rel_id',
- sortName: 'rel_id',
- toolbar: '#toolbar',
- fixedColumns: true,
- fixedRightNumber: 1,
- searchFormVisible:false,
- showExport:false,
- search:false,
- columns: [
- [
- // {checkbox: true},
- {field: 'fault_name', title: __('更换件')},
- {field: 'create_by', title: __('学员姓名')},
- {field: 'request_status', title: __('状态'),
- formatter: function(value, row,index) {
- if(value==1){
- return '<span class="text-warning">待处理</span>';
- }else if(value==2){
- return '<span class="text-success">已送</span>';
- }else if(value==3){
- return '<span class="text-danger">已驳回</span>';
- }
- }
- },
- {field: 'createtime', title: __('申请时间'), formatter: Table.api.formatter.datetime, operate: false, addclass: 'datetimerange', sortable: true},
- {field: 'operate', title: __('Operate'), table: table,
- events: Table.api.events.operate,
- // formatter: Table.api.formatter.operate
- formatter: Table.api.formatter.buttons,
- buttons: [
- {
- name: 'dispatch',
- text: '已送',
- icon: 'fa fa-check',
- title: '已送',
- classname: 'btn btn-success btn-xs btn-magic btn-ajax',
- url: 'teacher/exams/handle/type/1',
- visible: function (rr) {
- if(rr.request_status == 1 || rr.request_status == 0){
- return true;
- }
- return false;
- },
- success: function (data, ret) {
- table.bootstrapTable("refresh");
- },
- },{
- name: 'dispatch',
- text: '驳回',
- icon: 'fa fa-reply-all',
- title: '驳回',
- classname: 'btn btn-danger btn-xs btn-magic btn-ajax',
- url: 'teacher/exams/handle/type/2',
- visible: function (rr) {
- if(rr.request_status == 1 || rr.request_status == 0){
- return true;
- }
- return false;
- },
- success: function (data, ret) {
- table.bootstrapTable("refresh");
- },
- }
- ],
- }
- ]
- ]
- });
- // 为表格绑定事件
- Table.api.bindevent(table);
- var table1 = $("#table1");
- // 初始化表格
- table1.bootstrapTable({
- url: $.fn.bootstrapTable.defaults.extend.indexed_url,
- pk: 'exam_collection_id',
- sortName: 'exam_collection_id',
- toolbar: '#toolbar1',
- fixedColumns: true,
- fixedRightNumber: 1,
- searchFormVisible:false,
- columns: [
- [
- // {checkbox: true},
- {field: 'seat_id', title: __('座号')},
- {field: '', title: __('模拟器状态'),
- formatter: function(value, row,index) {
- return '<span class="text-success">就绪</span>';
- }
- },
- {field: 'user_username', title: __('学员学号')},
- {field: 'user_nickname', title: __('学员姓名')},
- {field: '', title: __('考试状态'),
- formatter: function(value, row,index) {
- return '<span class="text-success">已交卷</span>';
- }
- },
- {field: 'total_score', title: __('考试成绩')},
- // {field: 'fault_names', title: __('出题题目'),formatter: Table.api.formatter.faultname},
- // {field: 'xianxiang_names', title: __('故障现象'),formatter: Table.api.formatter.faultname},
- // {field: 'yuanyin_names', title: __('可能原因'),formatter: Table.api.formatter.faultname},
- // {field: 'buwei_names', title: __('故障部位'),formatter: Table.api.formatter.faultname},
- // {field: 'fangfa_names', title: __('排除方法'),formatter: Table.api.formatter.faultname},
- ]
- ]
- });
- // 为表格绑定事件
- Table.api.bindevent(table1);
- //关闭考试 并且
- $(document).on('click', '.btn-closes', function () {
- var ids = Config.ids;
- Backend.api.closetabs('/admin/teacher/practice/persent/ids/'+Config.ids)
- // Backend.api.addtabs('teacher/practice','练习列表');
- // $.ajax({
- // type:'post',
- // url:'teacher/collection/multi',
- // data:{ids:ids,params:'exam_collection_state=3'}, //重点必须为一个变量如:data
- // success:function(data){
- // if(data.code==1){
- // Backend.api.closetabs('/admin/teacher/exams/persent/ids/'+Config.ids)
- // Backend.api.addtabs('teacher/collection','考试列表');
- // }
- // },
- // error:function(){
- // layer.alert("操作失败");
- // return;
- // }
- // })
- });
- },
- add: function () {
- Controller.api.bindevent();
- },
- edit: function () {
- Controller.api.bindevent();
- },
- api: {
- bindevent: function () {
- var rel_Ids = [];
- var qudui_total = 0;
- var xueyuan_total = 0;
- Table.api.init({
- extend: {
- index_url: 'department/admin/departadmintotal' + 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){
- // console.log(row.id+'####'+Config.row_info.depart_ids)
- if(Config.row_info != undefined && Config.row_info.depart_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},
- ]
- ],
- 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;
- }
- });
- $(".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;
- $(".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);
- },
- // 取消每一个单选框时对应的操作;
- onUncheck:function(row){
- 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;
- $(".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);
- }
- });
- // 为表格绑定事件
- 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');
- }else if($(this).val()==2){
- $(".btn-sm").show();
- $(".btn-task").css('display','none');
- }else if($(this).val()==3){
- $(".btn-sm").css('display','none');
- $(".btn-task").show();
- }
- $(".question_ids").val(0);
- $(".task_id").val(0);
- $("#c-task_name").val('');
- $("#c-fault_name").val('');
- $("#c-question_name").val('');
- $(".tasks,.questions").css('display','none')
- });
- //考题
- $(document).on('click', '.btn-sm', function () {
- var simtype = $("#c-sim_type").val();
- if(!simtype){
- Layer.alert('请选择模拟器类型');
- return false
- }
- var title = '选择考题';
- Fast.api.open(Fast.api.fixurl("teacher/collection/faults/type/"+simtype), title, {
- area: ["85%", "85%"],
- maxmin: true,
- moveOut: false,
- offset: ['40px'],
- callback: function(value) {
- if (value.task_id) {
- $(".questions").css('display','block')
- $(".question_ids").val(value.task_id);
- $("#c-question_name").val(value.task_name);
- $(".tasks").css('display','none')
- $(".task_id").val(0);
- $("#c-task_name").val('');
- $("#c-fault_name").val('');
- }
- }
- });
- });
- //任务
- $(document).on('click', '.btn-task', function () {
- var simtype = $("#c-sim_type").val();
- if(!simtype){
- Layer.alert('请选择模拟器类型');
- return false;
- }
- var title = '选择任务';
- parent.Fast.api.open(Fast.api.fixurl("teacher/collection/task/type/"+simtype), title, {
- area: ["65%", "70%"],
- maxmin: true,
- moveOut: false,
- offset: ['40px'],
- callback: function(value) {
- console.log(value);
- if (value.task_id) {
- $(".tasks").css('display','block')
- $(".task_id").val(value.task_id);
- $("#c-task_name").val(value.task_name);
- $("#c-fault_name").val(value.fault_name);
- $(".questions").css('display','none')
- $(".question_ids").val(0);
- $("#c-question_name").val('');
- }
- }
- });
- });
- // $("input[name='btSelectAll']").click(function () {
- // var ids = Table.api.selectedids(table);
- // console.log(ids);
- // $(".depart_ids").val(ids);
- // });
- $("button[name=commonSearch]").css('display','none');
- $("input[name='btSelectAll']").css('display','none');
- Form.api.bindevent($("form[role=form]"));
- }
- }
- };
- return Controller;
- });
|