添加任务-从原料库中添加
This commit is contained in:
@ -22,3 +22,7 @@ export const getTaskSchedulesDetail = (id: string) => {
|
|||||||
console.log('id', id);
|
console.log('id', id);
|
||||||
return Http.get(`/v1/task-schedules/${id}`);
|
return Http.get(`/v1/task-schedules/${id}`);
|
||||||
};
|
};
|
||||||
|
//任务管理-手动添加
|
||||||
|
export const createTask = (params = {}) => {
|
||||||
|
return Http.post(`/v1/task-schedules/manual`,params);
|
||||||
|
};
|
||||||
@ -6,6 +6,7 @@
|
|||||||
placement="right"
|
placement="right"
|
||||||
v-model:visible="showDriwer"
|
v-model:visible="showDriwer"
|
||||||
@after-visible-change="showDriwerChange"
|
@after-visible-change="showDriwerChange"
|
||||||
|
@ok="handleCreateTask"
|
||||||
width="480px"
|
width="480px"
|
||||||
class="task-drawer"
|
class="task-drawer"
|
||||||
style="z-index: 999"
|
style="z-index: 999"
|
||||||
@ -70,8 +71,22 @@
|
|||||||
</template>
|
</template>
|
||||||
从原料库添加
|
从原料库添加
|
||||||
</Button>
|
</Button>
|
||||||
<div v-if="hasChoseMaterial" class="flex flex-col items-center">
|
<div v-if="hasChoseMaterial" class="flex flex-col items-center w-full">
|
||||||
|
<div
|
||||||
|
v-for="item in selectedMaterials.texts"
|
||||||
|
:key="item.id"
|
||||||
|
class="flex items-center bg-#F7F8FA border-rounded-8px w-full justify-items-center pt-8px pb-8px pl-12px pr-12px mb-16px"
|
||||||
|
>
|
||||||
|
{{ item }}
|
||||||
|
</div>
|
||||||
|
<div class="flex items-center w-full">
|
||||||
|
<img
|
||||||
|
v-for="item in selectedMaterials.images"
|
||||||
|
:key="item.id"
|
||||||
|
:src="item.cover"
|
||||||
|
class="w-88 h-88 mr-8px border-rounded-8px"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div v-else class="flex flex-col items-center">
|
<div v-else class="flex flex-col items-center">
|
||||||
<p class="material-hint">AI会参考添加的文本、图片、视频等素材,完成符合需求的创作</p>
|
<p class="material-hint">AI会参考添加的文本、图片、视频等素材,完成符合需求的创作</p>
|
||||||
@ -206,7 +221,8 @@ const props = defineProps({
|
|||||||
|
|
||||||
// 本地筛选状态(保持上次选择)
|
// 本地筛选状态(保持上次选择)
|
||||||
const localQuery = ref({
|
const localQuery = ref({
|
||||||
accounts: props.query?.ids || [],
|
accounts: props.query?.name || [],
|
||||||
|
ids: props.query?.ids || [],
|
||||||
});
|
});
|
||||||
|
|
||||||
// 原料库查询参数
|
// 原料库查询参数
|
||||||
@ -234,7 +250,7 @@ const selectedMaterials = ref({
|
|||||||
data: [],
|
data: [],
|
||||||
text: '',
|
text: '',
|
||||||
images: [],
|
images: [],
|
||||||
texts: []
|
texts: [],
|
||||||
});
|
});
|
||||||
|
|
||||||
const selectedProducts = ref({
|
const selectedProducts = ref({
|
||||||
@ -276,7 +292,7 @@ const handleMaterialConfirm = (result) => {
|
|||||||
data: result.selectedData,
|
data: result.selectedData,
|
||||||
text: result.choseText,
|
text: result.choseText,
|
||||||
images: result.choseImgArray,
|
images: result.choseImgArray,
|
||||||
texts: result.selectedTexts || []
|
texts: result.selectedTexts || [],
|
||||||
};
|
};
|
||||||
hasChoseMaterial.value = result.selectedKeys.length > 0;
|
hasChoseMaterial.value = result.selectedKeys.length > 0;
|
||||||
};
|
};
|
||||||
@ -341,14 +357,49 @@ watch(showDriwer, (newVal) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 点击创建任务按钮时触发
|
||||||
|
const handleCreateTask = () => {
|
||||||
|
// 验证表单
|
||||||
|
if (isActive.value === 'chose' && selectedProducts.value.keys.length === 0) {
|
||||||
|
// 可以添加错误提示:请选择发布内容
|
||||||
|
console.log('请选择发布内容');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
console.log(localQuery.value);
|
||||||
|
// 准备提交的数据
|
||||||
|
const taskData = {
|
||||||
|
media_account_id: localQuery.value.ids[0],
|
||||||
|
is_ai_generate: isActive.value == 'chose' ? 0 : 1,
|
||||||
|
description: taskDescription.value,
|
||||||
|
raw_material_ids: selectedMaterials.value.keys,
|
||||||
|
products: selectedProducts.value.keys,
|
||||||
|
publish_type: publishType.value == 'immediate' ? 0 : 1,
|
||||||
|
execution_time:
|
||||||
|
publishType.value === 'timing' ? `${dayjs(currentDate.value).format('YYYY-MM-DD')} ${strValue.value}` : null,
|
||||||
|
};
|
||||||
|
// 发射创建任务事件
|
||||||
|
emit('create-task', taskData);
|
||||||
|
|
||||||
|
// 关闭抽屉
|
||||||
|
showDriwer.value = false;
|
||||||
|
};
|
||||||
|
|
||||||
// 暴露方法给父组件
|
// 暴露方法给父组件
|
||||||
const showDrawer = (accountInfo = null) => {
|
const showDrawer = (accountInfo = null, selectedDate = null) => {
|
||||||
showDriwer.value = true;
|
showDriwer.value = true;
|
||||||
if (accountInfo && accountInfo.id) {
|
if (accountInfo && accountInfo.id) {
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
localQuery.value.accounts = [accountInfo.name];
|
localQuery.value.accounts = [accountInfo.name];
|
||||||
|
localQuery.value.ids = [accountInfo.id];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
console.log('selectedDate', selectedDate);
|
||||||
|
// 如果传入了日期,则设置为默认日期
|
||||||
|
if (selectedDate) {
|
||||||
|
currentDate.value = selectedDate;
|
||||||
|
console.log('currentDate', currentDate.value);
|
||||||
|
publishType.value = 'timing';
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// 定义事件发射器
|
// 定义事件发射器
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
<a-trigger trigger="click" position="br" @click.stop>
|
<a-trigger trigger="click" position="br" @click.stop>
|
||||||
<div class="task-item">
|
<div class="task-item">
|
||||||
<div class="color-indicator" :style="{ background: getTaskColor() }"></div>
|
<div class="color-indicator" :style="{ background: getTaskColor() }"></div>
|
||||||
<div class="task-name" :title="task?.name || '-'">{{ task?.name || '-' }}</div>
|
<div class="task-name" :title="task?.name || '-'">{{ task?.name || 'AI生成内容' }}</div>
|
||||||
</div>
|
</div>
|
||||||
<template #content>
|
<template #content>
|
||||||
<div class="flex flex-col items-start popup-content" @click="gotoDetail">
|
<div class="flex flex-col items-start popup-content" @click="gotoDetail">
|
||||||
@ -13,7 +13,7 @@
|
|||||||
:src="getPlatformIcon(record.platform)"
|
:src="getPlatformIcon(record.platform)"
|
||||||
style="border-radius: 8px; width: 16px; height: 16px; margin-right: 8px; font-size: 14px"
|
style="border-radius: 8px; width: 16px; height: 16px; margin-right: 8px; font-size: 14px"
|
||||||
/>
|
/>
|
||||||
<div class="task-title" :title="record.name || '-'">{{ record.name || '-' }}</div>
|
<div class="task-title" :title="record.name || 'AI生成内容'">{{ record.name || 'AI生成内容' }}</div>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
class="status-tag"
|
class="status-tag"
|
||||||
@ -31,8 +31,8 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="font-size-14px color-#211F24 color-#211F24 task-description" :title="task.name || '未命名'">
|
<div class="font-size-14px color-#211F24 color-#211F24 task-description" :title="task.name || 'AI生成内容'">
|
||||||
{{ task.name || '未命名' }}
|
{{ task.name || 'AI生成内容' }}
|
||||||
</div>
|
</div>
|
||||||
<div v-if="task.ai_generate_status == 0" class="AILoding">
|
<div v-if="task.ai_generate_status == 0" class="AILoding">
|
||||||
<ASpin />
|
<ASpin />
|
||||||
|
|||||||
@ -29,7 +29,7 @@
|
|||||||
style="width: 100%"
|
style="width: 100%"
|
||||||
:pagination="false"
|
:pagination="false"
|
||||||
@change="handleTableChange"
|
@change="handleTableChange"
|
||||||
@row-click="handleRowClick"
|
@cell-click="handleCellClick"
|
||||||
>
|
>
|
||||||
<!-- 空数据显示 -->
|
<!-- 空数据显示 -->
|
||||||
<template #empty>
|
<template #empty>
|
||||||
@ -113,7 +113,7 @@
|
|||||||
<template #title>{{ deleteTitle }}</template>
|
<template #title>{{ deleteTitle }}</template>
|
||||||
<div>{{ deleteContent }}</div>
|
<div>{{ deleteContent }}</div>
|
||||||
</a-modal>
|
</a-modal>
|
||||||
<DrowPopup ref="drawerPopupRef" />
|
<DrowPopup ref="drawerPopupRef" @create-task="handleCreateTask" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
@ -128,7 +128,7 @@ import FilterPopup from './components/filter-popup.vue';
|
|||||||
import DrowPopup from './components/draw-popup.vue';
|
import DrowPopup from './components/draw-popup.vue';
|
||||||
import TaskItem from './components/task-item.vue';
|
import TaskItem from './components/task-item.vue';
|
||||||
// API引入
|
// API引入
|
||||||
import { getTaskSchedules, delTaskSchedules, editTaskSchedules } from '@/api/all/assignment-management';
|
import { getTaskSchedules, delTaskSchedules, editTaskSchedules, createTask } from '@/api/all/assignment-management';
|
||||||
import { fetchAccountOperators, getMediaAccountList } from '@/api/all/propertyMarketing';
|
import { fetchAccountOperators, getMediaAccountList } from '@/api/all/propertyMarketing';
|
||||||
// 工具引入
|
// 工具引入
|
||||||
import { useTableSelectionWithPagination } from '@/hooks/useTableSelectionWithPagination';
|
import { useTableSelectionWithPagination } from '@/hooks/useTableSelectionWithPagination';
|
||||||
@ -246,6 +246,12 @@ const handleAddTask = () => {
|
|||||||
drawerPopupRef.value?.showDrawer();
|
drawerPopupRef.value?.showDrawer();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleCreateTask = async (value) => {
|
||||||
|
console.log('handleCreateTask', value);
|
||||||
|
const res = await createTask(value);
|
||||||
|
console.log('res', res);
|
||||||
|
};
|
||||||
|
|
||||||
// 添加对DrowPopup组件的引用
|
// 添加对DrowPopup组件的引用
|
||||||
const drawerPopupRef = ref();
|
const drawerPopupRef = ref();
|
||||||
|
|
||||||
@ -366,7 +372,6 @@ const handleSearch = () => {
|
|||||||
|
|
||||||
// 添加一个标志位来避免死循环
|
// 添加一个标志位来避免死循环
|
||||||
let isDateSelectorUpdating = false;
|
let isDateSelectorUpdating = false;
|
||||||
|
|
||||||
// 日期选择器变化处理
|
// 日期选择器变化处理
|
||||||
const handleDateSelectorChange = (value: any) => {
|
const handleDateSelectorChange = (value: any) => {
|
||||||
// 如果正在更新中,则跳过
|
// 如果正在更新中,则跳过
|
||||||
@ -439,17 +444,27 @@ const handleTableChange = (pagination: any, sorter: any) => {
|
|||||||
handleSearch();
|
handleSearch();
|
||||||
};
|
};
|
||||||
|
|
||||||
// 处理表格行单击事件(用于调试)
|
const handleCellClick = (record: any, rowIndex: any, column: any) => {
|
||||||
const handleRowClick = (record: any, index: number, event: Event) => {
|
|
||||||
console.log('单击行:', record);
|
|
||||||
console.log('行索引:', index);
|
|
||||||
console.log('事件对象:', event);
|
|
||||||
const accountInfo = {
|
const accountInfo = {
|
||||||
id: record.id,
|
id: record.id,
|
||||||
name: record.name,
|
name: record.name,
|
||||||
platform: record.platform,
|
platform: record.platform,
|
||||||
};
|
};
|
||||||
drawerPopupRef.value.showDrawer(accountInfo);
|
const selectedDate = rowIndex.date;
|
||||||
|
|
||||||
|
// 检查选中的日期是否小于今天,如果是则不处理
|
||||||
|
const today = new Date();
|
||||||
|
today.setHours(0, 0, 0, 0);
|
||||||
|
const selectedDateTime = new Date(selectedDate);
|
||||||
|
selectedDateTime.setHours(0, 0, 0, 0);
|
||||||
|
|
||||||
|
if (selectedDateTime < today) {
|
||||||
|
console.log('选择的日期已过去,不打开抽屉');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('selectedDate', selectedDate);
|
||||||
|
drawerPopupRef.value.showDrawer(accountInfo, selectedDate);
|
||||||
};
|
};
|
||||||
|
|
||||||
// 任务操作处理
|
// 任务操作处理
|
||||||
|
|||||||
Reference in New Issue
Block a user