选中提示

This commit is contained in:
lq
2025-09-20 15:39:46 +08:00
parent 0ae5531f97
commit a770e2b74d

View File

@ -187,6 +187,18 @@
@page-size-change="onPageSizeChange" @page-size-change="onPageSizeChange"
/> />
</div> </div>
<template #footer>
<div class="flex items-center justify-between">
<div class="flex items-center">
<div class="color-#737478 font-size-14px">已选择</div>
<div class="color-#737478 font-size-14px">{{ choseText }}</div>
</div>
<div class="flex justify-end">
<Button @click="handleCancel">取消</Button>
<Button class="ml-16px" type="primary" @click="handleOk">确定</Button>
</div>
</div>
</template>
</a-drawer> </a-drawer>
</a-drawer> </a-drawer>
</template> </template>
@ -200,7 +212,7 @@ import dayjs from 'dayjs';
import { getRawMaterialsPage } from '@/api/all/generationWorkshop'; import { getRawMaterialsPage } from '@/api/all/generationWorkshop';
// 工具引入 // 工具引入
import { useTableSelectionWithPagination } from '@/hooks/useTableSelectionWithPagination'; import { useTableSelectionWithPagination } from '@/hooks/useTableSelectionWithPagination';
const choseText = ref('');
const columns = ref([ const columns = ref([
{ {
title: '文件名称', title: '文件名称',
@ -239,6 +251,18 @@ const { pageInfo, onPageChange, onPageSizeChange, rowSelection, selectedRowKeys
watch(selectedRowKeys, (newVal) => { watch(selectedRowKeys, (newVal) => {
console.log(newVal); console.log(newVal);
query.ids = newVal; query.ids = newVal;
const filteredData = materialData.value.filter((item) => newVal.includes(item.id));
choseText.value = '';
const typeCount = filteredData.reduce((acc, item) => {
acc[item.type] = (acc[item.type] || 0) + 1;
return acc;
}, {});
console.log('+++++', typeCount);
Object.entries(typeCount).forEach(([type, count]) => {
console.log('++++tyype', type, getType(type));
console.log(`${getType(type)}: ${count}`);
choseText.value += `${getType(type)}: ${count}`;
});
}); });
// 定义props和emit // 定义props和emit
@ -276,12 +300,19 @@ const publishOptions = ref([
const publishType = ref('immediate'); const publishType = ref('immediate');
const getType = (type) => { const getType = (type) => {
// 处理字符串和数字类型的type值
switch (type) { switch (type) {
case RawMaterialType.Image: case RawMaterialType.Image:
case '0':
case 0:
return '图片'; return '图片';
case RawMaterialType.Video: case RawMaterialType.Video:
case '1':
case 1:
return '视频'; return '视频';
case RawMaterialType.Text: case RawMaterialType.Text:
case '2':
case 2:
return '文本'; return '文本';
default: default:
return '未知'; return '未知';