define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) { var Controller = { index: function () { // 初始化表格参数配置 Table.api.init({ extend: { index_url: 'guidechannel/index', add_url: 'guidechannel/add', edit_url: 'guidechannel/edit', del_url: 'guidechannel/del', multi_url: 'guidechannel/multi', table: 'guide_relation' }, clickToSelect:false }); var table = $("#table"); // 初始化表格 table.bootstrapTable({ url: $.fn.bootstrapTable.defaults.extend.index_url, pk: 'id', sortName: 'gr.updatetime desc', sortOrder:'', search: false, searchFormVisible: true, columns: [ [ {checkbox: true}, {field: 'admin_id', title: __('Admin_id'), operate: 'LIKE %...%'}, {field: 'a.username', title: __('Admin_username'), operate: 'LIKE %...%',formatter:function(value, row, index){ return row.username; }}, {field: 'a.nickname', title: __('Admin_nickname'), operate: 'LIKE %...%',formatter:function(value, row, index){ return row.nickname; }}, {field: 'ae.create_by', title: __('开户人'), visible:false, operate: '=', searchList:{}},//仅用于搜索 {field: 'ae.create_by', title: __('开户人ID'), operate: false,formatter:function(value, row, index){ return row.create_by; }}, {field: 'a2.username', title: __('开户人账户'), operate: false,formatter:function(value, row, index){ return row.create_username; }}, {field: 'a2.nickname', title: __('开户人昵称'), operate: false,formatter:function(value, row, index){ return row.create_nickname; }}, {field: 'gd.id', title: __('Domain_host')+"ID", operate: 'LIKE %...%',formatter:function(value, row, index){ return (new String(row.hostid_concat)).split(",").join("
"); }}, {field: 'gd.host', title: __('Domain_host'), operate: 'LIKE %...%',formatter:function(value, row, index){ return (new String(row.host_concat)).split(",").join("
"); }}, {field: 'createtime', title: __('Createtime'), formatter: Table.api.formatter.datetime,type: 'datetime', operate: 'RANGE',addclass:'datetimerange',formatter:function(value, row, index){ return (new String(row.createtime_concat)).split(",").join("
"); }}, {field: 'updatetime', title: __('Updatetime'), formatter: Table.api.formatter.datetime,type: 'datetime', operate: 'RANGE',addclass:'datetimerange',formatter:function(value, row, index){ return (new String(row.updatetime_concat)).split(",").join("
"); }}, {field: 'operate', title: '操作', table: table, events: Table.api.events.operate,formatter: Table.api.formatter.buttons, buttons:[ {name: 'del', text: '', icon: 'fa fa-trash',classname: 'btn btn-xs btn-danger btn-ajax', url: $.fn.bootstrapTable.defaults.extend.del_url,confirm:'确定删除此项?',success:function (data){ table.bootstrapTable('refresh'); }}, ]} ] ], onLoadSuccess: function (data) { //配置搜索栏"开户人"下拉列表 var formControlCreateBy = $(".form-control[name='ae.create_by']"); if(formControlCreateBy.children("option").length<=1){ $.each(data.create_list, function (index, row) { formControlCreateBy.append(''); }); } } }); // 为表格绑定事件 Table.api.bindevent(table); }, add: function () { $(":checkbox[name='btSelectAll']").click(function(){ $(this).closest("table").find(":checkbox").prop("checked", $(this).prop("checked")); }); Controller.api.bindevent(); }, edit: function () { Controller.api.bindevent(); }, api: { bindevent: function () { Form.api.bindevent($("form[role=form]")); } } }; return Controller; });