fjcl.vue
6.43 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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
<template>
<div class="main">
<el-upload
class="upload-demo"
action="/api/file/uploadList"
:data="fileData"
:on-preview="handlePreview"
:on-remove="handleRemove"
:before-remove="beforeRemove"
:on-success="uploadSuccess"
:on-error="uploadError"
:show-file-list="false"
multiple
:on-exceed="handleExceed"
:disabled="isDisabled"
>
<el-button size="small" type="primary" :disabled="isDisabled" icon="iconfont iconshangchuan">上传</el-button>
</el-upload>
<table border="2">
<tr>
<th class="xh">序号</th>
<th class="mc">文件名称</th>
<th class="lx">文件类型</th>
<th class="cz">操作</th>
</tr>
<tr v-if="list.length===0">
<td colspan="4" class="noData">
<span>暂无数据</span>
</td>
</tr>
<tr v-else v-for="(item,index) in list" :key="index">
<td class="xh">{{index+1}}</td>
<td class="mc">{{item.filename}}</td>
<td class="lx">{{item.filepostfix}}</td>
<td class="cz">
<span @click="downloadFile(item.fileurl)">下载</span>
<span>/</span>
<span @click="loadFile(item.bsm)">预览</span>
<span>/</span>
<span @click="deleteFile(item.bsm)">删除</span>
</td>
</tr>
</table>
</div>
</template>
<script>
import {insertFile, getFileLis, downloadFile, loadFile, deleteFile} from "@api/common"
import {queryStatus} from "@api/search"
export default {
name: "fjcl",
data() {
return {
fileData: {
glbsm: '',
dylx: ''
},
list: []
}
},
mounted() {
this.getFileList()
},
created(){
},
props: {
isDisabled:{
type:Boolean,
default:false
}
},
methods: {
deleteFile(bsm) {
this.$confirm('将删除该文件, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
deleteFile(bsm).then(res => {
if (res.success) {
this.getFileList();
} else {
this.$message.error("删除失败")
}
})
}).catch(() => {
this.$message({
type: 'info',
message: '已取消'
});
});
},
loadFile(bsm) {
loadFile(bsm).then(res => {
if (res.success) {
window.open(res.message)
}
})
},
downloadFile(url) {
// window.open(`/api/file/download?url=` + url);
let downloadUrl= `/api/file/download?url=${url}`
let elemIF = document.createElement("iframe");
elemIF.src = downloadUrl;
elemIF.style.display = "none";
document.body.appendChild(elemIF)
},
getFileList() {
switch (this.$route.name) {
case "宗地":
this.fileData.dylx = 'zd';
this.fileData.glbsm = this.$store.state.zdbsm;
break;
case "自然幢":
this.fileData.dylx = 'zrz';
this.fileData.glbsm = this.$store.state.zrzbsm;
break;
case "多幢":
this.fileData.dylx = 'dz';
this.fileData.glbsm = this.$store.state.dzbsm;
break;
case "户":
this.fileData.dylx = 'h';
this.fileData.glbsm = this.$store.state.hbsm;
break;
default:
break
}
getFileLis(this.fileData.glbsm).then(res => {
if (res.success) {
this.list = res.result;
} else {
}
})
},
uploadError(err, file, fileList) {
console.log("上传文件失败", err)
},
uploadSuccess(res, file, fileList) {
this.getFileList();
},
handleRemove(file, fileList) {
console.log(file, fileList);
},
handlePreview(file) {
console.log(file);
},
handleExceed(files, fileList) {
console.log(fileList)
// this.$message.warning(`当前限制选择 3 个文件,本次选择了 ${files.length} 个文件,共选择了 ${files.length + fileList.length} 个文件`);
this.$message.warning("上传失败")
},
beforeRemove(file, fileList) {
return this.$confirm(`确定移除 ${ file.name }?`);
}
},
watch: {}
}
</script>
<style scoped lang="less">
.main {
box-sizing: border-box;
padding: 18px;
height: auto;
width: 100%;
}
table {
margin-top: 10px;
cursor: pointer;
background-color: #fff;
font-size: 14px;
width: 100%;
td, th {
text-align: center;
height: 36px;
min-width: 50px;
}
td span {
color: blue;
}
.cz span:hover {
color: blue;
text-decoration: underline;
}
.xh {
width: 100px;
}
.mc {
width: 300px;
}
.lx {
width: 120px;
}
.cz {
width: 150px;
}
.noData span {
color: #BBB;
}
}
</style>