import { computed, defineComponent, ref } from 'vue'; import { NImage, NDivider, NButton, NModal, useMessage, ImageRenderToolbarProps } from 'naive-ui'; import TheNoticeBar from '/src/components/TheNoticeBar'; import styles from './index.module.less'; import { PageEnum } from '/src/enums/pageEnum'; import nodata from '../images/nomore.png'; import CardPreview from '/src/components/card-preview'; import { checkUrlType, iframeDislableKeyboard } from '/src/utils'; import { useUserStore } from '/src/store/modules/users'; import { vaildMusicScoreUrl } from '/src/utils/urlUtils'; import { saveAs } from 'file-saver'; export default defineComponent({ name: 'work-item', props: { item: { type: Object, default: () => ({}) } }, setup(props) { const userStore = useUserStore(); const message = useMessage(); const previewShow = ref(false); const preivewItem = ref({ type: 'MUSIC', content: props.item.musicId, title: props.item.musicName, studentName: props.item.studentName }); const reportSrc = ref(''); const detailVisiable = ref(false); // 下载资源 const onDownload = (src: any) => { if (!src) { message.error('下载失败'); return; } const fileUrl = src; // props.item.studentName const title = props.item.musicName + (props.item.studentName ? '-' + props.item.studentName : ''); const suffix = src.substring(src.lastIndexOf('.')); // 发起Fetch请求 fetch(fileUrl) .then(response => response.blob()) .then(blob => { saveAs(blob, (title || new Date().getTime() + '') + suffix); }) .catch(() => { message.error('下载失败'); }); }; return () => (
{/* ("文件类型:评测:EVALUATION,IMG:图片,SOUND:音频,VIDEO:视频") private String fileType; */} {!props.item.fileList?.fileType && ( )} {props.item.fileList?.fileType === 'IMG' && ( { return [ nodes.prev, nodes.next, nodes.rotateCounterclockwise, nodes.rotateClockwise, nodes.resizeToOriginalSize, nodes.zoomOut,
onDownload(props.item.fileList?.filePath)}>
, nodes.close ]; }} /> )} {props.item.fileList?.fileType === 'SOUND' && (
{ preivewItem.value.content = props.item.fileList?.filePath; preivewItem.value.title = props.item.musicName; preivewItem.value.type = 'SONG'; previewShow.value = true; }}>
)} {props.item.fileList?.fileType === 'EVALUATION' && (checkUrlType(props.item.fileList?.content) === 'video' ? (
{ preivewItem.value.content = props.item.fileList?.content; preivewItem.value.title = props.item.musicName; preivewItem.value.type = 'VIDEO'; previewShow.value = true; }}>
) : (
{ preivewItem.value.content = props.item.fileList?.content; preivewItem.value.title = props.item.musicName; preivewItem.value.type = 'SONG'; previewShow.value = true; }}>
))} {/* 'https://oss.dayaedu.com/ktqy/1715586967518b42c4fe5.mp4' */} {props.item.fileList?.fileType === 'VIDEO' && (
{ preivewItem.value.content = props.item.fileList?.filePath; preivewItem.value.title = props.item.musicName; preivewItem.value.type = 'VIDEO'; previewShow.value = true; }}>
)} {/* 判断是否过期 */} {props.item.fileList?.expireFlag && (
文件已过期
)} {props.item.recordId && ( { if (!props.item.recordId) { message.error('暂无评测记录'); return; } const tockn = userStore.getToken; reportSrc.value = vaildMusicScoreUrl() + `/instrument/#/evaluat-report?id=${props.item.recordId}&Authorization=${tockn}`; detailVisiable.value = true; }}> 评测报告 )}
{props.item.trainingType === 'EVALUATION' ? '评测' : '练习'}
{props.item.typeList?.map((type: string, index: number) => ( <> {type} {props.item.typeList.length - 1 > index && ( )} ))}
{props.item.trainingType === 'EVALUATION' ? (
{props.item.trainingStatus !== 'UNSUBMITTED' ? ( <> {props.item.trainingTimes} ) : ( 未提交 )}
) : (
{props.item.trainingStatus !== 'UNSUBMITTED' ? ( <> {props.item.trainingTimes ? parseInt(props.item.trainingTimes / 60 + '') : 0} 分钟 ) : ( 未提交 )}
)}
); } });