【fix ESLint】src/components/jero/JUpload

This commit is contained in:
zhaoxiao
2023-03-06 09:28:25 +08:00
parent e5dd766606
commit 932a22d267
+15 -15
View File
@@ -42,9 +42,9 @@ const Base64 = require('js-base64').Base64
const FILE_TYPE_ALL = 'all'
const FILE_TYPE_IMG = 'image'
const FILE_TYPE_TXT = 'file'
const uidGenerator = () => {
return '-' + parseInt(Math.random() * 10000 + 1, 10)
return '-' + parseInt(Math.random() * 10000 + 1 + '', 10)
}
export default {
name: 'JUpload',
@@ -54,7 +54,8 @@ export default {
headers: {},
fileList: [],
newFileList: [],
uploadGoOn: true
uploadGoOn: true,
containerId: null
}
},
props: {
@@ -143,7 +144,6 @@ export default {
computed: {
// 透传给下级组件的事件,需要排除本组件使用的change事件
childListeners () {
const vm = this
const result = Object.assign({},
this.$listeners
)
@@ -166,11 +166,11 @@ export default {
},
methods: {
initFileListArr (val) {
if (!val || val.length == 0) {
if (!val || val.length === 0) {
this.fileList = []
return
}
for (var a = 0; a < val.length; a++) {
for (let a = 0; a < val.length; a++) {
this.fileList.forEach((item) => {
if (item.url === val[a]) {
item.uid = uidGenerator()
@@ -180,12 +180,12 @@ export default {
}
},
initFileList (paths) {
if (!paths || paths.length == 0) {
if (!paths || paths.length === 0) {
this.fileList = []
return
}
const arr = paths.split(',')
for (var a = 0; a < arr.length; a++) {
for (let a = 0; a < arr.length; a++) {
this.fileList.forEach((item) => {
if (item.url === arr[a]) {
item.uid = uidGenerator()
@@ -197,12 +197,12 @@ export default {
handlePathChange () {
const uploadFiles = this.fileList
let path = ''
if (!uploadFiles || uploadFiles.length == 0) {
if (!uploadFiles || uploadFiles.length === 0) {
path = ''
}
const arr = []
for (var a = 0; a < uploadFiles.length; a++) {
for (let a = 0; a < uploadFiles.length; a++) {
if (uploadFiles[a].status === 'done') {
arr.push(uploadFiles[a].url)
} else {
@@ -216,7 +216,7 @@ export default {
},
doBeforeUpload (file) {
this.uploadGoOn = true
var fileType = file.type
const fileType = file.type
if (this.fileType === FILE_TYPE_IMG) {
if (fileType.indexOf('image') < 0) {
this.$message.warning('请上传图片')
@@ -262,10 +262,10 @@ export default {
} else {
// returnUrl为false时返回文件名称、文件路径及文件大小
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】多个文件同时上传时,控制台报错
if (fileList[a].status === 'done') {
var fileJson = {
const fileJson = {
fileName: fileList[a].name,
filePath: fileList[a].url,
fileSize: fileList[a].size
@@ -286,14 +286,14 @@ export default {
},
handlePreview (file) {
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))}`
window.open(url)
}
},
handleDownload (file) {
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)
}
}