😎调整日志相关管理页面

This commit is contained in:
zuohuaijun 2024-07-11 01:13:59 +08:00
parent c88067ac0b
commit e06ddafce6
5 changed files with 304 additions and 327 deletions

View File

@ -21,7 +21,7 @@
<el-row>
<el-col>
<el-button-group>
<el-button type="primary" icon="ele-Search" @click="handleQuery(true)" v-auth="'sysDifflog:page'" :loading="options.loading"> 查询 </el-button>
<el-button type="primary" icon="ele-Search" @click="handleQuery" v-auth="'sysDifflog:page'" :loading="options.loading"> 查询 </el-button>
<el-button icon="ele-Refresh" @click="resetQuery" :loading="options.loading"> 重置 </el-button>
</el-button-group>
</el-col>
@ -29,7 +29,7 @@
</el-card>
<el-card class="full-table" shadow="hover" style="margin-top: 5px">
<vxe-grid ref="xGrid" class="xGrid-style" v-bind="options" @sort-change="sortChange">
<vxe-grid ref="xGrid" class="xGrid-style" v-bind="options" v-on="gridEvents">
<template #toolbar_buttons>
<el-button icon="ele-DeleteFilled" type="danger" @click="handleClear" v-auth="'sysDifflog:clear'"> 清空 </el-button>
</template>
@ -39,15 +39,6 @@
<template #empty>
<el-empty :image-size="200" />
</template>
<template #pager>
<vxe-pager
:loading="options.loading"
v-model:current-page="state.tableParams.page"
v-model:page-size="state.tableParams.pageSize"
:total="state.tableParams.total"
@page-change="pageChange"
/>
</template>
</vxe-grid>
</el-card>
</div>
@ -58,12 +49,13 @@ import { onMounted, reactive, ref } from 'vue';
import { ElMessage } from 'element-plus';
import { useDateTimeShortCust } from '/@/hooks/dateTimeShortCust';
import { auth } from '/@/utils/authFunction';
import { VxeGridInstance, VxePagerEvents, VxePagerDefines } from 'vxe-table';
import { useVxeTable } from '/@/hooks/vxeTableOptionsHook';
import { VxeGridInstance, VxeGridListeners, VxeGridPropTypes } from 'vxe-table';
import { useVxeTable } from '/@/hooks/useVxeTableOptionsHook';
import { Local } from '/@/utils/storage';
import { getAPI } from '/@/utils/axios-utils';
import { SysLogDiffApi } from '/@/api-services/api';
import { SysLogDiff } from '/@/api-services/models';
import { SysLogDiff, PageLogInput } from '/@/api-services/models';
const xGrid = ref<VxeGridInstance>();
const shortcuts = useDateTimeShortCust();
@ -72,66 +64,82 @@ const state = reactive({
startTime: undefined,
endTime: undefined,
},
tableParams: {
page: 1,
pageSize: 50,
field: 'id', //
order: 'desc', //
descStr: 'desc', //
total: 0 as any,
localPageParam: {
pageSize: 50 as number,
defaultSort: { field: 'orderNo', order: 'asc', descStr: 'desc' },
},
});
//
const localPageParamKey = 'localPageParam:sysDiffLog';
//
const options = useVxeTable<SysLogDiff>({
id: 'sysDiffLog',
name: '差异日志',
columns: [
// { type: 'checkbox', width: 40 },
{ type: 'seq', title: '序号', width: 60, fixed: 'left' },
{ field: 'diffType', title: '差异操作', minWidth: 150, showOverflow: 'tooltip' },
{ field: 'sql', title: 'Sql语句', minWidth: 150, showOverflow: 'tooltip' },
{ field: 'parameters', title: '参数', minWidth: 150, showOverflow: 'tooltip' },
{ field: 'elapsed', title: '耗时(ms)', minWidth: 150, showOverflow: 'tooltip' },
{ field: 'message', title: '日志消息', minWidth: 150, showOverflow: 'tooltip' },
{ field: 'beforeData', title: '操作前记录', minWidth: 150, showOverflow: 'tooltip' },
{ field: 'afterData', title: '操作后记录', minWidth: 150, showOverflow: 'tooltip' },
{ field: 'businessData', title: '业务对象', minWidth: 150, showOverflow: 'tooltip' },
{ field: 'createTime', title: '操作时间', minWidth: 100, showOverflow: 'tooltip' },
],
enableExport: auth('sysDifflog:export'),
searchCallback: () => handleQuery(),
queryAllCallback: () => fetchData({ pageSize: 99999 }),
});
const options = useVxeTable<SysLogDiff>(
{
id: 'sysDiffLog',
name: '差异日志',
columns: [
// { type: 'checkbox', width: 40 },
{ type: 'seq', title: '序号', width: 60, fixed: 'left' },
{ field: 'diffType', title: '差异操作', minWidth: 150, showOverflow: 'tooltip' },
{ field: 'sql', title: 'Sql语句', minWidth: 150, showOverflow: 'tooltip' },
{ field: 'parameters', title: '参数', minWidth: 150, showOverflow: 'tooltip' },
{ field: 'elapsed', title: '耗时(ms)', minWidth: 150, showOverflow: 'tooltip' },
{ field: 'message', title: '日志消息', minWidth: 150, showOverflow: 'tooltip' },
{ field: 'beforeData', title: '操作前记录', minWidth: 150, showOverflow: 'tooltip' },
{ field: 'afterData', title: '操作后记录', minWidth: 150, showOverflow: 'tooltip' },
{ field: 'businessData', title: '业务对象', minWidth: 150, showOverflow: 'tooltip' },
{ field: 'createTime', title: '操作时间', minWidth: 100, showOverflow: 'tooltip' },
],
},
// vxeGrid()vxe-table
{
//
proxyConfig: { autoLoad: true, ajax: { query: ({ page, sort }) => handleQueryApi(page, sort) } },
//
sortConfig: { defaultSort: Local.get(localPageParamKey)?.defaultSort || state.localPageParam.defaultSort },
//
pagerConfig: { pageSize: Local.get(localPageParamKey)?.pageSize || state.localPageParam.pageSize },
//
toolbarConfig: { export: false },
}
);
//
onMounted(async () => {
state.localPageParam = Local.get(localPageParamKey) || state.localPageParam;
await handleQuery();
});
//
const handleQuery = async (reset = false) => {
options.loading = true;
if (reset) state.tableParams.page = 1;
var res = await fetchData(null);
xGrid.value?.loadData(res.data.result?.items ?? []);
state.tableParams.total = res.data.result?.total;
options.loading = false;
};
//
const fetchData = async (tableParams: any) => {
if (state.queryParams.startTime == null) state.queryParams.startTime = undefined;
if (state.queryParams.endTime == null) state.queryParams.endTime = undefined;
let params = Object.assign(state.queryParams, state.tableParams, tableParams);
// api
const handleQueryApi = async (page: VxeGridPropTypes.ProxyAjaxQueryPageParams, sort: VxeGridPropTypes.ProxyAjaxQuerySortCheckedParams) => {
const params = Object.assign(state.queryParams, { page: page.currentPage, pageSize: page.pageSize, field: sort.field, order: sort.order, descStr: 'desc' }) as PageLogInput;
return getAPI(SysLogDiffApi).apiSysLogDiffPagePost(params);
};
//
const handleQuery = async () => {
await xGrid.value?.commitProxy('query');
};
//
const resetQuery = () => {
const resetQuery = async () => {
state.queryParams.startTime = undefined;
state.queryParams.endTime = undefined;
handleQuery(true);
await xGrid.value?.commitProxy('reload');
};
//
const gridEvents: VxeGridListeners<SysLogDiff> = {
// pager-config
async pageChange({ pageSize }) {
state.localPageParam.pageSize = pageSize;
Local.set(localPageParamKey, state.localPageParam);
},
//
async sortChange({ field, order }) {
state.localPageParam.defaultSort = { field: field, order: order!, descStr: 'desc' };
Local.set(localPageParamKey, state.localPageParam);
},
};
//
@ -142,18 +150,4 @@ const handleClear = async () => {
ElMessage.success('清空成功');
handleQuery();
};
//
const pageChange: VxePagerEvents.PageChange = ({ currentPage, pageSize }: VxePagerDefines.PageChangeEventParams) => {
state.tableParams.page = currentPage;
state.tableParams.pageSize = pageSize;
handleQuery();
};
//
const sortChange = (options: any) => {
state.tableParams.field = options.field;
state.tableParams.order = options.order;
handleQuery();
};
</script>

View File

@ -15,12 +15,12 @@
</el-col>
<el-col class="mb5" :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
<el-form-item label="显示名称" prop="displayTitle">
<el-input v-model="state.queryParams.displayTitle" clearable placeholder="显示名称" @keyup.enter.native="handleQuery(true)" />
<el-input v-model="state.queryParams.displayTitle" clearable placeholder="显示名称" @keyup.enter.native="handleQuery" />
</el-form-item>
</el-col>
<el-col class="mb5" :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
<el-form-item label="操作人" prop="realName">
<el-input v-model="state.queryParams.realName" clearable placeholder="操作人" @keyup.enter.native="handleQuery(true)" />
<el-input v-model="state.queryParams.realName" clearable placeholder="操作人" @keyup.enter.native="handleQuery" />
</el-form-item>
</el-col>
</el-row>
@ -31,7 +31,7 @@
<el-row>
<el-col>
<el-button-group>
<el-button type="primary" icon="ele-Search" @click="handleQuery(true)" v-auth="'sysExlog:page'" :loading="options.loading"> 查询 </el-button>
<el-button type="primary" icon="ele-Search" @click="handleQuery" v-auth="'sysExlog:page'" :loading="options.loading"> 查询 </el-button>
<el-button icon="ele-Refresh" @click="resetQuery" :loading="options.loading"> 重置 </el-button>
</el-button-group>
</el-col>
@ -39,7 +39,7 @@
</el-card>
<el-card class="full-table" shadow="hover" style="margin-top: 5px">
<vxe-grid ref="xGrid" class="xGrid-style" v-bind="options" @cell-dblclick="handleView" @sort-change="sortChange">
<vxe-grid ref="xGrid" class="xGrid-style" v-bind="options" v-on="gridEvents" @cell-dblclick="handleView">
<template #toolbar_buttons>
<el-button icon="ele-DeleteFilled" type="danger" @click="handleClear" v-auth="'sysExlog:clear'"> 清空 </el-button>
</template>
@ -61,15 +61,6 @@
<template #row_buttons="{ row }">
<el-button icon="ele-InfoFilled" text type="primary" @click="handleView({ row })">详情</el-button>
</template>
<template #pager>
<vxe-pager
:loading="options.loading"
v-model:current-page="state.tableParams.page"
v-model:page-size="state.tableParams.pageSize"
:total="state.tableParams.total"
@page-change="pageChange"
/>
</template>
</vxe-grid>
</el-card>
@ -106,15 +97,16 @@ import { onMounted, reactive, ref } from 'vue';
import { ElMessage } from 'element-plus';
import { useDateTimeShortCust } from '/@/hooks/dateTimeShortCust';
import { auth } from '/@/utils/authFunction';
import { VxeGridInstance, VxePagerEvents, VxePagerDefines } from 'vxe-table';
import { useVxeTable } from '/@/hooks/vxeTableOptionsHook';
import { VxeGridInstance, VxeGridListeners, VxeGridPropTypes } from 'vxe-table';
import { useVxeTable } from '/@/hooks/useVxeTableOptionsHook';
import { Local } from '/@/utils/storage';
import VueJsonPretty from 'vue-json-pretty';
import 'vue-json-pretty/lib/styles.css';
import { StringToObj } from '/@/utils/json-utils';
import { getAPI } from '/@/utils/axios-utils';
import { SysLogExApi } from '/@/api-services/api';
import { SysLogEx } from '/@/api-services/models';
import { SysLogEx, PageLogInput } from '/@/api-services/models';
const xGrid = ref<VxeGridInstance>();
const shortcuts = useDateTimeShortCust();
@ -125,13 +117,9 @@ const state = reactive({
displayTitle: '',
realName: '',
},
tableParams: {
page: 1,
pageSize: 50,
field: 'id', //
order: 'desc', //
descStr: 'desc', //
total: 0 as any,
localPageParam: {
pageSize: 50 as number,
defaultSort: { field: 'orderNo', order: 'asc', descStr: 'desc' },
},
visible: false,
detail: {
@ -143,70 +131,90 @@ const state = reactive({
activeTab: 'message',
});
//
const localPageParamKey = 'localPageParam:sysExLog';
//
const options = useVxeTable<SysLogEx>({
id: 'sysExLog',
name: '异常日志',
columns: [
// { type: 'checkbox', width: 40 },
{ type: 'seq', title: '序号', width: 60, fixed: 'left' },
{ field: 'controllerName', title: '模块名称', minWidth: 100, showOverflow: 'tooltip' },
{ field: 'displayTitle', title: '显示名称', minWidth: 150, showOverflow: 'tooltip' },
{ field: 'actionName', title: '方法名称', minWidth: 100, showOverflow: 'tooltip' },
{ field: 'httpMethod', title: '请求方式', minWidth: 90, showOverflow: 'tooltip' },
{ field: 'requestUrl', title: '请求地址', minWidth: 300, showOverflow: 'tooltip' },
{ field: 'logLevel', title: '级别', minWidth: 70, showOverflow: 'tooltip', slots: { default: 'row_logLevel' } },
{ field: 'eventId', title: '事件Id', minWidth: 80, showOverflow: 'tooltip' },
{ field: 'threadId', title: '线程Id', minWidth: 90, showOverflow: 'tooltip' },
{ field: 'traceId', title: '请求跟踪Id', minWidth: 150, showOverflow: 'tooltip' },
{ field: 'account', title: '账号名称', minWidth: 100, showOverflow: 'tooltip' },
{ field: 'realName', title: '真实姓名', minWidth: 100, showOverflow: 'tooltip' },
{ field: 'remoteIp', title: 'IP地址', minWidth: 100, showOverflow: 'tooltip' },
{ field: 'location', title: '登录地点', minWidth: 100, showOverflow: 'tooltip' },
{ field: 'longitude', title: '经度', minWidth: 100, showOverflow: 'tooltip' },
{ field: 'latitude', title: '纬度', minWidth: 100, showOverflow: 'tooltip' },
{ field: 'browser', title: '浏览器', minWidth: 100, showOverflow: 'tooltip' },
{ field: 'os', title: '操作系统', minWidth: 100, showOverflow: 'tooltip' },
{ field: 'status', title: '状态', minWidth: 70, showOverflow: 'tooltip', slots: { default: 'row_status' } },
{ field: 'elapsed', title: '耗时(ms)', minWidth: 100, showOverflow: 'tooltip' },
{ field: 'logDateTime', title: '日志时间', minWidth: 160, showOverflow: 'tooltip' },
{ title: '操作', fixed: 'right', width: 100, showOverflow: true, slots: { default: 'row_buttons' } },
],
enableExport: auth('sysExlog:export'),
searchCallback: () => handleQuery(),
queryAllCallback: () => fetchData({ pageSize: 99999 }),
});
const options = useVxeTable<SysLogEx>(
{
id: 'sysExLog',
name: '异常日志',
columns: [
// { type: 'checkbox', width: 40 },
{ type: 'seq', title: '序号', width: 60, fixed: 'left' },
{ field: 'controllerName', title: '模块名称', minWidth: 100, showOverflow: 'tooltip' },
{ field: 'displayTitle', title: '显示名称', minWidth: 150, showOverflow: 'tooltip' },
{ field: 'actionName', title: '方法名称', minWidth: 100, showOverflow: 'tooltip' },
{ field: 'httpMethod', title: '请求方式', minWidth: 90, showOverflow: 'tooltip' },
{ field: 'requestUrl', title: '请求地址', minWidth: 300, showOverflow: 'tooltip' },
{ field: 'logLevel', title: '级别', minWidth: 70, showOverflow: 'tooltip', slots: { default: 'row_logLevel' } },
{ field: 'eventId', title: '事件Id', minWidth: 80, showOverflow: 'tooltip' },
{ field: 'threadId', title: '线程Id', minWidth: 90, showOverflow: 'tooltip' },
{ field: 'traceId', title: '请求跟踪Id', minWidth: 150, showOverflow: 'tooltip' },
{ field: 'account', title: '账号名称', minWidth: 100, showOverflow: 'tooltip' },
{ field: 'realName', title: '真实姓名', minWidth: 100, showOverflow: 'tooltip' },
{ field: 'remoteIp', title: 'IP地址', minWidth: 100, showOverflow: 'tooltip' },
{ field: 'location', title: '登录地点', minWidth: 100, showOverflow: 'tooltip' },
{ field: 'longitude', title: '经度', minWidth: 100, showOverflow: 'tooltip' },
{ field: 'latitude', title: '纬度', minWidth: 100, showOverflow: 'tooltip' },
{ field: 'browser', title: '浏览器', minWidth: 100, showOverflow: 'tooltip' },
{ field: 'os', title: '操作系统', minWidth: 100, showOverflow: 'tooltip' },
{ field: 'status', title: '状态', minWidth: 70, showOverflow: 'tooltip', slots: { default: 'row_status' } },
{ field: 'elapsed', title: '耗时(ms)', minWidth: 100, showOverflow: 'tooltip' },
{ field: 'logDateTime', title: '日志时间', minWidth: 160, showOverflow: 'tooltip' },
{ title: '操作', fixed: 'right', width: 100, showOverflow: true, slots: { default: 'row_buttons' } },
],
},
// vxeGrid()vxe-table
{
//
proxyConfig: { autoLoad: true, ajax: { query: ({ page, sort }) => handleQueryApi(page, sort) } },
//
sortConfig: { defaultSort: Local.get(localPageParamKey)?.defaultSort || state.localPageParam.defaultSort },
//
pagerConfig: { pageSize: Local.get(localPageParamKey)?.pageSize || state.localPageParam.pageSize },
//
toolbarConfig: { export: false },
}
);
//
onMounted(async () => {
state.localPageParam = Local.get(localPageParamKey) || state.localPageParam;
await handleQuery();
});
//
const handleQuery = async (reset = false) => {
options.loading = true;
if (reset) state.tableParams.page = 1;
var res = await fetchData(null);
xGrid.value?.loadData(res.data.result?.items ?? []);
state.tableParams.total = res.data.result?.total;
options.loading = false;
};
//
const fetchData = async (tableParams: any) => {
if (state.queryParams.startTime == null) state.queryParams.startTime = undefined;
if (state.queryParams.endTime == null) state.queryParams.endTime = undefined;
let params = Object.assign(state.queryParams, state.tableParams, tableParams);
// api
const handleQueryApi = async (page: VxeGridPropTypes.ProxyAjaxQueryPageParams, sort: VxeGridPropTypes.ProxyAjaxQuerySortCheckedParams) => {
const params = Object.assign(state.queryParams, { page: page.currentPage, pageSize: page.pageSize, field: sort.field, order: sort.order, descStr: 'desc' }) as PageLogInput;
return getAPI(SysLogExApi).apiSysLogExPagePost(params);
};
//
const handleQuery = async () => {
await xGrid.value?.commitProxy('query');
};
//
const resetQuery = () => {
const resetQuery = async () => {
state.queryParams.startTime = undefined;
state.queryParams.endTime = undefined;
state.queryParams.displayTitle = '';
state.queryParams.realName = '';
handleQuery(true);
await xGrid.value?.commitProxy('reload');
};
//
const gridEvents: VxeGridListeners<SysLogEx> = {
// pager-config
async pageChange({ pageSize }) {
state.localPageParam.pageSize = pageSize;
Local.set(localPageParamKey, state.localPageParam);
},
//
async sortChange({ field, order }) {
state.localPageParam.defaultSort = { field: field, order: order!, descStr: 'desc' };
Local.set(localPageParamKey, state.localPageParam);
},
};
//
@ -215,7 +223,7 @@ const handleClear = async () => {
await getAPI(SysLogExApi).apiSysLogExClearPost();
options.loading = false;
ElMessage.success('清空成功');
handleQuery(true);
await handleQuery();
};
//
@ -228,20 +236,6 @@ const handleView = async ({ row }: any) => {
state.detail.returnResult = StringToObj(data?.result?.returnResult);
state.visible = true;
};
//
const pageChange: VxePagerEvents.PageChange = ({ currentPage, pageSize }: VxePagerDefines.PageChangeEventParams) => {
state.tableParams.page = currentPage;
state.tableParams.pageSize = pageSize;
handleQuery();
};
//
const sortChange = (options: any) => {
state.tableParams.field = options.field;
state.tableParams.order = options.order;
handleQuery();
};
</script>
<style lang="scss" scoped>

View File

@ -15,12 +15,12 @@
</el-col>
<el-col class="mb5" :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
<el-form-item label="显示名称" prop="displayTitle">
<el-input v-model="state.queryParams.displayTitle" clearable placeholder="显示名称" @keyup.enter.native="handleQuery(true)" />
<el-input v-model="state.queryParams.displayTitle" clearable placeholder="显示名称" @keyup.enter.native="handleQuery" />
</el-form-item>
</el-col>
<el-col class="mb5" :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
<el-form-item label="操作人" prop="realName">
<el-input v-model="state.queryParams.realName" clearable placeholder="操作人" @keyup.enter.native="handleQuery(true)" />
<el-input v-model="state.queryParams.realName" clearable placeholder="操作人" @keyup.enter.native="handleQuery" />
</el-form-item>
</el-col>
</el-row>
@ -31,7 +31,7 @@
<el-row>
<el-col>
<el-button-group>
<el-button type="primary" icon="ele-Search" @click="handleQuery(true)" v-auth="'sysOplog:page'" :loading="options.loading"> 查询 </el-button>
<el-button type="primary" icon="ele-Search" @click="handleQuery" v-auth="'sysOplog:page'" :loading="options.loading"> 查询 </el-button>
<el-button icon="ele-Refresh" @click="resetQuery" :loading="options.loading"> 重置 </el-button>
</el-button-group>
</el-col>
@ -39,7 +39,7 @@
</el-card>
<el-card class="full-table" shadow="hover" style="margin-top: 5px">
<vxe-grid ref="xGrid" class="xGrid-style" v-bind="options" @cell-dblclick="handleView" @sort-change="sortChange">
<vxe-grid ref="xGrid" class="xGrid-style" v-bind="options" v-on="gridEvents" @cell-dblclick="handleView">
<template #toolbar_buttons>
<el-button icon="ele-DeleteFilled" type="danger" @click="handleClear" v-auth="'sysOplog:clear'"> 清空 </el-button>
</template>
@ -61,15 +61,6 @@
<template #row_buttons="{ row }">
<el-button icon="ele-InfoFilled" text type="primary" @click="handleView({ row })">详情</el-button>
</template>
<template #pager>
<vxe-pager
:loading="options.loading"
v-model:current-page="state.tableParams.page"
v-model:page-size="state.tableParams.pageSize"
:total="state.tableParams.total"
@page-change="pageChange"
/>
</template>
</vxe-grid>
</el-card>
@ -106,15 +97,16 @@ import { onMounted, reactive, ref } from 'vue';
import { ElMessage } from 'element-plus';
import { useDateTimeShortCust } from '/@/hooks/dateTimeShortCust';
import { auth } from '/@/utils/authFunction';
import { VxeGridInstance, VxePagerEvents, VxePagerDefines } from 'vxe-table';
import { useVxeTable } from '/@/hooks/vxeTableOptionsHook';
import { VxeGridInstance, VxeGridListeners, VxeGridPropTypes } from 'vxe-table';
import { useVxeTable } from '/@/hooks/useVxeTableOptionsHook';
import { Local } from '/@/utils/storage';
import VueJsonPretty from 'vue-json-pretty';
import 'vue-json-pretty/lib/styles.css';
import { StringToObj } from '/@/utils/json-utils';
import { getAPI } from '/@/utils/axios-utils';
import { SysLogOpApi } from '/@/api-services/api';
import { SysLogOp } from '/@/api-services/models';
import { SysLogOp, PageLogInput } from '/@/api-services/models';
const shortcuts = useDateTimeShortCust();
const xGrid = ref<VxeGridInstance>();
@ -125,13 +117,9 @@ const state = reactive({
displayTitle: '',
realName: '',
},
tableParams: {
page: 1,
pageSize: 50,
field: 'id', //
order: 'desc', //
descStr: 'desc', //
total: 0 as any,
localPageParam: {
pageSize: 50 as number,
defaultSort: { field: 'orderNo', order: 'asc', descStr: 'desc' },
},
visible: false,
detail: {
@ -143,72 +131,92 @@ const state = reactive({
activeTab: 'message',
});
//
const localPageParamKey = 'localPageParam:sysOpLog';
//
const options = useVxeTable<SysLogOp>({
id: 'sysOpLog',
name: '操作日志',
columns: [
// { type: 'checkbox', width: 40 },
{ type: 'seq', title: '序号', width: 60, fixed: 'left' },
{ field: 'controllerName', title: '模块名称', minWidth: 120, showOverflow: 'tooltip' },
{ field: 'displayTitle', title: '显示名称', minWidth: 150, showOverflow: 'tooltip' },
{ field: 'actionName', title: '方法名称', minWidth: 150, showOverflow: 'tooltip' },
{ field: 'httpMethod', title: '请求方式', minWidth: 90, showOverflow: 'tooltip' },
// { field: 'returnResult', title: '', minWidth: 150, showOverflow: 'tooltip' },
{ field: 'logLevel', title: '级别', minWidth: 70, showOverflow: 'tooltip', slots: { default: 'row_logLevel' } },
{ field: 'eventId', title: '事件Id', minWidth: 80, showOverflow: 'tooltip' },
{ field: 'threadId', title: '线程Id', minWidth: 90, showOverflow: 'tooltip' },
{ field: 'traceId', title: '请求跟踪Id', minWidth: 150, showOverflow: 'tooltip' },
{ field: 'account', title: '账号名称', minWidth: 100, showOverflow: 'tooltip' },
{ field: 'realName', title: '真实姓名', minWidth: 100, showOverflow: 'tooltip' },
{ field: 'remoteIp', title: 'IP地址', minWidth: 100, showOverflow: 'tooltip' },
{ field: 'location', title: '登录地点', minWidth: 100, showOverflow: 'tooltip' },
{ field: 'longitude', title: '经度', minWidth: 100, showOverflow: 'tooltip' },
{ field: 'latitude', title: '纬度', minWidth: 100, showOverflow: 'tooltip' },
{ field: 'browser', title: '浏览器', minWidth: 100, showOverflow: 'tooltip' },
{ field: 'os', title: '操作系统', minWidth: 100, showOverflow: 'tooltip' },
{ field: 'status', title: '状态', minWidth: 70, showOverflow: 'tooltip', slots: { default: 'row_status' } },
{ field: 'elapsed', title: '耗时(ms)', minWidth: 100, showOverflow: 'tooltip' },
// { field: 'exception', title: '', minWidth: 150, showOverflow: 'tooltip' },
// { field: 'message', title: '', minWidth: 160, showOverflow: 'tooltip' },
{ field: 'logDateTime', title: '日志时间', minWidth: 160, showOverflow: 'tooltip' },
{ title: '操作', fixed: 'right', width: 100, showOverflow: true, slots: { default: 'row_buttons' } },
],
enableExport: auth('sysOplog:export'),
searchCallback: () => handleQuery(),
queryAllCallback: () => fetchData({ pageSize: 99999 }),
});
const options = useVxeTable<SysLogOp>(
{
id: 'sysOpLog',
name: '操作日志',
columns: [
// { type: 'checkbox', width: 40 },
{ type: 'seq', title: '序号', width: 60, fixed: 'left' },
{ field: 'controllerName', title: '模块名称', minWidth: 120, showOverflow: 'tooltip' },
{ field: 'displayTitle', title: '显示名称', minWidth: 150, showOverflow: 'tooltip' },
{ field: 'actionName', title: '方法名称', minWidth: 150, showOverflow: 'tooltip' },
{ field: 'httpMethod', title: '请求方式', minWidth: 90, showOverflow: 'tooltip' },
// { field: 'returnResult', title: '', minWidth: 150, showOverflow: 'tooltip' },
{ field: 'logLevel', title: '级别', minWidth: 70, showOverflow: 'tooltip', slots: { default: 'row_logLevel' } },
{ field: 'eventId', title: '事件Id', minWidth: 80, showOverflow: 'tooltip' },
{ field: 'threadId', title: '线程Id', minWidth: 90, showOverflow: 'tooltip' },
{ field: 'traceId', title: '请求跟踪Id', minWidth: 150, showOverflow: 'tooltip' },
{ field: 'account', title: '账号名称', minWidth: 100, showOverflow: 'tooltip' },
{ field: 'realName', title: '真实姓名', minWidth: 100, showOverflow: 'tooltip' },
{ field: 'remoteIp', title: 'IP地址', minWidth: 100, showOverflow: 'tooltip' },
{ field: 'location', title: '登录地点', minWidth: 100, showOverflow: 'tooltip' },
{ field: 'longitude', title: '经度', minWidth: 100, showOverflow: 'tooltip' },
{ field: 'latitude', title: '纬度', minWidth: 100, showOverflow: 'tooltip' },
{ field: 'browser', title: '浏览器', minWidth: 100, showOverflow: 'tooltip' },
{ field: 'os', title: '操作系统', minWidth: 100, showOverflow: 'tooltip' },
{ field: 'status', title: '状态', minWidth: 70, showOverflow: 'tooltip', slots: { default: 'row_status' } },
{ field: 'elapsed', title: '耗时(ms)', minWidth: 100, showOverflow: 'tooltip' },
// { field: 'exception', title: '', minWidth: 150, showOverflow: 'tooltip' },
// { field: 'message', title: '', minWidth: 160, showOverflow: 'tooltip' },
{ field: 'logDateTime', title: '日志时间', minWidth: 160, showOverflow: 'tooltip' },
{ title: '操作', fixed: 'right', width: 100, showOverflow: true, slots: { default: 'row_buttons' } },
],
},
// vxeGrid()vxe-table
{
//
proxyConfig: { autoLoad: true, ajax: { query: ({ page, sort }) => handleQueryApi(page, sort) } },
//
sortConfig: { defaultSort: Local.get(localPageParamKey)?.defaultSort || state.localPageParam.defaultSort },
//
pagerConfig: { pageSize: Local.get(localPageParamKey)?.pageSize || state.localPageParam.pageSize },
//
toolbarConfig: { export: false },
}
);
//
onMounted(async () => {
state.localPageParam = Local.get(localPageParamKey) || state.localPageParam;
await handleQuery();
});
//
const handleQuery = async (reset = false) => {
options.loading = true;
if (reset) state.tableParams.page = 1;
var res = await fetchData(null);
xGrid.value?.loadData(res.data.result?.items ?? []);
state.tableParams.total = res.data.result?.total;
options.loading = false;
};
//
const fetchData = async (tableParams: any) => {
if (state.queryParams.startTime == null) state.queryParams.startTime = undefined;
if (state.queryParams.endTime == null) state.queryParams.endTime = undefined;
let params = Object.assign(state.queryParams, state.tableParams, tableParams);
// api
const handleQueryApi = async (page: VxeGridPropTypes.ProxyAjaxQueryPageParams, sort: VxeGridPropTypes.ProxyAjaxQuerySortCheckedParams) => {
const params = Object.assign(state.queryParams, { page: page.currentPage, pageSize: page.pageSize, field: sort.field, order: sort.order, descStr: 'desc' }) as PageLogInput;
return getAPI(SysLogOpApi).apiSysLogOpPagePost(params);
};
//
const handleQuery = async () => {
await xGrid.value?.commitProxy('query');
};
//
const resetQuery = () => {
const resetQuery = async () => {
state.queryParams.startTime = undefined;
state.queryParams.endTime = undefined;
state.queryParams.displayTitle = '';
state.queryParams.realName = '';
handleQuery(true);
await xGrid.value?.commitProxy('reload');
};
//
const gridEvents: VxeGridListeners<SysLogOp> = {
// pager-config
async pageChange({ pageSize }) {
state.localPageParam.pageSize = pageSize;
Local.set(localPageParamKey, state.localPageParam);
},
//
async sortChange({ field, order }) {
state.localPageParam.defaultSort = { field: field, order: order!, descStr: 'desc' };
Local.set(localPageParamKey, state.localPageParam);
},
};
//
@ -217,7 +225,7 @@ const handleClear = async () => {
await getAPI(SysLogOpApi).apiSysLogOpClearPost();
options.loading = false;
ElMessage.success('清空成功');
handleQuery(true);
await handleQuery();
};
//
@ -230,20 +238,6 @@ const handleView = async ({ row }: any) => {
state.detail.returnResult = StringToObj(data?.result?.returnResult);
state.visible = true;
};
//
const pageChange: VxePagerEvents.PageChange = ({ currentPage, pageSize }: VxePagerDefines.PageChangeEventParams) => {
state.tableParams.page = currentPage;
state.tableParams.pageSize = pageSize;
handleQuery();
};
//
const sortChange = (options: any) => {
state.tableParams.field = options.field;
state.tableParams.order = options.order;
handleQuery();
};
</script>
<style lang="scss" scoped>

View File

@ -15,12 +15,12 @@
</el-col>
<el-col class="mb5" :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
<el-form-item label="显示名称" prop="displayTitle">
<el-input v-model="state.queryParams.displayTitle" clearable placeholder="显示名称" @keyup.enter.native="handleQuery(true)" />
<el-input v-model="state.queryParams.displayTitle" clearable placeholder="显示名称" @keyup.enter.native="handleQuery" />
</el-form-item>
</el-col>
<el-col class="mb5" :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
<el-form-item label="操作人" prop="realName">
<el-input v-model="state.queryParams.realName" clearable placeholder="操作人" @keyup.enter.native="handleQuery(true)" />
<el-input v-model="state.queryParams.realName" clearable placeholder="操作人" @keyup.enter.native="handleQuery" />
</el-form-item>
</el-col>
</el-row>
@ -31,7 +31,7 @@
<el-row>
<el-col>
<el-button-group>
<el-button type="primary" icon="ele-Search" @click="handleQuery(true)" v-auth="'sysVislog:page'" :loading="options.loading"> 查询 </el-button>
<el-button type="primary" icon="ele-Search" @click="handleQuery" v-auth="'sysVislog:page'" :loading="options.loading"> 查询 </el-button>
<el-button icon="ele-Refresh" @click="resetQuery" :loading="options.loading"> 重置 </el-button>
</el-button-group>
</el-col>
@ -39,7 +39,7 @@
</el-card>
<el-card class="full-table" shadow="hover" style="margin-top: 5px">
<vxe-grid ref="xGrid" class="xGrid-style" v-bind="options" @sort-change="sortChange">
<vxe-grid ref="xGrid" class="xGrid-style" v-bind="options" v-on="gridEvents">
<template #toolbar_buttons>
<el-button icon="ele-DeleteFilled" type="danger" @click="handleClear" v-auth="'sysVislog:clear'"> 清空 </el-button>
<el-button icon="ele-MapLocation" type="primary" @click="handleMap"> 热力图 </el-button>
@ -52,15 +52,6 @@
<el-tag v-if="row.status === '200'" type="success">成功</el-tag>
<el-tag v-else type="danger">失败</el-tag>
</template>
<template #pager>
<vxe-pager
:loading="options.loading"
v-model:current-page="state.tableParams.page"
v-model:page-size="state.tableParams.pageSize"
:total="state.tableParams.total"
@page-change="pageChange"
/>
</template>
</vxe-grid>
</el-card>
@ -73,12 +64,13 @@ import { onMounted, reactive, ref, defineAsyncComponent } from 'vue';
import { ElMessage } from 'element-plus';
import { useDateTimeShortCust } from '/@/hooks/dateTimeShortCust';
import { auth } from '/@/utils/authFunction';
import { VxeGridInstance, VxePagerEvents, VxePagerDefines } from 'vxe-table';
import { useVxeTable } from '/@/hooks/vxeTableOptionsHook';
import { VxeGridInstance, VxeGridListeners, VxeGridPropTypes } from 'vxe-table';
import { useVxeTable } from '/@/hooks/useVxeTableOptionsHook';
import { Local } from '/@/utils/storage';
import { getAPI } from '/@/utils/axios-utils';
import { SysLogVisApi } from '/@/api-services';
import { SysLogVis } from '/@/api-services/models';
import { SysLogVis, PageLogInput } from '/@/api-services/models';
const VisMap = defineAsyncComponent(() => import('./component/visMap.vue'));
@ -92,73 +84,89 @@ const state = reactive({
displayTitle: '',
realName: '',
},
tableParams: {
page: 1,
pageSize: 50,
field: 'id', //
order: 'desc', //
descStr: 'desc', //
total: 0 as any,
localPageParam: {
pageSize: 50 as number,
defaultSort: { field: 'orderNo', order: 'asc', descStr: 'desc' },
},
title: '',
});
//
const localPageParamKey = 'localPageParam:sysVisLog';
//
const options = useVxeTable<SysLogVis>({
id: 'sysVisLog',
name: '访问日志',
columns: [
// { type: 'checkbox', width: 40 },
{ type: 'seq', title: '序号', width: 60, fixed: 'left' },
{ field: 'displayTitle', title: '显示名称', minWidth: 150, showOverflow: 'tooltip' },
{ field: 'actionName', title: '方法名称', minWidth: 150, showOverflow: 'tooltip' },
{ field: 'account', title: '账号名称', minWidth: 150, showOverflow: 'tooltip' },
{ field: 'realName', title: '真实姓名', minWidth: 150, showOverflow: 'tooltip' },
{ field: 'remoteIp', title: 'IP地址', minWidth: 150, showOverflow: 'tooltip' },
{ field: 'location', title: '登录地点', minWidth: 150, showOverflow: 'tooltip' },
{ field: 'longitude', title: '经度', minWidth: 100, showOverflow: 'tooltip' },
{ field: 'latitude', title: '纬度', minWidth: 100, showOverflow: 'tooltip' },
{ field: 'browser', title: '浏览器', minWidth: 150, showOverflow: 'tooltip' },
{ field: 'os', title: '操作系统', minWidth: 150, showOverflow: 'tooltip' },
{ field: 'status', title: '状态', minWidth: 70, showOverflow: 'tooltip', slots: { default: 'row_status' } },
{ field: 'elapsed', title: '耗时(ms)', minWidth: 100, showOverflow: 'tooltip' },
{ field: 'logDateTime', title: '日志时间', minWidth: 150, showOverflow: 'tooltip' },
],
enableExport: auth('sysVislog:export'),
searchCallback: () => handleQuery(),
queryAllCallback: () => fetchData({ pageSize: 99999 }),
});
const options = useVxeTable<SysLogVis>(
{
id: 'sysVisLog',
name: '访问日志',
columns: [
// { type: 'checkbox', width: 40 },
{ type: 'seq', title: '序号', width: 60, fixed: 'left' },
{ field: 'displayTitle', title: '显示名称', minWidth: 150, showOverflow: 'tooltip' },
{ field: 'actionName', title: '方法名称', minWidth: 150, showOverflow: 'tooltip' },
{ field: 'account', title: '账号名称', minWidth: 150, showOverflow: 'tooltip' },
{ field: 'realName', title: '真实姓名', minWidth: 150, showOverflow: 'tooltip' },
{ field: 'remoteIp', title: 'IP地址', minWidth: 150, showOverflow: 'tooltip' },
{ field: 'location', title: '登录地点', minWidth: 150, showOverflow: 'tooltip' },
{ field: 'longitude', title: '经度', minWidth: 100, showOverflow: 'tooltip' },
{ field: 'latitude', title: '纬度', minWidth: 100, showOverflow: 'tooltip' },
{ field: 'browser', title: '浏览器', minWidth: 150, showOverflow: 'tooltip' },
{ field: 'os', title: '操作系统', minWidth: 150, showOverflow: 'tooltip' },
{ field: 'status', title: '状态', minWidth: 70, showOverflow: 'tooltip', slots: { default: 'row_status' } },
{ field: 'elapsed', title: '耗时(ms)', minWidth: 100, showOverflow: 'tooltip' },
{ field: 'logDateTime', title: '日志时间', minWidth: 150, showOverflow: 'tooltip' },
],
},
// vxeGrid()vxe-table
{
//
proxyConfig: { autoLoad: true, ajax: { query: ({ page, sort }) => handleQueryApi(page, sort) } },
//
sortConfig: { defaultSort: Local.get(localPageParamKey)?.defaultSort || state.localPageParam.defaultSort },
//
pagerConfig: { pageSize: Local.get(localPageParamKey)?.pageSize || state.localPageParam.pageSize },
//
toolbarConfig: { export: false },
}
);
//
onMounted(async () => {
state.localPageParam = Local.get(localPageParamKey) || state.localPageParam;
await handleQuery();
});
//
const handleQuery = async (reset = false) => {
options.loading = true;
if (reset) state.tableParams.page = 1;
var res = await fetchData(null);
xGrid.value?.loadData(res.data.result?.items ?? []);
state.tableParams.total = res.data.result?.total;
options.loading = false;
};
//
const fetchData = async (tableParams: any) => {
if (state.queryParams.startTime == null) state.queryParams.startTime = undefined;
if (state.queryParams.endTime == null) state.queryParams.endTime = undefined;
let params = Object.assign(state.queryParams, state.tableParams, tableParams);
// api
const handleQueryApi = async (page: VxeGridPropTypes.ProxyAjaxQueryPageParams, sort: VxeGridPropTypes.ProxyAjaxQuerySortCheckedParams) => {
const params = Object.assign(state.queryParams, { page: page.currentPage, pageSize: page.pageSize, field: sort.field, order: sort.order, descStr: 'desc' }) as PageLogInput;
return getAPI(SysLogVisApi).apiSysLogVisPagePost(params);
};
//
const handleQuery = async () => {
await xGrid.value?.commitProxy('query');
};
//
const resetQuery = () => {
const resetQuery = async () => {
state.queryParams.startTime = undefined;
state.queryParams.endTime = undefined;
state.queryParams.displayTitle = '';
state.queryParams.realName = '';
handleQuery(true);
await xGrid.value?.commitProxy('reload');
};
//
const gridEvents: VxeGridListeners<SysLogVis> = {
// pager-config
async pageChange({ pageSize }) {
state.localPageParam.pageSize = pageSize;
Local.set(localPageParamKey, state.localPageParam);
},
//
async sortChange({ field, order }) {
state.localPageParam.defaultSort = { field: field, order: order!, descStr: 'desc' };
Local.set(localPageParamKey, state.localPageParam);
},
};
//
@ -167,7 +175,7 @@ const handleClear = async () => {
await getAPI(SysLogVisApi).apiSysLogVisClearPost();
options.loading = false;
ElMessage.success('清空成功');
handleQuery(true);
await handleQuery();
};
// 访
@ -175,18 +183,4 @@ const handleMap = async () => {
state.title = '访问者热力图';
mapRef.value?.openDialog();
};
//
const pageChange: VxePagerEvents.PageChange = ({ currentPage, pageSize }: VxePagerDefines.PageChangeEventParams) => {
state.tableParams.page = currentPage;
state.tableParams.pageSize = pageSize;
handleQuery();
};
//
const sortChange = (options: any) => {
state.tableParams.field = options.field;
state.tableParams.order = options.order;
handleQuery();
};
</script>

View File

@ -135,6 +135,7 @@ const options = useVxeTable<SysNotice>(
//
onMounted(async () => {
state.localPageParam = Local.get(localPageParamKey) || state.localPageParam;
await handleQuery();
});