generated from Leo_Ding/web-template
Merge branch 'master' of https://gitlab.guxuan.icu/Leo_Ding/zhonghai_admin
This commit is contained in:
commit
94bcce4499
@ -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' })
|
||||||
|
|||||||
@ -5,5 +5,9 @@ export const getRegion = (params) => request.basic.get('/region', params)
|
|||||||
|
|
||||||
// 获取 验证码ID
|
// 获取 验证码ID
|
||||||
export const getCaptcha = (params) => request.basic.get('/api/v1/captcha/id', params)
|
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'}})
|
export const uploadImg=(params)=>request.basic.post('/api/v1/upload',params,{Headers:{'Content-Type': 'multipart/form-data'}})
|
||||||
@ -20,9 +20,10 @@ const options = {
|
|||||||
},
|
},
|
||||||
interceptorRequestCatch: () => {},
|
interceptorRequestCatch: () => {},
|
||||||
interceptorResponse: (response) => {
|
interceptorResponse: (response) => {
|
||||||
|
const list = ['/api/v1/activity-details/export', '/api/v1/captcha/image']
|
||||||
// 错误处理
|
// 错误处理
|
||||||
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 +88,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 {
|
||||||
|
|||||||
@ -6,12 +6,14 @@
|
|||||||
<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',
|
||||||
})
|
})
|
||||||
@ -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)
|
||||||
|
}
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* 重置
|
* 重置
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -2,17 +2,10 @@
|
|||||||
<div>
|
<div>
|
||||||
<a-tabs>
|
<a-tabs>
|
||||||
<!-- 账号登录 -->
|
<!-- 账号登录 -->
|
||||||
<a-tab-pane
|
<a-tab-pane key="account" :tab="$t('pages.login.accountLogin.tab')">
|
||||||
key="account"
|
<a-form :model="formData" :rules="formRules" ref="formRef">
|
||||||
:tab="$t('pages.login.accountLogin.tab')">
|
|
||||||
<a-form
|
|
||||||
:model="formData"
|
|
||||||
:rules="formRules"
|
|
||||||
ref="formRef">
|
|
||||||
<a-form-item name="username">
|
<a-form-item name="username">
|
||||||
<a-input
|
<a-input :placeholder="$t('pages.login.username.placeholder')" v-model:value="formData.username"
|
||||||
:placeholder="$t('pages.login.username.placeholder')"
|
|
||||||
v-model:value="formData.username"
|
|
||||||
size="large">
|
size="large">
|
||||||
<template #prefix>
|
<template #prefix>
|
||||||
<user-outlined></user-outlined>
|
<user-outlined></user-outlined>
|
||||||
@ -20,18 +13,14 @@
|
|||||||
</a-input>
|
</a-input>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item name="password">
|
<a-form-item name="password">
|
||||||
<a-input
|
<a-input v-model:value="formData.password" size="large" type="password"
|
||||||
v-model:value="formData.password"
|
:placeholder="$t('pages.login.password.placeholder')" @pressEnter="handleLogin">
|
||||||
size="large"
|
|
||||||
type="password"
|
|
||||||
:placeholder="$t('pages.login.password.placeholder')"
|
|
||||||
@pressEnter="handleLogin">
|
|
||||||
<template #prefix>
|
<template #prefix>
|
||||||
<lock-outlined></lock-outlined>
|
<lock-outlined></lock-outlined>
|
||||||
</template>
|
</template>
|
||||||
</a-input>
|
</a-input>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<!-- <a-form-item name="captcha_code">
|
<a-form-item name="captcha_code">
|
||||||
<a-space>
|
<a-space>
|
||||||
<a-input
|
<a-input
|
||||||
v-model:value="formData.captcha_code"
|
v-model:value="formData.captcha_code"
|
||||||
@ -50,15 +39,10 @@
|
|||||||
:height="42"
|
:height="42"
|
||||||
:src="captcha_img" />
|
:src="captcha_img" />
|
||||||
</a-space>
|
</a-space>
|
||||||
</a-form-item> -->
|
</a-form-item>
|
||||||
<a-form-item>
|
<a-form-item>
|
||||||
<a-button
|
<a-button type="primary" size="large" block :loading="loading" @click="handleLogin">{{
|
||||||
type="primary"
|
$t('pages.login.submit') }}
|
||||||
size="large"
|
|
||||||
block
|
|
||||||
:loading="loading"
|
|
||||||
@click="handleLogin"
|
|
||||||
>{{ $t('pages.login.submit') }}
|
|
||||||
</a-button>
|
</a-button>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-form>
|
</a-form>
|
||||||
@ -124,27 +108,33 @@ async function getCaptcha() {
|
|||||||
async function handleLogin() {
|
async function handleLogin() {
|
||||||
formRef.value.validate().then(async (values) => {
|
formRef.value.validate().then(async (values) => {
|
||||||
values.captcha_id = captcha_id.value
|
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
|
loading.value = true
|
||||||
const { success } = await userStore
|
try {
|
||||||
.login({
|
const response = await userStore.login({ ...values })
|
||||||
...values,
|
|
||||||
})
|
|
||||||
.catch(() => {
|
|
||||||
loading.value = false
|
loading.value = false
|
||||||
getCaptcha()
|
if (config('http.code.success') === response.success) {
|
||||||
})
|
|
||||||
loading.value = false
|
|
||||||
if (config('http.code.success') === success) {
|
|
||||||
// 加载完成
|
|
||||||
if (appStore.complete) {
|
if (appStore.complete) {
|
||||||
goIndex()
|
goIndex()
|
||||||
} else {
|
} else {
|
||||||
await appStore.init()
|
await appStore.init()
|
||||||
goIndex()
|
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)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user