define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) { var Controller = { index: function () { // 初始化表格参数配置 Table.api.init({ extend: { index_url: 'books/books/index' + location.search, add_url: 'books/books/add', edit_url: 'books/books/edit', del_url: 'books/books/del', multi_url: 'books/books/multi', import_url: 'books/books/import', table: 'books', } }); var table = $("#table"); // 初始化表格 table.bootstrapTable({ url: $.fn.bootstrapTable.defaults.extend.index_url, pk: 'id', sortName: 'id', fixedColumns: true, searchFormVisible: true, searchFormTemplate: 'customformtpl', fixedRightNumber: 1, columns: [ [ {checkbox: true}, {field: 'id', title: __('Id')}, {field: 'title', title: __('Title'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, {field: 'image', title: __('Image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image}, {field: 'isbn', title: __('Isbn'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, {field: 'format', title: __('Format'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, {field: 'sheet', title: __('Sheet'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, {field: 'print', title: __('Print'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, {field: 'pubdate', title: __('Pubdate'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, {field: 'edition', title: __('Edition'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, {field: 'publisher', title: __('Publisher'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, {field: 'book_type', title: __('教材类型'), searchList: {"0":__('纸质书'),"1":__('电子书')}, formatter: Table.api.formatter.normal}, {field: 'is_new_recommend', title: __('是否新书推荐'), searchList: {"0":__('是'),"1":__('否')}, formatter: Table.api.formatter.normal}, {field: 'author', title: __('Author'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, {field: 'is_awards', title: __('是否获奖'), searchList: {"0":__('是'),"1":__('否')}, formatter: Table.api.formatter.normal}, {field: 'is_series', title: __('是否可以按系列购买'), searchList: {"0":__('是'),"1":__('否')}, formatter: Table.api.formatter.normal}, {field: 'price', title: __('Price'), operate:'BETWEEN'}, {field: 'entity_price', title: __('Entity_price'), operate:'BETWEEN'}, {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, { field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate, buttons: [{ name: 'detail', title: '文件列表', classname: 'btn btn-xs btn-primary btn-dialog', icon: 'fa fa-list', url: 'books.books_file/index?books_id={id}', extend: 'data-area=\'["75%","75%"]\'', callback: function (data) { Layer.alert("接收到回传数据:" + JSON.stringify(data), {title: "回传数据"}); } },], } ] ] }); // 为表格绑定事件 Table.api.bindevent(table); }, add: function () { Controller.api.bindevent(); }, edit: function () { Controller.api.bindevent(); }, api: { bindevent: function () { Form.api.bindevent($("form[role=form]")); } } }; return Controller; });