$(function(){ ua.table.render({ init: init, toolbar: [], defaultToolbar: ['filter'], cols: [[ {type: 'checkbox'}, {field: 'time_local', title: '时间', width: 170, search: 'range', templet: ua.table.date}, {field: 'method', title: '方法', width: 80, search: 'select', selectList: {GET: 'GET', POST: 'POST', PUT: 'PUT', DELETE: 'DELETE', HEAD: 'HEAD', OPTIONS: 'OPTIONS', PATCH: 'PATCH'}}, {field: 'uri', title: 'URI', minWidth: 200, searchOp: '%*%'}, {field: 'status', title: '状态码', width: 90, search: 'select', selectList: {200: '200', 301: '301', 302: '302', 304: '304', 400: '400', 401: '401', 403: '403', 404: '404', 499: '499', 500: '500', 502: '502', 503: '503', 504: '504'}, templet: function(d) { var s = parseInt(d.status); var cls = 'layui-badge'; if (s >= 200 && s < 300) cls = 'layui-badge layui-bg-green'; else if (s >= 300 && s < 400) cls = 'layui-badge layui-bg-blue'; else if (s >= 400 && s < 500) cls = 'layui-badge layui-bg-orange'; else if (s >= 500) cls = 'layui-badge layui-bg-red'; return '' + d.status + ''; }}, {field: 'node_id', title: '节点', width: 120, searchOp: '='}, {field: 'remote_addr', title: '客户端IP', width: 140, searchOp: '%*%'}, {field: 'request_time', title: '耗时(秒)', width: 100, search: 'number_limit', templet: function(d) { var t = parseFloat(d.request_time); if (t >= 1) return '' + t + 's'; if (t >= 0.3) return '' + t + 's'; return t + 's'; }}, {field: 'body_bytes_sent', title: '响应字节', width: 100, search: 'number_limit'}, {field: 'http_user_agent', title: 'User-Agent', minWidth: 200, search: false}, { width: 100, title: '操作', templet: ua.table.tool, fixed: 'right', operat: [ [{ class: 'layui-btn layui-btn-primary layui-btn-xs', method: 'tab', field: 'id', text: '详情', title: '查看详情', auth: 'read', url: init.readUrl, icon: '' }] ] }, ]], }); ua.listen(); })