Files
lingji-work-fe/src/views/property-marketing/assignment-management/components/task-item.vue

262 lines
6.6 KiB
Vue
Raw Normal View History

2025-09-18 14:40:47 +08:00
<template>
2025-09-20 11:25:34 +08:00
<a-trigger trigger="click" position="br" @click.stop>
2025-09-19 17:58:13 +08:00
<div class="task-item">
2025-09-20 11:25:34 +08:00
<div class="color-indicator" :style="{ background: getTaskColor() }"></div>
<div class="task-name" :title="task?.name || '-'">{{ task?.name || '-' }}</div>
2025-09-19 16:08:00 +08:00
</div>
<template #content>
2025-09-20 11:25:34 +08:00
<div class="flex flex-col items-start popup-content" @click="gotoDetail">
2025-09-19 17:58:13 +08:00
<div class="flex flex-col items-start p-16px w-full" @click="gotoDetail">
<div class="flex justify-between w-full items-center">
2025-09-20 11:25:34 +08:00
<div class="flex items-center title-container">
2025-09-19 17:58:13 +08:00
<img
:src="getPlatformIcon(record.platform)"
style="border-radius: 8px; width: 16px; height: 16px; margin-right: 8px; font-size: 14px"
/>
2025-09-20 11:25:34 +08:00
<div class="task-title" :title="record.name || '-'">{{ record.name || '-' }}</div>
2025-09-19 17:58:13 +08:00
</div>
<div
2025-09-20 11:25:34 +08:00
class="status-tag"
2025-09-19 17:58:13 +08:00
:style="{
color: getTaskColor(),
backgroundColor: getTaskColor() + '50',
}"
>
2025-09-20 11:25:34 +08:00
{{ getTaskStatusText(task.status) }}
2025-09-19 17:58:13 +08:00
</div>
</div>
<div class="text-12px color-#939499 mt-4px h-22px" @click="gotoDetail">
{{ timestampToTime1(task.execution_time) }}
</div>
</div>
2025-09-20 11:25:34 +08:00
<div class="font-size-14px color-#211F24 color-#211F24 p-12px task-description" :title="task.name || '未命名'">
2025-09-19 17:58:13 +08:00
{{ task.name || '未命名' }}
</div>
2025-09-20 12:37:28 +08:00
<div v-if="task.ai_generate_status == 0" class="AILoding">
<ASpin />
<div style="color: #9a56ba">内容生成中...</div>
<div style="color: #9a56ba">完成后将自动展示您可先返回其他操作</div>
</div>
2025-09-19 17:58:13 +08:00
<div class="flex items-center mt-12px w-full h-1px bg-#E6E6E8"></div>
2025-09-20 11:25:34 +08:00
<div class="flex items-center mt-12px mb-16px action-buttons">
2025-09-19 17:58:13 +08:00
<div class="flex items-center mr-12px" @click.stop="handleDelete">
2025-09-20 11:25:34 +08:00
<icon-delete style="font-size: 20px; margin-left: 16px" />
2025-09-19 17:58:13 +08:00
</div>
<button class="opt-btn" @click.stop="handleTimeChange">修改发布时间</button>
<button class="opt-btn ml-12px opt-right mr-16px" @click.stop="handleAICreate">AI立即生成</button>
</div>
</div>
2025-09-19 16:08:00 +08:00
</template>
</a-trigger>
2025-09-19 10:34:26 +08:00
</template>
<script setup lang="ts">
2025-09-19 17:58:13 +08:00
import { ref } from 'vue';
2025-09-20 12:37:28 +08:00
import { Spin as ASpin } from 'ant-design-vue';
2025-09-19 17:58:13 +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-19 15:53:12 +08:00
// 定义props和emit
const props = defineProps({
task: Object,
record: Object,
});
2025-09-19 17:58:13 +08:00
2025-09-20 11:25:34 +08:00
onMounted(() => {
console.log('props.task', props.task, props.record);
});
2025-09-19 17:58:13 +08:00
const isPanelVisible = ref(false);
const handleDelete = () => {
emit('handle-task', 'delete', props.task, props.record);
};
const gotoDetail = () => {
console.log('跳转详情');
emit('handle-task', 'goto-detail', props.task, props.record);
};
const handleTimeChange = (time: string) => {
if (time) {
emit('handle-task', 'edit-time', props.task, timestampToTime1() + ' ' + time + ':00');
}
};
const handleAICreate = (task, record) => {};
const timestampToTime1 = (): string => {
const timestamp = Date.now();
const date = new Date(timestamp);
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0'); // 补零
const day = String(date.getDate()).padStart(2, '0'); // 补零
return `${month}${day}`;
2025-09-19 15:53:12 +08:00
};
2025-09-19 17:58:13 +08:00
2025-09-19 16:08:00 +08:00
const emit = defineEmits(['filter-change', 'handle-task']);
2025-09-19 17:58:13 +08:00
// 平台配置
const platformConfig = {
icons: {
0: iconDy,
1: iconXhs,
2: iconBilibili,
3: iconKs,
4: iconSph,
5: iconWb,
6: iconGzh,
},
};
// 获取平台图标
const getPlatformIcon = (platform: number) => platformConfig.icons[platform] || iconWarn;
2025-09-19 15:53:12 +08:00
// 根据任务类型获取颜色
const getTaskColor = () => {
if (!props.task) return '#000';
// 根据colorTip.vue中的颜色定义设置不同状态的颜色
switch (props.task.status) {
case 0: // 待生成
return '#ffae00';
case 1: // 待发布
return '#6d4cfe';
case 2: // 已发布
return '#939499';
case 3: // 发布失败
return '#f64b31';
default:
return props.task.color || '#939499';
}
};
2025-09-19 17:58:13 +08:00
const getTaskStatusText = (status) => {
2025-09-20 11:25:34 +08:00
console.log('任务状态:', status);
2025-09-19 17:58:13 +08:00
switch (status) {
case 0:
return '待生成';
case 1:
return '待发布';
case 2:
return '已发布';
case 3:
return '发布失败';
default:
return '未知状态';
}
};
2025-09-19 10:34:26 +08:00
</script>
<style lang="less" scoped>
.task-item {
width: 100%;
2025-09-19 15:53:12 +08:00
font-size: 12px;
height: 19px;
display: flex;
align-items: center;
gap: 4px;
2025-09-20 11:25:34 +08:00
min-width: 0;
2025-09-19 15:53:12 +08:00
&:last-child {
margin-bottom: 0;
}
2025-09-19 10:34:26 +08:00
}
2025-09-19 17:58:13 +08:00
2025-09-20 11:25:34 +08:00
.color-indicator {
width: 4px;
height: 18px;
border-radius: 2px;
flex-shrink: 0;
}
.task-name {
flex: 1;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
min-width: 0;
width: 0;
}
.popup-content {
width: 388px;
background-color: #fff;
box-shadow: #e6e6e8 0px 2px 8px;
border-radius: 4px;
}
.title-container {
flex: 1;
min-width: 0;
}
.task-title {
font-size: 16px;
font-weight: 500;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
flex: 1;
min-width: 0;
line-height: 1.2;
}
.task-description {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
line-height: 1.2;
flex: 1;
min-width: 0;
width: 365px;
}
.status-tag {
padding: 2px 8px;
border-radius: 4px;
flex-shrink: 0;
}
2025-09-19 17:58:13 +08:00
.opt-btn {
width: 154px;
height: 32px;
font-size: 14px;
background: #f2f3f5;
border: none;
border-radius: 4px;
}
.opt-right {
background: linear-gradient(90deg, #fbf9ff 0%, #f3fafe 100%);
color: #9a56ba;
}
2025-09-20 12:37:28 +08:00
.AILoding {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
width: 356px;
height: 108px;
border-radius: 8px;
background: linear-gradient(90deg, #fbf9ff 0%, #f3fafe 100%);
color: linear-gradient(90deg, #9a56ba 0%, #576fd1 100%);
margin-left: 16px;
font-weight: 400;
font-style: Regular;
font-size: 12px;
leading-trim: NONE;
line-height: 20px;
letter-spacing: 0%;
text-align: center;
}
2025-09-19 10:34:26 +08:00
</style>