1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- 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+"<br>"+row.platform.name;}},
- {field: 'host', title: __('Host')},
- {field: 'hostfile', title: __('Hostfile')},
- {field: 'isdefault', title: __('Isdefault'), visible:false, searchList: {"isdefault 0":__('Isdefault 0'),"isdefault 1":__('Isdefault 1')}},
- {field: 'isdefault_text', title: __('Isdefault'), operate:false},
- {field: 'status', title: __('Status'), visible:false, searchList: {"status 0":__('Status 0'),"status 1":__('Status 1')}},
- {field: 'status_text', title: __('Status'), operate:false},
- {field: 'p_desc', title: __('描述'), operate:false},
- {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;
- });
|