1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
| <template>
| <div>
| <el-upload ref="upload" action="#" :before-upload="beforeUpload" :http-request="uploadFile"
| :file-list="fileList" :on-success="uploadFileSuccess" accept=".xls, .xlsx" :limit="1" :auto-upload="true"
| :show-file-list="false">
| <el-button size="small" type="primary">导入</el-button>
| </el-upload>
| </div>
| </template>
| <script>
| import {
| yearPlanDetailImport
| } from '@/api/cnas/personnel/personnelInfo.js'
| export default {
| data() {
| return {
| fileList: []
| }
| },
| methods: {
| /**
| * @desc 上传文件
| */
| beforeUpload(file) {
| this.fileList = [file]
| },
| /**
| * @desc 上传至服务器
| */
| async uploadFile() {
| console.log('文件', this.fileList[0])
| let formData = new FormData()
| formData.append('file', this.fileList[0])
| const { code, data } = await yearPlanDetailImport(formData)
| if (code == 200) {
| this.$emit('upload')
| }
| },
| uploadFileSuccess() {
| this.$refs.upload.clearFiles()
| }
| }
| }
| </script>
|
|