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', field: 'costTime',
title: '操作耗时', title: '操作耗时',
sortable: true,
formatter({ cellValue }) { formatter({ cellValue }) {
return `${cellValue} ms`; return `${cellValue} ms`;
}, },

View File

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