feat: 操作日志 排序查询

This commit is contained in:
dap 2024-10-10 08:27:56 +08:00
parent 493a0effe8
commit df79908056
2 changed files with 21 additions and 4 deletions

View File

@ -78,10 +78,11 @@ export const columns: VxeGridProps['columns'] = [
},
},
},
{ field: 'operTime', title: '操作日期' },
{ field: 'operTime', title: '操作日期', sortable: true },
{
field: 'costTime',
title: '操作耗时',
sortable: true,
formatter({ cellValue }) {
return `${cellValue} ms`;
},

View File

@ -10,6 +10,7 @@ import { $t } from '@vben/locales';
import { Modal, Space } from 'ant-design-vue';
import dayjs from 'dayjs';
import { isEmpty } from 'lodash-es';
import { useVbenVxeGrid, type VxeGridProps } from '#/adapter';
import {
@ -47,7 +48,7 @@ const gridOptions: VxeGridProps<OperationLog> = {
pagerConfig: {},
proxyConfig: {
ajax: {
query: async ({ page }, formValues = {}) => {
query: async ({ page, sort }, formValues = {}) => {
//
if (formValues?.createTime) {
formValues.params = {
@ -62,11 +63,20 @@ const gridOptions: VxeGridProps<OperationLog> = {
} else {
Reflect.deleteProperty(formValues, 'params');
}
return await operLogList({
const params: any = {
pageNum: page.currentPage,
pageSize: page.pageSize,
...formValues,
});
};
console.log(sort);
if (!isEmpty(sort)) {
params.orderByColumn = sort.field;
params.isAsc = sort.order;
}
console.log(params);
return await operLogList(params);
},
},
},
@ -74,6 +84,9 @@ const gridOptions: VxeGridProps<OperationLog> = {
isHover: true,
keyField: 'operId',
},
sortConfig: {
remote: true,
},
round: true,
align: 'center',
showOverflow: true,
@ -84,6 +97,9 @@ const [BasicTable, tableApi] = useVbenVxeGrid({
formOptions,
gridOptions,
gridEvents: {
sortChange: () => {
tableApi.query();
},
checkboxChange: (e: any) => {
checked.value = e.records.length > 0;
},