123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174 |
- 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/collection/index' + location.search,
- add_url: 'teacher/collection/add',
- edit_url: 'teacher/collection/edit',
- del_url: 'teacher/collection/del',
- multi_url: 'teacher/collection/multi',
- import_url: 'teacher/collection/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,
- columns: [
- [
- {checkbox: true},
- {field: 'exam_collection_id', title: __('编号')},
- {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: __('Exam_collection_state'),
- 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:false, addclass:'datetimerange', autocomplete:false},
- {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: '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/collection/edit',
- },
- // {
- // name: 'dispatch',
- // text: '',
- // icon: 'fa fa-trash',
- // title: '删除',
- // classname: 'btn btn-danger btn-xs btn-magic btn-ajax',
- // url: 'teacher/collection/del',
- // confirm: '确定要删除吗?',
- // success: function (data, ret) {
- // $(".btn-refresh").trigger("click");
- // },
- // error: function (data, ret) {
- // Layer.alert(ret.msg);
- // return false;
- // }
- // }
- ],
- }
- ]
- ]
- });
- // 为表格绑定事件
- Table.api.bindevent(table);
- },
- add: function () {
- Controller.api.bindevent();
- },
- edit: function () {
- Controller.api.bindevent();
- },
- api: {
- bindevent: function () {
- var rel_Ids = [];
- 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,
- 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},
- ]
- ]
- });
- // 为表格绑定事件
- 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)){
- arr = $.grep(rel_Ids, function(value) {
- return value != row["id"];
- });
- rel_Ids = arr;
- }else if(rel_Ids.indexOf(row.id)>-1){
- var index = rel_Ids.indexOf(row.id);
- if (index > -1) {
- rel_Ids.splice(index, 1);
- }
- }else{
- rel_Ids.push(row.id);
- }
- $(".depart_ids").val(rel_Ids.join());
- });
- // $("input[name='btSelectAll']").click(function () {
- // var ids = Table.api.selectedids(table);
- // console.log(ids);
- // $(".depart_ids").val(ids);
- // });
- $("input[name='btSelectAll']").css('display','none')
- Form.api.bindevent($("form[role=form]"));
- }
- }
- };
- return Controller;
- });
|