[update 海外会议] 限制上传图片格式
This commit is contained in:
@@ -89,8 +89,14 @@
|
||||
type:Number,
|
||||
required:false,
|
||||
default:0
|
||||
}
|
||||
},
|
||||
//update-end-author:wangshuai date:20201021 for:LOWCOD-969 新增number属性,用于判断上传数量
|
||||
// 限制的后缀数组
|
||||
fileTypeList: {
|
||||
type: Array,
|
||||
required: false,
|
||||
default: () => []
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
//透传给下级组件的事件,需要排除本组件使用的change事件
|
||||
@@ -190,6 +196,15 @@
|
||||
this.$message.warning('请上传图片')
|
||||
return false
|
||||
}
|
||||
// 限制文件类型
|
||||
if (this.fileTypeList && this.fileTypeList.length) {
|
||||
const tmpArr = file.name.split('.')
|
||||
const fileSuffix = tmpArr[tmpArr.length - 1].toLowerCase()
|
||||
if (!this.fileTypeList.some(t => t === fileSuffix)) {
|
||||
this.$message.warning('图片格式必须是' + this.fileTypeList.join(','))
|
||||
return false
|
||||
}
|
||||
}
|
||||
},
|
||||
handleChange(info) {
|
||||
this.picUrl = false
|
||||
|
||||
@@ -10,7 +10,9 @@
|
||||
<a-row :gutter="24">
|
||||
<a-col :xxl="8" :xl="12" :sm="24">
|
||||
<a-form-item label="照片" :labelCol="labelCol" :wrapperCol="wrapperCol">
|
||||
<j-image-upload v-decorator="['photo',validatorRules.photo]" :return-id="true"></j-image-upload>
|
||||
<j-image-upload v-decorator="['photo',validatorRules.photo]" :return-id="true"
|
||||
accept=".jpg,.jpeg,.png"
|
||||
:file-type-list="['jpg', 'jpeg', 'png']"></j-image-upload>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
|
||||
Reference in New Issue
Block a user