|
@@ -19,6 +19,16 @@
|
|
<span>{{ checkJson.score2 }}分</span><span style="margin: 0 10px">/</span><span>{{ checkJson.score }}分</span>
|
|
<span>{{ checkJson.score2 }}分</span><span style="margin: 0 10px">/</span><span>{{ checkJson.score }}分</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
+ <div class="choices">
|
|
|
|
+ <div class="file_box" v-if="checkJson.mobanFile && checkJson.mobanFile.length" v-loading="loading">
|
|
|
|
+ <div class="file_item" v-for="(item, index) in checkJson.mobanFile" :key="index">
|
|
|
|
+ <div class="file_name">{{ item.name }}</div>
|
|
|
|
+ <div class="file_btns">
|
|
|
|
+ <div class="file_btn" @click="downloadMobanFile(index)">下载</div>
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
<div class="choices">
|
|
<div class="choices">
|
|
<div class="binfo_input">
|
|
<div class="binfo_input">
|
|
<div class="fileBox" v-if="checkJson.file && checkJson.file.length">
|
|
<div class="fileBox" v-if="checkJson.file && checkJson.file.length">
|
|
@@ -108,6 +118,41 @@ import wpdf from '../file/wPdf2.vue'
|
|
import wVideo from '../file/wVideo.vue'
|
|
import wVideo from '../file/wVideo.vue'
|
|
import wOffice from '../file/wOffice.vue'
|
|
import wOffice from '../file/wOffice.vue'
|
|
|
|
|
|
|
|
+const getFile = url => {
|
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
|
+ var credentials = {
|
|
|
|
+ accessKeyId: 'AKIATLPEDU37QV5CHLMH',
|
|
|
|
+ secretAccessKey: 'Q2SQw37HfolS7yeaR1Ndpy9Jl4E2YZKUuuy2muZR'
|
|
|
|
+ } // 秘钥形式的登录上传
|
|
|
|
+ window.AWS.config.update(credentials)
|
|
|
|
+ window.AWS.config.region = 'cn-northwest-1' // 设置区域
|
|
|
|
+ const url2 = url
|
|
|
|
+ let _url2 = ''
|
|
|
|
+ if (url2.indexOf('https://view.officeapps.live.com/op/view.aspx?src=') != -1) {
|
|
|
|
+ _url2 = url2.split('https://view.officeapps.live.com/op/view.aspx?src=')[1]
|
|
|
|
+ } else {
|
|
|
|
+ _url2 = url2
|
|
|
|
+ }
|
|
|
|
+ var s3 = new window.AWS.S3({ params: { Bucket: 'ccrb' } })
|
|
|
|
+ const name = decodeURIComponent(
|
|
|
|
+ _url2.split('https://ccrb.s3.cn-northwest-1.amazonaws.com.cn/')[1].replace(/\+/g, ' ')
|
|
|
|
+ )
|
|
|
|
+ var params = {
|
|
|
|
+ Bucket: 'ccrb',
|
|
|
|
+ Key: name
|
|
|
|
+ }
|
|
|
|
+ s3.getObject(params, function(err, data) {
|
|
|
|
+ if (err) {
|
|
|
|
+ console.log(err, err.stack)
|
|
|
|
+ resolve({ data: 1 })
|
|
|
|
+ } else {
|
|
|
|
+ resolve({ data: data.Body })
|
|
|
|
+ console.log(data)
|
|
|
|
+ } // sxuccessful response
|
|
|
|
+ })
|
|
|
|
+ // axios({
|
|
|
|
+ })
|
|
|
|
+}
|
|
export default {
|
|
export default {
|
|
components: {
|
|
components: {
|
|
wpdf,
|
|
wpdf,
|
|
@@ -206,11 +251,11 @@ export default {
|
|
var credentials = {
|
|
var credentials = {
|
|
accessKeyId: 'AKIATLPEDU37QV5CHLMH',
|
|
accessKeyId: 'AKIATLPEDU37QV5CHLMH',
|
|
secretAccessKey: 'Q2SQw37HfolS7yeaR1Ndpy9Jl4E2YZKUuuy2muZR'
|
|
secretAccessKey: 'Q2SQw37HfolS7yeaR1Ndpy9Jl4E2YZKUuuy2muZR'
|
|
- } //秘钥形式的登录上传
|
|
|
|
|
|
+ } // 秘钥形式的登录上传
|
|
window.AWS.config.update(credentials)
|
|
window.AWS.config.update(credentials)
|
|
- window.AWS.config.region = 'cn-northwest-1' //设置区域
|
|
|
|
|
|
+ window.AWS.config.region = 'cn-northwest-1' // 设置区域
|
|
|
|
|
|
- var bucket = new window.AWS.S3({ params: { Bucket: 'ccrb' } }) //选择桶
|
|
|
|
|
|
+ var bucket = new window.AWS.S3({ params: { Bucket: 'ccrb' } }) // 选择桶
|
|
var _this = this
|
|
var _this = this
|
|
|
|
|
|
_this.progress = 0
|
|
_this.progress = 0
|
|
@@ -229,7 +274,7 @@ export default {
|
|
Body: file,
|
|
Body: file,
|
|
'Access-Control-Allow-Credentials': '*',
|
|
'Access-Control-Allow-Credentials': '*',
|
|
ACL: 'public-read'
|
|
ACL: 'public-read'
|
|
- } //key可以设置为桶的相抵路径,Body为文件, ACL最好要设置
|
|
|
|
|
|
+ } // key可以设置为桶的相抵路径,Body为文件, ACL最好要设置
|
|
var options = {
|
|
var options = {
|
|
partSize: 2048 * 1024 * 1024,
|
|
partSize: 2048 * 1024 * 1024,
|
|
queueSize: 2,
|
|
queueSize: 2,
|
|
@@ -238,7 +283,7 @@ export default {
|
|
bucket
|
|
bucket
|
|
.upload(params, options)
|
|
.upload(params, options)
|
|
.on('httpUploadProgress', function(evt) {
|
|
.on('httpUploadProgress', function(evt) {
|
|
- //这里可以写进度条
|
|
|
|
|
|
+ // 这里可以写进度条
|
|
// console.log("Uploaded : " + parseInt((evt.loaded * 80) / evt.total) + '%');
|
|
// console.log("Uploaded : " + parseInt((evt.loaded * 80) / evt.total) + '%');
|
|
_this.progress = parseInt((evt.loaded / evt.total) * 100)
|
|
_this.progress = parseInt((evt.loaded / evt.total) * 100)
|
|
_this.isFinishSize = (evt.loaded / 1024 / 1024).toFixed(2)
|
|
_this.isFinishSize = (evt.loaded / 1024 / 1024).toFixed(2)
|
|
@@ -311,21 +356,21 @@ export default {
|
|
if (
|
|
if (
|
|
fileA.indexOf(data.Location.split('.')[data.Location.split('.').length - 1].toLocaleUpperCase()) != -1
|
|
fileA.indexOf(data.Location.split('.')[data.Location.split('.').length - 1].toLocaleUpperCase()) != -1
|
|
) {
|
|
) {
|
|
- _type = 1 //word 文件
|
|
|
|
|
|
+ _type = 1 // word 文件
|
|
} else if (
|
|
} else if (
|
|
videoA.indexOf(data.Location.split('.')[data.Location.split('.').length - 1].toLocaleUpperCase()) != -1
|
|
videoA.indexOf(data.Location.split('.')[data.Location.split('.').length - 1].toLocaleUpperCase()) != -1
|
|
) {
|
|
) {
|
|
- _type = 2 //视频
|
|
|
|
|
|
+ _type = 2 // 视频
|
|
} else if (
|
|
} else if (
|
|
imgA.indexOf(data.Location.split('.')[data.Location.split('.').length - 1].toLocaleLowerCase()) != -1
|
|
imgA.indexOf(data.Location.split('.')[data.Location.split('.').length - 1].toLocaleLowerCase()) != -1
|
|
) {
|
|
) {
|
|
- _type = 3 //图片
|
|
|
|
|
|
+ _type = 3 // 图片
|
|
} else if (
|
|
} else if (
|
|
'pdf'.indexOf(data.Location.split('.')[data.Location.split('.').length - 1].toLocaleLowerCase()) != -1
|
|
'pdf'.indexOf(data.Location.split('.')[data.Location.split('.').length - 1].toLocaleLowerCase()) != -1
|
|
) {
|
|
) {
|
|
- _type = 4 //pdf
|
|
|
|
|
|
+ _type = 4 // pdf
|
|
} else {
|
|
} else {
|
|
- _type = 5 //文件
|
|
|
|
|
|
+ _type = 5 // 文件
|
|
}
|
|
}
|
|
if (_this.checkJson.file) {
|
|
if (_this.checkJson.file) {
|
|
_this.checkJson.file.push({
|
|
_this.checkJson.file.push({
|
|
@@ -350,25 +395,48 @@ export default {
|
|
})
|
|
})
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
+ downloadMobanFile(index) {
|
|
|
|
+ this.loading = true
|
|
|
|
+ const file = this.checkJson.mobanFile[index]
|
|
|
|
+ getFile(file.url).then(data => {
|
|
|
|
+ this.loading = false
|
|
|
|
+ if (data.data !== 1) {
|
|
|
|
+ // 下载文件, 并存成ArrayBuffer对象
|
|
|
|
+ const file_name = file.name // 获取文件名
|
|
|
|
+ const file_data = data.data // 获取文件数据
|
|
|
|
+ const url = window.URL.createObjectURL(new Blob([file_data]))
|
|
|
|
+ const a = document.createElement('a')
|
|
|
|
+ a.name = file_name
|
|
|
|
+ a.href = url
|
|
|
|
+ a.download = file_name
|
|
|
|
+ a.click()
|
|
|
|
+ console.log(data)
|
|
|
|
+ this.$message.success('下载成功')
|
|
|
|
+ } else {
|
|
|
|
+ this.$message.error('下载失败')
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+
|
|
downloadFile(f) {
|
|
downloadFile(f) {
|
|
var credentials = {
|
|
var credentials = {
|
|
accessKeyId: 'AKIATLPEDU37QV5CHLMH',
|
|
accessKeyId: 'AKIATLPEDU37QV5CHLMH',
|
|
secretAccessKey: 'Q2SQw37HfolS7yeaR1Ndpy9Jl4E2YZKUuuy2muZR'
|
|
secretAccessKey: 'Q2SQw37HfolS7yeaR1Ndpy9Jl4E2YZKUuuy2muZR'
|
|
- } //秘钥形式的登录上传
|
|
|
|
|
|
+ } // 秘钥形式的登录上传
|
|
window.AWS.config.update(credentials)
|
|
window.AWS.config.update(credentials)
|
|
- window.AWS.config.region = 'cn-northwest-1' //设置区域
|
|
|
|
- let url2 = f.url
|
|
|
|
|
|
+ window.AWS.config.region = 'cn-northwest-1' // 设置区域
|
|
|
|
+ const url2 = f.url
|
|
let _url2 = ''
|
|
let _url2 = ''
|
|
if (url2.indexOf('https://view.officeapps.live.com/op/view.aspx?src=') != -1) {
|
|
if (url2.indexOf('https://view.officeapps.live.com/op/view.aspx?src=') != -1) {
|
|
_url2 = url2.split('https://view.officeapps.live.com/op/view.aspx?src=')[1]
|
|
_url2 = url2.split('https://view.officeapps.live.com/op/view.aspx?src=')[1]
|
|
} else {
|
|
} else {
|
|
_url2 = url2
|
|
_url2 = url2
|
|
}
|
|
}
|
|
- let _this = this
|
|
|
|
|
|
+ const _this = this
|
|
|
|
|
|
_this.downLoading = _url2
|
|
_this.downLoading = _url2
|
|
var s3 = new window.AWS.S3({ params: { Bucket: 'ccrb' } })
|
|
var s3 = new window.AWS.S3({ params: { Bucket: 'ccrb' } })
|
|
- let name = decodeURIComponent(_url2.split('https://ccrb.s3.cn-northwest-1.amazonaws.com.cn/')[1])
|
|
|
|
|
|
+ const name = decodeURIComponent(_url2.split('https://ccrb.s3.cn-northwest-1.amazonaws.com.cn/')[1])
|
|
var params = {
|
|
var params = {
|
|
Bucket: 'ccrb',
|
|
Bucket: 'ccrb',
|
|
Key: name
|
|
Key: name
|
|
@@ -378,8 +446,8 @@ export default {
|
|
if (err) console.log(err, err.stack)
|
|
if (err) console.log(err, err.stack)
|
|
// an error occurred
|
|
// an error occurred
|
|
else {
|
|
else {
|
|
- let url = window.URL.createObjectURL(new Blob([data.Body]))
|
|
|
|
- let a = document.createElement('a')
|
|
|
|
|
|
+ const url = window.URL.createObjectURL(new Blob([data.Body]))
|
|
|
|
+ const a = document.createElement('a')
|
|
a.name = f.name
|
|
a.name = f.name
|
|
a.href = url
|
|
a.href = url
|
|
a.download = f.name
|
|
a.download = f.name
|
|
@@ -598,5 +666,44 @@ export default {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ .file_box {
|
|
|
|
+ /* padding: 0 0 0 15px; */
|
|
|
|
+ width: 100%;
|
|
|
|
+ box-sizing: border-box;
|
|
|
|
+ margin: 10px 0;
|
|
|
|
+ .file_item {
|
|
|
|
+ display: flex;
|
|
|
|
+ width: 100%;
|
|
|
|
+ padding: 5px;
|
|
|
|
+ box-sizing: border-box;
|
|
|
|
+ border-radius: 5px;
|
|
|
|
+
|
|
|
|
+ + .file_item {
|
|
|
|
+ margin-top: 5px;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ &:hover {
|
|
|
|
+ background: #eee;
|
|
|
|
+ }
|
|
|
|
+ .file_name {
|
|
|
|
+ color: #747474;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ .file_btns {
|
|
|
|
+ margin-left: auto;
|
|
|
|
+ display: flex;
|
|
|
|
+ align-items: center;
|
|
|
|
+
|
|
|
|
+ .file_btn {
|
|
|
|
+ color: #3681fc;
|
|
|
|
+ cursor: pointer;
|
|
|
|
+ + .file_btn {
|
|
|
|
+ margin-left: 5px;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
</style>
|
|
</style>
|