fjcl.vue
4.28 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
<template>
<div class="main">
<el-upload
class="upload-demo"
action="/api/file/uploadList"
:on-preview="handlePreview"
:on-remove="handleRemove"
:before-remove="beforeRemove"
:on-success="uploadSuccess"
:on-error="uploadError"
multiple
:limit="3"
:on-exceed="handleExceed"
>
<el-button size="small" type="primary">上传</el-button>
</el-upload>
<table border="2">
<tr>
<th>序号</th>
<th>文件名称</th>
<th>文件类型</th>
<th>操作</th>
</tr>
<tr v-for="(item,index) in list" :key="index">
<td>{{index+1}}</td>
<td>{{item.wjmc}}</td>
<td>{{item.wjlx}}</td>
<td>
<span>下载</span>
<span>预览</span>
</td>
</tr>
</table>
</div>
</template>
<script>
import {insertFile} from "./../../../api/common"
import {Message} from "element-ui"
export default {
name: "fjcl",
data() {
return {
list: [
{
wjmc: '调查文档1',
wjlx: 'doc',
url: ''
},
{
wjmc: '调查文档2',
wjlx: 'doc',
url: ''
},
{
wjmc: '调查文档3',
wjlx: 'doc',
url: ''
},
{
wjmc: '调查文档4',
wjlx: 'doc',
url: ''
},
],
filesData:{
dylx: "",
glbsm: "",
list: [
{
filename: "",
filepostfix: "",
fileurl: ""
}
]
},
}
},
mounted(){
switch (this.$route.name) {
case "宗地":
this.filesData.dylx='zd';
this.filesData.glbsm=this.$store.state.zdbsm
break;
case "自然幢":
this.filesData.dylx='zrz';
this.filesData.glbsm=this.$store.state.zrzbsm
break
default:
break
}
},
methods: {
uploadError(err,file,fileList){
console.log("上传文件失败",err)
},
uploadSuccess(res, file, fileList) {
this.filesData.list = res.result;
console.log(res,"res=========")
insertFile(this.filesData).then(res=>{
if (res.success) {
Message.warning("上传成功")
}else {
Message.error(res.message)
}
})
},
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} 个文件`);
},
beforeRemove(file, fileList) {
return this.$confirm(`确定移除 ${ file.name }?`);
}
},
watch:{
}
}
</script>
<style scoped lang="less">
.main {
box-sizing: border-box;
padding: 18px;
height: auto;
width: 80%;
}
table {
margin-top: 10px;
background-color: #fff;
font-size: 14px;
width: 100%;
td, th {
text-align: center;
height: 36px;
min-width: 50px;
}
}
</style>