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