【fix ESLint】src/components/jero/JUpload
This commit is contained in:
@@ -42,9 +42,9 @@ const Base64 = require('js-base64').Base64
|
|||||||
|
|
||||||
const FILE_TYPE_ALL = 'all'
|
const FILE_TYPE_ALL = 'all'
|
||||||
const FILE_TYPE_IMG = 'image'
|
const FILE_TYPE_IMG = 'image'
|
||||||
const FILE_TYPE_TXT = 'file'
|
|
||||||
const uidGenerator = () => {
|
const uidGenerator = () => {
|
||||||
return '-' + parseInt(Math.random() * 10000 + 1, 10)
|
return '-' + parseInt(Math.random() * 10000 + 1 + '', 10)
|
||||||
}
|
}
|
||||||
export default {
|
export default {
|
||||||
name: 'JUpload',
|
name: 'JUpload',
|
||||||
@@ -54,7 +54,8 @@ export default {
|
|||||||
headers: {},
|
headers: {},
|
||||||
fileList: [],
|
fileList: [],
|
||||||
newFileList: [],
|
newFileList: [],
|
||||||
uploadGoOn: true
|
uploadGoOn: true,
|
||||||
|
containerId: null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
@@ -143,7 +144,6 @@ export default {
|
|||||||
computed: {
|
computed: {
|
||||||
// 透传给下级组件的事件,需要排除本组件使用的change事件
|
// 透传给下级组件的事件,需要排除本组件使用的change事件
|
||||||
childListeners () {
|
childListeners () {
|
||||||
const vm = this
|
|
||||||
const result = Object.assign({},
|
const result = Object.assign({},
|
||||||
this.$listeners
|
this.$listeners
|
||||||
)
|
)
|
||||||
@@ -166,11 +166,11 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
initFileListArr (val) {
|
initFileListArr (val) {
|
||||||
if (!val || val.length == 0) {
|
if (!val || val.length === 0) {
|
||||||
this.fileList = []
|
this.fileList = []
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
for (var a = 0; a < val.length; a++) {
|
for (let a = 0; a < val.length; a++) {
|
||||||
this.fileList.forEach((item) => {
|
this.fileList.forEach((item) => {
|
||||||
if (item.url === val[a]) {
|
if (item.url === val[a]) {
|
||||||
item.uid = uidGenerator()
|
item.uid = uidGenerator()
|
||||||
@@ -180,12 +180,12 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
initFileList (paths) {
|
initFileList (paths) {
|
||||||
if (!paths || paths.length == 0) {
|
if (!paths || paths.length === 0) {
|
||||||
this.fileList = []
|
this.fileList = []
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const arr = paths.split(',')
|
const arr = paths.split(',')
|
||||||
for (var a = 0; a < arr.length; a++) {
|
for (let a = 0; a < arr.length; a++) {
|
||||||
this.fileList.forEach((item) => {
|
this.fileList.forEach((item) => {
|
||||||
if (item.url === arr[a]) {
|
if (item.url === arr[a]) {
|
||||||
item.uid = uidGenerator()
|
item.uid = uidGenerator()
|
||||||
@@ -197,12 +197,12 @@ export default {
|
|||||||
handlePathChange () {
|
handlePathChange () {
|
||||||
const uploadFiles = this.fileList
|
const uploadFiles = this.fileList
|
||||||
let path = ''
|
let path = ''
|
||||||
if (!uploadFiles || uploadFiles.length == 0) {
|
if (!uploadFiles || uploadFiles.length === 0) {
|
||||||
path = ''
|
path = ''
|
||||||
}
|
}
|
||||||
const arr = []
|
const arr = []
|
||||||
|
|
||||||
for (var a = 0; a < uploadFiles.length; a++) {
|
for (let a = 0; a < uploadFiles.length; a++) {
|
||||||
if (uploadFiles[a].status === 'done') {
|
if (uploadFiles[a].status === 'done') {
|
||||||
arr.push(uploadFiles[a].url)
|
arr.push(uploadFiles[a].url)
|
||||||
} else {
|
} else {
|
||||||
@@ -216,7 +216,7 @@ export default {
|
|||||||
},
|
},
|
||||||
doBeforeUpload (file) {
|
doBeforeUpload (file) {
|
||||||
this.uploadGoOn = true
|
this.uploadGoOn = true
|
||||||
var fileType = file.type
|
const fileType = file.type
|
||||||
if (this.fileType === FILE_TYPE_IMG) {
|
if (this.fileType === FILE_TYPE_IMG) {
|
||||||
if (fileType.indexOf('image') < 0) {
|
if (fileType.indexOf('image') < 0) {
|
||||||
this.$message.warning('请上传图片')
|
this.$message.warning('请上传图片')
|
||||||
@@ -262,10 +262,10 @@ export default {
|
|||||||
} else {
|
} else {
|
||||||
// returnUrl为false时返回文件名称、文件路径及文件大小
|
// returnUrl为false时返回文件名称、文件路径及文件大小
|
||||||
this.newFileList = []
|
this.newFileList = []
|
||||||
for (var a = 0; a < fileList.length; a++) {
|
for (let a = 0; a < fileList.length; a++) {
|
||||||
// update-begin-author:lvdandan date:20200603 for:【TESTA-514】【开源issue】多个文件同时上传时,控制台报错
|
// update-begin-author:lvdandan date:20200603 for:【TESTA-514】【开源issue】多个文件同时上传时,控制台报错
|
||||||
if (fileList[a].status === 'done') {
|
if (fileList[a].status === 'done') {
|
||||||
var fileJson = {
|
const fileJson = {
|
||||||
fileName: fileList[a].name,
|
fileName: fileList[a].name,
|
||||||
filePath: fileList[a].url,
|
filePath: fileList[a].url,
|
||||||
fileSize: fileList[a].size
|
fileSize: fileList[a].size
|
||||||
@@ -286,14 +286,14 @@ export default {
|
|||||||
},
|
},
|
||||||
handlePreview (file) {
|
handlePreview (file) {
|
||||||
if (file && file.url) {
|
if (file && file.url) {
|
||||||
var fileFullUrl = `${window._CONFIG.domianWebSocketURL}/sys/common/download/${file.response.result.id}?token=${Vue.ls.get(ACCESS_TOKEN)}&fullfilename=${file.name}`
|
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(Base64.encode(fileFullUrl))}`
|
const url = `${window._CONFIG.onlinePreviewDomainURL}?url=${encodeURIComponent(Base64.encode(fileFullUrl))}`
|
||||||
window.open(url)
|
window.open(url)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
handleDownload (file) {
|
handleDownload (file) {
|
||||||
if (file && file.url) {
|
if (file && file.url) {
|
||||||
var fileFullUrl = `${window._CONFIG.domianWebSocketURL}/sys/common/download/${file.response.result.id}?token=${Vue.ls.get(ACCESS_TOKEN)}&fullfilename=${file.name}`
|
const fileFullUrl = `${window._CONFIG.domianWebSocketURL}/sys/common/download/${file.response.result.id}?token=${Vue.ls.get(ACCESS_TOKEN)}&fullfilename=${file.name}`
|
||||||
window.open(fileFullUrl)
|
window.open(fileFullUrl)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user