define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) { var Controller = { index: function () { // 初始化表格参数配置 Table.api.init({ extend: { index_url: 'search/keyword/index', add_url: 'book/book/select', del_url: 'search/keyword/del', multi_url: 'search/keyword/multi', table: 'search_keyword', }, showToggle:false, showColumns:false, showExport:false, commonSearch:false, }); var table = $("#table"); // 初始化表格 table.bootstrapTable({ url: $.fn.bootstrapTable.defaults.extend.index_url, pk: 'id', sortName: 'weigh', columns: [ [ {checkbox: true}, {field: 'id', title: __('Id')}, {field: 'keyword', title: __('Keyword')}, {field: 'book_id', title: __('书籍id')}, {field: 'weigh', title: __('Weigh')}, {field: 'sex_text', title: __('频道'), operate:false}, {field: 'createtime', title: __('Createtime'), formatter: Table.api.formatter.datetime}, {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} ] ] }); // 为表格绑定事件 Table.api.bindevent(table); Controller.api.bindevent(); }, add: function () { Controller.api.bindevent(); }, edit: function () { Controller.api.bindevent(); }, api: { bindevent: function () { Form.api.bindevent($("form[role=form]")); //搜索关键词 选择书籍后回调 var refreshkey = function (data) { var ids = []; for ( var i = data.length - 1; i >= 0 ; i-- ) { ids.push(data[i].id); } Fast.api.ajax({ url: "search/keyword/add", type: "get", data: {ids: ids.join(',')}, },function () { $('.btn-refresh').trigger('click'); }); }; $(document).on('click', "#select-resources", function () { var block_id = Config.block_id; parent.Backend.api.open($(this).attr("href") + "?action=searchkeyword&state=1" , __('Select'), {callback: refreshkey}); return false; }); } } }; return Controller; });