define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) { var Controller = { index: function () { // 初始化表格参数配置 Table.api.init({ extend: { index_url: 'matter/index' + location.search, add_url: 'matter/add', edit_url: 'matter/edit', del_url: 'matter/del', import_url:'matter/import', table: 'matter', } }); var table = $("#table"); // 初始化表格 table.bootstrapTable({ url: $.fn.bootstrapTable.defaults.extend.index_url, pk: 'id', sortName: 'id', columns: [ [ {checkbox: true}, {field: 'id', title: __('Id')}, {field: 'code', title: __('Code')}, {field: 'name', title: __('Name')}, {field: 'weight', title: '重量(g)'}, // {field: 'quality', title: __('Quality')}, // {field: 'create', title: __('Create'), operate:'RANGE', addclass:'datetimerange'}, {field: 'operate', title: __('Operate'), table: table, buttons:[{ name:'read',text:'查看',title:'查看',icon:'fa fa-list',classname:'btn btn-xs btn-info btn-fields btn-dialog',url:'matter/read/id/{id}' }], events: Table.api.events.operate, formatter: function (value, row, index) { var that = $.extend({}, this); $(table).data("operate-del", null); // 列表页面隐藏 .编辑operate-edit - 删除按钮operate-del $(table).data("operate-edit", null); that.table = table; return Table.api.formatter.operate.call(that, value, row, index); }} ] ] }); // 为表格绑定事件 Table.api.bindevent(table); }, add: function () { Controller.api.bindevent(); }, edit: function () { Controller.api.bindevent(); }, read: function () { // 初始化表格参数配置 Table.api.init({ extend: { index_url: 'matter/read' + location.search, } }); var table = $("#table"); // 初始化表格 table.bootstrapTable({ url: $.fn.bootstrapTable.defaults.extend.index_url, pk: 'id', sortName: 'id', columns: [ [ // {checkbox: true}, {field: 'id', title: 'ID'}, {field: 'code', title: __('Code')}, {field: 'name', title: __('Name')}, {field: 'bach', title:'批次号'}, {field: 'weight', title:'重量(g)'}, ] ] }); // 为表格绑定事件 Table.api.bindevent(table); }, api: { bindevent: function () { Form.api.bindevent($("form[role=form]")); } } }; return Controller; });