+
![]()
+
+
@@ -30,10 +33,11 @@
import Vue from 'vue'
import { ACCESS_TOKEN } from '@/store/mutation-types'
import { getFileAccessHttpUrl } from '@/api/manage'
-const Base64 = require('js-base64').Base64
+
+// const Base64 = require('js-base64').Base64
const uidGenerator = () => {
- return '-' + parseInt(Math.random() * 10000 + 1 + '', 10)
+ return '-' + parseInt(Math.random() * 10000 + 1, 10)
}
export default {
name: 'JImageUpload',
@@ -84,6 +88,7 @@ export default {
computed: {
// 透传给下级组件的事件,需要排除本组件使用的change事件
childListeners () {
+ // const vm = this
const result = Object.assign({},
this.$listeners
)
@@ -118,23 +123,15 @@ export default {
return
}
this.picUrl = true
- const fileList = []
const arr = paths.split(',')
for (let a = 0; a < arr.length; a++) {
- const url = getFileAccessHttpUrl(arr[a])
- fileList.push({
- uid: uidGenerator(),
- name: arr[a],
- status: 'done',
- url: url,
- response: {
- status: 'history',
- message: arr[a]
+ this.fileList.forEach((item) => {
+ if (item.url === arr[a]) {
+ item.uid = uidGenerator()
+ item.response.status = 'history'
}
})
}
-
- this.fileList = fileList
},
beforeUpload: function (file) {
const fileType = file.type
@@ -147,7 +144,7 @@ export default {
this.picUrl = false
let fileList = info.fileList
// update-begin-author:wangshuai date:20201022 for:LOWCOD-969 判断number是否大于0和是否多选,返回选定的元素。
- if (this.number > 0) {
+ if (this.number > 0 && this.isMultiple) {
fileList = fileList.slice(-this.number)
}
// update-end-author:wangshuai date:20201022 for:LOWCOD-969 判断number是否大于0和是否多选,返回选定的元素。
@@ -156,7 +153,7 @@ export default {
this.picUrl = true
fileList = fileList.map((file) => {
if (file.response) {
- file.url = `${file.response.result.id}`
+ file.url = `${file.response.result.id}?token=${Vue.ls.get(ACCESS_TOKEN)}&fullfilename=${file.response.result.fileName}`
}
return file
})
@@ -175,8 +172,8 @@ export default {
// 预览
handlePreview (file) {
if (file && file.url) {
- const fileFullUrl = `${window._CONFIG.domianWebSocketURL}/${file.url}`
- const url = `${window._CONFIG.onlinePreviewDomainURL}?url=${encodeURIComponent(Base64.encode(fileFullUrl))}`
+ const fileFullUrl = `${window._CONFIG.domianWebSocketURL}/sys/common/download/${file.response.result.id}?token=${Vue.ls.get(ACCESS_TOKEN)}&fullfilename=${file.name}`
+ const url = `${window._CONFIG.onlinePreviewDomainURL}?url=${encodeURIComponent(fileFullUrl)}`
window.open(url)
}
},
@@ -193,7 +190,7 @@ export default {
path = ''
}
const arr = []
- if (!this.isMultiple && uploadFiles && uploadFiles.length > 0) {
+ if (!this.isMultiple) {
arr.push(uploadFiles[uploadFiles.length - 1].url)
} else {
for (let a = 0; a < uploadFiles.length; a++) {