define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) { var Controller = { index: function () { // 初始化表格参数配置 Table.api.init({ extend: { index_url: 'uidsale/index' + location.search, add_url: 'uidsale/add', edit_url: 'uidsale/edit', // del_url: 'uidsale/del', multi_url: 'uidsale/multi', import_url: 'uidsale/import', table: 'uidsale', } }); var table = $("#table"); // 初始化表格 table.bootstrapTable({ url: $.fn.bootstrapTable.defaults.extend.index_url, pk: 'id', sortName: 'id', columns: [ [ {checkbox: true}, {field: 'id', title: __('Id')}, {field: 'new_id', title: __('New_id')}, {field: 'price', title: __('Price')}, {field: 'status', title: __('Status'), searchList: {"1":__('Status 1'),"0":__('Status 0')}, formatter: Table.api.formatter.status}, {field: 'is_show', title: __('Is_show'), searchList: {"1":__('Is_show 1'),"0":__('Is_show 0')}, formatter: Table.api.formatter.normal}, {field: 'user_id', title: __('User_id')}, {field: 'user.username', title: __('User.username'), operate: 'LIKE'}, {field: 'saletime', title: __('Saletime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, // {field: 'type_id', title: __('Type_id')}, {field: 'uidsaletype.type', title: __('Uidsaletype.type'), operate: 'LIKE'}, {field: 'operate', title: __('Operate'), table: table, buttons:[ { name:'shangjia', text:'上架', title:'上架', icon:'fa fa-exclamation-circle', classname:'btn btn-xs btn-success btn-ajax', url:'uidsale/shangjia/ids/{ids}?dialog=1', target:'_self', refresh:true, hidden:function(row){ return (row.status==0 && row.is_show == 0) ? false : true; } }, { name:'xiajia', text:'下架', title:'下架', icon:'fa fa-exclamation-circle', classname:'btn btn-xs btn-danger btn-ajax', url:'uidsale/xiajia/ids/{ids}?dialog=1', target:'_self', refresh:true, hidden:function(row){ return (row.status==0 && row.is_show == 1) ? false : true; } }, { name:'edit', text:'编辑', title:'编辑', icon:'fa fa-exclamation-circle', classname:'btn btn-xs btn-info btn-dialog', url:'uidsale/edit/ids/{ids}?dialog=1', target:'_self', refresh:true, hidden:function(row){ return (row.status==0 && row.is_show == 0) ? false : true; } } ], events: Table.api.events.operate, formatter: Table.api.formatter.operate} ] ] }); // 为表格绑定事件 Table.api.bindevent(table); }, add: function () { Controller.api.bindevent(); }, edit: function () { Controller.api.bindevent(); }, shangjia: function () { Controller.api.bindevent(); }, xiajia: function () { Controller.api.bindevent(); }, api: { bindevent: function () { Form.api.bindevent($("form[role=form]")); } } }; return Controller; });