|
|
@ -2,7 +2,7 @@ |
|
|
|
<el-card style="margin-top: 50px; min-height: 90vh; max-height: 90vh;"> |
|
|
|
<!-- 搜索栏 --> |
|
|
|
<div class="gray-container"> |
|
|
|
<h2>中奖管理</h2> |
|
|
|
<h2>用户管理</h2> |
|
|
|
<el-form :inline="true" class="search-bar"> |
|
|
|
<el-form-item label="姓名"> |
|
|
|
<el-input v-model="searchParams.username" placeholder="请输入姓名"></el-input> |
|
|
@ -14,23 +14,6 @@ |
|
|
|
@input="handleJingwangIdInput" |
|
|
|
></el-input> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item label="中奖等级"> |
|
|
|
<el-select |
|
|
|
v-model="searchParams.gradeId" |
|
|
|
placeholder="请选择" |
|
|
|
class="prize-level-select" |
|
|
|
style="width: 220px" |
|
|
|
> |
|
|
|
<el-option label="全部" value=""></el-option> |
|
|
|
<el-option |
|
|
|
v-for="item in gradeOptions" |
|
|
|
:key="item.id" |
|
|
|
:label="item.gradeName" |
|
|
|
:value="item.id" |
|
|
|
> |
|
|
|
</el-option> |
|
|
|
</el-select> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item> |
|
|
|
<el-button type="primary" @click="handleSearch">搜索</el-button> |
|
|
|
</el-form-item> |
|
|
@ -38,7 +21,7 @@ |
|
|
|
<el-button @click="handleReset">重置</el-button> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item> |
|
|
|
<el-button type="primary" @click="handleExport">导出数据</el-button> |
|
|
|
<el-button type="primary" @click="addusershow">添加用户</el-button> |
|
|
|
</el-form-item> |
|
|
|
</el-form> |
|
|
|
|
|
|
@ -83,29 +66,15 @@ |
|
|
|
pageNum: 1, |
|
|
|
pageSize: 10, |
|
|
|
username: "", |
|
|
|
gradeId: "", |
|
|
|
jwcode: "" |
|
|
|
}) |
|
|
|
|
|
|
|
// 中奖等级选项 |
|
|
|
const gradeOptions = ref([]) |
|
|
|
|
|
|
|
|
|
|
|
// 表格数据 |
|
|
|
const tableData = ref([]) |
|
|
|
const total = ref(0) |
|
|
|
|
|
|
|
// 获取中奖等级列表 |
|
|
|
const fetchWinLevelList = async () => { |
|
|
|
try { |
|
|
|
const res = await getWinLevelList() |
|
|
|
if (res.code === 200) { |
|
|
|
gradeOptions.value = res.data |
|
|
|
} |
|
|
|
} catch (error) { |
|
|
|
console.error('获取中奖等级列表失败:', error) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const handleSizeChange = (val) => { |
|
|
|
searchParams.value.pageSize = val |
|
|
|
searchParams.value.pageNum = 1 |
|
|
@ -121,7 +90,7 @@ |
|
|
|
try { |
|
|
|
const requestData = { |
|
|
|
username: activityStone.searchUsername, |
|
|
|
gradeId: winStone.searchgradeId, |
|
|
|
gradeId: "" , |
|
|
|
jwcode: activityStone.searchJwcode, |
|
|
|
pageNum: searchParams.value.pageNum, |
|
|
|
pageSize: searchParams.value.pageSize |
|
|
@ -142,55 +111,14 @@ |
|
|
|
const handleSearch = () => { |
|
|
|
searchParams.value.pageNum = 1 |
|
|
|
|
|
|
|
// 更新持久化值 |
|
|
|
activityStone.setSearchUsername(searchParams.value.username) |
|
|
|
activityStone.setSearchJwcode(searchParams.value.jwcode) |
|
|
|
winStone.setSearchgradeId(searchParams.value.gradeId) |
|
|
|
// // 更新持久化值 |
|
|
|
// activityStone.setSearchUsername(searchParams.value.username) |
|
|
|
// activityStone.setSearchJwcode(searchParams.value.jwcode) |
|
|
|
// winStone.setSearchgradeId(searchParams.value.gradeId) |
|
|
|
|
|
|
|
fetchWinList() |
|
|
|
} |
|
|
|
|
|
|
|
// 导出数据 |
|
|
|
const handleExport = async () => { |
|
|
|
try { |
|
|
|
|
|
|
|
const username = activityStone.searchUsername; |
|
|
|
const jwcode = activityStone.searchJwcode; |
|
|
|
const gradeId = winStone.searchgradeId; |
|
|
|
|
|
|
|
// 构造请求参数 |
|
|
|
const exportData = { |
|
|
|
gradeId, |
|
|
|
username, |
|
|
|
jwcode |
|
|
|
}; |
|
|
|
|
|
|
|
// 调用导出接口(返回的是 blob 数据) |
|
|
|
const response = await exportWinExcel(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('导出数据失败'); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
// 重置搜索 |
|
|
@ -204,9 +132,9 @@ |
|
|
|
} |
|
|
|
|
|
|
|
// 清空持久化值 |
|
|
|
activityStone.setSearchUsername('') |
|
|
|
activityStone.setSearchJwcode('') |
|
|
|
winStone.setSearchgradeId('') |
|
|
|
// activityStone.setSearchUsername('') |
|
|
|
// activityStone.setSearchJwcode('') |
|
|
|
// winStone.setSearchgradeId('') |
|
|
|
|
|
|
|
fetchWinList() |
|
|
|
} |
|
|
@ -218,23 +146,22 @@ |
|
|
|
|
|
|
|
// 页面加载时获取数据 |
|
|
|
onMounted(() => { |
|
|
|
fetchWinLevelList() |
|
|
|
fetchWinList() |
|
|
|
}) |
|
|
|
|
|
|
|
onBeforeRouteLeave((to, from, next) => { |
|
|
|
// 判断是否跳转到 activity/index 页面 |
|
|
|
if (to.name !== 'zhongchouwinning') { |
|
|
|
// 清空 winStone 中的 gradeId |
|
|
|
winStone.setSearchgradeId('') |
|
|
|
// onBeforeRouteLeave((to, from, next) => { |
|
|
|
// // 判断是否跳转到 activity/index 页面 |
|
|
|
// if (to.name !== 'zhongchouwinning') { |
|
|
|
// // 清空 winStone 中的 gradeId |
|
|
|
// winStone.setSearchgradeId('') |
|
|
|
|
|
|
|
// 清空 activityStone 中的搜索值 |
|
|
|
activityStone.setSearchUsername('') |
|
|
|
activityStone.setSearchJwcode('') |
|
|
|
} |
|
|
|
// // 清空 activityStone 中的搜索值 |
|
|
|
// activityStone.setSearchUsername('') |
|
|
|
// activityStone.setSearchJwcode('') |
|
|
|
// } |
|
|
|
|
|
|
|
next() // 必须调用 next() |
|
|
|
}) |
|
|
|
// next() // 必须调用 next() |
|
|
|
// }) |
|
|
|
</script> |
|
|
|
|
|
|
|
<style scoped> |
|
|
|