添加上传图片文件验证
This commit is contained in:
@ -80,6 +80,10 @@ export default {
|
|||||||
this.dialogImageUrl = file.url;
|
this.dialogImageUrl = file.url;
|
||||||
},
|
},
|
||||||
beforeUpload(file) {
|
beforeUpload(file) {
|
||||||
|
if (file.type.indexOf("image/") == -1) {
|
||||||
|
this.msgError("文件格式错误,请上传图片类型,如:JPG,PNG后缀的文件。");
|
||||||
|
return false
|
||||||
|
}
|
||||||
let _self = this;
|
let _self = this;
|
||||||
if (!this.useOss) {
|
if (!this.useOss) {
|
||||||
//不使用oss不需要获取策略
|
//不使用oss不需要获取策略
|
||||||
|
@ -86,9 +86,11 @@
|
|||||||
<el-input
|
<el-input
|
||||||
placeholder="请输入"
|
placeholder="请输入"
|
||||||
v-model="ruleForm.address"
|
v-model="ruleForm.address"
|
||||||
maxlength="25"
|
maxlength="80"
|
||||||
show-word-limit
|
show-word-limit
|
||||||
:disabled="check"
|
:disabled="check"
|
||||||
|
type="textarea"
|
||||||
|
:autosize="{ minRows: 3, maxRows: 4 }"
|
||||||
></el-input>
|
></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="登录手机号" prop="username">
|
<el-form-item label="登录手机号" prop="username">
|
||||||
@ -456,3 +458,8 @@ export default {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
/deep/.el-input__count {
|
||||||
|
background-color: unset;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
@ -131,6 +131,7 @@
|
|||||||
:action="upload.url"
|
:action="upload.url"
|
||||||
:disabled="upload.isUploading"
|
:disabled="upload.isUploading"
|
||||||
:on-progress="handleFileUploadProgress"
|
:on-progress="handleFileUploadProgress"
|
||||||
|
:before-upload="beforeUpload"
|
||||||
:on-success="handleFileSuccess"
|
:on-success="handleFileSuccess"
|
||||||
:auto-upload="false"
|
:auto-upload="false"
|
||||||
drag
|
drag
|
||||||
@ -265,6 +266,14 @@ export default {
|
|||||||
// resetForm(formName) {
|
// resetForm(formName) {
|
||||||
// this.$refs[formName].resetFields();
|
// this.$refs[formName].resetFields();
|
||||||
// }
|
// }
|
||||||
|
beforeUpload(file){
|
||||||
|
const fileSuffix = file.name.substring(file.name.lastIndexOf(".") + 1);
|
||||||
|
const whiteList = ["pdf", "doc", "docx", "xls", "xlsx"];
|
||||||
|
if (whiteList.indexOf(fileSuffix.toLowerCase()) === -1) {
|
||||||
|
this.msgError("上传文件只能是 pdf、doc、docx、xls、xlsx格式。");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
},
|
||||||
// 文件上传中处理
|
// 文件上传中处理
|
||||||
handleFileUploadProgress(event, file, fileList) {
|
handleFileUploadProgress(event, file, fileList) {
|
||||||
this.upload.isUploading = true;
|
this.upload.isUploading = true;
|
||||||
|
Reference in New Issue
Block a user