From 5b1e7a743f3f091bef40216d996c5a4e77974947 Mon Sep 17 00:00:00 2001
From: rd <1344903914@qq.com>
Date: Wed, 9 Jul 2025 11:30:25 +0800
Subject: [PATCH 01/10] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E7=AC=94?=
=?UTF-8?q?=E8=AE=B0=E9=93=BE=E6=8E=A5?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/views/property-marketing/component.scss | 3 ++-
.../components/add-account-modal/index.vue | 16 ++++++++++++++++
2 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/src/views/property-marketing/component.scss b/src/views/property-marketing/component.scss
index 14e6920..c23d0db 100644
--- a/src/views/property-marketing/component.scss
+++ b/src/views/property-marketing/component.scss
@@ -7,7 +7,8 @@
border-color: #d7d7d9;
background-color: #fff;
&:focus-within,
- &.arco-input-focus {
+ &.arco-input-focus,
+ &.arco-textarea-focus {
background-color: var(--color-bg-2);
border-color: rgb(var(--primary-6));
box-shadow: 0 0 0 0 var(--color-primary-light-2);
diff --git a/src/views/property-marketing/media-account/account-manage/components/add-account-modal/index.vue b/src/views/property-marketing/media-account/account-manage/components/add-account-modal/index.vue
index 567df68..85241b6 100644
--- a/src/views/property-marketing/media-account/account-manage/components/add-account-modal/index.vue
+++ b/src/views/property-marketing/media-account/account-manage/components/add-account-modal/index.vue
@@ -115,6 +115,21 @@
+
+
+ 笔记链接
+
+
+
+
+
+
@@ -166,6 +181,7 @@ const INITIAL_FORM = {
platform: 0,
group_id: undefined,
tag_ids: [],
+ note_url: '',
};
const groupOptions = ref([]);
From 8389f1fac10b749f5542629a151ba110afee7144 Mon Sep 17 00:00:00 2001
From: rd <1344903914@qq.com>
Date: Wed, 9 Jul 2025 11:47:45 +0800
Subject: [PATCH 02/10] =?UTF-8?q?perf:=20=E6=8E=88=E6=9D=83=E8=B4=A6?=
=?UTF-8?q?=E5=8F=B7=E6=97=B6=EF=BC=8C=E5=85=B3=E9=97=AD=E6=B7=BB=E5=8A=A0?=
=?UTF-8?q?=E5=BC=B9=E7=AA=97?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../account-manage/components/add-account-modal/index.vue | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/src/views/property-marketing/media-account/account-manage/components/add-account-modal/index.vue b/src/views/property-marketing/media-account/account-manage/components/add-account-modal/index.vue
index 85241b6..6abdfd0 100644
--- a/src/views/property-marketing/media-account/account-manage/components/add-account-modal/index.vue
+++ b/src/views/property-marketing/media-account/account-manage/components/add-account-modal/index.vue
@@ -334,10 +334,8 @@ async function onSubmit() {
if (code === 200) {
isEdit.value && AMessage.success('修改成功');
emits('update');
-
- if (isEdit.value) {
- onClose();
- } else {
+ onClose();
+ if (!isEdit.value) {
startAuthorized(data?.id, data?.platform);
}
}
From edc6b3e7ca44404448b493063623d17ae4feadd4 Mon Sep 17 00:00:00 2001
From: rd <1344903914@qq.com>
Date: Wed, 9 Jul 2025 13:47:34 +0800
Subject: [PATCH 03/10] =?UTF-8?q?perf:=20=E4=BF=AE=E6=94=B9=E5=BC=95?=
=?UTF-8?q?=E7=94=A8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../property-marketing/media-account/account-manage/index.vue | 1 -
.../property-marketing/put-account/account-manage/index.vue | 3 +--
2 files changed, 1 insertion(+), 3 deletions(-)
diff --git a/src/views/property-marketing/media-account/account-manage/index.vue b/src/views/property-marketing/media-account/account-manage/index.vue
index 863de0c..2a383fc 100644
--- a/src/views/property-marketing/media-account/account-manage/index.vue
+++ b/src/views/property-marketing/media-account/account-manage/index.vue
@@ -191,7 +191,6 @@ const getHealthData = async () => {
const { code, data } = await getMediaAccountsHealth();
if (code === 200) {
healthData.value = data;
- console.log(healthData.value);
}
};
const getAccountData = async () => {
diff --git a/src/views/property-marketing/put-account/account-manage/index.vue b/src/views/property-marketing/put-account/account-manage/index.vue
index 1d665b2..da35605 100644
--- a/src/views/property-marketing/put-account/account-manage/index.vue
+++ b/src/views/property-marketing/put-account/account-manage/index.vue
@@ -164,10 +164,9 @@ const getData = () => {
};
const getHealthData = async () => {
- const { code, data } = await getMediaAccountsHealth();
+ const { code, data } = await getPlacementAccountsHealth();
if (code === 200) {
healthData.value = data;
- console.log(healthData.value);
}
};
const getAccountData = async () => {
From 1cee677c75561317c30f7b463517453e86b1e769 Mon Sep 17 00:00:00 2001
From: rd <1344903914@qq.com>
Date: Wed, 9 Jul 2025 13:52:41 +0800
Subject: [PATCH 04/10] =?UTF-8?q?perf:=20=E4=BF=AE=E6=94=B9=E7=AC=94?=
=?UTF-8?q?=E8=AE=B0=E9=93=BE=E6=8E=A5=E5=AE=9A=E4=B9=89?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../account-manage/components/add-account-modal/index.vue | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/views/property-marketing/media-account/account-manage/components/add-account-modal/index.vue b/src/views/property-marketing/media-account/account-manage/components/add-account-modal/index.vue
index 6abdfd0..206659d 100644
--- a/src/views/property-marketing/media-account/account-manage/components/add-account-modal/index.vue
+++ b/src/views/property-marketing/media-account/account-manage/components/add-account-modal/index.vue
@@ -115,7 +115,7 @@
-
+
笔记链接
@@ -123,7 +123,7 @@
Date: Wed, 9 Jul 2025 14:24:09 +0800
Subject: [PATCH 05/10] =?UTF-8?q?feat(property-marketing):=20=E4=BC=98?=
=?UTF-8?q?=E5=8C=96=E6=8A=95=E6=94=BE=E6=8C=87=E5=8D=97=E4=B8=8B=E8=BD=BD?=
=?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=B9=B6=E9=87=8D=E6=9E=84PDF=E7=94=9F?=
=?UTF-8?q?=E6=88=90=E9=80=BB=E8=BE=91?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../table-data/guideListHistory.vue | 34 ++--
.../components/table-data/listSearchForm.vue | 2 +-
.../table-data/placementGuideList.vue | 3 +-
.../investment-guidelines/index.vue | 147 +++++++++++++-----
4 files changed, 123 insertions(+), 63 deletions(-)
diff --git a/src/views/property-marketing/put-account/investment-guidelines/components/table-data/guideListHistory.vue b/src/views/property-marketing/put-account/investment-guidelines/components/table-data/guideListHistory.vue
index eac738f..cba3821 100644
--- a/src/views/property-marketing/put-account/investment-guidelines/components/table-data/guideListHistory.vue
+++ b/src/views/property-marketing/put-account/investment-guidelines/components/table-data/guideListHistory.vue
@@ -21,7 +21,7 @@
- 下载
+ 下载
详情
@@ -82,32 +82,24 @@ const goDetail = async (id) => {
router.push(`/put-account/detail/${id}`);
};
-const downloadDetailAsImage = (id) => {
- const url = `/put-account/detail/${id}`;
- const win = window.open(url, '_blank');
-
- win.onload = () => {
- setTimeout(() => {
- html2canvas(win.document.body, {
- useCORS: true,
- scale: 2,
- }).then((canvas) => {
- const imgData = canvas.toDataURL('image/png');
- const link = document.createElement('a');
- link.href = imgData;
- link.download = `详情页面_${Date.now()}.png`;
- link.click();
- win.close(); // 关闭新窗口
- });
- }, 2000); // 等待页面加载
- };
+const downLoad = (fileUrl) => {
+ if (isEmpty(fileUrl)) {
+ Message.error('下载失败,文件不存在');
+ return;
+ }
+ const link = document.createElement('a');
+ link.href = fileUrl;
+ link.download = '投放指南.pdf';
+ document.body.appendChild(link);
+ link.click();
+ document.body.removeChild(link);
};
const deleteData = async (id) => {
const { code, message } = await deleteHistorylog(id);
if (code == 200) {
Message.success(message);
emits('onSearch');
- console.log('onsearch')
+ console.log('onsearch');
}
};
diff --git a/src/views/property-marketing/put-account/investment-guidelines/components/table-data/listSearchForm.vue b/src/views/property-marketing/put-account/investment-guidelines/components/table-data/listSearchForm.vue
index a28c68f..816b0cb 100644
--- a/src/views/property-marketing/put-account/investment-guidelines/components/table-data/listSearchForm.vue
+++ b/src/views/property-marketing/put-account/investment-guidelines/components/table-data/listSearchForm.vue
@@ -50,7 +50,7 @@
-
+
diff --git a/src/views/property-marketing/put-account/investment-guidelines/components/table-data/placementGuideList.vue b/src/views/property-marketing/put-account/investment-guidelines/components/table-data/placementGuideList.vue
index 456372c..ebd2c5b 100644
--- a/src/views/property-marketing/put-account/investment-guidelines/components/table-data/placementGuideList.vue
+++ b/src/views/property-marketing/put-account/investment-guidelines/components/table-data/placementGuideList.vue
@@ -54,8 +54,7 @@
-
- {{ PLATFORM_LIST[record.platform].label }}
+
diff --git a/src/views/property-marketing/put-account/investment-guidelines/index.vue b/src/views/property-marketing/put-account/investment-guidelines/index.vue
index 20298ce..a1f079a 100644
--- a/src/views/property-marketing/put-account/investment-guidelines/index.vue
+++ b/src/views/property-marketing/put-account/investment-guidelines/index.vue
@@ -5,7 +5,7 @@
@@ -16,6 +16,7 @@
-
-
-
+
+
-
-
+
@@ -89,7 +93,10 @@ import {
} from '@/api/all/propertyMarketing';
import { Message } from '@arco-design/web-vue';
import html2canvas from 'html2canvas';
+import { jsPDF } from 'jspdf';
import { AiResultStatus } from '@/views/property-marketing/put-account/investment-guidelines/constants';
+import { fetchUploadFile } from '@/api/all';
+import axios from 'axios';
const tabData = ref('placement_guide');
@@ -121,6 +128,7 @@ const handleUpdateQuery = (payload) => {
query.sort_column = payload.column;
query.sort_order = payload.order;
isGetAi.value = false;
+ loading.value = false;
onSearch();
};
@@ -143,11 +151,10 @@ const onSearch = async () => {
guideHistoryList.value = result?.data?.data || [];
}
listData.total = result.data.total;
- if (placementGuideList.value.length > 0) {
+ if (placementGuideList.value.length > 0 && isGetAi.value) {
loading.value = true;
- if (isGetAi.value) {
- startTask();
- }
+ syncGetAiResult();
+ startTask();
}
isGetAi.value = true;
};
@@ -159,15 +166,14 @@ const aiResult = reactive({
// 下载当前页面
const downPage = async () => {
- await nextTick(); // 确保 DOM 更新完成
- html2canvas(document.querySelector('.guidelines-data-wrap')).then((canvas) => {
- const imgData = canvas.toDataURL('image/png');
- const link = document.createElement('a');
- link.href = imgData;
- const timestamp = new Date().getTime();
- link.download = `投放指南-${timestamp}.png`;
- link.click();
- });
+ await nextTick();
+ const fileUrl = await uploadPdf();
+ const link = document.createElement('a');
+ link.href = fileUrl;
+ link.download = '投放指南.pdf';
+ document.body.appendChild(link);
+ link.click();
+ document.body.removeChild(link);
};
const saveForm = reactive({
account: [],
@@ -175,33 +181,48 @@ const saveForm = reactive({
platform: [],
aiResult: [],
code: '',
+ file_url: '',
});
const timerRef = ref(null);
const startTask = () => {
if (timerRef.value !== null) return;
timerRef.value = setInterval(async () => {
- try {
- const { code, data } = await getAiResult(query);
- console.log('定时任务执行结果:', data);
- if (data.ai_result_status === AiResultStatus.SUCCESS || data.ai_result_status === AiResultStatus.FAILED) {
- stopTask();
- console.log('任务已完成,定时器已关闭');
- }
- if (data.ai_result_status === AiResultStatus.SUCCESS) {
- loading.value = false;
- aiResult.optimization = data.result?.optimization?.modules || [];
- aiResult.action_guide = data.result?.action_guide?.modules || [];
- aiResult.overview = data.result?.overview?.content_blocks[0] || [];
- }
- saveForm.code = data?.code;
- console.log(aiResult, 'aiResult');
- } catch (error) {
- console.error('定时任务执行出错:', error);
- stopTask();
- }
+ syncGetAiResult();
}, 5000);
};
+const syncGetAiResult = async () => {
+ try {
+ const { code, data } = await getAiResult(query);
+ saveForm.file_url = '';
+ console.log('定时任务执行结果:', data);
+ if (data.ai_result_status === AiResultStatus.SUCCESS || data.ai_result_status === AiResultStatus.FAILED) {
+ stopTask();
+ console.log('任务已完成,定时器已关闭');
+ }
+ if (data.ai_result_status === AiResultStatus.SUCCESS) {
+ loading.value = false;
+ aiResult.optimization = data.result?.optimization?.modules || [];
+ aiResult.action_guide = data.result?.action_guide?.modules || [];
+ aiResult.overview = data.result?.overview?.content_blocks[0] || [];
+ } else if (data.ai_result_status === AiResultStatus.FAILED) {
+ Message.error('AI分析失败');
+ aiError();
+ }
+ saveForm.code = data?.code;
+ } catch (error) {
+ aiError();
+ }
+};
+
+// ai 检测失败执行方法
+const aiError = () => {
+ aiResult.optimization = [];
+ aiResult.action_guide = [];
+ aiResult.overview = [];
+ stopTask();
+};
+
const handleReset = () => {
console.log('handleReset');
query.page = 1;
@@ -226,6 +247,7 @@ onUnmounted(() => {
stopTask();
});
const handleSave = async () => {
+ await uploadPdf();
const updatedSaveForm = {
...saveForm,
ai_result: aiResult,
@@ -235,6 +257,52 @@ const handleSave = async () => {
Message.success(message);
}
};
+
+// 上传pdf文件
+const uploadPdf = async () => {
+ if (saveForm.file_url !== '') {
+ return saveForm.file_url;
+ }
+ const response = await fetchUploadFile({ suffix: 'pdf' });
+ const preSignedUrl = response?.data?.upload_url;
+ const fileUrl = response?.data?.file_url;
+ if (!preSignedUrl) {
+ throw new Error('未能获取有效的预签名上传地址');
+ }
+ saveForm.file_url = fileUrl;
+ const pdfBlob = await generatePDF(); // 生成 PDF Blob
+ console.log('pdfBlob', pdfBlob);
+ await axios.put(preSignedUrl, pdfBlob, {
+ headers: {
+ 'Content-Type': pdfBlob.type,
+ },
+ });
+ return fileUrl;
+};
+
+const generatePDF = async (): Promise => {
+ await nextTick();
+ const sections = document.querySelectorAll('.guidelines-data-wrap');
+ const pdf = new jsPDF('p', 'mm', 'a4');
+ let position = 0;
+ for (const section of sections) {
+ if (section.children.length === 0) continue; // 跳过空内容区域
+ const canvas = await html2canvas(section as HTMLElement, {
+ ignoreElements: (element) => {
+ return element.classList.contains('ignore-export'); // 例如:忽略 class 为 ignore-export 的元素
+ },
+ });
+ const imgData = canvas.toDataURL('image/png');
+ const imgProps = pdf.getImageProperties(imgData);
+ const pdfWidth = pdf.internal.pageSize.getWidth();
+ const pdfHeight = (imgProps.height * pdfWidth) / imgProps.width;
+ pdf.addImage(imgData, 'PNG', 0, position, pdfWidth, pdfHeight);
+ position += pdfHeight + 10;
+ }
+
+ return pdf.output('blob');
+};
+
onMounted(() => {
onSearch();
});
@@ -242,6 +310,7 @@ onMounted(() => {