|
@@ -118,7 +118,7 @@
|
|
|
border
|
|
|
:cell-class-name="tableCell"
|
|
|
:header-row-class-name="tableRowClassName"
|
|
|
- @cell-click="handle"
|
|
|
+ @sort-change="handleSort"
|
|
|
height="100%"
|
|
|
>
|
|
|
<el-table-column
|
|
@@ -131,14 +131,10 @@
|
|
|
:label="item.label"
|
|
|
v-for="(item, index) in state.tHeard"
|
|
|
:key="index"
|
|
|
+ :prop="item"
|
|
|
header-align="center"
|
|
|
show-overflow-tooltip
|
|
|
- sortable
|
|
|
- :sort-method="
|
|
|
- (a, b) => {
|
|
|
- return thSort(a, b, item);
|
|
|
- }
|
|
|
- "
|
|
|
+ sortable="custom"
|
|
|
>
|
|
|
<template #default="{ row }">
|
|
|
<div class="bar">
|
|
@@ -146,10 +142,13 @@
|
|
|
class="bar-percent"
|
|
|
:style="{
|
|
|
width:
|
|
|
- (row[`${item.code}_count`] /
|
|
|
- (row[`${item.code}_count`] + row[`${item.code}_time`])) *
|
|
|
- 100 +
|
|
|
- 'px',
|
|
|
+ row[`${item.code}_count`] && row[`${item.code}_time`]
|
|
|
+ ? (row[`${item.code}_count`] /
|
|
|
+ (row[`${item.code}_count`] +
|
|
|
+ row[`${item.code}_time`])) *
|
|
|
+ 100 +
|
|
|
+ 'px'
|
|
|
+ : '0px',
|
|
|
}"
|
|
|
></div>
|
|
|
<span class="value">{{ row[`${item.code}_count`] }} 次数</span>
|
|
@@ -159,10 +158,13 @@
|
|
|
class="bar-percent"
|
|
|
:style="{
|
|
|
width:
|
|
|
- (row[`${item.code}_time`] /
|
|
|
- (row[`${item.code}_count`] + row[`${item.code}_time`])) *
|
|
|
- 100 +
|
|
|
- 'px',
|
|
|
+ row[`${item.code}_count`] && row[`${item.code}_time`]
|
|
|
+ ? (row[`${item.code}_time`] /
|
|
|
+ (row[`${item.code}_count`] +
|
|
|
+ row[`${item.code}_time`])) *
|
|
|
+ 100 +
|
|
|
+ 'px'
|
|
|
+ : '0px',
|
|
|
}"
|
|
|
></div>
|
|
|
<span class="value">{{ row[`${item.code}_time`] }} 分钟</span>
|
|
@@ -429,9 +431,23 @@ function getTableList() {
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-const thSort = function (a, b, item) {
|
|
|
- return a[`${item.code}_count`] - b[`${item.code}_count`];
|
|
|
+//列排序
|
|
|
+const handleSort = function (val) {
|
|
|
+ let item = val.prop;
|
|
|
+ let list = JSON.parse(JSON.stringify(state.tableData));
|
|
|
+ if (val.order == "ascending") {
|
|
|
+ state.tableData = list.sort(compare(`${item.code}_count`));
|
|
|
+ } else if (val.order == "descending") {
|
|
|
+ state.tableData = list.sort(compare(`${item.code}_count`)).reverse();
|
|
|
+ }
|
|
|
+};
|
|
|
+//排序函数
|
|
|
+const compare = function (property) {
|
|
|
+ return function (a, b) {
|
|
|
+ var value1 = a[property];
|
|
|
+ var value2 = b[property];
|
|
|
+ return value1 - value2;
|
|
|
+ };
|
|
|
};
|
|
|
|
|
|
// // 单元格点击事件
|