优化报废图片上传问题
This commit is contained in:
parent
ee30623248
commit
6a64086767
|
|
@ -1,6 +1,6 @@
|
|||
import request from '@/utils/request'
|
||||
//资源图片上传
|
||||
export function imgUpLoad(param){
|
||||
export function imgUpLoad(param) {
|
||||
const formData = new FormData()
|
||||
formData.append('file', param.file)
|
||||
formData.append('fileType', param.type)
|
||||
|
|
@ -8,12 +8,12 @@ export function imgUpLoad(param){
|
|||
url: '/system/sys/file/upload',
|
||||
method: 'post',
|
||||
data: formData,
|
||||
header:'multipart/form-data'
|
||||
header: 'multipart/form-data'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
//资源文件上传
|
||||
export function fileUpLoad(param){
|
||||
export function fileUpLoad(param) {
|
||||
const formData = new FormData()
|
||||
formData.append('file', param.file)
|
||||
return request({
|
||||
|
|
@ -21,7 +21,7 @@ export function fileUpLoad(param){
|
|||
method: 'post',
|
||||
data: formData,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -34,8 +34,6 @@ export default {
|
|||
return
|
||||
}
|
||||
let real_src = this.src.split(',')[0]
|
||||
|
||||
console.log(this.src, '图片地址--')
|
||||
return real_src
|
||||
},
|
||||
realSrcList() {
|
||||
|
|
|
|||
|
|
@ -49,7 +49,8 @@ export default {
|
|||
},
|
||||
data() {
|
||||
return {
|
||||
uploadImgUrl: process.env.VUE_APP_BASE_API + '/dev-api' + this.actionUrl,
|
||||
uploadImgUrl:
|
||||
process.env.VUE_APP_BASE_API + '/dev-api' + this.actionUrl,
|
||||
headers: {
|
||||
Authorization: 'Bearer ' + getToken(),
|
||||
},
|
||||
|
|
@ -70,9 +71,9 @@ export default {
|
|||
},
|
||||
handleExceed(files, fileList) {
|
||||
this.$message.warning(
|
||||
`当前限制选择 ${this.limit} 个文件,本次选择了 ${files.length} 个文件,共选择了 ${
|
||||
files.length + fileList.length
|
||||
} 个文件`
|
||||
`当前限制选择 ${this.limit} 个文件,本次选择了 ${
|
||||
files.length
|
||||
} 个文件,共选择了 ${files.length + fileList.length} 个文件`,
|
||||
)
|
||||
this.$emit('exceed', files, fileList)
|
||||
},
|
||||
|
|
@ -85,7 +86,10 @@ export default {
|
|||
},
|
||||
beforeUpload(file) {
|
||||
console.log('file', file)
|
||||
const isJPGorPNG = file.type == 'image/png' || file.type == 'image/jpg' || file.type == 'image/jpeg'
|
||||
const isJPGorPNG =
|
||||
file.type == 'image/png' ||
|
||||
file.type == 'image/jpg' ||
|
||||
file.type == 'image/jpeg'
|
||||
const isLt5M = file.size / 1024 / 1024 < 5 // 小于 5MB
|
||||
if (!isJPGorPNG) {
|
||||
this.$message.error('只能上传 jpg、jpeg、png 格式的图片')
|
||||
|
|
|
|||
Loading…
Reference in New Issue