1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
- var Controller = {
- index: function () {
- // 初始化表格参数配置
- Table.api.init({
- extend: {
- index_url: 'teacher/info/index',
- add_url: 'teacher/info/add',
- edit_url: 'teacher/info/edit',
- del_url: 'teacher/info/del',
- // multi_url: 'auth/admin/multi',
- }
- });
- var table = $("#table");
- //在表格内容渲染完成后回调的事件
- table.on('post-body.bs.table', function (e, json) {
- $("tbody tr[data-index]", this).each(function () {
- if (parseInt($("td:eq(1)", this).text()) == Config.admin.id) {
- $("input[type=checkbox]", this).prop("disabled", true);
- }
- });
- });
- // 初始化表格
- table.bootstrapTable({
- url: $.fn.bootstrapTable.defaults.extend.index_url,
- searchFormVisible:true,
- search:false,
- columns: [
- [
- {field: 'state', checkbox: true, },
- // {field: 'id', title: '编号'},
- {field: 'username', title: __('Username'),operate: 'like'},
- {field: 'nickname', title: __('Nickname'),operate: 'like'},
- // {field: 'groups_text', title: __('Group'), operate:false, formatter: Table.api.formatter.label},
- // {field: 'email', title: __('Email')},
- {field: 'mobile', title: __('Mobile'),operate: 'like'},
- {field: 'status', title: __("Status"), searchList: {"normal":__('Normal'),"hidden":__('Hidden')}, formatter: Table.api.formatter.status},
- {field: 'createtime', title: __('Create time'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true},
- {
- field: 'operate', title: __('Operate'), table: table,
- formatter: Table.api.formatter.buttons,
- buttons: [
- {
- name: 'dispatch',
- text: '编辑',
- icon: 'fa fa-pencil',
- title: '编辑',
- classname: 'btn btn-success btn-xs btn-magic btn-dialog',
- url: 'teacher/info/edit',
- }, {
- name: 'dispatch',
- text: '删除',
- icon: 'fa fa-trash',
- title: '删除',
- classname: 'btn btn-danger btn-xs btn-magic btn-ajax',
- url: 'teacher/info/del',
- confirm: '确定要删除吗?',
- success: function (data, ret) {
- $(".btn-refresh").trigger("click");
- },
- error: function (data, ret) {
- Layer.alert(ret.msg);
- return false;
- }
- }
- ],
- // events: Table.api.events.operate,
- // formatter: function (value, row, index) {
- // if(row.id == Config.admin.id){
- // return '';
- // }
- // return Table.api.formatter.operate.call(this, value, row, index);
- // }}
- }
- ]
- ]
- });
- // 为表格绑定事件
- Table.api.bindevent(table);
- },
- add: function () {
- Form.api.bindevent($("form[role=form]"));
- },
- edit: function () {
- Form.api.bindevent($("form[role=form]"));
- }
- };
- return Controller;
- });
|