$(function(){
ua.table.render({
init: init,
toolbar: [],
defaultToolbar: ['filter'],
cols: [[
{field: 'id', title: 'ID', width: 80, sort: true},
{field: 'watch_id', title: '监控规则', width: 160, search: 'select', searchOp: '=', selectList: ua.getDataBrage('select_list_watch'), templet: function(d) {
return d.watch && d.watch.name ? d.watch.name : ('#' + d.watch_id);
}},
{field: 'run.url', title: '请求 URL', minWidth: 220, search: false, templet: function(d) {
if (!d.run || !d.run.url) {
return '#' + d.run_id + '';
}
var esc = String(d.run.url).replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"');
return '' + esc + '';
}},
{field: 'run.request_time', title: '请求时间', width: 170, search: 'range', templet: function(d) {
if (!d.run || !d.run.request_time) {
return '-';
}
var ts = parseFloat(d.run.request_time);
if (isNaN(ts) || ts <= 0) {
return '-';
}
return window.UA_CORE.util.toDateString(ts * 1000, 'yyyy-MM-dd HH:mm:ss');
}},
{field: 'ct', title: '命中次数', width: 100, search: 'number_limit'},
{field: 'wt_sum', title: '耗时合计(ms)', width: 140, search: 'number_limit', templet: function(d) {
var ms = parseFloat(d.wt_sum) / 1000;
var threshold = d.watch ? parseInt(d.watch.threshold_ms, 10) : 0;
var text = (isNaN(ms) ? 0 : ms).toFixed(3) + ' ms';
if (threshold > 0 && ms > threshold) {
return '' + text + '(超阈值 ' + threshold + 'ms)';
}
return text;
}},
{field: 'wt_max', title: '单次最大(ms)', width: 130, search: 'number_limit', templet: function(d) {
var ms = parseFloat(d.wt_max) / 1000;
return (isNaN(ms) ? 0 : ms).toFixed(3) + ' ms';
}},
{field: 'create_time', title: '入库时间', width: 170, search: false, templet: ua.table.date},
{
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();
})