/**
 * 组织机构管理
 */
$(function(){

    AppOrganization = {
        Events : {'click .btn': function (e, value, row, index) {
			var event = $(e.target).data('event');
			if(event == 'view'){
                AppOrganization.view(value);
			}else if(event == 'edit'){
                AppOrganization.edit(value);
			}else if(event == 'power'){
                AppOrganization.power(value);
            }
		}},
		add : function(){
			window.location = String.format(Config.ROOT+'/auth/jump_basic?moduleId={0}&url=/sys/organization/edit', $('#moduleId').val());
		},
		edit: function(oid){
			window.location = String.format(Config.ROOT+'/auth/jump_basic?moduleId={0}&url=/sys/organization/edit?id={1}', $('#moduleId').val(), oid);
		},
        view: function(oid){
            window.location = String.format(Config.ROOT+'/auth/jump_basic?moduleId={0}&url=/sys/organization/edit&editType=view&id={1}', $('#moduleId').val(), oid);
        },
        power: function (oid){
            MsgBox.window({
                title	: '权限管理',
                url		: Config.ROOT+'/sys/organization/power?id='+oid,
                width   : 500,
                height  : 600
            });
        }
	};
	
	
	//初始化表格
    var $table = new App.Table({
        url: Config.ROOT + '/sys/organization/list',
        search: true,
        searchParamName: 'name',
        searchPlaceholder: '名称',
        columns	:[
            {checkbox: true},
            {field:'name', title:'组织机构名称'},
            {field:'state', title:'状态', tpl: 'tpl_state'},
            {field:'administratorRealName', title:'管理员姓名'},
            {field:'administratorUsername', title:'管理员账号'},
            {field:'contactName', title:'联系人'},
            {field:'contactMobile', title:'联系人电话'},
            {field:'id', title:'操作', width: 150, toolbar: 'tableRowToolbar', events: AppOrganization.Events}
        ]
    });

});