feat(property-marketing): 新增PDF导出功能并优化投放指南页面交互

This commit is contained in:
林志军
2025-07-09 15:15:16 +08:00
parent 239a5e9c91
commit 41873335d5
8 changed files with 162 additions and 81 deletions

View File

@ -54,8 +54,16 @@
<!-- 投放建议-->
<PlacementSuggestions :optimization="aiResult.optimization"></PlacementSuggestions>
<!-- 投放行动指南-->
<ActionGuideDistribution :action_guide="aiResult.action_guide"></ActionGuideDistribution>
</div>
<div class="ignore-export">
<a-space class="down-btn">
<a-button type="outline" :loading="exportLoading" @click="downPage">
<template #icon>
<icon-download />
</template>
<template #default>下载</template>
</a-button>
</a-space>
</div>
</div>
</template>
@ -65,17 +73,18 @@ import { reactive, ref } from 'vue';
import MonthData from './components/month-data/index.vue';
import PlacementSuggestions from './components/placement-suggestions/index.vue';
import ActionGuideDistribution from './components/action-guide-distribution';
import { PLATFORM_LIST } from '@/views/property-marketing/put-account/common_constants.ts';
import { getPlacementGuideDetail } from '@/api/all/propertyMarketing';
import { useRoute } from 'vue-router';
import { uploadPdf } from '@/views/property-marketing/put-account/investment-guidelines/constants';
import { Message } from '@arco-design/web-vue';
const aiResult = reactive({
optimization: [], // 投放建议优化
action_guide: [], // 新投放建议生成
overview: [], // 新投放建议生成
});
const fileUrl = ref('');
const detailData = reactive({
created_at: '',
account: '',
@ -92,6 +101,27 @@ const getDetail = async () => {
}
};
const exportLoading = ref(false);
const downPage = async () => {
try {
let downFileUrl = fileUrl.value;
exportLoading.value = true;
if (downFileUrl === '') {
downFileUrl = await uploadPdf('投放指南.pdf', '.guidelines-data-wrap');
fileUrl.value = downFileUrl;
}
const link = document.createElement('a');
link.href = downFileUrl;
link.download = '投放指南.pdf';
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
exportLoading.value = false;
} catch (error) {
Message.error(error.message);
exportLoading.value = false;
}
};
onMounted(() => {
getDetail();
});