增加文档自定义排序

This commit is contained in:
龙运模
2024-07-30 15:45:25 +08:00
parent 67f098aa07
commit 06638fe04c
4 changed files with 67 additions and 20 deletions
+35 -9
View File
@@ -9,7 +9,7 @@
<template>
<div class="scTable" :style="{'height':_height}" ref="scTableMain" v-loading="loading">
<div class="scTable-table" :style="{'height':_table_height}">
<div class="scTable-table" :class="hidePagination && hideDo?'bottomNoBorder':''" :style="{'height':_table_height}">
<el-table v-bind="$attrs" :header-cell-style="{'background': '#F5F7FA','color':'#606266'}" :data="tableData" :row-key="rowKey" :key="toggleIndex" ref="scTable" :height="height=='auto'?null:'100%'" :size="config.size" :border="config.config.border" :stripe="config.config.stripe" :summary-method="remoteSummary?remoteSummaryMethod:summaryMethod" @sort-change="sortChange" @filter-change="filterChange">
<slot></slot>
<template v-for="(item, index) in userColumn" :key="index">
@@ -95,7 +95,8 @@
hideRefresh: { type: Boolean, default: false },
hideSetting: { type: Boolean, default: false },
paginationLayout: { type: String, default: config.paginationLayout },
rowChild:{type:Boolean, default:true}
rowChild:{type:Boolean, default:true},
docsSort:{type:Boolean, default:false},
},
watch: {
//监听从props里拿到值了
@@ -122,7 +123,7 @@
data() {
return {
scPageSize: this.pageSize,
isActivat: true,
isAvatar: true,
emptyText: "暂无数据",
toggleIndex: 0,
tableData: [],
@@ -130,6 +131,7 @@
currentPage: 1,
prop: null,
order: null,
sort_orders:{},
loading: false,
tableHeight:'100%',
tableParams: this.params,
@@ -161,12 +163,12 @@
}
},
activated(){
if(!this.isActivat){
if(!this.isAvatar){
this.$refs.scTable.doLayout()
}
},
deactivated(){
this.isActivat = false;
this.isAvatar = false;
},
methods: {
//获取列
@@ -181,8 +183,14 @@
[config.request.page]: this.currentPage,
[config.request.pageSize]: this.scPageSize,
[config.request.prop]: this.prop,
[config.request.order]: this.order
[config.request.order]: this.order,
};
if(this.docsSort){
reqData[config.request.sort_orders] = this.sort_orders;
delete reqData[config.request.prop]
delete reqData[config.request.order]
console.log(this.tableParams,344)
}
if(this.hidePagination){
delete reqData[config.request.page]
delete reqData[config.request.pageSize]
@@ -311,8 +319,25 @@
this.prop = null
this.order = null
}
this.sort_orders = {};
this.addObjectProperty(this.sort_orders,{key:obj.prop, value:obj.order});
this.getData()
},
addObjectProperty(obj, { key, value }) {
let val = value=='ascending'?'asc':value=='descending'?'desc':'';
if (!(key in obj)) {
obj[key] = val;
if(this.docsSort && key == 'name'){
obj.client_file_name = val;
}
}else{
obj[key] = val;
if(this.docsSort && key == 'name'){
obj.client_file_name = val;
}
}
},
//本地过滤
filterHandler(value, row, column){
const property = column.property;
@@ -430,7 +455,8 @@
.scTable-table {height: calc(100% - 50px);}
.scTable-page {height:50px;display: flex;align-items: center;justify-content: space-between;padding:0 15px;}
.scTable-do {white-space: nowrap;}
.scTable:deep(.el-table__footer) .cell {font-weight: bold;}
.scTable:deep(.el-table__body-wrapper) .el-scrollbar__bar.is-horizontal {height: 12px;border-radius: 12px;}
.scTable:deep(.el-table__body-wrapper) .el-scrollbar__bar.is-vertical {width: 12px;border-radius: 12px;}
.scTable ::v-deep .el-table__footer .cell {font-weight: bold;}
.scTable ::v-deep .el-table__body-wrapper .el-scrollbar__bar.is-horizontal {height: 12px;border-radius: 12px;}
.scTable ::v-deep .el-table__body-wrapper .el-scrollbar__bar.is-vertical {width: 12px;border-radius: 12px;}
.bottomNoBorder ::v-deep .el-table__inner-wrapper:before{height: 0;}
</style>