sxdr.vue
4.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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<template>
<div>
<el-dialog v-dialogDrag :close-on-click-modal="false"
title="属性导入"
:visible.sync="isVisible"
width="30%"
:before-close="close">
<div class="wrap">
<div class="main-button">
<el-upload
class="upload-demo"
action="/api/tx/excelGeo/import"
:data="sxdrData"
:on-success="uploadSuccess"
:show-file-list="false"
multiple
>
<el-button type="primary" icon="iconfont iconshangchuan">上传</el-button>
</el-upload>
</div>
<el-button type="primary" class="download" @click="downloadTemplate">下载模板</el-button>
</div>
<ul>
<li v-for="(item,index) in errorData" :key="index">{{item}}</li>
</ul>
<span slot="footer" class="dialog-footer">
<el-button @click="cancel">取 消</el-button>
<!-- <el-button type="primary" @click="confirm">确 定</el-button> -->
</span>
</el-dialog>
</div>
</template>
<script>
export default {
name: "sxdr",
props: {
sxdrVisible: {
type: Boolean,
default: false
},
dylx: {
type: String,
},
bsm: {
type: String
}
},
data() {
return {
isVisible: false,
sxdrData: {
bsm: '',
type:''
},
errorData: []
}
},
mounted() {
this.$store.state.sxdrType = '';
},
methods: {
cancel(){
this.close()
},
confirm(){
console.log("确定....")
},
loading() {
this.$store.state.sxdrType = this.dylx;
},
reset() {
this.errorData = [];
this.sxdrData = {bsm: ''};
},
close() {
this.$emit('close')
this.reset();
},
downloadTemplate() {
let url= `/api/tx/excelGeo/template?type=${this.dylx}`
let elemIF = document.createElement("iframe");
elemIF.src = url;
elemIF.style.display = "none";
document.body.appendChild(elemIF)
},
uploadSuccess(res, file, fileList) {
this.errorData = [];
if (res.success) {
this.$message.success("上传成功")
this.loading();
this.close()
} else {
if (res.result == null) {
this.$message.error(res.message)
} else {
this.$message.error("上传失败")
this.errorData = res.result;
}
}
},
uploadError(err, file, fileList) {
console.log("上传文件失败", err)
},
},
watch: {
sxdrVisible(val) {
this.isVisible = val;
},
dylx(val) {
this.sxdrData.type=val;
},
bsm(val) {
this.sxdrData.bsm = val;
}
}
}
</script>
<style scoped lang="less">
.wrap{
width: 100%;
height: 30px;
position: relative;
.main-button {
display: -webkit-flex;
display: flex;
flex-direction: column-reverse;
flex-wrap: nowrap;
position: absolute;
left: 165px;
top: 18px;
}
.download{
position: absolute;
left: 300px;
top: 18px;
}
}
ul {
margin-top: 40px;
li {
line-height: 20px;
color: red;
}
}
</style>