ImportStore.vue
3.25 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
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>
<div>
<el-dialog title="批量导入" :visible.sync="dialogVisible" width="500px">
<div class="download_template">
<span>请下载门店模板,按格式修改后导入</span>
<el-button size="mini" type="text" plain @click="downloadFn">下载模板</el-button>
</div>
<div class="upload_content">
<el-upload
drag
accept=".xls, .xlsx"
:action="actionUrl"
:limit="1"
:headers="headers"
ref="upload"
:on-remove="handleRemove"
:on-change="setFileData"
:auto-upload="false">
<i class="el-icon-upload"></i>
<div style="font-size: 12px">
将文件拖拽到此区域
<p style="margin: 3px 0">仅支持xls、xlsx格式文件</p>
<el-button size="mini" type="primary" plain>上传文件</el-button>
</div>
</el-upload>
</div>
<div class="tip">
<div class="title">填写说明</div>
<div style="margin-bottom: 3px">1、门店名称、所属地区、门店地址必填;</div>
<div style="margin-bottom: 3px">2、门店名称不可重复,重复则自动过滤;</div>
<div>3、所属地区请务必按照“xxx省xxx市xxx区/县”格式填写。</div>
</div>
<span slot="footer" class="dialog-footer">
<el-button @click="dialogVisible = false">取 消</el-button>
<el-button type="primary" @click="submitImport" v-loading="submitLoading">确 定</el-button>
</span>
</el-dialog>
</div>
</template>
<script>
import { download, toFormData } from '@/utils/common'
import { downloadTemplate, uploadStore } from '@/api/drainageCode/store'
export default {
name: 'import-store',
data() {
return {
headers: window.lwConfig.headers,
submitLoading: false,
actionUrl: '',
file: '',
}
},
props: {
visible: {
type: Boolean,
default: false,
},
},
computed: {
dialogVisible: {
get() {
return this.visible
},
set(val) {
this.$emit('update:visible', val)
},
},
},
methods: {
submitImport() {
if (!this.file) {
this.msgInfo('请先上传文件!')
return false
}
uploadStore(toFormData({ file: this.file })).then((res) => {
if (res.code === 200) {
this.msgSuccess(res.data)
this.dialogVisible = false
this.$emit('update')
}
})
},
handleRemove() {},
setFileData(f, fl) {
this.file = f.raw
},
downloadFn() {
downloadTemplate().then((res) => {
if (res != null) {
download(res.data)
}
})
},
},
created() {},
}
</script>
<style lang="scss" scoped>
.download_template {
padding: 5px 20px;
// color: #ebb563;
background-color: #eee;
border-radius: 4px;
display: flex;
justify-content: space-between;
align-items: center;
}
.upload_content {
margin-top: 10px;
text-align: center;
::v-deep .el-upload-dragger {
width: 460px;
.el-icon-upload {
margin: 20px 0 16px;
}
}
}
.tip {
padding: 5px 20px;
margin-top: 10px;
font-size: 12px;
color: #999999;
.title {
margin-bottom: 10px;
font-size: 14px;
}
}
</style>