generated from Leo_Ding/web-template
修改
This commit is contained in:
parent
1ee082eb90
commit
f34ecf2b58
@ -2,6 +2,7 @@
|
|||||||
* 区域模块接口
|
* 区域模块接口
|
||||||
*/
|
*/
|
||||||
import request from '@/utils/request'
|
import request from '@/utils/request'
|
||||||
|
|
||||||
// 获取项目列表
|
// 获取项目列表
|
||||||
export const getProjectList = (params) => request.basic.get('/api/v1/activities', params)
|
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 delItem = (id) => request.basic.delete(`/api/v1/activities/${id}`)
|
||||||
//获取活动报名列表
|
//获取活动报名列表
|
||||||
export const getActivityList=(params)=>request.basic.get('/api/v1/activity-details',params)
|
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: () => {},
|
interceptorRequestCatch: () => {},
|
||||||
interceptorResponse: (response) => {
|
interceptorResponse: (response) => {
|
||||||
|
console.log('response',response)
|
||||||
|
const list=['/api/v1/activity-details/export']
|
||||||
// 错误处理
|
// 错误处理
|
||||||
const { success, msg = 'Network Error' } = response.data || {}
|
const { success, msg = 'Network Error' } = response.data || {}
|
||||||
if (![true].includes(success)) {
|
if (![true].includes(success)&&!list.includes(response.config.url)){
|
||||||
message.error({
|
message.error({
|
||||||
content: msg,
|
content: msg,
|
||||||
key: MSG_ERROR_KEY,
|
key: MSG_ERROR_KEY,
|
||||||
@ -87,6 +89,7 @@ const basic = new XYHttp({
|
|||||||
...options,
|
...options,
|
||||||
baseURL: config('http.apiBasic'),
|
baseURL: config('http.apiBasic'),
|
||||||
})
|
})
|
||||||
|
|
||||||
console.log(basic)
|
console.log(basic)
|
||||||
const readFile = new ReadFile()
|
const readFile = new ReadFile()
|
||||||
export default {
|
export default {
|
||||||
|
|||||||
@ -5,13 +5,15 @@
|
|||||||
<a-row :gutter="12">
|
<a-row :gutter="12">
|
||||||
<a-col :span="12">
|
<a-col :span="12">
|
||||||
<a-form-item label="活动名称" name="name">
|
<a-form-item label="活动名称" name="name">
|
||||||
<a-select v-model:value="searchFormData.activityId" >
|
<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-select>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
<a-col class="align-right" :span="12">
|
<a-col class="align-right" :span="12">
|
||||||
<a-space>
|
<a-space>
|
||||||
|
<a-button @click="handleExport">导出文件</a-button>
|
||||||
<a-button @click="handleResetSearch">{{ $t('button.reset') }}</a-button>
|
<a-button @click="handleResetSearch">{{ $t('button.reset') }}</a-button>
|
||||||
<a-button ghost type="primary" @click="handleSearch">
|
<a-button ghost type="primary" @click="handleSearch">
|
||||||
{{ $t('button.search') }}
|
{{ $t('button.search') }}
|
||||||
@ -84,7 +86,7 @@ import { usePagination } from '@/hooks'
|
|||||||
import { customersEnum, areaEnum } from "@/enums/useEnum"
|
import { customersEnum, areaEnum } from "@/enums/useEnum"
|
||||||
import { PlusOutlined, EditOutlined, DeleteOutlined, QrcodeOutlined } from '@ant-design/icons-vue'
|
import { PlusOutlined, EditOutlined, DeleteOutlined, QrcodeOutlined } from '@ant-design/icons-vue'
|
||||||
import { useI18n } from 'vue-i18n'
|
import { useI18n } from 'vue-i18n'
|
||||||
|
import axios from 'axios'
|
||||||
defineOptions({
|
defineOptions({
|
||||||
name: 'activityOrder',
|
name: 'activityOrder',
|
||||||
})
|
})
|
||||||
@ -101,7 +103,7 @@ const columns = [
|
|||||||
|
|
||||||
// { title: t('button.action'), key: 'action', fixed: 'right', width: 150, align: 'center' },
|
// { title: t('button.action'), key: 'action', fixed: 'right', width: 150, align: 'center' },
|
||||||
]
|
]
|
||||||
const activityList=ref([])
|
const activityList = ref([])
|
||||||
const { listData, loading, showLoading, hideLoading, paginationState, resetPagination, searchFormData } =
|
const { listData, loading, showLoading, hideLoading, paginationState, resetPagination, searchFormData } =
|
||||||
usePagination()
|
usePagination()
|
||||||
|
|
||||||
@ -113,7 +115,7 @@ async function getActiveList() {
|
|||||||
showLoading()
|
showLoading()
|
||||||
const { success, data } = await apis.activity
|
const { success, data } = await apis.activity
|
||||||
.getProjectList({
|
.getProjectList({
|
||||||
pageSize:99,
|
pageSize: 99,
|
||||||
current: 1,
|
current: 1,
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
@ -121,7 +123,7 @@ async function getActiveList() {
|
|||||||
})
|
})
|
||||||
hideLoading()
|
hideLoading()
|
||||||
if (config('http.code.success') === success) {
|
if (config('http.code.success') === success) {
|
||||||
activityList.value = data.map(item=>({id:item.id,title:item.title}))
|
activityList.value = data.map(item => ({ id: item.id, title: item.title }))
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
hideLoading()
|
hideLoading()
|
||||||
@ -199,6 +201,34 @@ function handleSearch() {
|
|||||||
resetPagination()
|
resetPagination()
|
||||||
getPageList()
|
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