/**
 * 系统用户选择
 */
$(function(){

    AppUserSelect = {
        Events : {'click .btn': function (e, value, row, index) {
            var event = $(e.target).data('event');
            if(event == 'select'){
                parent.MsgBox.windowReturnData({
                    'id'    : value,
                    'name'  : row.realName
                });
                parent.MsgBox.close();
            }
        }}
	};

    $('#administrator_tree_id').zTreeInit({
        url     : Config.ROOT + '/sys/dept/treeList',
        callback: {
            onClick: function(event, treeId, treeNode) {
                var deptId = treeNode.oid || treeNode.id;
                var postData = {
                    'deptId': deptId
                };
                $table.search(postData);
            }
        }
    });
	
	//初始化表格
    var $table = new App.Table({
        url: Config.ROOT + '/sys/user/list?state=1',
        search: true,
        searchParamName: 'realName',
        searchPlaceholder: '名称',
        showToggle: false,
        showColumns: false,
        columns	:[
            {field:'realName', title:'姓名', sortable: true},
            {field:'username', title:'登录名', sortable: true},
            {field:'oid', title:'操作', width: 80, toolbar: 'tableRowToolbar', events: AppUserSelect.Events}
        ]
    });

});