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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
| <template>
| <basic-container>
|
| <el-text type="warning" style="margin-bottom:20px;">请上传派工excel数据文件<br/></el-text>
| <avue-form ref="form" style="margin-top: 50px;" :option="excelOption" v-model="excelForm" :upload-after="uploadAfter">
| <template #excelTemplate>
| <el-button type="plain" @click="handleDownloadTpl">
| 下载<i class="el-icon-download"></i>
| </el-button>
| </template>
|
| <template #excelResult>
| <el-button type="primary" :disabled="importResult.name == null" @click="handleDownload">
| 下载<i class="el-icon-download el-icon--right"></i>
| </el-button>
| </template>
|
| </avue-form>
| </basic-container>
| </template>
|
| <script>
|
| import { baseUrl } from '@/config/env';
| import { downloadFile,downloadXls } from '@/utils/util';
| import { exportBlob } from '@/api/common';
| import { getToken } from '@/utils/auth';
| import NProgress from 'nprogress';
| export default {
|
| watch: {
|
| },
| data() {
| return {
|
| loading: false,
| fileId:0,
| excelForm: {},
| importResult:{},
| excelOption: {
| submitBtn: false,
| emptyBtn: false,
| column: [
| {
| label: '上传文件',
| prop: 'excelFile',
| type: 'upload',
| drag: true,
| loadText: '任务文件导入,请稍等',
| //data:{authCode:this.excelForm.authCode},
| span: 12,
| /*propsHttp: {
| res: 'data',
| },*/
| tip: '',
| action: baseUrl+'/blade-mdm/flow/mgr/import-task',
| },
| {
| label: '数据模板',
| prop: 'excelTemplate',
| type: 'link',
| span: 12,
| },
| {
| label: '导入结果',
| prop: 'excelResult',
| type: 'button',
| span: 24,
| tip: '',
| },
|
| ],
| },
| };
| },
| methods: {
|
| uploadAfter(res, done, loading, column) {
|
| console.log('resdata',res.data);
| if(res.code == 200){
| this.importResult = res.data;
| this.$message.success("导入完成,请点击下载获取结果")
| }else{
| this.$message.error("导入失败:"+res.msg)
| }
|
| done();
| },
| handleDownloadTpl(){
| NProgress.start();
| exportBlob(
| `/blade-mdm/flow/mgr/download-task-template`,
| { }
| ).then(res => {
| let name = res.headers['content-disposition'].split('filename=')[1]
| //console.log(res.headers['content-disposition'].split('filename=')[1]);
| name = decodeURI(name)
| //console.log(name)
| downloadFile(res.data, `${name}`);
| NProgress.done();
| });
| },
| handleDownload(){
| //window.open(`${baseUrl}/blade-system/flowmgr/download-impreuslt?id=${this.fileId}&blade-auth=bearer ${getToken()}`);
| // this.fileId =0;
| exportBlob(
| `/blade-mdm/flow/mgr/download-import-result`,
| {name:this.importResult.name,originalName:this.importResult.originalName}
|
| ).then(res => {
| let name = res.headers['content-disposition'].split('filename=')[1]
| //console.log(res.headers['content-disposition'].split('filename=')[1]);
| name = decodeURI(name)
| //console.log(name)
| downloadFile(res.data, `${name}`);
| NProgress.done();
| });
|
| }
| },
| };
| </script>
|
| <style lang="scss">
|
| </style>
|
|