define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
var Controller = {
index: function () {
// 初始化表格参数配置
Table.api.init({
extend: {
index_url: 'ophost/index',
add_url: 'ophost/add',
edit_url: 'ophost/edit',
// del_url: 'ophost/del',
multi_url: 'ophost/multi',
table: 'ophost',
}
});
var table = $("#table");
// 初始化表格
table.bootstrapTable({
url: $.fn.bootstrapTable.defaults.extend.index_url,
pk: 'id',
sortName: 'id',
columns: [
[
{checkbox: true},
{field: 'id', title: __('Id')},
{field: 'platform_id', title: __('Platform_id'),formatter:function(value,row,index){return value+"
"+row.platform.name;}},
{field: 'host', title: __('Host')},
{field: 'hostfile', title: __('Hostfile')},
{field: 'isdefault', title: __('Isdefault'), visible:false, searchList: {"0":__('Isdefault 0'),"1":__('Isdefault 1')}},
{field: 'isdefault_text', title: __('Isdefault'), operate:false},
{field: 'status', title: __('Status'), visible:false, searchList: {"0":__('Status 0'),"1":__('Status 1')}},
{field: 'status_text', title: __('Status'), operate:false},
{
field: 'allow_changed',
title: __('AllowChanged'),
operate: '=',
searchList: {"0": __('AllowChanged0'), "1": __('AllowChanged1')},
formatter: function (value) {
if (value == '1') {
return '是';
} else {
return '否';
}
}
},
{field: 'p_desc', title: __('描述'), operate:false},
{field: 'download', title: __('渠道信息下载'), formatter:function(value){return '下载';}},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
]
]
});
// 为表格绑定事件
Table.api.bindevent(table);
},
add: function () {
Controller.api.isdefault();
Controller.api.bindevent();
},
edit: function () {
Controller.api.isdefault();
Controller.api.bindevent();
},
api: {
bindevent: function () {
Form.api.bindevent($("form[role=form]"));
},
isdefault:function (){
$("#c-isdefault").change(function(){
if($(this).val()==1){
if(!confirm("确定修改为默认吗?")){
$(this).val(0);
}
}
});
}
}
};
return Controller;
});