解决排序后刷新表头不显示排序的问题

main
wuyize 2022-07-14 15:14:32 +08:00
parent a014053d98
commit 4e547e43b6
2 changed files with 12 additions and 0 deletions

View File

@ -11,6 +11,7 @@
ref="tableRef" ref="tableRef"
class="projectTable" class="projectTable"
:height="tableHeight" :height="tableHeight"
:default-sort="defaultSort"
@sort-change="onSortChange" @sort-change="onSortChange"
@row-click="onRowClick" @row-click="onRowClick"
:data="tableData"> :data="tableData">
@ -72,6 +73,7 @@ const pageSize = ref(10)
const total = ref(0) const total = ref(0)
const sortBy = ref(null) const sortBy = ref(null)
const asc = ref(null) const asc = ref(null)
const defaultSort = ref(null)
const redirect = () => { const redirect = () => {
router.push({path: '/project/closed', query: {currentPage: currentPage.value, pageSize: pageSize.value, sortBy: sortBy.value, asc: asc.value}}) router.push({path: '/project/closed', query: {currentPage: currentPage.value, pageSize: pageSize.value, sortBy: sortBy.value, asc: asc.value}})
} }
@ -127,6 +129,10 @@ watch(
sortBy.value = router.currentRoute.value.query.sortBy sortBy.value = router.currentRoute.value.query.sortBy
if (router.currentRoute.value.query.asc) if (router.currentRoute.value.query.asc)
asc.value = router.currentRoute.value.query.asc asc.value = router.currentRoute.value.query.asc
defaultSort.value = {
prop: sortBy.value,
order: asc.value
}
getClosedProjects() getClosedProjects()
}, },
// //

View File

@ -12,6 +12,7 @@
<el-table <el-table
ref="tableRef" ref="tableRef"
class="projectTable" class="projectTable"
:default-sort="defaultSort"
@row-click="onRowClick" @row-click="onRowClick"
@sort-change="onSortChange" @sort-change="onSortChange"
:height="tableHeight" :height="tableHeight"
@ -87,6 +88,7 @@ const pageSize = ref(10)
const total = ref(0) const total = ref(0)
const sortBy = ref(null) const sortBy = ref(null)
const asc = ref(null) const asc = ref(null)
const defaultSort = ref(null)
const redirect = () => { const redirect = () => {
router.push({path: '/', query: {currentPage: currentPage.value, pageSize: pageSize.value, sortBy: sortBy.value, asc: asc.value}}) router.push({path: '/', query: {currentPage: currentPage.value, pageSize: pageSize.value, sortBy: sortBy.value, asc: asc.value}})
} }
@ -143,6 +145,10 @@ watch(
sortBy.value = router.currentRoute.value.query.sortBy sortBy.value = router.currentRoute.value.query.sortBy
if (router.currentRoute.value.query.asc) if (router.currentRoute.value.query.asc)
asc.value = router.currentRoute.value.query.asc asc.value = router.currentRoute.value.query.asc
defaultSort.value = {
prop: sortBy.value,
order: asc.value
}
getProjects() getProjects()
}, },
// //