Browse Source

限制只能上传一份文件

duy 1 month ago
parent
commit
40efd29d3c
1 changed files with 5 additions and 0 deletions
  1. 5 0
      src/views/codeRule/ruleManage.vue

+ 5 - 0
src/views/codeRule/ruleManage.vue

@@ -424,6 +424,8 @@
               :file-list="fileForm.standardFileUrl"
               :on-change="uploadImportData"
                accept=".pdf, application/pdf"
+             :on-exceed="handleExceed"
+             :limit="1"
               >
               <el-button size="small" type="primary">点击上传</el-button>
               <div slot="tip" class="el-upload__tip">允许文件格式.pdf</div>
@@ -813,6 +815,9 @@ import { getStore, setStore } from "@/util/store";
           this.fileForm.standardFileUrl = this.fileForm.files.map(file => ({
             name: file.name,
           }));
+      },
+      handleExceed(files, fileList) {
+        this.$message.warning(`当前限制只能上传一个文件,您已选择了 ${files.length + fileList.length} 个文件,请重新选择!`);
       },
         async addFileRoleForm(){
           const isValid = await this.$refs.fileFormRef.validate()