|
|
|
@ -111,15 +111,13 @@ |
|
|
|
</template> |
|
|
|
|
|
|
|
<script> |
|
|
|
import { getLandingListApi, exportLandingDetailApi } from '../../api/member.js'; |
|
|
|
import { getLandingDetailApi, exportLandingDetailApi } from '../../api/member.js'; |
|
|
|
import { ElMessage } from 'element-plus'; |
|
|
|
|
|
|
|
export default { |
|
|
|
name: 'LandingDetail', |
|
|
|
data() { |
|
|
|
return { |
|
|
|
// 活动详情数据 |
|
|
|
detailData: '详情', |
|
|
|
// 筛选表单数据 |
|
|
|
filterForm: { |
|
|
|
startTime: '', |
|
|
|
@ -167,7 +165,7 @@ export default { |
|
|
|
const activityId = this.$route.params.id; |
|
|
|
if (activityId) { |
|
|
|
// 调用接口获取活动详情及相关数据 |
|
|
|
this.getActivityDetail(activityId); |
|
|
|
this.getLandingDetail(activityId); |
|
|
|
} else { |
|
|
|
ElMessage.error('未获取到活动ID,无法加载详情'); |
|
|
|
} |
|
|
|
@ -178,15 +176,30 @@ export default { |
|
|
|
this.$router.back(); |
|
|
|
}, |
|
|
|
|
|
|
|
// 获取活动详情及表格数据 |
|
|
|
async getActivityDetail(id) { |
|
|
|
// 格式化时间为 'YYYY-MM-DD HH:mm:ss' |
|
|
|
formatDateTime(date) { |
|
|
|
if (!date) return ''; |
|
|
|
const year = date.getFullYear(); |
|
|
|
const month = String(date.getMonth() + 1).padStart(2, '0'); |
|
|
|
const day = String(date.getDate()).padStart(2, '0'); |
|
|
|
const hours = String(date.getHours()).padStart(2, '0'); |
|
|
|
const minutes = String(date.getMinutes()).padStart(2, '0'); |
|
|
|
const seconds = String(date.getSeconds()).padStart(2, '0'); |
|
|
|
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`; |
|
|
|
}, |
|
|
|
|
|
|
|
// 获取活动详情数据 |
|
|
|
async getLandingDetail(id) { |
|
|
|
this.loading = true; |
|
|
|
try { |
|
|
|
const res = await getLandingListApi({ |
|
|
|
id: id, // 活动ID |
|
|
|
const { startTime, endTime, status } = this.filterForm; |
|
|
|
const res = await getLandingDetailApi({ |
|
|
|
id: id, |
|
|
|
page: this.currentPage, |
|
|
|
pageSize: this.pageSize, |
|
|
|
...this.filterForm |
|
|
|
startTime: this.formatDateTime(startTime), |
|
|
|
endTime: this.formatDateTime(endTime), |
|
|
|
status: status |
|
|
|
}); |
|
|
|
|
|
|
|
if (res.code === 200) { |
|
|
|
@ -205,17 +218,19 @@ export default { |
|
|
|
// 执行查询操作 |
|
|
|
handleQuery() { |
|
|
|
this.currentPage = 1; |
|
|
|
this.getActivityDetail(this.$route.params.id); |
|
|
|
this.getLandingDetail(this.$route.params.id); |
|
|
|
}, |
|
|
|
|
|
|
|
// 执行导出操作 |
|
|
|
handleExport() { |
|
|
|
this.loading = true; |
|
|
|
try { |
|
|
|
// 调用导出接口(携带活动ID和筛选条件) |
|
|
|
const { startTime, endTime, status } = this.filterForm; |
|
|
|
exportLandingDetailApi({ |
|
|
|
id: this.$route.params.id, |
|
|
|
...this.filterForm |
|
|
|
startTime: this.formatDateTime(startTime), |
|
|
|
endTime: this.formatDateTime(endTime), |
|
|
|
status: status |
|
|
|
}).then(res => { |
|
|
|
if (res.code === 200) { |
|
|
|
ElMessage.success('导出成功'); |
|
|
|
@ -224,7 +239,7 @@ export default { |
|
|
|
const url = URL.createObjectURL(blob); |
|
|
|
const a = document.createElement('a'); |
|
|
|
a.href = url; |
|
|
|
a.download = `${this.detailData?.name || '活动数据'}.xlsx`; |
|
|
|
a.download = `${'活动数据'}.xlsx`; |
|
|
|
a.click(); |
|
|
|
URL.revokeObjectURL(url); |
|
|
|
} else { |
|
|
|
@ -242,13 +257,13 @@ export default { |
|
|
|
handleSizeChange(val) { |
|
|
|
this.pageSize = val; |
|
|
|
this.currentPage = 1; |
|
|
|
this.getActivityDetail(this.$route.params.id); |
|
|
|
this.getLandingDetail(this.$route.params.id); |
|
|
|
}, |
|
|
|
|
|
|
|
// 分页页码变更 |
|
|
|
handleCurrentChange(val) { |
|
|
|
this.currentPage = val; |
|
|
|
this.getActivityDetail(this.$route.params.id); |
|
|
|
this.getLandingDetail(this.$route.params.id); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|