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 6c00f83..1aeacc1 100644 --- a/src/views/property-marketing/assignment-management/components/draw-popup.vue +++ b/src/views/property-marketing/assignment-management/components/draw-popup.vue @@ -117,7 +117,10 @@ @click="handleDelte" /> -
{{ selectedProducts.data[0].title }}
+
{{ selectedProducts.data[0].title }}
+
+ {{ selectedProducts.data[0].content }} +
@@ -385,6 +388,7 @@ const handleMaterialCancel = () => { // 处理成品库选择确认 const handleProductConfirm = (result) => { + console.log('handleProductConfirm', result); selectedProducts.value = { keys: result.selectedKeys, data: result.selectedData, @@ -448,7 +452,6 @@ const handleCreateTask = () => { message.error('请选择发布内容'); return; } - console.log('有问题已返回'); // 准备提交的数据 const taskData = { media_account_id: localQuery.value.ids[0], @@ -484,12 +487,69 @@ 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 emit = defineEmits(['filter-change', 'create-task']); // 暴露方法 defineExpose({ showDrawer, + fillTaskData, // 暴露新的数据回填方法 }); diff --git a/src/views/property-marketing/assignment-management/index.vue b/src/views/property-marketing/assignment-management/index.vue index e72b7a8..97291ee 100644 --- a/src/views/property-marketing/assignment-management/index.vue +++ b/src/views/property-marketing/assignment-management/index.vue @@ -513,7 +513,15 @@ 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); + }); break; } };