|
|
|
@ -148,7 +148,7 @@ |
|
|
|
/> |
|
|
|
<el-button type="primary" class="search-btn" @click="handleSearchRegion">搜索</el-button> |
|
|
|
<el-button type="primary" class="reset-btn" @click="handleResetRegion">重置</el-button> |
|
|
|
<el-button type="danger" class="export-btn">数据导出</el-button> |
|
|
|
<el-button type="danger" class="export-btn" @click="handleExportRegion">数据导出</el-button> |
|
|
|
</div> |
|
|
|
|
|
|
|
<!-- 表格1: 各地区活跃数据 --> |
|
|
|
@ -223,7 +223,8 @@ |
|
|
|
import { ref, onMounted, nextTick, watch } from 'vue'; |
|
|
|
import { useRoute, useRouter } from 'vue-router'; |
|
|
|
import * as echarts from 'echarts'; |
|
|
|
import { getUserLoginList, getUserLoginTrend, getRegionActiveData, getRegionActiveDataHistogram, getUserLoginChannel, getUserLoginChannelMember, getUserLoginChannelNoMember, getRegionUserDistribution } from '../../api/platformData'; |
|
|
|
import { getUserLoginList, getUserLoginTrend, getRegionActiveData, getRegionActiveDataHistogram, getUserLoginChannel, getUserLoginChannelMember, getUserLoginChannelNoMember, getRegionUserDistribution, exportRegionActiveData } from '../../api/platformData'; |
|
|
|
import { ElMessage } from 'element-plus'; |
|
|
|
|
|
|
|
const route = useRoute(); |
|
|
|
const router = useRouter(); |
|
|
|
@ -812,6 +813,41 @@ const updatePieChart = (chartRef, chartInstance, data) => { |
|
|
|
instance.setOption(option); |
|
|
|
}; |
|
|
|
|
|
|
|
const handleExportRegion = async () => { |
|
|
|
let params = {}; |
|
|
|
if (dateRangeRegion.value && dateRangeRegion.value.length === 2) { |
|
|
|
params.start_time = formatDate(dateRangeRegion.value[0]); |
|
|
|
params.end_time = formatDate(dateRangeRegion.value[1]); |
|
|
|
} |
|
|
|
|
|
|
|
try { |
|
|
|
const res = await exportRegionActiveData(params); |
|
|
|
console.log("导出地区活跃数据响应(Blob):", res); |
|
|
|
|
|
|
|
// 创建Blob对象,处理二进制流下载 |
|
|
|
const blob = new Blob([res], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' }); |
|
|
|
const url = window.URL.createObjectURL(blob); |
|
|
|
const link = document.createElement('a'); |
|
|
|
link.href = url; |
|
|
|
|
|
|
|
// 设置下载文件名,添加时间戳防止重名 |
|
|
|
const fileName = `各地区登录活跃数据_${formatDate(new Date())}.xlsx`; |
|
|
|
link.setAttribute('download', fileName); |
|
|
|
|
|
|
|
document.body.appendChild(link); |
|
|
|
link.click(); |
|
|
|
|
|
|
|
// 清理资源 |
|
|
|
document.body.removeChild(link); |
|
|
|
window.URL.revokeObjectURL(url); |
|
|
|
|
|
|
|
ElMessage.success('导出成功'); |
|
|
|
} catch (e) { |
|
|
|
console.error('导出地区活跃数据失败:', e); |
|
|
|
ElMessage.error('导出请求发生错误'); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
const handleSearchRegion = () => { |
|
|
|
// 更新 URL 参数 |
|
|
|
const query = { ...route.query }; |
|
|
|
|