From 89c773ac65e7fcbcb4bdc01b5f6d6c4b4e71c71e Mon Sep 17 00:00:00 2001 From: lq <121091329@qq.com> Date: Thu, 25 Sep 2025 15:37:50 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BB=BB=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/all/assignment-management.ts | 6 ++ .../components/draw-popup.vue | 72 +++++-------------- .../assignment-management/index.vue | 14 ++-- 3 files changed, 32 insertions(+), 60 deletions(-) diff --git a/src/api/all/assignment-management.ts b/src/api/all/assignment-management.ts index f9aa270..26cd548 100644 --- a/src/api/all/assignment-management.ts +++ b/src/api/all/assignment-management.ts @@ -37,3 +37,9 @@ export const editTaskSchedulesTime = (id: string, params = {}) => { console.log('id', id); return Http.patch(`/v1/task-schedules/${id}/execution-time`, params); }; + + +export const getWorkDetail = (id: string) => { + console.log('id', id); + return Http.get(`/v1/works/${id}`); +}; \ No newline at end of file diff --git a/src/views/property-marketing/assignment-management/components/draw-popup.vue b/src/views/property-marketing/assignment-management/components/draw-popup.vue index 1aeacc1..958075b 100644 --- a/src/views/property-marketing/assignment-management/components/draw-popup.vue +++ b/src/views/property-marketing/assignment-management/components/draw-popup.vue @@ -215,6 +215,8 @@ import RawMaterialDrawer from './raw-material-drawer.vue'; import FinishedProductDrawer from './finished-product-drawer.vue'; import { message } from 'ant-design-vue'; import { getMediaAccountList } from '@/api/all/propertyMarketing'; +// 导入任务详情API +import { getWorkDetail } from '@/api/all/assignment-management'; // 平台图标 import iconDy from '@/assets/img/platform/icon-dy.png'; import iconXhs from '@/assets/img/platform/icon-xhs.png'; @@ -388,14 +390,12 @@ const handleMaterialCancel = () => { // 处理成品库选择确认 const handleProductConfirm = (result) => { - console.log('handleProductConfirm', result); selectedProducts.value = { keys: result.selectedKeys, data: result.selectedData, text: result.choseText, images: result.choseImgArray, }; - // 如果是单选模式,确保只选择一个项目 if (result.selectedRows && result.selectedRows.length > 0) { hasChoseFinishedProducts.value = true; @@ -407,6 +407,7 @@ const handleProductConfirm = (result) => { text: '1个稿件', images: [selectedProduct], }; + fillTaskData(selectedProduct.id); } }; @@ -488,58 +489,21 @@ const showDrawer = (accountInfo = null, selectedDate = null) => { }; // 新增:编辑任务时的数据回填方法 -const fillTaskData = (taskData) => { - // 设置账号信息 - if (taskData.media_account) { - nextTick(() => { - localQuery.value.accounts = [taskData.media_account.name]; - localQuery.value.ids = [taskData.media_account.id]; - }); - } - - // 设置AI生成或成品库选择 - isActive.value = taskData.is_ai_generate ? 'ai' : 'chose'; - - // 设置任务描述(AI生成时) - if (taskData.is_ai_generate && taskData.ai_prompt) { - taskDescription.value = taskData.ai_prompt; - } - - // 设置发布时间 - if (taskData.publish_type === 1 && taskData.execution_time) { - // 定时发布 - publishType.value = 'timing'; - const execTime = new Date(taskData.execution_time * 1000); - currentDate.value = execTime; - strValue.value = dayjs(execTime).format('HH:mm'); - } else { - // 立即发布 - publishType.value = 'immediate'; - } - - // 设置选中的素材(AI生成时) - if (taskData.is_ai_generate && taskData.raw_materials && taskData.raw_materials.length > 0) { - const materials = taskData.raw_materials; - selectedMaterials.value = { - keys: materials.map((m) => m.id), - data: materials, - text: '', - images: materials.filter((m) => m.type === 0), // 图片 - texts: materials.filter((m) => m.type === 2), // 文本 - }; - hasChoseMaterial.value = materials.length > 0; - } - - // 设置选中的成品(成品库选择时) - if (!taskData.is_ai_generate && taskData.work) { - const work = taskData.work; - selectedProducts.value = { - keys: [work.id], - data: [work], - text: work.title || '1个稿件', - images: work.files ? work.files.filter((f) => f.type === 0) : [], // 图片文件 - }; - hasChoseFinishedProducts.value = true; +const fillTaskData = async (taskData_id) => { + try { + const res = await getWorkDetail(taskData_id); + if (res && res.code === 200) { + // const fullTaskData = res.data; + // selectedProducts.value = { + // keys: [fullTaskData.id], + // data: [fullTaskData], + // text: fullTaskData.title || '1个稿件', + // images: fullTaskData.files ? fullTaskData.files.filter((f) => f.type === 0) : [], // 图片文件 + // }; + // console.log('获取任务详情成功:', selectedProducts.value); + } + } catch (error) { + console.error('获取任务详情失败:', error); } }; diff --git a/src/views/property-marketing/assignment-management/index.vue b/src/views/property-marketing/assignment-management/index.vue index 97291ee..7e278f0 100644 --- a/src/views/property-marketing/assignment-management/index.vue +++ b/src/views/property-marketing/assignment-management/index.vue @@ -513,14 +513,16 @@ const handleTaskAction = async (action: string, task: any, ...args: any[]) => { }; const selectedDate = task.execution_time; const date = new Date(selectedDate); - - // 显示抽屉 - drawerPopupRef.value.showDrawer(accountInfo, date); - + // 等待抽屉打开后再填充数据 nextTick(() => { - // 直接使用传入的task数据填充表单 - drawerPopupRef.value.fillTaskData(task); + console.log('修改任务'); + // 显示抽屉 + drawerPopupRef.value.showDrawer(accountInfo, date); + // if (task.work && task.work.id) { + // console.log('修改任务', task, task.work, task.work.id); + // drawerPopupRef.value.fillTaskData(task.work.id); + // } }); break; }