提交 d1cf15c2 authored 作者: 王鹏飞's avatar 王鹏飞

feat: 课后资料支持多个文件

上级 10fb0788
......@@ -8,7 +8,7 @@ import httpRequest from '@/utils/axios'
export function getCourse(semesterId, courseId) {
return httpRequest.get(`/api/zy/v2/education/courses/${courseId}`).then(response => {
response.chapters = response.chapters.filter(item => {
item.children = item.children.filter(child => child.type === 2)
item.children = item.children.filter(child => child.type === 2 || child.type === 4)
return item.children.length
})
return response
......
<template>
<container :title="chapter.name">
<file-list :files="files"></file-list>
......@@ -32,12 +31,7 @@ export default {
},
computed: {
files() {
const reading = this.chapter.reading
const file = {
file_name: reading.reading_content,
file_url: reading.reading_attachment
}
return [file]
return this.chapter.reading ? this.chapter.reading.reading_attachment : []
}
}
}
......
<template>
<div>
<ul class="file-list" v-if="files.length">
<li class="file-list-item" v-for="file in files" :key="file.id">
<ul class="file-list" v-if="currentFiles.length">
<li class="file-list-item" v-for="file in currentFiles" :key="file.id">
<a :href="file.file_url" target="_blank">
<i class="el-icon-document"></i>
<div class="file-list-item__inner" v-html="file.file_name"></div>
......@@ -28,6 +28,14 @@ export default {
title: { type: String, default: '课程资料' },
// 文件列表
files: { type: Array, default: () => [] }
},
computed: {
currentFiles() {
return this.files.map(file => {
file.file_url = file.file_url || file.url
return file
})
}
}
}
</script>
......
......@@ -64,7 +64,7 @@ export default {
return `已学${value}%`
},
handleClick(data) {
if (data.type === 2) {
if (data.type === 2 || data.type === 4) {
this.$router.push({ name: 'viewerCourseChapter', params: { cid: this.courseId, id: data.id } })
}
},
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论