添加排序

This commit is contained in:
GGJ
2025-04-28 09:14:56 +08:00
parent 1e3b60eaaa
commit adc9b5a955
5 changed files with 24 additions and 8 deletions

View File

@@ -78,7 +78,7 @@
</el-button>
</template>
</TableHeader>
<Table ref="tableRef" :checkbox-config="checkboxConfig" :key="tableKey"></Table>
<Table ref="tableRef" :checkbox-config="checkboxConfig" :key="tableKey" @sort-change="handleSortChange"></Table>
<el-dialog
:title="dialogTitle"
@@ -305,7 +305,7 @@ const tableStore = new TableStore({
return row.cellValue === 'MQTT' ? 'MQTT' : row.cellValue === 'CLD' ? 'CLD' : row.cellValue
}
},
{ title: '录入时间', field: 'createTime' },
{ title: '录入时间', field: 'createTime',sortable: true },
{
title: '使用状态',
@@ -638,6 +638,8 @@ tableStore.table.params.devType = ''
tableStore.table.params.devModel = ''
tableStore.table.params.devAccessMethod = ''
tableStore.table.params.status = ''
tableStore.table.params.sortBy = ''
tableStore.table.params.orderBy = ''
// 设备类型
const devTypeChange = (e: any) => {
@@ -732,7 +734,21 @@ const downLoadQrCode = async () => {
qrcodeFlag.value = false
}, 500)
}
// 排序
const handleSortChange = ({ column, order }: { column: TableColumn; order: 'asc' | 'desc' | null }) => {
// console.log('排序列:', column?.property);
// console.log('排序顺序:', order);
// tableStore.onTableAction('sortable', { column, order })
tableStore.table.params.sortBy = column?.property
tableStore.table.params.orderBy = order
tableStore.table.params.pageNum = 1
tableStore.index()
// // 在这里可以根据 column 和 order 进行相应的数据排序操作
// if (order === 'asc') {
// } else if (order === 'desc') {
// }
}
// 示例用法
// 新增