Переглянути джерело

Merge branch 'dev-online' into 'PrivateReleaseOfXC'

Dev online

See merge request crowd-2019/crowd-test-service-front!210
郭超 4 роки тому
батько
коміт
34ebca2129
1 змінених файлів з 17 додано та 4 видалено
  1. 17 4
      src/components/task/TaskCreate.vue

+ 17 - 4
src/components/task/TaskCreate.vue

@@ -104,8 +104,8 @@
             :before-remove="beforeRemove"
             :limit="1"
             :on-exceed="handleExceed"
-            :before-upload="beforeFileUpload"
-            :http-request="uploadThreePageDoc"
+            :before-upload="beforeThreePageUpload"
+            :http-request="uploadThreePageFile"
             :file-list="task.threePageList"
           >
             <i class="el-icon-upload"></i>
@@ -451,8 +451,21 @@ export default {
         notify('error', '上传失败:' + error.data)
       })
     },
+
+    beforeThreePageUpload(file) {
+      const isPDF = file.type === 'application/pdf'
+      const isDOC = file.type === 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
+      const isEXCEL = file.type === 'application/vnd.ms-excel'
+      const isXLS = file.type === 'application/x-xls'
+      const isTXT = file.type === 'text/plain'
+      const isXLSX = file.type === 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
+      if (!(isEXCEL || isXLS || isXLSX)) {
+        this.$message.error('上传文件只能是 XLS、XLSX 格式!')
+      }
+      return isEXCEL || isXLS || isXLSX
+    },
     //todo:上传测试大纲
-    uploadThreePageDoc(param) {
+    uploadThreePageFile(param) {
       const formData = new FormData()
       let config = {
         //添加请求头
@@ -464,7 +477,7 @@ export default {
         this.task.endPoint.threePageUrl = res.data;
         this.$refs.task.validateField('endPoint.threePageUrl');
       }).catch((error) => {
-        notify('error', '上传失败:' + error.data)
+        notify('error', '上传失败:' + error)
       })
     },
     setServiceType() {