generated from Leo_Ding/web-template
修改
This commit is contained in:
parent
1ee082eb90
commit
f34ecf2b58
@ -2,6 +2,7 @@
|
||||
* 区域模块接口
|
||||
*/
|
||||
import request from '@/utils/request'
|
||||
|
||||
// 获取项目列表
|
||||
export const getProjectList = (params) => request.basic.get('/api/v1/activities', params)
|
||||
// 获取单挑数据
|
||||
@ -14,3 +15,5 @@ export const updateItem = (id, params) => request.basic.put(`/api/v1/activities/
|
||||
export const delItem = (id) => request.basic.delete(`/api/v1/activities/${id}`)
|
||||
//获取活动报名列表
|
||||
export const getActivityList=(params)=>request.basic.get('/api/v1/activity-details',params)
|
||||
// 导出文件
|
||||
export const exportFile = (params) => request.basic.get('/api/v1/activity-details/export', params, { responseType: 'blob' })
|
||||
|
||||
@ -20,9 +20,11 @@ const options = {
|
||||
},
|
||||
interceptorRequestCatch: () => {},
|
||||
interceptorResponse: (response) => {
|
||||
console.log('response',response)
|
||||
const list=['/api/v1/activity-details/export']
|
||||
// 错误处理
|
||||
const { success, msg = 'Network Error' } = response.data || {}
|
||||
if (![true].includes(success)) {
|
||||
if (![true].includes(success)&&!list.includes(response.config.url)){
|
||||
message.error({
|
||||
content: msg,
|
||||
key: MSG_ERROR_KEY,
|
||||
@ -87,6 +89,7 @@ const basic = new XYHttp({
|
||||
...options,
|
||||
baseURL: config('http.apiBasic'),
|
||||
})
|
||||
|
||||
console.log(basic)
|
||||
const readFile = new ReadFile()
|
||||
export default {
|
||||
|
||||
@ -6,12 +6,14 @@
|
||||
<a-col :span="12">
|
||||
<a-form-item label="活动名称" name="name">
|
||||
<a-select v-model:value="searchFormData.activityId">
|
||||
<a-select-option v-for="item of activityList" :value="item.id">{{ item.title }}</a-select-option>
|
||||
<a-select-option v-for="item of activityList" :value="item.id">{{ item.title
|
||||
}}</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col class="align-right" :span="12">
|
||||
<a-space>
|
||||
<a-button @click="handleExport">导出文件</a-button>
|
||||
<a-button @click="handleResetSearch">{{ $t('button.reset') }}</a-button>
|
||||
<a-button ghost type="primary" @click="handleSearch">
|
||||
{{ $t('button.search') }}
|
||||
@ -84,7 +86,7 @@ import { usePagination } from '@/hooks'
|
||||
import { customersEnum, areaEnum } from "@/enums/useEnum"
|
||||
import { PlusOutlined, EditOutlined, DeleteOutlined, QrcodeOutlined } from '@ant-design/icons-vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
import axios from 'axios'
|
||||
defineOptions({
|
||||
name: 'activityOrder',
|
||||
})
|
||||
@ -199,6 +201,34 @@ function handleSearch() {
|
||||
resetPagination()
|
||||
getPageList()
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载文件
|
||||
*/
|
||||
async function handleExport() {
|
||||
try {
|
||||
const activityId = searchFormData.value.activityId
|
||||
if (!activityId) {
|
||||
message.warning('请选择活动')
|
||||
return
|
||||
}
|
||||
|
||||
// 注意添加 { responseType: 'blob' }
|
||||
const response = await apis.activity.exportFile({ activityId })
|
||||
console.log(response)
|
||||
const url = window.URL.createObjectURL(new Blob([response]))
|
||||
const link = document.createElement('a')
|
||||
link.href = url
|
||||
link.setAttribute('download', 'filename.xlsx') // 设置下载文件名
|
||||
document.body.appendChild(link)
|
||||
link.click()
|
||||
document.body.removeChild(link)
|
||||
window.URL.revokeObjectURL(url)
|
||||
} catch (error) {
|
||||
// message.error('导出失败:' + (error.message || '未知错误'))
|
||||
// console.error('导出文件出错:', error)
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 重置
|
||||
*/
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user