修改任务
This commit is contained in:
@ -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);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user