|
|
|
@ -114,16 +114,12 @@ |
|
|
|
|
<span>上传要求说明:</span> |
|
|
|
|
<div class="html-parse" v-html="ques.uploadInstructions"></div> |
|
|
|
|
</div> |
|
|
|
|
<Upload style="max-width: 700px;" accept=".csv,.xlsx,.xls,.docx,.doc,.pdf,.jpg,.png,.zip,.rar,.7z" |
|
|
|
|
:max-size="50" :file-list="ques.uploadList" :on-remove="e => handleRemove(ques)" |
|
|
|
|
@onSuccess="e => uploadSuccess(e, ques)"> |
|
|
|
|
<div slot="trigger"> |
|
|
|
|
<el-button type="primary" plain>上传文件</el-button> |
|
|
|
|
</div> |
|
|
|
|
<template slot="tip"> |
|
|
|
|
<p></p> |
|
|
|
|
</template> |
|
|
|
|
</Upload> |
|
|
|
|
<el-upload style="max-width: 700px;" accept=".csv,.xlsx,.xls,.docx,.doc,.pdf,.jpg,.png,.zip,.rar,.7z" |
|
|
|
|
:before-upload="beforeUpload" :on-remove="e => handleRemove(ques)" :on-error="uploadError" |
|
|
|
|
:before-remove="beforeRemove" :on-preview="handlePreview" :limit="1" action="#" |
|
|
|
|
:on-exceed="handleExceed" :file-list="ques.fileList" :http-request="e => handleRequest(e, ques)"> |
|
|
|
|
<el-button type="primary" plain>上传文件</el-button> |
|
|
|
|
</el-upload> |
|
|
|
|
</div> |
|
|
|
|
</template> |
|
|
|
|
</div> |
|
|
|
@ -146,11 +142,13 @@ import Setting from "@/setting" |
|
|
|
|
import QuesConst from '@/const/ques' |
|
|
|
|
import TestPaperConst from '@/const/testPaper' |
|
|
|
|
import _ from 'lodash' |
|
|
|
|
import Oss from '@/components/upload/upload.js' |
|
|
|
|
import Upload from '@/components/upload' |
|
|
|
|
import UeditorPlus from '@/components/ueditorPlus' |
|
|
|
|
import PdfDia from '@/components/pdf' |
|
|
|
|
import Bus from '@/libs/bus' |
|
|
|
|
import OSS from 'ali-oss' |
|
|
|
|
import OssConfig from '@/components/upload/config.js' |
|
|
|
|
import Oss from '@/components/upload/upload.js' |
|
|
|
|
|
|
|
|
|
export default { |
|
|
|
|
components: { |
|
|
|
@ -207,6 +205,7 @@ export default { |
|
|
|
|
previewImg: '', |
|
|
|
|
pdfVisible: false, |
|
|
|
|
pdfSrc: '', |
|
|
|
|
client: null, |
|
|
|
|
}; |
|
|
|
|
}, |
|
|
|
|
mounted () { |
|
|
|
@ -220,6 +219,7 @@ export default { |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
this.getCompetition(1) |
|
|
|
|
this.initOss() |
|
|
|
|
}, |
|
|
|
|
methods: { |
|
|
|
|
// 获取竞赛信息 |
|
|
|
@ -302,6 +302,13 @@ export default { |
|
|
|
|
n.answer = type === 'essay' && curQues ? curQues.answerContent : '' |
|
|
|
|
n.attachmentName = curQues ? curQues.attachmentName : '' |
|
|
|
|
n.attachmentUrl = curQues ? curQues.attachmentUrl : '' |
|
|
|
|
n.fileList = [] |
|
|
|
|
if (n.attachmentUrl) { |
|
|
|
|
n.fileList = [{ |
|
|
|
|
name: n.attachmentName, |
|
|
|
|
url: n.attachmentUrl |
|
|
|
|
}] |
|
|
|
|
} |
|
|
|
|
// 附件 |
|
|
|
|
const url = n.attachmentUrl |
|
|
|
|
if (url) { |
|
|
|
@ -319,7 +326,7 @@ export default { |
|
|
|
|
|
|
|
|
|
// 给填空题的每个空监听input事件,用以显示已作答状态 |
|
|
|
|
this.$nextTick(() => { |
|
|
|
|
const w = document.querySelector('#quesWrap').clientWidth - 200 |
|
|
|
|
cache || this.submit(0) // 如果没有缓存,则先缓存一次(只是为了缓存进入时间,因为只有在每个小题答题后才会调缓存接口,所以只能第一次进入就缓存一次进入时间) |
|
|
|
|
paper.map(e => { |
|
|
|
|
e.examQuestions.map(n => { |
|
|
|
|
if (e.questionType === 'fill_blank') { |
|
|
|
@ -331,7 +338,6 @@ export default { |
|
|
|
|
e.addEventListener('input', () => { |
|
|
|
|
const answers = [] |
|
|
|
|
let hasFillLen = 0 |
|
|
|
|
let text = e.innerText |
|
|
|
|
for (const e of inputs) { |
|
|
|
|
const val = e.innerText |
|
|
|
|
if (val) hasFillLen++ |
|
|
|
@ -346,16 +352,6 @@ export default { |
|
|
|
|
this.submit(0) |
|
|
|
|
this.calcProgress() |
|
|
|
|
}, 500) |
|
|
|
|
|
|
|
|
|
text = text.trim() |
|
|
|
|
|
|
|
|
|
// // 调整宽度 |
|
|
|
|
e.style.width = Math.min(w, text.length * 14) + 'px'; // 每个字符大约占7像素 |
|
|
|
|
|
|
|
|
|
// // 调整高度 |
|
|
|
|
const lineHeight = 28; // 每行高度 |
|
|
|
|
const lineCount = text.split('\n').length; |
|
|
|
|
e.style.height = Math.max(lineCount * lineHeight, 28) + 'px'; |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -541,15 +537,63 @@ export default { |
|
|
|
|
download (name, url) { |
|
|
|
|
Util.downloadFile(name, url) |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async initOss () { |
|
|
|
|
const o = await OssConfig() |
|
|
|
|
this.client = new OSS(o.config) |
|
|
|
|
}, |
|
|
|
|
// 附件上传前 |
|
|
|
|
beforeUpload (file) { |
|
|
|
|
const oversize = file.size / 1024 / 1024 < 50 |
|
|
|
|
if (!oversize) Util.warningMsg('请上传小于50M的文件!') |
|
|
|
|
if (oversize) { |
|
|
|
|
return true |
|
|
|
|
} else { |
|
|
|
|
return false |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
// 自定义上传 |
|
|
|
|
async handleRequest (e, ques) { |
|
|
|
|
const { file } = e |
|
|
|
|
try { |
|
|
|
|
ques.fileList = [] |
|
|
|
|
const { name } = await this.client.multipartUpload(Date.now() + '.' + Util.getFileExt(file.name), file) |
|
|
|
|
const url = 'https://huoran.oss-cn-shenzhen.aliyuncs.com/' + name |
|
|
|
|
ques.fileList = [{ |
|
|
|
|
name: file.name, |
|
|
|
|
url |
|
|
|
|
}] |
|
|
|
|
ques.attachmentName = file.name |
|
|
|
|
ques.attachmentUrl = url |
|
|
|
|
this.submit(0) |
|
|
|
|
} catch (e) { } |
|
|
|
|
}, |
|
|
|
|
handlePreview ({ url }) { |
|
|
|
|
this.preview(url) |
|
|
|
|
}, |
|
|
|
|
uploadError () { |
|
|
|
|
this.$message({ |
|
|
|
|
message: "上传出错,请重试!", |
|
|
|
|
type: "error", |
|
|
|
|
center: true |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
beforeRemove (file) { |
|
|
|
|
return this.$confirm(`确定移除 ${file.name}?`); |
|
|
|
|
}, |
|
|
|
|
handleExceed () { |
|
|
|
|
Util.warningMsg(`当前限制选择 1 个文件,如需更换,请删除上一个文件再重新选择!`); |
|
|
|
|
}, |
|
|
|
|
handleRemove (ques) { |
|
|
|
|
Oss.del(ques.attachmentUrl) |
|
|
|
|
ques.fileList = [] |
|
|
|
|
ques.attachmentName = '' |
|
|
|
|
ques.attachmentUrl = '' |
|
|
|
|
this.submit(0) |
|
|
|
|
}, |
|
|
|
|
uploadSuccess (file, ques) { |
|
|
|
|
ques.attachmentName = file.name |
|
|
|
|
ques.attachmentUrl = file.url |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 解析富文本加载完毕回调 |
|
|
|
|
answerAnalysisReady (editor) { |
|
|
|
|
this.answerAnalysis && editor.setContent(this.answerAnalysis) |
|
|
|
|