瀏覽代碼

批量上传简历

noob 4 年之前
父節點
當前提交
27c500e204
共有 2 個文件被更改,包括 36 次插入4 次删除
  1. 20 1
      src/components/vInput/vInput.vue
  2. 16 3
      src/views/candidateManage/candidateAll.vue

+ 20 - 1
src/components/vInput/vInput.vue

@@ -38,7 +38,16 @@
                   style="display:inline-block"
                   v-else
                   :action="action"
-                  :file-list="fileList">
+                  :file-list="fileList"
+                  :before-upload="handleBefore"
+                  :on-success="handleSuccess"
+                  :show-file-list="false"
+                  :headers="{
+                    Authorization:token
+                  }"
+                  :data="{
+                    companyId: 12
+                  }">
                   <el-button size="small" type="primary">{{item.name}}</el-button>
                 </el-upload>
                 <span class="prompt" v-if="item.message">{{item.message}}</span>
@@ -67,6 +76,7 @@ export default {
       form: {},
       date: null,
       fileList: [],
+      token: localStorage.getItem('token'),
       action: process.env.VUE_APP_API + '/admin/resumeInfo/batchUploadResume'
     }
   },
@@ -93,6 +103,15 @@ export default {
       this.date && this.date.length && (reqdata.beginTime = this.date[0])
       this.date && this.date.length && (reqdata.endTime = this.date[1])
       this.$emit(item.method, reqdata)
+    },
+    handleBefore (file) {
+      if (file.type !== 'application/x-zip-compressed') {
+        this.$message.error('请上传zip格式')
+        return false
+      }
+    },
+    handleSuccess (result) {
+      this.$emit('success', result)
     }
   }
 }

+ 16 - 3
src/views/candidateManage/candidateAll.vue

@@ -4,11 +4,11 @@
  * @Autor: XuTongZhang
  * @Date: 2020-07-30 10:17:25
  * @LastEditors  : yuanrunwei
- * @LastEditTime : 2021-02-05 17:11:16
+ * @LastEditTime : 2021-02-07 19:47:19
 -->
 <template>
 <div class="indexPage">
-    <v-input :btn="btn" :list="list" @search="search" @exports="exports" @upload="upload=true" @excel="handleExcel"></v-input>
+    <v-input :btn="btn" :list="list" @search="search" @exports="exports" @upload="upload=true" @excel="handleExcel" @success="handleSuccess"></v-input>
     <v-table :table="table" :tableList="tableList" :sortType="true" :queryData="queryData" :form="searchForm" @details="details" @update="update" @duplicate="handleDuplicate" @delete="handleDelete"></v-table>
     <v-pager @page="callPage" :total="totalrecords"></v-pager>
     <!-- <resume :dialogFormVisible="dialogFormVisible" :close="close" :info="info" :searchForm="searchForm" :queryData="queryData"></resume> -->
@@ -322,7 +322,7 @@ export default {
         method: 'upload'
       },
       {
-        name: '导入简历',
+        name: '批量导入简历',
         type: 'upload',
         method: 'excel'
       }
@@ -648,6 +648,19 @@ export default {
           }
         })
       })
+    },
+    handleSuccess (result) {
+      if (result.list.length) {
+        console.log(111)
+        this.$alert(`
+          <div>以下文件上传失败,请检查无误后重新上传</div>
+          <div>${result.list}</div>
+        `, '上传提示', {
+          dangerouslyUseHTMLString: true
+        })
+      } else {
+        this.$message.success('上传成功')
+      }
     }
   }
 }