修改bug
This commit is contained in:
@@ -52,7 +52,13 @@
|
||||
mark: {
|
||||
type: [String, Number],
|
||||
default: ''
|
||||
}
|
||||
},
|
||||
fileType: {
|
||||
type: Array,
|
||||
default: function() {
|
||||
return ['jpg', 'png']
|
||||
}
|
||||
},
|
||||
})
|
||||
// 状态管理
|
||||
const fileList = reactive([])
|
||||
@@ -105,13 +111,22 @@
|
||||
success: async ({
|
||||
tempFilePaths
|
||||
}) => {
|
||||
const valid = tempFilePaths.every(url => {
|
||||
if (props.fileType.length === 0) return true;
|
||||
console.log(url);
|
||||
const lastDotIndex = url.lastIndexOf('.')
|
||||
if (lastDotIndex === -1) return false;
|
||||
const extension = url.slice(lastDotIndex + 1).split('?')[0].toLowerCase()
|
||||
return props.fileType.includes(extension)
|
||||
})
|
||||
if (!valid) return common.msg('您选择的图片格式有误。')
|
||||
console.log(valid)
|
||||
const data = {
|
||||
bizScen: 'S3005'
|
||||
}
|
||||
console.log(tempFilePaths[0]);
|
||||
const upload_map = tempFilePaths.map((file) => uploadFile(file, data))
|
||||
Promise.all(upload_map).then(res => {
|
||||
fileList.push(...res)
|
||||
fileList.push(...res.splice(0, props.limit - fileList.length))
|
||||
emits('update:modelValue', fileList.map(res => res.fileId))
|
||||
|
||||
}).catch(() => {
|
||||
|
||||
Reference in New Issue
Block a user