|
60 | 60 | },
|
61 | 61 |
|
62 | 62 | mounted: function () {
|
| 63 | + $.fn.dataTable.ext.type.order['duration-pre'] = function (data) { |
| 64 | + var matches = data.match(/^(\d+(?:\.\d+)?)\s*([a-z]+)/i); |
| 65 | + if (!matches) { |
| 66 | + return -1; |
| 67 | + } |
| 68 | + var duration = parseFloat(matches[1]); |
| 69 | + switch (matches[2]) { |
| 70 | + case "d": |
| 71 | + duration *= 24; |
| 72 | + case "h": |
| 73 | + duration *= 60; |
| 74 | + case "m": |
| 75 | + duration *= 60; |
| 76 | + case "s": |
| 77 | + duration *= 1000; |
| 78 | + } |
| 79 | + return duration; |
| 80 | + }; |
63 | 81 | var me = this, dt = me.dataTable = $(me.$el).find('table:first').DataTable({
|
64 | 82 | bDestroy: true,
|
65 | 83 | bProcessing: true,
|
|
70 | 88 | {title: "方法名", data: "methodName", name: "methodName"},
|
71 | 89 | {title: "成功数", data: "successCount", name: "successCount"},
|
72 | 90 | {title: "失败数", data: "errorCount", name: "errorCount"},
|
73 |
| - {title: "最小时长", data: "minDuration", name: "minDuration"}, |
74 |
| - {title: "最大时长", data: "maxDuration", name: "maxDuration"}, |
75 |
| - {title: "总时长", data: "totalDuration", name: "totalDuration"}, |
| 91 | + { |
| 92 | + title: "最小时长", |
| 93 | + data: "minDuration", |
| 94 | + name: "minDuration", |
| 95 | + type: "duration", |
| 96 | + render: function (data, type, row, meta) { |
| 97 | + return Tools.formatMillisec(data); |
| 98 | + } |
| 99 | + }, |
| 100 | + { |
| 101 | + title: "最大时长", |
| 102 | + data: "maxDuration", |
| 103 | + name: "maxDuration", |
| 104 | + type: "duration", |
| 105 | + render: function (data, type, row, meta) { |
| 106 | + return Tools.formatMillisec(data); |
| 107 | + } |
| 108 | + }, |
| 109 | + { |
| 110 | + title: "总时长", |
| 111 | + data: "totalDuration", |
| 112 | + name: "totalDuration", |
| 113 | + type: "duration", |
| 114 | + render: function (data, type, row, meta) { |
| 115 | + return Tools.formatMillisec(data); |
| 116 | + } |
| 117 | + }, |
76 | 118 | {
|
77 | 119 | title: "平均时长",
|
78 | 120 | render: function (data, type, row, meta) {
|
79 |
| - return Math.round(row.totalDuration / (row.successCount + row.errorCount)); |
| 121 | + return Tools.formatMillisec(row.totalDuration / (row.successCount + row.errorCount)); |
80 | 122 | }
|
81 | 123 | }
|
82 | 124 | ],
|
|
0 commit comments