|
|
@ -71,11 +71,11 @@ |
|
|
|
<script setup> |
|
|
|
import { ref, onMounted } from 'vue' |
|
|
|
import { useRouter } from 'vue-router' |
|
|
|
import { useactivitytone } from '@/stone/activityStone' |
|
|
|
import { getDetailListbyActivityId, getDetailMessage, getMarket } from '@/api/manage/activity' |
|
|
|
import { useactivityStone } from '@/stone/activityStone' |
|
|
|
import { getDetailListbyActivityId, getDetailMessage, getMarket, exportActivityDataExcel } from '@/api/manage/activity' |
|
|
|
import { ElMessage } from 'element-plus' |
|
|
|
|
|
|
|
const activityStone = useactivitytone() |
|
|
|
const activityStone = useactivityStone() |
|
|
|
const router = useRouter() |
|
|
|
|
|
|
|
// 响应式数据 |
|
|
@ -102,6 +102,7 @@ const fetchMarketList = async () => { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 搜索参数(初始化时使用持久化值) |
|
|
|
const searchdata = ref({ |
|
|
|
username: '', |
|
|
|
jwcode: '', |
|
|
@ -109,8 +110,7 @@ const searchdata = ref({ |
|
|
|
}) |
|
|
|
|
|
|
|
const tableData = ref([]) |
|
|
|
const total = ref(0) // ✅ 新增 total |
|
|
|
|
|
|
|
const total = ref(0) |
|
|
|
const currentPage = ref(1) |
|
|
|
const pageSize = ref(10) |
|
|
|
|
|
|
@ -122,7 +122,11 @@ const goBack = () => { |
|
|
|
// 搜索逻辑 |
|
|
|
const handleSearch = () => { |
|
|
|
currentPage.value = 1 |
|
|
|
// 更新持久化值 |
|
|
|
activityStone.setSearchUsername(searchdata.value.username) |
|
|
|
activityStone.setSearchJwcode(searchdata.value.jwcode) |
|
|
|
getDetailData() |
|
|
|
// 清空输入框 |
|
|
|
searchdata.value = { |
|
|
|
username: '', |
|
|
|
jwcode: '', |
|
|
@ -137,13 +141,58 @@ const handleReset = () => { |
|
|
|
jwcode: '', |
|
|
|
marketSign: '' |
|
|
|
} |
|
|
|
// 同步清空持久化搜索值 |
|
|
|
activityStone.setSearchUsername('') |
|
|
|
activityStone.setSearchJwcode('') |
|
|
|
getDetailData() |
|
|
|
} |
|
|
|
|
|
|
|
// 导出数据 |
|
|
|
const handleExport = () => { |
|
|
|
console.log('Export Data') |
|
|
|
} |
|
|
|
// 导出数据 |
|
|
|
const handleExport = async () => { |
|
|
|
try { |
|
|
|
const activityId = activityStone.selectactivityId; |
|
|
|
const username = activityStone.searchUsername; |
|
|
|
const jwcode = activityStone.searchJwcode; |
|
|
|
|
|
|
|
if (!activityId) { |
|
|
|
ElMessage.warning('活动ID为空,无法导出数据'); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
// 构造请求参数 |
|
|
|
const exportData = { |
|
|
|
activityId, |
|
|
|
username, |
|
|
|
jwcode |
|
|
|
}; |
|
|
|
|
|
|
|
// 调用导出接口(返回的是 blob 数据) |
|
|
|
const response = await exportActivityDataExcel(exportData); |
|
|
|
|
|
|
|
// 创建 Blob 对象 |
|
|
|
const blob = new Blob([response], { |
|
|
|
type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' |
|
|
|
}); |
|
|
|
|
|
|
|
// 创建下载链接 |
|
|
|
const downloadUrl = window.URL.createObjectURL(blob); |
|
|
|
|
|
|
|
// 创建 <a> 标签并模拟点击 |
|
|
|
const link = document.createElement('a'); |
|
|
|
link.href = downloadUrl; |
|
|
|
link.setAttribute('download', '周年庆活动.xlsx'); // 指定文件名为“周年庆活动.xlsx” |
|
|
|
document.body.appendChild(link); |
|
|
|
link.click(); |
|
|
|
|
|
|
|
// 清理资源 |
|
|
|
link.remove(); |
|
|
|
window.URL.revokeObjectURL(downloadUrl); |
|
|
|
} catch (error) { |
|
|
|
console.error('导出数据失败:', error); |
|
|
|
ElMessage.error('导出数据失败'); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
// 分页 size 改变 |
|
|
|
const handleSizeChange = (val) => { |
|
|
@ -170,11 +219,14 @@ onMounted(async () => { |
|
|
|
fetchMarketList() |
|
|
|
}) |
|
|
|
|
|
|
|
// ✅ 获取详情数据(带分页参数) |
|
|
|
// 获取详情数据(带分页参数) |
|
|
|
const getDetailData = async () => { |
|
|
|
try { |
|
|
|
const activityId = activityStone.selectactivityId |
|
|
|
const { username, jwcode, marketSign } = searchdata.value |
|
|
|
// 使用持久化搜索值 |
|
|
|
const username = activityStone.searchUsername |
|
|
|
const jwcode = activityStone.searchJwcode |
|
|
|
const marketSign = searchdata.value.marketSign |
|
|
|
|
|
|
|
if (!activityId) { |
|
|
|
console.warn('未获取到 activityId') |
|
|
@ -223,8 +275,8 @@ const fetchDetailMessage = async () => { |
|
|
|
hkParticipants.value = data.marketTwoPeople |
|
|
|
hkAssists.value = data.marketTwoTotal |
|
|
|
|
|
|
|
marketOneLabel.value = data.market_one |
|
|
|
marketTwoLabel.value = data.market_two |
|
|
|
marketOneLabel.value = data.marketOneName |
|
|
|
marketTwoLabel.value = data.marketTwoName |
|
|
|
} else { |
|
|
|
console.error('获取顶部信息失败:', response.message) |
|
|
|
ElMessage.error(response.message || '获取顶部信息失败') |
|
|
|