😎调整差异日志页面
This commit is contained in:
parent
46d81dd0a7
commit
d1b749fcae
@ -1,147 +1,159 @@
|
||||
<template>
|
||||
<div class="sys-difflog-container">
|
||||
<el-card shadow="hover" :body-style="{ paddingBottom: '0' }">
|
||||
<el-form :model="state.queryParams" ref="queryForm" :inline="true">
|
||||
<el-form-item label="开始时间">
|
||||
<el-date-picker v-model="state.queryParams.startTime" type="datetime" placeholder="开始时间" value-format="YYYY-MM-DD HH:mm:ss" :shortcuts="shortcuts" />
|
||||
</el-form-item>
|
||||
<el-form-item label="结束时间">
|
||||
<el-date-picker v-model="state.queryParams.endTime" type="datetime" placeholder="结束时间" value-format="YYYY-MM-DD HH:mm:ss" :shortcuts="shortcuts" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button-group>
|
||||
<el-button type="primary" icon="ele-Search" @click="handleQuery" v-auth="'sysDifflog:page'"> 查询 </el-button>
|
||||
<el-button icon="ele-Refresh" @click="resetQuery"> 重置 </el-button>
|
||||
</el-button-group>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button icon="ele-DeleteFilled" type="danger" @click="clearLog" v-auth="'sysDifflog:clear'"> 清空 </el-button>
|
||||
</el-form-item>
|
||||
<div class="sys-difflog-container" v-loading="options.loading">
|
||||
<el-card shadow="hover" :body-style="{ padding: '5px 5px 0 5px', display: 'flex', width: '100%', height: '100%', alignItems: 'start' }">
|
||||
<el-form :model="state.queryParams" ref="queryForm" :show-message="false" :inlineMessage="true" :label-width="'60px'" style="flex: 1 1 0%">
|
||||
<el-row :gutter="10">
|
||||
<el-col class="mb5" :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
|
||||
<el-form-item label="开始时间" prop="name">
|
||||
<el-date-picker v-model="state.queryParams.startTime" type="datetime" placeholder="开始时间" :shortcuts="shortcuts" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col class="mb5" :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
|
||||
<el-form-item label="结束时间" prop="code">
|
||||
<el-date-picker v-model="state.queryParams.endTime" type="datetime" placeholder="结束时间" :shortcuts="shortcuts" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
|
||||
<el-divider style="height: calc(100% - 5px); margin: 0 10px" direction="vertical" />
|
||||
|
||||
<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 icon="ele-Refresh" @click="resetQuery" :loading="options.loading"> 重置 </el-button>
|
||||
</el-button-group>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-card>
|
||||
|
||||
<el-card class="full-table" shadow="hover" style="margin-top: 5px">
|
||||
<el-table :data="state.logData" style="width: 100%" v-loading="state.loading" border>
|
||||
<el-table-column type="index" label="序号" width="55" align="center" />
|
||||
<el-table-column prop="diffType" label="差异操作" header-align="center" show-overflow-tooltip />
|
||||
<el-table-column prop="sql" label="Sql语句" header-align="center" show-overflow-tooltip />
|
||||
<el-table-column prop="parameters" label="参数" header-align="center" show-overflow-tooltip />
|
||||
<el-table-column prop="elapsed" label="耗时(ms)" header-align="center" show-overflow-tooltip />
|
||||
<el-table-column prop="message" label="日志消息" header-align="center" show-overflow-tooltip />
|
||||
<el-table-column prop="beforeData" label="操作前记录" header-align="center" show-overflow-tooltip />
|
||||
<el-table-column prop="afterData" label="操作后记录" header-align="center" show-overflow-tooltip />
|
||||
<el-table-column prop="businessData" label="业务对象" header-align="center" show-overflow-tooltip />
|
||||
<el-table-column prop="createTime" label="操作时间" align="center" show-overflow-tooltip />
|
||||
</el-table>
|
||||
<el-pagination
|
||||
v-model:currentPage="state.tableParams.page"
|
||||
v-model:page-size="state.tableParams.pageSize"
|
||||
:total="state.tableParams.total"
|
||||
:page-sizes="[10, 20, 50, 100]"
|
||||
small
|
||||
background
|
||||
@size-change="handleSizeChange"
|
||||
@current-change="handleCurrentChange"
|
||||
layout="total, sizes, prev, pager, next, jumper"
|
||||
/>
|
||||
<vxe-grid ref="xGrid" class="xGrid-style" v-bind="options" @sort-change="sortChange">
|
||||
<template #toolbar_buttons>
|
||||
<el-button icon="ele-DeleteFilled" type="danger" @click="handleClear" v-auth="'sysDifflog:clear'"> 清空 </el-button>
|
||||
</template>
|
||||
<template #toolbar_tools>
|
||||
<vxe-button circle icon="vxe-icon-upload" name="导入" code="showImport" class="mr12" />
|
||||
</template>
|
||||
<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>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup name="sysDiffLog">
|
||||
import { onMounted, reactive } from 'vue';
|
||||
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 { getAPI } from '/@/utils/axios-utils';
|
||||
import { SysLogDiffApi } from '/@/api-services/api';
|
||||
import { SysLogDiff } from '/@/api-services/models';
|
||||
|
||||
const xGrid = ref<VxeGridInstance>();
|
||||
const shortcuts = useDateTimeShortCust();
|
||||
const state = reactive({
|
||||
loading: false,
|
||||
queryParams: {
|
||||
startTime: undefined,
|
||||
endTime: undefined,
|
||||
},
|
||||
tableParams: {
|
||||
page: 1,
|
||||
pageSize: 10,
|
||||
pageSize: 50,
|
||||
field: 'id', // 默认的排序字段
|
||||
order: 'desc', // 排序方向
|
||||
descStr: 'desc', // 降序排序的关键字符
|
||||
total: 0 as any,
|
||||
},
|
||||
logData: [] as Array<SysLogDiff>,
|
||||
});
|
||||
|
||||
// 表格参数配置
|
||||
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 }),
|
||||
});
|
||||
|
||||
// 页面初始化
|
||||
onMounted(async () => {
|
||||
handleQuery();
|
||||
await handleQuery();
|
||||
});
|
||||
|
||||
// 查询操作
|
||||
const handleQuery = async () => {
|
||||
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;
|
||||
|
||||
state.loading = true;
|
||||
let params = Object.assign(state.queryParams, state.tableParams);
|
||||
var res = await getAPI(SysLogDiffApi).apiSysLogDiffPagePost(params);
|
||||
state.logData = res.data.result?.items ?? [];
|
||||
state.tableParams.total = res.data.result?.total;
|
||||
state.loading = false;
|
||||
let params = Object.assign(state.queryParams, state.tableParams, tableParams);
|
||||
return getAPI(SysLogDiffApi).apiSysLogDiffPagePost(params);
|
||||
};
|
||||
|
||||
// 重置操作
|
||||
const resetQuery = () => {
|
||||
state.queryParams.startTime = undefined;
|
||||
state.queryParams.endTime = undefined;
|
||||
handleQuery();
|
||||
handleQuery(true);
|
||||
};
|
||||
|
||||
// 清空日志
|
||||
const clearLog = async () => {
|
||||
state.loading = true;
|
||||
const handleClear = async () => {
|
||||
options.loading = true;
|
||||
await getAPI(SysLogDiffApi).apiSysLogDiffClearPost();
|
||||
state.loading = false;
|
||||
|
||||
options.loading = false;
|
||||
ElMessage.success('清空成功');
|
||||
handleQuery();
|
||||
};
|
||||
|
||||
// 改变页面容量
|
||||
const handleSizeChange = (val: number) => {
|
||||
state.tableParams.pageSize = val;
|
||||
// 改变页码序号或页面容量
|
||||
const pageChange: VxePagerEvents.PageChange = ({ currentPage, pageSize }: VxePagerDefines.PageChangeEventParams) => {
|
||||
state.tableParams.page = currentPage;
|
||||
state.tableParams.pageSize = pageSize;
|
||||
handleQuery();
|
||||
};
|
||||
|
||||
// 改变页码序号
|
||||
const handleCurrentChange = (val: number) => {
|
||||
state.tableParams.page = val;
|
||||
// 列排序
|
||||
const sortChange = (options: any) => {
|
||||
state.tableParams.field = options.field;
|
||||
state.tableParams.order = options.order;
|
||||
handleQuery();
|
||||
};
|
||||
|
||||
const shortcuts = [
|
||||
{
|
||||
text: '今天',
|
||||
value: new Date(),
|
||||
},
|
||||
{
|
||||
text: '昨天',
|
||||
value: () => {
|
||||
const date = new Date();
|
||||
date.setTime(date.getTime() - 3600 * 1000 * 24);
|
||||
return date;
|
||||
},
|
||||
},
|
||||
{
|
||||
text: '上周',
|
||||
value: () => {
|
||||
const date = new Date();
|
||||
date.setTime(date.getTime() - 3600 * 1000 * 24 * 7);
|
||||
return date;
|
||||
},
|
||||
},
|
||||
];
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.el-popper {
|
||||
max-width: 60%;
|
||||
}
|
||||
</style>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user