$(function () {
    loadGrid();
});

function loadGrid() {
    $('#tb').datagrid({
        iconCls: 'icon-list',
        title: '',
        height: gridheight - 40,
        width: gridwidth,
        url: g.ctx+ 'pc/sys/loginLog/rest/list',
        singleSelect: true,
        pagination: true,
        idField: 'id',
        autoHeight: true,
        loadMsg: "数据加载中......",
        rownumbers: true,
        fitColumns: false,
        nowrap: true,
        remoteSort: true,
        striped: true,
        page: 1,
        pageSize: 10,
        queryParams: {
            page: 1,
            rows: 10,
            name: "",
            desc: ""
        },
        columns: [[
            {
                field: 'ck',
                checkbox: true
            },
            {
                field: 'accountName',
                title: '登录账户',
                width: '15%',
                align: 'left'
            },
            {
                field: 'userName',
                title: '用户名',
                width: '15%',
                align: 'left'
            },
            {
                field: 'supplierName',
                title: '供应商名称',
                width: '15%',
                align: 'left'
            },
            {
                field: 'loginIp',
                title: '登录IP地址',
                width: '24%',
                align: 'left'
            },
            {
                field: 'deviceName',
                title: '登录设备',
                width: '20%',
                align: 'left'
            },
            {
                field: 'loginTime',
                title: '登录时间',
                width: '10%',
                align: 'left',
                formatter: function (value) {
                    if (!value) {
                        return '';
                    }
                    return moment(value).format('YYYY-MM-DD HH:mm:ss');
                }
            }
        ]],
        // toolbar: [{
        //     text: '导出数据',
        //     iconCls: 'icon-up',
        //     handler: function () {
        //         commonExportExcel("#tb", "exportLoginLogExcel");
        //     }
        // }]
    });
};

