refactor: 优化导出下载功能

This commit is contained in:
秋帆
2024-04-10 22:40:29 +08:00
parent 63da55ab03
commit 2f29a6e81c
6 changed files with 92 additions and 12 deletions

View File

@@ -22,7 +22,7 @@
</template>
<template #custom-right>
<a-tooltip content="导出">
<a-button>
<a-button @click="onExportFile">
<template #icon>
<icon-download />
</template>
@@ -45,13 +45,12 @@
</template>
<script setup lang="ts">
import { listLog } from '@/apis'
import { listLog,exportLog } from '@/apis'
import type { TableInstance } from '@arco-design/web-vue'
import DateRangePicker from '@/components/DateRangePicker/index.vue'
import { useTable } from '@/hooks'
import {useDownload} from '@/hooks'
defineOptions({ name: 'LoginLog' })
const filterChange = (values,record)=>{
try {
const slotName = columns[values.split('_').pop()].slotName as string
@@ -96,7 +95,10 @@ const columns: TableInstance['columns'] = [
{ title: '浏览器', dataIndex: 'browser', ellipsis: true, tooltip: true },
{ title: '终端系统', dataIndex: 'os', ellipsis: true, tooltip: true }
]
//导出登录日志
const onExportFile = ()=>{
useDownload(exportLog,'',queryForm)
}
const queryForm = reactive({
module: '登录',
ip: undefined,

View File

@@ -22,7 +22,7 @@
<a-button @click="reset">重置</a-button>
</template>
<template #custom-right>
<a-tooltip content="导出">
<a-tooltip content="导出" @click="onExportFile">
<a-button>
<template #icon>
<icon-download />
@@ -56,11 +56,11 @@
</template>
<script setup lang="ts">
import { listLog, type LogResp } from '@/apis'
import { listLog, type LogResp,exportOperateLog } from '@/apis'
import type { TableInstance } from '@arco-design/web-vue'
import DateRangePicker from '@/components/DateRangePicker/index.vue'
import OperationLogDetailDrawer from './OperationLogDetailDrawer.vue'
import { useTable } from '@/hooks'
import { useDownload, useTable } from '@/hooks'
defineOptions({ name: 'OperationLog' })
const filterChange = (values,record)=>{
@@ -109,7 +109,10 @@ const columns: TableInstance['columns'] = [
{ title: '浏览器', dataIndex: 'browser', ellipsis: true, tooltip: true },
{ title: '终端系统', dataIndex: 'os', ellipsis: true, tooltip: true }
]
//导出操作日志
const onExportFile = ()=>{
useDownload(exportOperateLog,'',queryForm)
}
const queryForm = reactive({
description: undefined,
ip: undefined,