Browse Source

fix(converter):拖拽文件到input框限制

liyangbin 2 years ago
parent
commit
1d66237e02
1 changed files with 9 additions and 9 deletions
  1. 9 9
      pages/converter.vue

+ 9 - 9
pages/converter.vue

@@ -128,7 +128,7 @@
                           <!-- 登录 -->
                           <input id="fileinput-explorer" ref="file" name="file" accept=".pdf" title="上传文件" type="file" multiple=""
                           class="absolute top-0 right-0 p-0 m-0 min-w-[100%] h-[100%] w-90px text-right opacity-0 bg-none bg-repeat bg-scroll block outline-none border-0 cursor-pointer"
-                          @change="addFile($event)" @click="handlSubmit($event, '')" v-if = " !showInputDisable "/>
+                          @change="addFile($event)" @click="handlSubmit($event, '')" @drop="handleEvent" @dragleave="handleEvent" @dragenter="handleEvent" @dragover="handleEvent" v-if = " !showInputDisable "/>
                         </div>
                         <div v-show="fileList.length > 0 && changeFileFlag" class="inline-block ml-30px bg-white border border-[#ff4f4f] boder-solid text-16px py-7px px-18px rounded-4px mt-4px cursor-pointer text-[#ff4f4f] leading-normal hover:bg-[#ff4f4f] hover:text-white" 
                           @click="deleteAllFile">清空</div>
@@ -516,14 +516,14 @@ export default {
             if(a != "docx" && a != "pptx" && a != "xlsx" && a != "txt" && a != "jpg" && a != "png"){
               a = "docx"
             }
-            // for(let i = 0; i < array.length; i++){
-            //   let name = array[i].name
-            //   let num= name.lastIndexOf(".")
-            //   let type = name.slice(num,name.length)
-            //   if(type !== ".pdf"){
-            //     return 
-            //   }
-            // }
+            //不是pdf文件不上传
+            let newArrs= [];
+            for(var item of array){
+              if(item.type.indexOf('pdf') !== -1){
+                newArrs.push(item);
+              }
+            }
+            array = newArrs
             const defaultPrice = await this.getFilePrice("pdf", a);
             for (let i = 0; i < array.length; i++) {
                 const id = Date.now() + Math.random().toString(36).slice(-8)