define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) { var Controller = { index: function () { // 初始化表格参数配置 Table.api.init({ extend: { index_url: 'info/index' + location.search, add_url: 'info/add', edit_url: 'info/edit', del_url: 'info/del', multi_url: 'info/multi', import_url: 'info/import', table: 'info', } }); var table = $("#table"); // 初始化表格 table.bootstrapTable({ url: $.fn.bootstrapTable.defaults.extend.index_url, pk: 'id', sortName: 'id', columns: [ [ //{checkbox: true}, {field: 'id', title: __('Id')}, {field: 'user.nickname', title: __('User.nickname'), operate: 'LIKE'}, {field: 'content', title: __('Content'), operate: 'LIKE'}, {field: 'images', title: __('Images'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.images}, {field: 'city', title: __('City')}, {field: 'position', title: __('Position')}, {field: 'created_at', title: __('创建时间'),operate: "RANGE",formatter: Table.api.formatter.datetime,addclass:'datetimerange'}, {field: 'like_count', title: __('点赞数'),operate: false,}, {field: 'comments_count', title: __('评论数'),operate: false,}, {field: 'is_rec', title: __('Is_rec'),searchList:{0:'否',1:'是'},formatter: Table.api.formatter.label}, {field: 'status', title: __('状态'),searchList:{0:'未审核',1:'通过',2:'拒绝'},formatter: Table.api.formatter.label}, { field: 'buttons', width: "120px", title: __('评论'), table: table, events: Table.api.events.operate, operate: false, buttons: [ { name: 'detail', text: __('查看评论'), title: __('查看评论'), classname: 'btn btn-xs btn-primary btn-click', icon: 'fa fa-list', callback: function (data) { Layer.alert("接收到回传数据:" + JSON.stringify(data), {title: "回传数据"}); }, visible: function (row) { //返回true时按钮显示,返回false隐藏 return true; }, click(row,data){ let a=$('.commentLink') if(!a.length) { $('body').append('') } $('.commentLink').attr('href','comment?info='+data.id) $('.commentLink').trigger('click') } } ], formatter: Table.api.formatter.buttons }, {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} ] ] }); // 为表格绑定事件 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; });