This commit is contained in:
Leo_Ding 2025-07-30 09:40:36 +08:00
commit 94bcce4499
5 changed files with 79 additions and 50 deletions

View File

@ -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' })

View File

@ -5,5 +5,9 @@ export const getRegion = (params) => request.basic.get('/region', params)
// 获取 验证码ID
export const getCaptcha = (params) => request.basic.get('/api/v1/captcha/id', params)
// 获取图片
export const getCaptchaImage = (params) => request.basic.get('/api/v1/captcha/image', params , { responseType: 'blob' })
//上传图片
export const uploadImg=(params)=>request.basic.post('/api/v1/upload',params,{Headers:{'Content-Type': 'multipart/form-data'}})

View File

@ -20,9 +20,10 @@ const options = {
},
interceptorRequestCatch: () => {},
interceptorResponse: (response) => {
const list = ['/api/v1/activity-details/export', '/api/v1/captcha/image']
// 错误处理
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 +88,7 @@ const basic = new XYHttp({
...options,
baseURL: config('http.apiBasic'),
})
console.log(basic)
const readFile = new ReadFile()
export default {

View File

@ -5,13 +5,15 @@
<a-row :gutter="12">
<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 v-model:value="searchFormData.activityId">
<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',
})
@ -101,7 +103,7 @@ const columns = [
// { 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 } =
usePagination()
@ -113,7 +115,7 @@ async function getActiveList() {
showLoading()
const { success, data } = await apis.activity
.getProjectList({
pageSize:99,
pageSize: 99,
current: 1,
})
.catch(() => {
@ -121,7 +123,7 @@ async function getActiveList() {
})
hideLoading()
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) {
hideLoading()
@ -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)
}
}
/**
* 重置
*/

View File

@ -2,17 +2,10 @@
<div>
<a-tabs>
<!-- 账号登录 -->
<a-tab-pane
key="account"
:tab="$t('pages.login.accountLogin.tab')">
<a-form
:model="formData"
:rules="formRules"
ref="formRef">
<a-tab-pane key="account" :tab="$t('pages.login.accountLogin.tab')">
<a-form :model="formData" :rules="formRules" ref="formRef">
<a-form-item name="username">
<a-input
:placeholder="$t('pages.login.username.placeholder')"
v-model:value="formData.username"
<a-input :placeholder="$t('pages.login.username.placeholder')" v-model:value="formData.username"
size="large">
<template #prefix>
<user-outlined></user-outlined>
@ -20,18 +13,14 @@
</a-input>
</a-form-item>
<a-form-item name="password">
<a-input
v-model:value="formData.password"
size="large"
type="password"
:placeholder="$t('pages.login.password.placeholder')"
@pressEnter="handleLogin">
<a-input v-model:value="formData.password" size="large" type="password"
:placeholder="$t('pages.login.password.placeholder')" @pressEnter="handleLogin">
<template #prefix>
<lock-outlined></lock-outlined>
</template>
</a-input>
</a-form-item>
<!-- <a-form-item name="captcha_code">
<a-form-item name="captcha_code">
<a-space>
<a-input
v-model:value="formData.captcha_code"
@ -50,15 +39,10 @@
:height="42"
:src="captcha_img" />
</a-space>
</a-form-item> -->
</a-form-item>
<a-form-item>
<a-button
type="primary"
size="large"
block
:loading="loading"
@click="handleLogin"
>{{ $t('pages.login.submit') }}
<a-button type="primary" size="large" block :loading="loading" @click="handleLogin">{{
$t('pages.login.submit') }}
</a-button>
</a-form-item>
</a-form>
@ -124,27 +108,33 @@ async function getCaptcha() {
async function handleLogin() {
formRef.value.validate().then(async (values) => {
values.captcha_id = captcha_id.value
if (values.password === 'abc-123') values.password = md5(values.password)
if (values.password === 'abc-123') {
values.password = md5(values.password)
}
loading.value = true
const { success } = await userStore
.login({
...values,
})
.catch(() => {
try {
const response = await userStore.login({ ...values })
loading.value = false
getCaptcha()
})
loading.value = false
if (config('http.code.success') === success) {
//
if (config('http.code.success') === response.success) {
if (appStore.complete) {
goIndex()
} else {
await appStore.init()
goIndex()
}
} else {
message.error(t(response.msg))
}
} catch (error) {
loading.value = false
getCaptcha()
const msg = error.msg || error.message || '登录失败,请重试'
message.error(t(msg))
console.log("登录出错:", error)
}
}).catch(validationError => {
console.log('表单校验失败', validationError)
})
}