define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) { var Controller = { index: function () { // 初始化表格参数配置 Table.api.init({ extend: { index_url: 'game/index' + location.search, add_url: 'game/add', edit_url: 'game/edit', del_url: 'game/del', multi_url: 'game/multi', import_url: 'game/import', table: 'game', } }); var table = $("#table"); // 初始化表格 table.bootstrapTable({ url: $.fn.bootstrapTable.defaults.extend.index_url, pk: 'id', sortName: 'id', fixedColumns: true, fixedRightNumber: 1, columns: [ [ {checkbox: true}, {field: 'id', title: __('Id')}, {field: 'name', title: __('Name'), operate: 'LIKE'}, {field: 'desc', title: __('Desc'), operate: 'LIKE'}, {field: 'image', title: __('Image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image}, {field: 'price', title: __('Price'), operate: 'LIKE'}, {field: 'signupendtime', title: __('Signupendtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, {field: 'starttime', title: __('Starttime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, {field: 'endtime', title: __('Endtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, {field: 'num', title: __('Num')}, {field: 'status', title: __('Status'), searchList: {"0":__('Status 0'),"1":__('Status 1'),"2":__('Status 2'),"3":__('Status 3')}, formatter: Table.api.formatter.status}, // {field: 'msgstatus', title: __('Msgstatus'), searchList: {"0":__('Msgstatus 0'),"1":__('Msgstatus 1')}, formatter: Table.api.formatter.status}, {field: 'showstatus', title: __('Showstatus'), searchList: {"0":__('Showstatus 0'),"1":__('Showstatus 1')}, formatter: Table.api.formatter.status}, /*{field: 'is_autoshow', title: __('Is_autoshow'), searchList: {"0":__('Is_autoshow 0'),"1":__('Is_autoshow 1')}, formatter: Table.api.formatter.normal}, {field: 'showtime', title: __('Showtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, {field: 'is_banner', title: __('Is_banner'), searchList: {"0":__('Is_banner 0'),"1":__('Is_banner 1')}, formatter: Table.api.formatter.normal},*/ {field: 'weigh', title: __('Weigh'), operate: false}, {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: 'gameplace', text: '比赛场地', title: __('比赛场地'), extend: 'data-area=\'["85%", "85%"]\'', classname: 'btn btn-xs btn-success btn-dialog', icon: 'fa fa-list', url: 'gameplace/index', // callback: function (data) { // Layer.alert("接收到回传数据:" + JSON.stringify(data), {title: "回传数据"}); // } // success: function (data, ret) { // // Layer.alert(ret.msg + ",返回数据:" + JSON.stringify(data)); // Layer.alert(ret.msg); // //如果需要阻止成功提示,则必须使用return false; // return false; // }, // error: function (data, ret) { // // console.log(data, ret); // Layer.alert(ret.msg); // return false; // }, // callback: function (data) { // Layer.alert("接收到回传数据:" + JSON.stringify(data), {title: "回传数据"}); // }, // visible: function (row) { // if (row.status == 1 && row.purpose == 3) { // return true; // } else { // return false; // } // } }, { name: 'gamepeople', text: '报名人员', title: __('报名人员'), extend: 'data-area=\'["85%", "85%"]\'', classname: 'btn btn-xs btn-success btn-dialog', icon: 'fa fa-list', url: 'gamepeople/index', // callback: function (data) { // Layer.alert("接收到回传数据:" + JSON.stringify(data), {title: "回传数据"}); // } // success: function (data, ret) { // // Layer.alert(ret.msg + ",返回数据:" + JSON.stringify(data)); // Layer.alert(ret.msg); // //如果需要阻止成功提示,则必须使用return false; // return false; // }, // error: function (data, ret) { // // console.log(data, ret); // Layer.alert(ret.msg); // return false; // }, // callback: function (data) { // Layer.alert("接收到回传数据:" + JSON.stringify(data), {title: "回传数据"}); // }, // visible: function (row) { // if (row.status == 1 && row.purpose == 3) { // return true; // } else { // return false; // } // } }, { name: 'edit', text: '', title: __('编辑'), // extend: 'data-area=\'["85%", "85%"]\'', classname: 'btn btn-xs btn-success btn-editone', icon: 'fa fa-pencil', // confirm: '确认删除?', url: 'game/edit', refresh: true, // success: function (data, ret) { // // Layer.alert(ret.msg + ",返回数据:" + JSON.stringify(data)); // Layer.alert(ret.msg); // //如果需要阻止成功提示,则必须使用return false; // return false; // }, // error: function (data, ret) { // // console.log(data, ret); // Layer.alert(ret.msg); // return false; // }, // callback: function (data) { // Layer.alert("接收到回传数据:" + JSON.stringify(data), {title: "回传数据"}); // }, // visible: function (row) { // if (row.status == 0) { // return true; // } else { // return false; // } // } }, { name: 'del', text: '', title: __('删除'), extend: 'data-area=\'["85%", "85%"]\'', classname: 'btn btn-xs btn-danger btn-delone', icon: 'fa fa-trash', confirm: '确认删除?', url: 'game/del', refresh: true, // success: function (data, ret) { // // Layer.alert(ret.msg + ",返回数据:" + JSON.stringify(data)); // Layer.alert(ret.msg); // //如果需要阻止成功提示,则必须使用return false; // return false; // }, // error: function (data, ret) { // // console.log(data, ret); // Layer.alert(ret.msg); // return false; // }, // callback: function (data) { // Layer.alert("接收到回传数据:" + JSON.stringify(data), {title: "回传数据"}); // }, visible: function (row) { if (row.status == 0) { return true; } else { return false; } } }, { name: 'dragsort', text: '', title: __('拖动'), extend: 'data-area=\'["85%", "85%"]\'', classname: 'btn btn-xs btn-danger btn-delone', icon: 'fa fa-trash', confirm: '确认删除?', url: 'game/del', refresh: true, // success: function (data, ret) { // // Layer.alert(ret.msg + ",返回数据:" + JSON.stringify(data)); // Layer.alert(ret.msg); // //如果需要阻止成功提示,则必须使用return false; // return false; // }, // error: function (data, ret) { // // console.log(data, ret); // Layer.alert(ret.msg); // return false; // }, // callback: function (data) { // Layer.alert("接收到回传数据:" + JSON.stringify(data), {title: "回传数据"}); // }, visible: function (row) { return false; } } ] } ] ] }); // 为表格绑定事件 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; });