回填显示任务详情

This commit is contained in:
lq
2025-09-25 15:44:29 +08:00
parent 89c773ac65
commit 064cc3c9f6
2 changed files with 72 additions and 22 deletions

View File

@ -216,7 +216,7 @@ import FinishedProductDrawer from './finished-product-drawer.vue';
import { message } from 'ant-design-vue'; import { message } from 'ant-design-vue';
import { getMediaAccountList } from '@/api/all/propertyMarketing'; import { getMediaAccountList } from '@/api/all/propertyMarketing';
// 导入任务详情API // 导入任务详情API
import { getWorkDetail } from '@/api/all/assignment-management'; import { getWorkDetail,getTaskSchedulesDetail } from '@/api/all/assignment-management';
// 平台图标 // 平台图标
import iconDy from '@/assets/img/platform/icon-dy.png'; import iconDy from '@/assets/img/platform/icon-dy.png';
import iconXhs from '@/assets/img/platform/icon-xhs.png'; import iconXhs from '@/assets/img/platform/icon-xhs.png';
@ -489,22 +489,74 @@ const showDrawer = (accountInfo = null, selectedDate = null) => {
}; };
// 新增:编辑任务时的数据回填方法 // 新增:编辑任务时的数据回填方法
const fillTaskData = async (taskData_id) => { const fillTaskData = async (taskData) => {
// 如果传入的数据包含完整信息,则直接使用,否则获取完整详情
let fullTaskData = taskData;
// 如果没有work或raw_materials等详细信息则需要获取完整详情
if ((!taskData.work && !taskData.raw_materials) || taskData.id) {
try { try {
const res = await getWorkDetail(taskData_id); const res = await getTaskSchedulesDetail(taskData.id);
if (res && res.code === 200) { if (res && res.code === 200) {
// const fullTaskData = res.data; 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) { } catch (error) {
console.error('获取任务详情失败:', error); console.error('获取任务详情失败:', error);
} }
}
// 设置账号信息
if (fullTaskData.media_account) {
nextTick(() => {
localQuery.value.accounts = [fullTaskData.media_account.name];
localQuery.value.ids = [fullTaskData.media_account.id];
});
}
// 设置AI生成或成品库选择
isActive.value = fullTaskData.is_ai_generate ? 'ai' : 'chose';
// 设置任务描述AI生成时
if (fullTaskData.is_ai_generate && fullTaskData.ai_prompt) {
taskDescription.value = fullTaskData.ai_prompt;
}
// 设置发布时间
if (fullTaskData.publish_type === 1 && fullTaskData.execution_time) {
// 定时发布
publishType.value = 'timing';
const execTime = new Date(fullTaskData.execution_time * 1000);
currentDate.value = execTime;
strValue.value = dayjs(execTime).format('HH:mm');
} else {
// 立即发布
publishType.value = 'immediate';
}
// 设置选中的素材AI生成时
if (fullTaskData.is_ai_generate && fullTaskData.raw_materials && fullTaskData.raw_materials.length > 0) {
const materials = fullTaskData.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 (!fullTaskData.is_ai_generate && fullTaskData.work) {
const work = fullTaskData.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;
}
}; };
// 定义事件发射器 // 定义事件发射器

View File

@ -514,15 +514,13 @@ const handleTaskAction = async (action: string, task: any, ...args: any[]) => {
const selectedDate = task.execution_time; const selectedDate = task.execution_time;
const date = new Date(selectedDate); const date = new Date(selectedDate);
// 等待抽屉打开后再填充数据
nextTick(() => {
console.log('修改任务');
// 显示抽屉 // 显示抽屉
drawerPopupRef.value.showDrawer(accountInfo, date); 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); nextTick(() => {
// } // 将任务信息回填到draw-popup组件
drawerPopupRef.value.fillTaskData(task);
}); });
break; break;
} }