yujialong 4 years ago
parent 8818e0bea3
commit 41467de512
  1. 2
      src/layouts/navbar/index.vue
  2. 14
      src/libs/util.js
  3. 3
      src/main.js
  4. 30
      src/mixins/file/index.js
  5. 9
      src/pages/achievement/assessment/index.vue
  6. 6
      src/pages/achievement/list/practiceResults.vue
  7. 7
      src/pages/achievement/practice/index.vue
  8. 6
      src/pages/exam/do/index.vue
  9. 12
      src/pages/index/list/index.vue
  10. 6
      src/pages/practice/list/myPractice.vue
  11. 12
      src/plugins/filters/index.js
  12. 3
      src/styles/pages/testPaperDetail.scss

@ -35,7 +35,7 @@ export default {
{ {
icon: 'el-icon-lx-copy', icon: 'el-icon-lx-copy',
index: '/wrongBook/list', index: '/wrongBook/list',
title: '我的错题本' title: '错题练习'
}, },
{ {
icon: 'el-icon-chat-dot-round', icon: 'el-icon-chat-dot-round',

@ -89,6 +89,20 @@ const util = {
getFileExt(fileName) { getFileExt(fileName) {
return fileName.substring(fileName.lastIndexOf('.') + 1) return fileName.substring(fileName.lastIndexOf('.') + 1)
}, },
// 传入文件名和路径,下载图片视频,支持跨域,a标签加download不支持跨域
downloadFile(fileName,url) {
var x = new XMLHttpRequest()
x.open("GET", url, true)
x.responseType = 'blob'
x.onload=function(e) {
var url = window.URL.createObjectURL(x.response)
var a = document.createElement('a')
a.href = url
a.download = fileName
a.click()
}
x.send()
},
} }
export default util export default util

@ -16,9 +16,12 @@ import permission from '@/router/permission';
// 插件 // 插件
import plugins from '@/plugins'; import plugins from '@/plugins';
import filters from '@/plugins/filters'
Vue.use(plugins); Vue.use(plugins);
Object.keys(filters).forEach(item => Vue.filter(item,filters[item]))
Vue.prototype.api = api; Vue.prototype.api = api;
Vue.prototype.$get = get; Vue.prototype.$get = get;
Vue.prototype.$post = post; Vue.prototype.$post = post;

@ -1,4 +1,5 @@
import util from '@/libs/util' import util from '@/libs/util'
import { Loading } from 'element-ui'
export default { export default {
data() { data() {
return { return {
@ -7,15 +8,16 @@ export default {
iframeSrc: '', iframeSrc: '',
pdfVisible: false, pdfVisible: false,
pdfSrc: '', pdfSrc: '',
imgName: '', isDownload: 0,
imgSrc: '' loadIns: null,
} }
}, },
mounted() { mounted() {
this.insertScript() this.insertScript()
}, },
methods: { methods: {
preview(url,isVideo){ preview(url,isVideo,isDownload){
this.isDownload = isDownload
let ext = util.getFileExt(url) let ext = util.getFileExt(url)
if(isVideo){ if(isVideo){
this.$get(`${this.api.getPlayAuth}/${url}`).then(res => { this.$get(`${this.api.getPlayAuth}/${url}`).then(res => {
@ -63,14 +65,22 @@ export default {
this.playAuth = '' this.playAuth = ''
this.player.pause() this.player.pause()
}, },
download(fileName,url){ download(fileName,url,isVideo){
let ext = util.getFileExt(url) if(isVideo){
if(util.isImg(ext)){ this.loadIns = Loading.service()
this.imgName = fileName this.preview(url,isVideo,1)
this.imgSrc = url setTimeout(() => {
this.$refs.picLink.click() util.downloadFile(fileName,document.querySelector('#player video').src)
this.loadIns.close()
this.playAuth = ''
},1000)
}else{ }else{
window.open(url) let ext = util.getFileExt(url)
if(util.isImg(ext)){
util.downloadFile(fileName,url)
}else{
window.open(url)
}
} }
} }
} }

@ -64,13 +64,13 @@
<template v-if="item.fileUrl"> <template v-if="item.fileUrl">
<div v-for="(url,fileName) in item.fileUrl" :key="fileName"> <div v-for="(url,fileName) in item.fileUrl" :key="fileName">
<el-button type="text" @click="preview(url,0)">{{fileName}}</el-button> <el-button type="text" @click="preview(url,0)">{{fileName}}</el-button>
<el-button type="primary" size="mini" @click="download(fileName,url)">下载</el-button> <el-button type="primary" size="mini" @click="download(fileName,url,0)">下载</el-button>
</div> </div>
</template> </template>
<template v-if="item.videoAudio"> <template v-if="item.videoAudio">
<div v-for="(url,fileName) in item.videoAudio" :key="fileName"> <div v-for="(url,fileName) in item.videoAudio" :key="fileName">
<el-button type="text" @click="preview(url,1)">{{fileName}}</el-button> <el-button type="text" @click="preview(url,1)">{{fileName}}</el-button>
<!-- <el-button type="primary" size="mini" @click="download(url)">下载</el-button> --> <el-button type="primary" size="mini" @click="download(fileName,url,1)">下载</el-button>
</div> </div>
</template> </template>
</div> </div>
@ -82,13 +82,14 @@
</div> </div>
</div> </div>
<div v-show="playAuth" class="el-image-viewer__wrapper" :class="{active: playAuth}" style="z-index: 2000"> <div v-show="playAuth" class="el-image-viewer__wrapper" :class="{over: isDownload}" style="z-index: 2000">
<div class="el-image-viewer__mask"></div> <div class="el-image-viewer__mask"></div>
<span class="el-image-viewer__btn el-image-viewer__close" @click="closePlayer"><i class="el-icon-circle-close" style="color: #fff"></i></span> <span class="el-image-viewer__btn el-image-viewer__close" @click="closePlayer"><i class="el-icon-circle-close" style="color: #fff"></i></span>
<div class="player" id="player"></div> <div class="player" id="player"></div>
</div> </div>
<pdf :visible.sync="pdfVisible" :src.sync="pdfSrc"></pdf> <pdf :visible.sync="pdfVisible" :src.sync="pdfSrc"></pdf>
<a ref="picLink" style="display: none;" crossOrigin="anonymous" download="用户上传图片.png" :href="imgSrc">下载图片</a> <a ref="videoLink" style="display: none;" crossOrigin="anonymous" download="用户上传视频.mp4" :href="videoSrc">下载</a>
<a ref="picLink" style="display: none;" crossOrigin="anonymous" download="用户上传图片.jpg" :href="imgSrc">下载</a>
</div> </div>
</template> </template>
<script> <script>

@ -24,17 +24,17 @@
<el-table-column prop="practiseNum" label="练习次数" align="center"></el-table-column> <el-table-column prop="practiseNum" label="练习次数" align="center"></el-table-column>
<el-table-column prop="timeCost" label="用时(分钟)" align="center"> <el-table-column prop="timeCost" label="用时(分钟)" align="center">
<template slot-scope="scope"> <template slot-scope="scope">
{{scope.row.timeCost !== '' ? scope.row.timeCost : '--'}} <p>{{scope.row.timeCost | defaultShow}}</p>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="examTime" label="练习时间" align="center"> <el-table-column prop="examTime" label="练习时间" align="center">
<template slot-scope="scope"> <template slot-scope="scope">
{{scope.row.examTime !== '' ? scope.row.examTime : '--'}} <p>{{scope.row.examTime | defaultShow}}</p>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="score" label="最新得分" align="center"> <el-table-column prop="score" label="最新得分" align="center">
<template slot-scope="scope"> <template slot-scope="scope">
{{scope.row.score !== '' ? scope.row.score : '--'}} <p>{{scope.row.score | defaultShow}}</p>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="操作" align="center" width="180"> <el-table-column label="操作" align="center" width="180">

@ -60,13 +60,13 @@
<template v-if="item.fileUrl"> <template v-if="item.fileUrl">
<div v-for="(url,fileName) in item.fileUrl" :key="fileName"> <div v-for="(url,fileName) in item.fileUrl" :key="fileName">
<el-button type="text" @click="preview(url,0)">{{fileName}}</el-button> <el-button type="text" @click="preview(url,0)">{{fileName}}</el-button>
<el-button type="primary" size="mini" @click="download(fileName,url)">下载</el-button> <el-button type="primary" size="mini" @click="download(fileName,url,0)">下载</el-button>
</div> </div>
</template> </template>
<template v-if="item.videoAudio"> <template v-if="item.videoAudio">
<div v-for="(url,fileName) in item.videoAudio" :key="fileName"> <div v-for="(url,fileName) in item.videoAudio" :key="fileName">
<el-button type="text" @click="preview(url,1)">{{fileName}}</el-button> <el-button type="text" @click="preview(url,1)">{{fileName}}</el-button>
<!-- <el-button type="primary" size="mini" @click="download(url)">下载</el-button> --> <el-button type="primary" size="mini" @click="download(fileName,url,1)">下载</el-button>
</div> </div>
</template> </template>
</div> </div>
@ -78,13 +78,12 @@
</div> </div>
</div> </div>
<div v-show="playAuth" class="el-image-viewer__wrapper" :class="{active: playAuth}" style="z-index: 2000"> <div v-show="playAuth" class="el-image-viewer__wrapper" :class="{over: isDownload}" style="z-index: 2000">
<div class="el-image-viewer__mask"></div> <div class="el-image-viewer__mask"></div>
<span class="el-image-viewer__btn el-image-viewer__close" @click="closePlayer"><i class="el-icon-circle-close" style="color: #fff"></i></span> <span class="el-image-viewer__btn el-image-viewer__close" @click="closePlayer"><i class="el-icon-circle-close" style="color: #fff"></i></span>
<div class="player" id="player"></div> <div class="player" id="player"></div>
</div> </div>
<pdf :visible.sync="pdfVisible" :src.sync="pdfSrc"></pdf> <pdf :visible.sync="pdfVisible" :src.sync="pdfSrc"></pdf>
<a ref="picLink" style="display: none;" crossOrigin="anonymous" download="用户上传图片.png" :href="imgSrc">下载图片</a>
</div> </div>
</template> </template>
<script> <script>

@ -177,7 +177,7 @@ export default {
mounted() { mounted() {
this.getData() this.getData()
this.addLeaveEvent() this.addLeaveEvent()
// this.queryState() this.queryState()
}, },
beforeDestroy(){ beforeDestroy(){
clearInterval(this.timer) clearInterval(this.timer)
@ -329,7 +329,7 @@ export default {
} }
n.fileUrl = JSON.stringify(n.fileUrl) n.fileUrl = JSON.stringify(n.fileUrl)
n.video = JSON.stringify(n.video) n.video = JSON.stringify(n.video)
if(userAnswer || n.fileUrl != '{}' || n.video != '{}'){ // if(userAnswer || n.fileUrl != '{}' || n.video != '{}'){
if(n.fileUrl == '{}') n.fileUrl = '' if(n.fileUrl == '{}') n.fileUrl = ''
if(n.video == '{}') n.video = '' if(n.video == '{}') n.video = ''
data1.push({ data1.push({
@ -342,7 +342,7 @@ export default {
fileUrl: n.fileUrl, fileUrl: n.fileUrl,
videoAudio: n.video videoAudio: n.video
}) })
} // }
}) })
}) })

@ -67,8 +67,16 @@
</el-table-column> </el-table-column>
<el-table-column prop="practiseName" label="练习试卷名称" align="center"></el-table-column> <el-table-column prop="practiseName" label="练习试卷名称" align="center"></el-table-column>
<el-table-column prop="startTime" label="开始时间" align="center"></el-table-column> <el-table-column prop="startTime" label="开始时间" align="center"></el-table-column>
<el-table-column prop="duration" label="练习时长(分钟)" align="center"></el-table-column> <el-table-column prop="duration" label="练习时长(分钟)" align="center">
<el-table-column prop="lastScore" label="得分" align="center"></el-table-column> <template slot-scope="scope">
<p>{{scope.row.duration | defaultShow}}</p>
</template>
</el-table-column>
<el-table-column prop="lastScore" label="得分" align="center">
<template slot-scope="scope">
<p>{{scope.row.lastScore | defaultShow}}</p>
</template>
</el-table-column>
</el-table> </el-table>
<div class="pagination"> <div class="pagination">
<el-pagination <el-pagination

@ -29,13 +29,13 @@
</el-table-column> </el-table-column>
<el-table-column prop="duration" label="时长(分钟)" align="center"> <el-table-column prop="duration" label="时长(分钟)" align="center">
<template slot-scope="scope"> <template slot-scope="scope">
{{scope.row.duration !== '' ? scope.row.duration : '--'}} <p>{{scope.row.duration | defaultShow}}</p>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="practiceNum" label="练习次数" align="center"></el-table-column> <el-table-column prop="practiceNum" label="练习次数" align="center"></el-table-column>
<el-table-column prop="lastScore" label="最后一次得分" align="center"> <el-table-column prop="lastScore" label="最后一次得分" align="center">
<template slot-scope="scope"> <template slot-scope="scope">
{{scope.row.lastScore !== '' ? scope.row.lastScore : '--'}} <p>{{scope.row.lastScore | defaultShow}}</p>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="操作" align="center" width="180"> <el-table-column label="操作" align="center" width="180">
@ -117,7 +117,7 @@ export default {
}, },
practice(row){ practice(row){
if(row.isHava){ if(row.isHava){
this.$confirm('是否要继续上次的考试?',{ this.$confirm('是否要继续上次的练习?',{
title: '提示', title: '提示',
confirmButtonText: '是', confirmButtonText: '是',
cancelButtonText: '否', cancelButtonText: '否',

@ -0,0 +1,12 @@
/**
* @description 返回缺省值
* 传入的如果是null就返回'--'
* 用例<Tag :default="val">text</Tag> <Tag>{{val | default}}</Tag>
* */
const defaultShow = (val) => {
return val == null ? '--' : val
}
module.exports = {
defaultShow
}

@ -93,6 +93,9 @@
} }
} }
} }
.over{
top: 5000px;
}
.player{ .player{
position: absolute; position: absolute;
top: 50%; top: 50%;

Loading…
Cancel
Save