😎增加日志导出功能

This commit is contained in:
zuohuaijun 2024-08-03 01:32:25 +08:00
parent e29254117b
commit 07115c646c
4 changed files with 30 additions and 6 deletions

View File

@ -5,12 +5,12 @@
<el-row :gutter="10"> <el-row :gutter="10">
<el-col class="mb5" :xs="24" :sm="12" :md="8" :lg="6" :xl="6"> <el-col class="mb5" :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
<el-form-item label="开始时间" prop="name"> <el-form-item label="开始时间" prop="name">
<el-date-picker v-model="state.queryParams.startTime" type="datetime" placeholder="开始时间" :shortcuts="shortcuts" /> <el-date-picker v-model="state.queryParams.startTime" type="datetime" placeholder="开始时间" :shortcuts="shortcuts" class="w100" />
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col class="mb5" :xs="24" :sm="12" :md="8" :lg="6" :xl="6"> <el-col class="mb5" :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
<el-form-item label="结束时间" prop="code"> <el-form-item label="结束时间" prop="code">
<el-date-picker v-model="state.queryParams.endTime" type="datetime" placeholder="结束时间" :shortcuts="shortcuts" /> <el-date-picker v-model="state.queryParams.endTime" type="datetime" placeholder="结束时间" :shortcuts="shortcuts" class="w100" />
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>

View File

@ -5,12 +5,12 @@
<el-row :gutter="10"> <el-row :gutter="10">
<el-col class="mb5" :xs="24" :sm="12" :md="8" :lg="6" :xl="6"> <el-col class="mb5" :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
<el-form-item label="开始时间" prop="name"> <el-form-item label="开始时间" prop="name">
<el-date-picker v-model="state.queryParams.startTime" type="datetime" placeholder="开始时间" :shortcuts="shortcuts" /> <el-date-picker v-model="state.queryParams.startTime" type="datetime" placeholder="开始时间" :shortcuts="shortcuts" class="w100" />
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col class="mb5" :xs="24" :sm="12" :md="8" :lg="6" :xl="6"> <el-col class="mb5" :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
<el-form-item label="结束时间" prop="code"> <el-form-item label="结束时间" prop="code">
<el-date-picker v-model="state.queryParams.endTime" type="datetime" placeholder="结束时间" :shortcuts="shortcuts" /> <el-date-picker v-model="state.queryParams.endTime" type="datetime" placeholder="结束时间" :shortcuts="shortcuts" class="w100" />
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col class="mb5" :xs="24" :sm="12" :md="8" :lg="6" :xl="6"> <el-col class="mb5" :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
@ -64,6 +64,7 @@
<el-card class="full-table" shadow="hover" style="margin-top: 5px"> <el-card class="full-table" shadow="hover" style="margin-top: 5px">
<vxe-grid ref="xGrid" class="xGrid-style" v-bind="options" v-on="gridEvents" @cell-dblclick="handleView"> <vxe-grid ref="xGrid" class="xGrid-style" v-bind="options" v-on="gridEvents" @cell-dblclick="handleView">
<template #toolbar_buttons> <template #toolbar_buttons>
<el-button icon="ele-FolderOpened" type="primary" @click="exportLog" v-auth="'sysLogEx/export'"> 导出 </el-button>
<el-button icon="ele-DeleteFilled" type="danger" @click="handleClear" v-auth="'sysLogEx/clear'"> 清空 </el-button> <el-button icon="ele-DeleteFilled" type="danger" @click="handleClear" v-auth="'sysLogEx/clear'"> 清空 </el-button>
</template> </template>
<template #toolbar_tools> </template> <template #toolbar_tools> </template>
@ -123,6 +124,7 @@ import { auth } from '/@/utils/authFunction';
import { VxeGridInstance, VxeGridListeners, VxeGridPropTypes } from 'vxe-table'; import { VxeGridInstance, VxeGridListeners, VxeGridPropTypes } from 'vxe-table';
import { useVxeTable } from '/@/hooks/useVxeTableOptionsHook'; import { useVxeTable } from '/@/hooks/useVxeTableOptionsHook';
import { Local } from '/@/utils/storage'; import { Local } from '/@/utils/storage';
import { downloadByData, getFileName } from '/@/utils/download';
import VueJsonPretty from 'vue-json-pretty'; import VueJsonPretty from 'vue-json-pretty';
import 'vue-json-pretty/lib/styles.css'; import 'vue-json-pretty/lib/styles.css';
import { StringToObj } from '/@/utils/json-utils'; import { StringToObj } from '/@/utils/json-utils';
@ -268,6 +270,16 @@ const handleView = async ({ row }: any) => {
state.detail.returnResult = StringToObj(data?.result?.returnResult); state.detail.returnResult = StringToObj(data?.result?.returnResult);
state.visible = true; state.visible = true;
}; };
//
const exportLog = async () => {
options.loading = true;
var res = await getAPI(SysLogExApi).apiSysLogExExportPost(state.queryParams, { responseType: 'blob' });
options.loading = false;
var fileName = getFileName(res.headers);
downloadByData(res.data as any, fileName);
};
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

