$(function(){
    loadGrid();
});
function loadGrid() {
    $('#tb').datagrid({
        iconCls : 'icon-list',
        title : '',
        height: gridheight + 20,
        width: gridwidth ,
        url :  g.ctx+'pc/sys/sapLog/rest/list',
        singleSelect : true,
        pagination : true,
        idField : 'id',
        autoHeight:true,
        loadMsg:"数据加载中......",
        rownumbers : true,
        fitColumns:false,
        remoteSort : true,
        page:1,
        pageSize:10,
        queryParams: {
            page:1,
            rows:10
        },
        columns : [ [
            {
                field : 'ck',
                checkbox : true
            },
            {
                field : 'id',
                title : 'id',
                width : '5%',
                hidden:true
            },
            {
                field : 'interfaceName',
                title : '接口名称',
                width : '25%',
                sortable:true
            },
            {
                field : 'callResult',
                title : '状态',
                width : '15%',
                sortable:true,
                formatter:function (value) {
                    if (value == 0){
                        return '<span style="color:red;">失败</span>';
                    }else if (value == 1){
                        return '<span style="color:green;">成功</span>';;
                    }
                }
            },
            {
                field : 'operateUser',
                title : '操作人',
                width : '8%',
                sortable:true

            },
            {
                field : 'operateTime',
                title : '操作时间',
                width : '19%',
                sortable:true,
                formatter:function (value) {
                    return moment(value).format("YYYY-MM-DD HH:mm:ss");
                }


},
            {
                field : 'logInfo',
                title : '接口信息',
                width : '20%',
                hidden:true
            },
            {
                field : 'logDesc',
                title : '接口反馈',
                width : '30%'

            }
        ] ],
        toolbar : [
            {
                text: '查看',
                iconCls: 'icon-add',
                handler: function () {
                    look();
                }
            },
        ]
    });
}

function look() {
    var row =  $('#tb').datagrid('getSelected');
    var url = g.ctx + 'pc/sys/sapLog/look?id=' + row.id ;
    lookDialog = openDialog('lookDialog',url,{
        title:'查看',
        width:850,
        height:800,
        cache: false,
        modal: true,
        border: 'thin',
        onClose : function() {
            lookDialog.dialog('destroy');
        },
        buttons:[{
            text:'关闭',
            handler:function(){
                lookDialog.dialog('close');
            }
        }]
    })
}


