<template>
	<div class="page">
		<BaseTable ref="baseTable" :action="action" :columns="columns" :search="search">
			<template v-slot:operation>
				<a-button type="primary" v-if="checkPermission('导出')" @click="handleExportData">导出</a-button>
			</template>
		</BaseTable>
	</div>
</template>

<script lang="ts" setup>
import { ref } from 'vue'
import BaseTable from '../../../components/table'
import { BaseUtil } from '../../../utils/base-util'
import columns from './columns'
import search from './search'
import requestMethod from '../../../api/system-log/file-upload'
import { messageMethod } from '../../../utils/message-util'
import { manageMethod } from '../../../components/form/method'
import { ResultModel } from '../../../http/result-model'
import { LogFile } from '../../../entity/system-log/log-file'
import { checkPermission } from '../../../utils/permission-util'

// 列表查询信息的api
const action = ref(requestMethod.page)

const useManageMethod = manageMethod<LogFile>()

// 导出事件
const handleExportData = async () => {
	const resultModel: ResultModel<string> = await requestMethod.upload({ ...useManageMethod.baseTable().queryList() })
	BaseUtil.downFile(resultModel.data, '文件上传记录')
	messageMethod.success(resultModel.message)
}
</script>

<style scoped>
.page {
	height: 100%;
	display: flex;
	flex-direction: column;
}
</style>