View File

@ -56,6 +56,7 @@
<el-card class="full-table" shadow="hover" style="margin-top: 5px"> <el-card class="full-table" shadow="hover" style="margin-top: 5px">
<vxe-grid ref="xGrid" class="xGrid-style" v-bind="options" v-on="gridEvents" @cell-dblclick="handleView"> <vxe-grid ref="xGrid" class="xGrid-style" v-bind="options" v-on="gridEvents" @cell-dblclick="handleView">
<template #toolbar_buttons> <template #toolbar_buttons>
<el-button icon="ele-FolderOpened" type="primary" @click="exportLog" v-auth="'sysLogOp/export'"> 导出 </el-button>
<el-button icon="ele-DeleteFilled" type="danger" @click="handleClear" v-auth="'sysLogOp/clear'"> 清空 </el-button> <el-button icon="ele-DeleteFilled" type="danger" @click="handleClear" v-auth="'sysLogOp/clear'"> 清空 </el-button>
</template> </template>
<template #toolbar_tools> </template> <template #toolbar_tools> </template>
@ -115,6 +116,7 @@ import { auth } from '/@/utils/authFunction';
import { VxeGridInstance, VxeGridListeners, VxeGridPropTypes } from 'vxe-table'; import { VxeGridInstance, VxeGridListeners, VxeGridPropTypes } from 'vxe-table';
import { useVxeTable } from '/@/hooks/useVxeTableOptionsHook'; import { useVxeTable } from '/@/hooks/useVxeTableOptionsHook';
import { Local } from '/@/utils/storage'; import { Local } from '/@/utils/storage';
import { downloadByData, getFileName } from '/@/utils/download';
import VueJsonPretty from 'vue-json-pretty'; import VueJsonPretty from 'vue-json-pretty';
import 'vue-json-pretty/lib/styles.css'; import 'vue-json-pretty/lib/styles.css';
import { StringToObj } from '/@/utils/json-utils'; import { StringToObj } from '/@/utils/json-utils';
@ -261,6 +263,16 @@ const handleView = async ({ row }: any) => {
state.detail.returnResult = StringToObj(data?.result?.returnResult); state.detail.returnResult = StringToObj(data?.result?.returnResult);
state.visible = true; state.visible = true;
}; };
//
const exportLog = async () => {
options.loading = true;
var res = await getAPI(SysLogOpApi).apiSysLogOpExportPost(state.queryParams, { responseType: 'blob' });
options.loading = false;
var fileName = getFileName(res.headers);
downloadByData(res.data as any, fileName);
};
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

View File

@ -59,8 +59,8 @@
<el-card class="full-table" shadow="hover" style="margin-top: 5px"> <el-card class="full-table" shadow="hover" style="margin-top: 5px">
<vxe-grid ref="xGrid" class="xGrid-style" v-bind="options" v-on="gridEvents"> <vxe-grid ref="xGrid" class="xGrid-style" v-bind="options" v-on="gridEvents">
<template #toolbar_buttons> <template #toolbar_buttons>
<el-button icon="ele-DeleteFilled" type="danger" @click="handleClear" v-auth="'sysLogVis/clear'"> 清空 </el-button>
<el-button icon="ele-MapLocation" type="primary" @click="handleMap" v-auth="'sysLogVis/list'"> 热力图 </el-button> <el-button icon="ele-MapLocation" type="primary" @click="handleMap" v-auth="'sysLogVis/list'"> 热力图 </el-button>
<el-button icon="ele-DeleteFilled" type="danger" @click="handleClear" v-auth="'sysLogVis/clear'"> 清空 </el-button>
</template> </template>
<template #toolbar_tools> </template> <template #toolbar_tools> </template>
<template #empty> <template #empty>