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

chore(课后作业): 课后作业可上传多个文件

上级 0fbfc0a6
......@@ -2,7 +2,7 @@
<div class="upload">
<el-upload action :disabled="disabled" :show-file-list="false" :http-request="httpRequest" v-bind="$attrs">
<slot></slot>
<el-button type="text" icon="el-icon-upload">{{ $t('viewerWork.clickUpload') }}</el-button>
<el-button type="text" icon="el-icon-upload" :loading="isUploading">{{ $t('viewerWork.clickUpload') }}</el-button>
<template v-slot:tip>
<div class="el-upload__tips">
<slot name="tip"></slot>
......@@ -43,7 +43,8 @@ export default {
},
data() {
return {
fileList: []
fileList: [],
isUploading: false
}
},
watch: {
......@@ -67,6 +68,7 @@ export default {
},
methods: {
httpRequest(xhr) {
this.isUploading = true
api
.uploadFile({ file: xhr.file })
.then(response => {
......@@ -79,8 +81,10 @@ export default {
this.$emit('input', response.url)
}
}
this.isUploading = false
})
.catch(error => {
this.isUploading = false
this.$message.error(error.message)
})
},
......
......@@ -123,7 +123,7 @@ export default {
formModel: {
id: item.id,
user_answer: item.user_answer ? Base64.decode(item.user_answer) : '',
attachments: item.attachments || ''
attachments: item.attachments || []
}
}
}
......
......@@ -275,7 +275,7 @@ export default {
formModel: {
id: item.id,
user_answer: item.user_answer ? Base64.decode(item.user_answer) : '',
attachments: item.attachments || ''
attachments: item.attachments || []
}
}
}
......@@ -296,7 +296,11 @@ export default {
const found = parseAnswers.find(answer => answer.question_id === item.id)
if (found) {
item.user_answer = found.descreption
item.attachments = found.file_url
let attachments = []
if (found.file_url) {
attachments = Array.isArray(found.file_url) ? found.file_url : [{ name: '附件下载', url: found.file_url }]
}
item.attachments = attachments
}
return item
})
......
......@@ -28,7 +28,7 @@
<!-- 简答题 -->
<template v-if="type === 3">
<v-editor v-model="currentValue.user_answer" :disabled="disabled"></v-editor>
<v-upload :disabled="disabled" v-model="currentValue.attachments" v-if="hasUpload"
<v-upload multiple :disabled="disabled" v-model="currentValue.attachments" v-if="hasUpload"
>{{ $t('viewerWork.workUrl.label') }}</v-upload
>
</template>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论