define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) { var Controller = { index: function () { // 初始化表格参数配置 Table.api.init({ extend: { index_url: 'usergangwei/index', add_url: 'usergangwei/add', edit_url: 'usergangwei/edit', del_url: 'usergangwei/del', multi_url: 'usergangwei/multi', dragsort_url: '', table: 'usergangwei', } }); var table = $("#table"); var tableOptions = { url: $.fn.bootstrapTable.defaults.extend.index_url, pk: 'id', sortName: 'weigh', pagination: false, commonSearch: false, search: false, columns: [ [ {checkbox: true}, {field: 'id', title: __('Id')}, {field: 'name', title: __('Name'), align: 'left', formatter:function (value, row, index) { return value.toString().replace(/(&|&)nbsp;/g, ' '); } }, {field: 'weigh', title: __('Weigh')}, {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} ] ] }; // 初始化表格 table.bootstrapTable(tableOptions); // 为表格绑定事件 Table.api.bindevent(table); //绑定TAB事件 $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) { // var options = table.bootstrapTable(tableOptions); var typeStr = $(this).attr("href").replace('#', ''); var options = table.bootstrapTable('getOptions'); options.pageNumber = 1; options.queryParams = function (params) { // params.filter = JSON.stringify({type: typeStr}); params.type = typeStr; return params; }; table.bootstrapTable('refresh', {}); return false; }); //必须默认触发shown.bs.tab事件 // $('ul.nav-tabs li.active a[data-toggle="tab"]').trigger("shown.bs.tab"); }, add: function () { Controller.api.bindevent(); }, edit: function () { Controller.api.bindevent(); }, api: { bindevent: function () { Form.api.bindevent($("form[role=form]")); } } }; return Controller; });