importDialog.vue
1.9 KB
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
<template>
<el-dialog
title="上传应用"
:visible.sync="visible"
:show="show"
width="400px"
append-to-body
@close="$emit('update:show', false)"
>
<el-upload
ref="upload"
:limit="1"
:headers="headers"
:action="url + '?updateSupport=' + updateSupport"
:on-progress="uploadProgress"
:on-success="fileSuccess"
:auto-upload="false"
drag
>
<i class="el-icon-upload" />
<div class="el-upload__text">
将文件拖到此处,或
<em>点击上传</em>
</div>
<div slot="tip" class="el-upload__tip">
<el-checkbox v-model="updateSupport" />是否更新已经存在的应用数据
</div>
</el-upload>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitFileForm">确 定</el-button>
<el-button @click="visible = false">取 消</el-button>
</div>
</el-dialog>
</template>
<script>
import axios from "axios";
import { getToken } from "@/utils/auth";
export default {
props: {
show: {
type: Boolean,
default: false,
},
},
data() {
return {
visible: this.show,
headers: { Authorization: "Bearer " + getToken() },
isUploading: false,
url: process.env.VUE_APP_BASE_API + "/system/apkinfo/upload/updateApk",
updateSupport: 0,
};
},
watch: {
show() {
this.visible = this.show;
},
},
methods: {
// 文件上传中处理
uploadProgress(event, file, fileList) {
this.isUploading = true;
},
// 文件上传成功处理
fileSuccess(response, file, fileList) {
this.isUploading = false;
this.$refs.upload.clearFiles();
this.$alert(response.msg, "导入结果", { dangerouslyUseHTMLString: true });
this.$parent.getList();
},
// 提交上传文件
submitFileForm() {
this.$refs.upload.submit();
},
},
};
</script>