NEZ-354 feat :表格添加根据字段排序的功能

This commit is contained in:
zhangyu
2020-07-15 18:32:25 +08:00
parent 514b907c97
commit 78dfc11028
11 changed files with 495 additions and 21 deletions

View File

@@ -94,7 +94,9 @@
v-show="mainResizeShow"
ref="endpointTable"
v-loading="loading"
style="width: 100%;">
style="width: 100%;"
@sort-change="tableDataSort"
>
<el-table-column
:resizable="false"
v-for="(item, index) in tablelable"
@@ -103,6 +105,8 @@
:key="`col-${index}`"
:label="item.label"
min-width="110px"
:sortable="sortableShow(item.prop)"
:prop="propTitle(item.prop)"
>
<template slot-scope="scope" :column="item" >
<span v-if="item.prop == 'asset' && scope.row[item.prop]" class="link" @click="detail(scope.row)">{{scope.row[item.prop].host}}</span>
@@ -578,6 +582,10 @@
},*/
//搜索
endpointSearch: function(searchObj) {
let orderBy='';
if(this.endpointSearchLabel.orderBy){
orderBy=this.endpointSearchLabel.orderBy
}
this.endpointSearchLabel = {};
this.endpointPageObj.pageNo = 1;
for (let item in searchObj) {
@@ -585,6 +593,9 @@
this.$set(this.endpointSearchLabel, item, searchObj[item]);
}
}
if(orderBy){
this.$set(this.endpointSearchLabel, 'orderBy', orderBy);
}
this.getEndpointTableData();
},
@@ -774,6 +785,39 @@
this.userData = response.data.list
}
})
},
//是否需要排序
sortableShow(prop){
switch(prop){
case 'id':
case 'asset':
case 'port':
case 'path':
return'custom';
default : return false;
}
},
// prop字段
propTitle(prop){
switch(prop){
case 'id': return'e.id';
case 'asset': return'a.host';
case 'port': return'e.port';
case 'path': return'e.path';
default : return prop;
}
},
// 数据排序
tableDataSort(item){
let orderBy='';
if(item.order==='ascending'){
orderBy=item.prop;
}
if(item.order==='descending'){
orderBy='-'+item.prop;
}
this.$set(this.endpointSearchLabel, "orderBy", orderBy);
this.getEndpointTableData();
}
},
created() {