【fix ESLint】src/components/jero/JImageUpload
This commit is contained in:
@@ -33,7 +33,7 @@ import { getFileAccessHttpUrl } from '@/api/manage'
|
|||||||
const Base64 = require('js-base64').Base64
|
const Base64 = require('js-base64').Base64
|
||||||
|
|
||||||
const uidGenerator = () => {
|
const uidGenerator = () => {
|
||||||
return '-' + parseInt(Math.random() * 10000 + 1, 10)
|
return '-' + parseInt(Math.random() * 10000 + 1 + '', 10)
|
||||||
}
|
}
|
||||||
export default {
|
export default {
|
||||||
name: 'JImageUpload',
|
name: 'JImageUpload',
|
||||||
@@ -84,7 +84,6 @@ export default {
|
|||||||
computed: {
|
computed: {
|
||||||
// 透传给下级组件的事件,需要排除本组件使用的change事件
|
// 透传给下级组件的事件,需要排除本组件使用的change事件
|
||||||
childListeners () {
|
childListeners () {
|
||||||
const vm = this
|
|
||||||
const result = Object.assign({},
|
const result = Object.assign({},
|
||||||
this.$listeners
|
this.$listeners
|
||||||
)
|
)
|
||||||
@@ -94,13 +93,13 @@ export default {
|
|||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
value: {
|
value: {
|
||||||
handler (val, oldValue) {
|
handler (val) {
|
||||||
if (val instanceof Array) {
|
if (val instanceof Array) {
|
||||||
this.initFileList(val.join(','))
|
this.initFileList(val.join(','))
|
||||||
} else {
|
} else {
|
||||||
this.initFileList(val)
|
this.initFileList(val)
|
||||||
}
|
}
|
||||||
if (!val || val.length == 0) {
|
if (!val || val.length === 0) {
|
||||||
this.picUrl = false
|
this.picUrl = false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -114,14 +113,14 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
initFileList (paths) {
|
initFileList (paths) {
|
||||||
if (!paths || paths.length == 0) {
|
if (!paths || paths.length === 0) {
|
||||||
this.fileList = []
|
this.fileList = []
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.picUrl = true
|
this.picUrl = true
|
||||||
const fileList = []
|
const fileList = []
|
||||||
const arr = paths.split(',')
|
const arr = paths.split(',')
|
||||||
for (var a = 0; a < arr.length; a++) {
|
for (let a = 0; a < arr.length; a++) {
|
||||||
const url = getFileAccessHttpUrl(arr[a])
|
const url = getFileAccessHttpUrl(arr[a])
|
||||||
fileList.push({
|
fileList.push({
|
||||||
uid: uidGenerator(),
|
uid: uidGenerator(),
|
||||||
@@ -138,7 +137,7 @@ export default {
|
|||||||
this.fileList = fileList
|
this.fileList = fileList
|
||||||
},
|
},
|
||||||
beforeUpload: function (file) {
|
beforeUpload: function (file) {
|
||||||
var fileType = file.type
|
const fileType = file.type
|
||||||
if (fileType.indexOf('image') < 0) {
|
if (fileType.indexOf('image') < 0) {
|
||||||
this.$message.warning('请上传图片')
|
this.$message.warning('请上传图片')
|
||||||
return false
|
return false
|
||||||
@@ -176,7 +175,7 @@ export default {
|
|||||||
// 预览
|
// 预览
|
||||||
handlePreview (file) {
|
handlePreview (file) {
|
||||||
if (file && file.url) {
|
if (file && file.url) {
|
||||||
var fileFullUrl = `${window._CONFIG.domianWebSocketURL}/${file.url}`
|
const fileFullUrl = `${window._CONFIG.domianWebSocketURL}/${file.url}`
|
||||||
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)
|
||||||
}
|
}
|
||||||
@@ -190,7 +189,7 @@ 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 = []
|
||||||
|
|||||||
Reference in New Issue
Block a user