Files
lingji-work-fe/src/views/property-marketing/assignment-management/index.vue

758 lines
21 KiB
Vue
Raw Normal View History

2025-08-29 14:05:27 +08:00
<template>
2025-09-26 16:31:34 +08:00
<div class="flex flex-col justify-between bg-white rounded-8px p-24px">
2025-09-15 19:40:07 +08:00
<!-- 日期选择器和筛选区域 -->
2025-09-26 16:31:34 +08:00
<div class="flex justify-between items-start w-full mb-24px">
2025-09-15 19:40:07 +08:00
<DateSelector v-model="dateSelectorModel" @date-change="handleDateSelectorChange" />
2025-09-26 16:31:34 +08:00
<div class="flex items-start gap-12px">
<ColorTip />
2025-09-12 17:46:01 +08:00
<FilterPopup
:operators="operators"
:platformOptions="platformOptions"
:accountList="accountList"
:query="query"
2025-09-15 14:19:43 +08:00
@filter-change="handleFilterChange"
2025-09-12 17:46:01 +08:00
/>
2025-09-26 16:31:34 +08:00
<a-button type="primary" class="w-112px" size="middle" @click="handleAddTask"> 创建任务 </a-button>
2025-08-29 14:05:27 +08:00
</div>
</div>
2025-09-15 19:40:07 +08:00
<!-- 表格内容区域 -->
2025-09-26 16:31:34 +08:00
<div class="flex-1 w-full">
<div class="flex flex-col" style="width: 100%; overflow-x: auto">
2025-09-03 17:57:09 +08:00
<a-table
:columns="columns"
2025-09-26 14:47:11 +08:00
:data-source="data"
2025-09-26 16:31:34 +08:00
:bordered="true"
2025-09-25 16:17:51 +08:00
:scroll="{ x: 'max-content' }"
2025-09-03 17:57:09 +08:00
:pagination="false"
2025-09-26 16:31:34 +08:00
:locale="{ emptyText: emptyText }"
2025-09-03 17:57:09 +08:00
@change="handleTableChange"
>
2025-09-15 19:40:07 +08:00
<!-- 账号与平台列 -->
2025-09-26 16:31:34 +08:00
<template #bodyCell="{ column, record, index }">
<!-- 账号名称列 -->
2025-09-26 14:47:11 +08:00
<template v-if="column.dataIndex === 'name'">
2025-09-26 16:31:34 +08:00
<div class="flex items-center justify-start color-#211F24">
2025-09-26 14:47:11 +08:00
<img
:src="getPlatformIcon(record.platform)"
2025-09-26 16:31:34 +08:00
class="w-16px h-16px mr-8px rounded-4px"
2025-09-26 14:47:11 +08:00
:alt="getPlatformName(record.platform)"
2025-09-15 19:40:07 +08:00
/>
2025-09-26 14:47:11 +08:00
{{ record.name || '-' }}
2025-08-29 14:05:27 +08:00
</div>
2025-09-26 14:47:11 +08:00
</template>
<!-- 动态日期单元格 -->
2025-09-26 16:31:34 +08:00
<template v-else-if="column.dataIndex === 'dateCell'">
<div
v-if="record[column.dataIndex]?.length"
class="task-container"
@click="handleCellClick(record, column)"
>
2025-09-26 14:47:11 +08:00
<!-- 任务数量3时显示更多 -->
<div v-if="record[column.dataIndex].length >= 3" class="task-more">
<TaskItem :task="record[column.dataIndex][0]" :record="record" @handle-task="handleTaskAction" />
<a-popover trigger="click" placement="bottomRight">
<template #content>
2025-09-26 16:31:34 +08:00
<div class="bg-white w-160px p-12px rounded-4px flex flex-col more-content">
2025-09-26 14:47:11 +08:00
<TaskItem
2025-09-26 16:31:34 +08:00
v-for="task in record[column.dataIndex].slice(1)"
2025-09-26 14:47:11 +08:00
:key="task.id"
:task="task"
:record="record"
@handle-task="handleTaskAction"
/>
</div>
</template>
2025-09-26 16:31:34 +08:00
<div class="size-12px color-#8f959f h-19px ml-4px rounded-2px cursor-pointer" @click.stop>
还有{{ record[column.dataIndex].length - 1 }}
</div>
2025-09-26 14:47:11 +08:00
</a-popover>
</div>
<!-- 任务数量<3时直接显示 -->
<div v-else>
<TaskItem
v-for="task in record[column.dataIndex]"
:key="task.id"
:task="task"
:record="record"
@handle-task="handleTaskAction"
/>
</div>
</div>
2025-09-26 16:31:34 +08:00
<div v-else class="no-task" @click="handleCellClick(record, column)"></div>
2025-09-26 14:47:11 +08:00
</template>
2025-09-03 17:57:09 +08:00
</template>
</a-table>
2025-09-15 19:40:07 +08:00
<!-- 分页控件 -->
2025-09-03 17:57:09 +08:00
<div v-if="pageInfo.total > 0" class="pagination-box">
<a-pagination
:total="pageInfo.total"
2025-09-26 14:47:11 +08:00
size="small"
2025-09-03 17:57:09 +08:00
show-total
show-jumper
2025-09-26 14:47:11 +08:00
show-size-changer
2025-09-03 17:57:09 +08:00
:current="pageInfo.page"
:page-size="pageInfo.page_size"
2025-09-26 14:47:11 +08:00
@change="handlePageChange"
2025-09-26 16:31:34 +08:00
@showSizeChange="handlePageSizeChange"
2025-09-03 17:57:09 +08:00
/>
</div>
</div>
2025-08-29 14:05:27 +08:00
</div>
</div>
2025-09-26 16:31:34 +08:00
2025-09-15 19:40:07 +08:00
<!-- 删除确认弹窗 -->
2025-09-26 16:31:34 +08:00
<a-modal
v-model:open="showModal"
@ok="handleDeleteConfirm"
@cancel="showModal = false"
ok-text="确认删除"
:title="deleteTitle"
>
2025-09-15 19:40:07 +08:00
<div>{{ deleteContent }}</div>
2025-09-02 14:30:42 +08:00
</a-modal>
2025-09-26 16:31:34 +08:00
<DrawPopup ref="drawerPopupRef" @create-task="handleCreateTask" />
2025-08-29 14:05:27 +08:00
</template>
<script lang="ts" setup>
2025-09-26 16:31:34 +08:00
import { ref, reactive, onMounted, computed, nextTick, h } from 'vue';
import { Table, Button, Popover, Pagination, Modal, notification, message } from 'ant-design-vue';
2025-09-26 14:47:11 +08:00
import type { TableProps } from 'ant-design-vue';
2025-09-15 19:40:07 +08:00
import router from '@/router';
import DateUtils from '@/utils/DateUtils';
2025-09-26 16:31:34 +08:00
2025-09-15 19:40:07 +08:00
// 组件引入
import DateSelector from './components/date-selector.vue';
2025-09-26 16:31:34 +08:00
import ColorTip from './components/colorTip.vue';
2025-09-15 19:40:07 +08:00
import FilterPopup from './components/filter-popup.vue';
2025-09-26 16:31:34 +08:00
import DrawPopup from './components/draw-popup.vue';
2025-09-19 10:34:26 +08:00
import TaskItem from './components/task-item.vue';
2025-09-26 16:31:34 +08:00
2025-09-15 19:40:07 +08:00
// API引入
2025-09-24 12:08:21 +08:00
import {
getTaskSchedules,
delTaskSchedules,
2025-09-24 16:20:33 +08:00
editTaskSchedulesTime,
2025-09-24 12:08:21 +08:00
createTask,
generateContent,
} from '@/api/all/assignment-management';
2025-09-03 17:57:09 +08:00
import { fetchAccountOperators, getMediaAccountList } from '@/api/all/propertyMarketing';
2025-09-26 16:31:34 +08:00
2025-09-15 19:40:07 +08:00
// 工具引入
2025-09-03 17:57:09 +08:00
import { useTableSelectionWithPagination } from '@/hooks/useTableSelectionWithPagination';
2025-09-26 16:31:34 +08:00
2025-09-15 19:40:07 +08:00
// 静态资源
2025-09-03 17:57:09 +08:00
import emptyIcon from '@/assets/img/media-account/icon-empty.png';
2025-09-15 19:40:07 +08:00
// 平台图标
import iconDy from '@/assets/img/platform/icon-dy.png';
import iconXhs from '@/assets/img/platform/icon-xhs.png';
import iconBilibili from '@/assets/img/platform/icon-bilibili.png';
import iconKs from '@/assets/img/platform/icon-ks.png';
import iconSph from '@/assets/img/platform/icon-sph.png';
import iconWb from '@/assets/img/platform/icon-wb.png';
import iconGzh from '@/assets/img/platform/icon-gzh.png';
import iconWarn from '@/assets/img/media-account/icon-warn.png';
2025-09-26 16:31:34 +08:00
2025-09-15 19:40:07 +08:00
// 表格分页逻辑
const { pageInfo, onPageChange, onPageSizeChange } = useTableSelectionWithPagination({
onPageChange: () => handleSearch(),
onPageSizeChange: () => handleSearch(),
2025-09-03 17:57:09 +08:00
});
2025-09-15 19:40:07 +08:00
// 状态管理
const dateSelectorModel = ref({
choseType: '周' as '日' | '周' | '月',
dayModel: new Date(),
weekModel: new Date(),
monthModel: new Date(),
2025-08-29 14:05:27 +08:00
});
2025-09-26 16:31:34 +08:00
2025-09-26 14:47:11 +08:00
const columns = ref<TableProps['columns']>([]);
2025-08-29 16:39:14 +08:00
const data = ref<any[]>([]);
2025-08-29 14:05:27 +08:00
const operators = ref([]);
2025-09-03 17:57:09 +08:00
const accountList = ref([]);
2025-09-15 19:40:07 +08:00
const showModal = ref(false);
const currentTask = ref<any>(null);
const deleteTitle = ref('');
const deleteContent = ref('');
2025-09-26 16:31:34 +08:00
const drawerPopupRef = ref();
// 空状态显示
const emptyText = () => {
return h('div', { class: 'flex flex-col items-center justify-center', style: { minHeight: '600px' } }, [
h('img', { src: emptyIcon, class: 'img mt-20px', alt: '暂无数据', width: 106, height: 72 }),
h('div', { class: 'text mt-36px' }, '暂无数据'),
h('div', { class: 'mt-12px mb-12px' }, '可通过账号管理添加账号,进行任务排期管理'),
h(Button, { type: 'primary', onClick: handleAddAccount }, '去添加'),
]);
};
2025-08-29 14:05:27 +08:00
2025-09-15 19:40:07 +08:00
// 获取当前周的日期范围
const getCurrentWeekRange = () => {
const weekRange = DateUtils.getWeekRangeByDate(new Date());
return [weekRange.startFormatted, weekRange.endFormatted];
};
// 查询参数
2025-08-29 14:05:27 +08:00
const query = reactive({
2025-09-15 19:40:07 +08:00
page: pageInfo.value.page,
page_size: pageInfo.value.page_size,
2025-09-04 09:21:18 +08:00
platforms: undefined,
2025-09-03 18:22:51 +08:00
operator_ids: undefined,
ids: [],
2025-09-26 16:31:34 +08:00
execution_time: getCurrentWeekRange(),
2025-09-15 19:40:07 +08:00
top_execution_time: undefined,
2025-08-29 14:05:27 +08:00
});
2025-09-15 19:40:07 +08:00
// 平台配置
const platformConfig = {
icons: { 0: iconDy, 1: iconXhs, 2: iconBilibili, 3: iconKs, 4: iconSph, 5: iconWb, 6: iconGzh },
names: { 0: '抖音', 1: '小红书', 2: 'B站', 3: '快手', 4: '视频号', 5: '微博', 6: '公众号' },
options: [
{ id: 0, name: '抖音', icon: iconDy },
{ id: 1, name: '小红书', icon: iconXhs },
{ id: 2, name: 'B站', icon: iconBilibili },
{ id: 3, name: '快手', icon: iconKs },
{ id: 4, name: '视频号', icon: iconSph },
{ id: 5, name: '微博', icon: iconWb },
{ id: 6, name: '公众号', icon: iconGzh },
],
2025-09-04 15:48:06 +08:00
};
2025-09-26 16:31:34 +08:00
2025-09-15 19:40:07 +08:00
const platformOptions = ref(platformConfig.options);
2025-09-04 15:48:06 +08:00
2025-09-15 19:40:07 +08:00
// 工具函数
const getPlatformIcon = (platform: number) => platformConfig.icons[platform] || iconWarn;
const getPlatformName = (platform: number) => platformConfig.names[platform] || '未知平台';
2025-08-29 14:05:27 +08:00
const timestampToDayNumber = (timestamp: number) => {
2025-09-15 19:40:07 +08:00
return new Date(timestamp * 1000).getDate();
2025-08-29 14:05:27 +08:00
};
2025-09-15 19:40:07 +08:00
// 处理表格数据
2025-08-29 14:05:27 +08:00
const processTableData = (apiData: any[]) => {
const processedData: any[] = [];
2025-09-15 19:40:07 +08:00
const dateHeaders = currentDateHeaders.value;
2025-09-26 16:31:34 +08:00
2025-08-29 14:05:27 +08:00
apiData.forEach((account) => {
const rowData: any = {
id: account.id,
name: account.name,
platform: account.platform,
};
2025-09-15 19:40:07 +08:00
// 初始化日期列
dateHeaders.forEach((day) => {
2025-08-29 14:05:27 +08:00
rowData[day] = [];
});
2025-09-26 16:31:34 +08:00
2025-09-15 19:40:07 +08:00
// 分配任务到对应日期列
if (account.task_schedules?.length) {
2025-08-29 14:05:27 +08:00
account.task_schedules.forEach((task: any) => {
const taskDay = timestampToDayNumber(task.execution_time);
2025-09-15 19:40:07 +08:00
if (dateHeaders.includes(taskDay)) {
2025-09-20 11:25:34 +08:00
rowData[taskDay].push(task);
2025-08-29 14:05:27 +08:00
}
});
}
processedData.push(rowData);
});
2025-09-26 16:31:34 +08:00
return processedData;
2025-09-23 17:11:51 +08:00
};
2025-09-15 19:40:07 +08:00
// 设置表格列
const setTableColumns = () => {
2025-09-26 16:31:34 +08:00
const baseColumns: TableProps['columns'] = [
2025-08-29 14:05:27 +08:00
{
title: '账号与发布平台',
2025-09-26 14:47:11 +08:00
dataIndex: 'name',
2025-09-26 16:31:34 +08:00
key: 'name',
2025-08-29 14:05:27 +08:00
width: 150,
2025-08-30 13:53:53 +08:00
ellipsis: true,
2025-09-26 16:31:34 +08:00
fixed: 'left',
},
2025-08-29 14:05:27 +08:00
];
2025-09-26 16:31:34 +08:00
2025-08-29 14:05:27 +08:00
let dateHeaders: any[] = [];
2025-09-15 19:40:07 +08:00
const { choseType } = dateSelectorModel.value;
2025-09-26 16:31:34 +08:00
2025-09-15 19:40:07 +08:00
if (choseType === '周') {
dateHeaders = DateUtils.getWeekDaysByDate(dateSelectorModel.value.weekModel, 0);
} else if (choseType === '月') {
const date = dateSelectorModel.value.monthModel;
dateHeaders = DateUtils.getDaysAndWeekdays(date.getFullYear(), date.getMonth());
2025-08-29 14:05:27 +08:00
} else {
2025-09-15 19:40:07 +08:00
const date = dateSelectorModel.value.dayModel;
dateHeaders = [
{
day: date.getDate(),
weekday: DateUtils.formatDateToWeekdayDay(date),
date,
},
];
2025-08-29 14:05:27 +08:00
}
2025-09-15 19:40:07 +08:00
2025-09-03 17:57:09 +08:00
// 判断是否为今天
const isToday = (date: Date) => {
2025-09-15 19:40:07 +08:00
if (!date) return false;
2025-09-03 17:57:09 +08:00
const today = new Date();
2025-09-15 19:40:07 +08:00
today.setHours(0, 0, 0, 0);
const targetDate = new Date(date);
targetDate.setHours(0, 0, 0, 0);
return targetDate.getTime() === today.getTime();
2025-09-03 17:57:09 +08:00
};
2025-09-15 19:40:07 +08:00
2025-08-29 14:05:27 +08:00
// 添加日期列
dateHeaders.forEach((item) => {
2025-09-15 19:40:07 +08:00
const isWeekend = item.date?.getDay() === 0 || item.date?.getDay() === 6;
2025-09-03 17:57:09 +08:00
const todayFlag = item.date ? isToday(item.date) : false;
2025-09-15 20:26:31 +08:00
2025-09-26 14:47:11 +08:00
const columnConfig: any = {
2025-09-26 16:31:34 +08:00
title: item.weekday,
2025-09-26 14:47:11 +08:00
dataIndex: item.day.toString(),
2025-09-26 16:31:34 +08:00
key: item.day.toString(),
2025-08-29 14:05:27 +08:00
width: 135,
2025-09-26 14:47:11 +08:00
sorter: true,
2025-09-26 16:31:34 +08:00
customRender: ({ text, record, index }) => {
if (!text || !text.length) {
return h('div', { class: 'no-task' });
}
if (text.length >= 3) {
return h('div', { class: 'task-more' }, [
h(TaskItem, {
task: text[0],
record: record,
onHandleTask: handleTaskAction,
}),
h(
Popover,
{
trigger: 'click',
placement: 'bottomRight',
},
{
content: () =>
h(
'div',
{ class: 'more-content' },
text.slice(1).map((task) =>
h(TaskItem, {
task: task,
record: record,
onHandleTask: handleTaskAction,
}),
),
),
default: () =>
h(
'div',
{
class: 'task-more-indicator',
onClick: (e: Event) => e.stopPropagation(),
},
`还有${text.length - 1}`,
),
},
),
]);
}
return h(
'div',
{},
text.map((task) =>
h(TaskItem, {
task: task,
record: record,
onHandleTask: handleTaskAction,
}),
),
);
2025-09-26 14:47:11 +08:00
},
2025-09-26 16:31:34 +08:00
onCell: (record, index) => ({
style: {
backgroundColor: isWeekend ? '#fbfaff' : todayFlag ? '#6d4cfe' : 'transparent',
},
class: todayFlag ? 'today-column' : isWeekend ? 'weekend-column' : '',
}),
onHeaderCell: () => ({
style: {
backgroundColor: todayFlag ? '#6d4cfe' : 'transparent',
color: todayFlag ? 'white' : 'inherit',
},
class: todayFlag ? 'today-column' : '',
}),
2025-09-15 19:40:07 +08:00
};
2025-09-15 20:26:31 +08:00
2025-09-26 16:31:34 +08:00
baseColumns.push(columnConfig);
2025-08-29 14:05:27 +08:00
});
2025-09-26 16:31:34 +08:00
columns.value = baseColumns;
2025-08-29 14:05:27 +08:00
};
2025-09-15 19:40:07 +08:00
// 当前日期头部计算
const currentDateHeaders = computed(() => {
const { choseType } = dateSelectorModel.value;
if (choseType === '周') {
return DateUtils.getWeekDaysByDate(dateSelectorModel.value.weekModel, 0).map((item) =>
parseInt(item.day.toString(), 10),
);
} else if (choseType === '月') {
const date = dateSelectorModel.value.monthModel;
return DateUtils.getDaysAndWeekdays(date.getFullYear(), date.getMonth()).map((item) =>
parseInt(item.day.toString(), 10),
);
} else {
return [dateSelectorModel.value.dayModel.getDate()];
}
});
2025-08-29 16:39:14 +08:00
2025-09-15 19:40:07 +08:00
// 数据获取
const handleSearch = () => {
query.page = pageInfo.value.page;
query.page_size = pageInfo.value.page_size;
2025-09-26 16:31:34 +08:00
2025-09-15 19:40:07 +08:00
getTaskSchedules(query)
.then((response) => {
if (response.data) {
const apiData = response.data.data || response.data;
2025-09-24 16:20:33 +08:00
if (apiData) {
data.value = processTableData(apiData);
}
2025-09-15 19:40:07 +08:00
pageInfo.value.total = response.data.total || apiData.length;
}
})
.catch(() => {
data.value = [];
2025-08-29 16:39:14 +08:00
});
2025-08-29 14:05:27 +08:00
};
2025-09-15 19:40:07 +08:00
// 日期选择器变化处理
2025-09-26 16:31:34 +08:00
let isDateSelectorUpdating = false;
2025-09-15 19:40:07 +08:00
const handleDateSelectorChange = (value: any) => {
2025-09-26 16:31:34 +08:00
if (isDateSelectorUpdating) return;
2025-08-29 14:05:27 +08:00
2025-09-15 19:40:07 +08:00
const newStartDate = value.dateRange.start;
const newEndDate = value.dateRange.end;
2025-08-29 16:39:14 +08:00
2025-09-15 19:40:07 +08:00
const currentStart =
Array.isArray(query.execution_time) && query.execution_time.length > 0 ? query.execution_time[0] : null;
const currentEnd =
Array.isArray(query.execution_time) && query.execution_time.length > 1 ? query.execution_time[1] : null;
2025-08-29 16:39:14 +08:00
2025-09-26 16:31:34 +08:00
if (currentStart === newStartDate && currentEnd === newEndDate) return;
2025-08-29 14:05:27 +08:00
2025-09-15 19:40:07 +08:00
isDateSelectorUpdating = true;
query.execution_time = [newStartDate, newEndDate];
setTableColumns();
handleSearch();
2025-08-29 14:05:27 +08:00
2025-09-15 19:40:07 +08:00
setTimeout(() => {
isDateSelectorUpdating = false;
}, 0);
2025-08-29 14:05:27 +08:00
};
2025-09-15 19:40:07 +08:00
// 筛选条件变化处理
const handleFilterChange = (filters: any) => {
if (typeof filters === 'object' && filters !== null) {
Object.keys(filters).forEach((key) => {
2025-09-15 14:19:43 +08:00
switch (key) {
case 'operator':
2025-09-15 19:40:07 +08:00
query.operator_ids = filters[key];
2025-09-15 14:19:43 +08:00
break;
case 'platform':
2025-09-15 19:40:07 +08:00
query.platforms = filters[key];
2025-09-15 14:19:43 +08:00
break;
case 'accounts':
2025-09-15 19:40:07 +08:00
query.ids = filters[key];
2025-09-15 14:19:43 +08:00
break;
default:
2025-09-15 19:40:07 +08:00
query[key] = filters[key];
2025-09-03 17:57:09 +08:00
}
2025-09-15 14:19:43 +08:00
});
handleSearch();
2025-09-03 17:57:09 +08:00
}
};
2025-08-29 14:05:27 +08:00
2025-09-15 19:40:07 +08:00
// 表格排序变化
2025-09-26 14:47:11 +08:00
const handleTableChange = (pagination: any, filters: any, sorter: any) => {
if (sorter && sorter.order === 'ascend' && sorter.column?.date) {
const column = sorter.column;
query.top_execution_time = DateUtils.formatDate(column.date);
2025-09-15 19:40:07 +08:00
} else {
query.top_execution_time = undefined;
}
handleSearch();
};
2025-09-26 16:31:34 +08:00
// 单元格点击事件
const handleCellClick = (record: any, column: any) => {
2025-09-19 18:36:20 +08:00
const accountInfo = {
id: record.id,
name: record.name,
platform: record.platform,
};
2025-09-23 17:11:51 +08:00
2025-09-26 16:31:34 +08:00
const selectedDate = column.date;
2025-09-23 17:11:51 +08:00
const today = new Date();
today.setHours(0, 0, 0, 0);
const selectedDateTime = new Date(selectedDate);
selectedDateTime.setHours(0, 0, 0, 0);
if (selectedDateTime < today) {
2025-09-26 16:31:34 +08:00
message.warning('选择的日期已过去,无法创建任务');
2025-09-23 17:11:51 +08:00
return;
}
2025-09-26 16:31:34 +08:00
drawerPopupRef.value?.showDrawer(accountInfo, selectedDate);
2025-09-19 18:36:20 +08:00
};
2025-09-15 19:40:07 +08:00
// 任务操作处理
2025-09-24 12:08:21 +08:00
const handleTaskAction = async (action: string, task: any, ...args: any[]) => {
2025-09-15 19:40:07 +08:00
switch (action) {
case 'delete':
currentTask.value = task;
deleteTitle.value = task.type === 1 ? '删除内容稿件排期' : '删除选题排期';
2025-09-26 16:31:34 +08:00
deleteContent.value = `确认删除"${task.name || 'AI生成内容'}"吗?`;
2025-09-15 19:40:07 +08:00
showModal.value = true;
break;
2025-09-26 16:31:34 +08:00
2025-09-15 19:40:07 +08:00
case 'edit-time':
2025-09-24 16:20:33 +08:00
editTaskSchedulesTime(task.id, { execution_time: args[0] }).then((res) => {
if (res.code === 200) {
message.success(res.message);
handleSearch();
}
});
2025-09-15 19:40:07 +08:00
break;
2025-09-26 16:31:34 +08:00
2025-09-15 19:40:07 +08:00
case 'goto-detail':
router.push(`/media-account/management-detail/${task.id}`);
break;
2025-09-26 16:31:34 +08:00
2025-09-24 12:08:21 +08:00
case 'ai-create':
const res = await generateContent(task.id);
if (res.code === 200) {
2025-09-24 16:20:33 +08:00
message.success(res.message);
2025-09-24 12:08:21 +08:00
}
break;
2025-09-26 16:31:34 +08:00
2025-09-25 14:31:39 +08:00
case 'edit-task':
const accountInfo = {
id: args[0].id,
name: args[0].name,
platform: args[0].platform,
};
const selectedDate = task.execution_time;
const date = new Date(selectedDate);
2025-09-25 15:37:50 +08:00
2025-09-26 16:31:34 +08:00
drawerPopupRef.value?.showDrawer(accountInfo, date);
2025-09-25 14:56:24 +08:00
nextTick(() => {
2025-09-26 16:31:34 +08:00
drawerPopupRef.value?.fillTaskData(task);
2025-09-25 14:56:24 +08:00
});
2025-09-25 14:31:39 +08:00
break;
2025-09-15 19:40:07 +08:00
}
};
2025-09-26 16:31:34 +08:00
// 创建任务
const handleAddTask = () => {
drawerPopupRef.value?.showDrawer();
};
const handleCreateTask = async (value: any) => {
const res = await createTask(value);
if (res && res.code === 200) {
message.success('创建成功');
handleSearch();
}
};
2025-09-15 19:40:07 +08:00
// 确认删除
const handleDeleteConfirm = () => {
if (currentTask.value) {
delTaskSchedules(currentTask.value.id).then(() => {
showModal.value = false;
2025-09-26 16:31:34 +08:00
message.success('删除成功');
2025-09-15 19:40:07 +08:00
handleSearch();
2025-08-29 14:05:27 +08:00
});
2025-09-15 19:40:07 +08:00
}
2025-08-29 14:05:27 +08:00
};
2025-09-15 19:40:07 +08:00
// 添加账号
const handleAddAccount = () => {
router.push('/media-account/add');
};
// 获取运营人员列表
2025-08-29 14:05:27 +08:00
const getOperators = async () => {
try {
const { code, data: operatorsData } = await fetchAccountOperators();
if (code === 200) {
operators.value = operatorsData.map((op: any) => ({
value: op.id,
2025-08-30 13:53:53 +08:00
name: op.name,
2025-08-29 14:05:27 +08:00
}));
}
} catch (error) {
2025-09-15 19:40:07 +08:00
console.error('获取运营人员失败:', error);
2025-08-29 14:05:27 +08:00
}
};
2025-09-15 19:40:07 +08:00
// 获取账号列表
2025-09-03 17:57:09 +08:00
const getAccountList = async () => {
try {
const { code, data: accountData } = await getMediaAccountList();
if (code === 200) {
accountList.value = accountData.map((account: any) => ({
value: account.id,
2025-09-15 19:40:07 +08:00
name: `${account.name}(${getPlatformName(account.platform)})`,
2025-09-04 11:09:21 +08:00
platform: account.platform,
icon: getPlatformIcon(account.platform),
2025-09-03 17:57:09 +08:00
}));
}
2025-09-15 19:40:07 +08:00
} catch (error) {
console.error('获取账号列表失败:', error);
2025-08-29 16:39:14 +08:00
}
2025-09-15 19:40:07 +08:00
};
2025-08-29 14:05:27 +08:00
2025-09-26 14:47:11 +08:00
// 分页处理
const handlePageChange = (page: number, pageSize: number) => {
onPageChange(page);
};
const handlePageSizeChange = (current: number, size: number) => {
onPageSizeChange(size);
};
2025-09-15 19:40:07 +08:00
// 初始化
2025-08-29 14:05:27 +08:00
onMounted(() => {
2025-09-15 19:40:07 +08:00
setTableColumns();
2025-08-29 14:05:27 +08:00
handleSearch();
getOperators();
2025-09-03 17:57:09 +08:00
getAccountList();
2025-08-29 14:05:27 +08:00
});
</script>
<style scoped>
.task-container {
display: flex;
flex-direction: column;
2025-08-30 13:53:53 +08:00
height: 100%;
2025-09-26 16:31:34 +08:00
min-height: 42px;
cursor: pointer;
2025-08-29 14:05:27 +08:00
}
.task-item {
display: flex;
2025-08-30 13:53:53 +08:00
align-items: center;
margin-bottom: 2px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
2025-08-29 14:05:27 +08:00
}
2025-08-30 13:53:53 +08:00
.task-more {
display: flex;
flex-direction: column;
2025-09-26 16:31:34 +08:00
}
.task-more-indicator {
color: #8f959f;
height: 19px;
margin-left: 4px;
border-radius: 2px;
2025-08-30 13:53:53 +08:00
cursor: pointer;
2025-09-26 16:31:34 +08:00
font-size: 12px;
2025-08-29 14:05:27 +08:00
}
.no-task {
2025-09-25 16:17:51 +08:00
min-height: 42px;
2025-08-30 13:53:53 +08:00
display: flex;
align-items: center;
justify-content: center;
2025-09-26 16:31:34 +08:00
cursor: pointer;
2025-08-29 14:05:27 +08:00
}
2025-08-30 13:53:53 +08:00
2025-09-15 19:40:07 +08:00
/* 周末列样式 */
2025-08-30 13:53:53 +08:00
:deep(.weekend-column) {
2025-09-15 20:26:31 +08:00
background-color: #fbfaff !important;
2025-09-15 19:40:07 +08:00
}
/* 今日列样式 */
2025-09-26 16:31:34 +08:00
:deep(.today-column) {
2025-09-15 20:26:31 +08:00
background-color: #6d4cfe !important;
2025-08-29 14:05:27 +08:00
}
2025-08-30 15:54:54 +08:00
2025-09-26 16:31:34 +08:00
:deep(.today-column .ant-table-cell) {
color: white !important;
2025-08-30 15:54:54 +08:00
}
2025-09-26 16:31:34 +08:00
:deep(.today-column .ant-table-cell .task-item) {
color: white !important;
2025-09-15 19:40:07 +08:00
}
2025-09-26 16:31:34 +08:00
/* 添加表格分割线和固定行高 */
:deep(.ant-table) {
border: 1px solid #f0f0f0;
2025-08-30 15:54:54 +08:00
}
2025-09-26 16:31:34 +08:00
:deep(.ant-table-container) {
border-left: 1px solid #f0f0f0;
border-right: 1px solid #f0f0f0;
}
:deep(.ant-table-thead > tr > th) {
border-right: 1px solid #f0f0f0 !important;
background-color: #fafafa;
font-weight: 600;
height: 42px;
padding: 8px 12px;
2025-09-25 16:20:52 +08:00
}
2025-09-26 16:31:34 +08:00
:deep(.ant-table-tbody > tr > td) {
border-right: 1px solid #f0f0f0 !important;
height: 42px;
padding: 8px 12px;
vertical-align: top;
2025-09-25 16:20:52 +08:00
}
2025-09-26 16:31:34 +08:00
/* 第一列垂直居中 */
:deep(.ant-table-tbody > tr > td:first-child) {
vertical-align: middle !important;
2025-09-15 19:40:07 +08:00
}
2025-09-26 16:31:34 +08:00
/* 移除最后一列的右边框 */
:deep(.ant-table-thead > tr > th:last-child),
:deep(.ant-table-tbody > tr > td:last-child) {
border-right: none !important;
2025-09-24 17:12:33 +08:00
}
2025-09-26 16:31:34 +08:00
.task-container {
display: flex;
flex-direction: column;
height: 100%;
min-height: 42px;
cursor: pointer;
}
2025-09-15 19:40:07 +08:00
/* 分页样式 */
2025-09-03 17:57:09 +08:00
.pagination-box {
display: flex;
width: 100%;
padding: 16px 0;
justify-content: flex-end;
align-items: center;
}
2025-09-15 19:40:07 +08:00
2025-09-24 17:12:33 +08:00
.more-content {
border-radius: 8px;
background: #fff;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.1);
2025-09-26 16:31:34 +08:00
max-height: 300px;
overflow-y: auto;
2025-09-24 17:12:33 +08:00
}
2025-08-29 14:05:27 +08:00
</style>