原料库和成品库

This commit is contained in:
lq
2025-09-23 14:28:20 +08:00
parent ff7e20f8cf
commit ab31959733
3 changed files with 82 additions and 52 deletions

View File

@ -22,7 +22,11 @@
>
<template #name="{ record }">
<div class="name-cell flex items-center">
<img :src="record.cover" alt="类型图标" class="w-44px h-44px border-rounded-8px bg-#F0EDFF" />
<img
:src="record.type == 2 ? icon5 : record.cover"
alt="类型图标"
class="w-44px h-44px border-rounded-8px bg-#F0EDFF"
/>
<div class="flex flex-col ml-8px">
<span class="material-name">{{ record.name }}</span>
<span class="material-type">{{ record.uid }}</span>
@ -72,6 +76,15 @@
class="w-44px h-44px border-rounded-8px bg-#F0EDFF"
/>
</div>
<div
v-for="item in choseTextArray"
:key="item.id"
class="ml-16px bg-#F7F8FA h-44px overflow-hidden w-75px border-rounded-8px flex items-center"
>
<div class="whitespace-nowrap overflow-hidden text-ellipsis w-full px-2" :title="item.name">
{{ item.name }}
</div>
</div>
</div>
<div class="flex justify-end">
<Button @click="handleCancel">取消</Button>
@ -94,6 +107,7 @@ import icon2 from '@/assets/img/creative-generation-workshop/icon-photo.png';
import icon3 from '@/assets/img/creative-generation-workshop/icon-video.png';
import icon4 from '@/assets/img/error-img.png';
import { RawMaterialType } from '@/views/material-center/components/raw-material/constants';
import icon5 from '../../../../views/material-center/components/raw-material/img/icon-no-text.png';
// 定义Props
const props = defineProps({
visible: {
@ -133,14 +147,27 @@ const getOrigin = (origin: number): string => {
};
return fromMap[origin] || '未知';
};
// 定义Emits
const emit = defineEmits(['update:visible', 'after-visible-change', 'confirm', 'cancel']);
// 定义Emits类型
const emit = defineEmits<{
(e: 'update:visible', value: boolean): void;
(e: 'after-visible-change', visible: boolean): void;
(
e: 'confirm',
data: {
selectedKeys: string[];
selectedData: any[];
choseText: string;
choseImgArray: any[];
selectedTexts: string[];
},
): void;
(e: 'cancel'): void;
}>();
// 内部状态管理
const materialData = ref([]);
const choseText = ref('');
const choseImgArray = ref([]);
const choseTextArray = ref([]);
// 表格列配置
const columns = ref([
{ title: '文件名称', dataIndex: 'name', width: 200, slots: { customRender: 'name' } },
@ -188,21 +215,20 @@ watchEffect(() => {
watch(selectedRowKeys, (newKeys) => {
const filteredData = materialData.value.filter((item) => newKeys.includes(item.id));
// 统计各类型数量
const typeCount = filteredData.reduce((acc, item) => {
const typeKey = item.type === EnumManuscriptType.Image ? 'image' : 'video';
acc[typeKey] = (acc[typeKey] || 0) + 1;
return acc;
}, {});
const typeCount: Record<string, number> = {};
filteredData.forEach((item) => {
typeCount[item.type] = (typeCount[item.type] || 0) + 1;
});
// 生成选中文本
choseText.value = [];
if (typeCount.image) choseText.value.push(`图文: ${typeCount.image}`);
if (typeCount.video) choseText.value.push(`视频: ${typeCount.video}`);
choseText.value = choseText.value.join(' ');
choseText.value = Object.entries(typeCount)
.map(([type, count]) => {
const typeName = getType(Number(type));
return `${typeName}: ${count}`;
})
.join(' ');
// 筛选选中的内容用于预览
choseImgArray.value = filteredData;
choseImgArray.value = filteredData.filter((item) => [0, 1].includes(item.type));
choseTextArray.value = filteredData.filter((item) => [2].includes(item.type));
});
// 格式化审核状态显示
@ -250,11 +276,15 @@ const handleCancel = () => {
// 确定按钮处理
const handleOk = () => {
const selectedData = materialData.value.filter((item) => selectedRowKeys.value.includes(item.id));
const selectedTexts = selectedData
.filter((item) => item.type === RawMaterialType.Text)
.map((item) => item.content || item.name);
emit('confirm', {
selectedKeys: selectedRowKeys.value,
selectedData,
choseText: choseText.value,
choseImgArray: choseImgArray.value,
selectedTexts: selectedTexts,
});
emit('update:visible', false);
};