dzqm.vue
2.18 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
<template>
<div class="from-clues">
<!-- 表单部分 -->
<div class="from-clues-header">
<el-form :model="ruleForm" label-width="80px">
<el-row>
<el-col :span="5">
<el-form-item label="电子签名">
<el-input v-model="ruleForm.dzqm"></el-input>
</el-form-item>
</el-col>
<el-col :span="19" class="btnColRight">
<el-form-item>
<el-button type="primary" native-type="submit">查询</el-button>
</el-form-item>
</el-col>
</el-row>
</el-form>
</div>
<el-upload
class="upload-demo"
action=""
:limit="1"
multiple
:auto-upload="false"
accept=".jpg, .png"
:on-change="handleChange"
:before-upload="beforeUpload"
:file-list="fileList"
list-type="picture"
drag>
<i class="el-icon-upload"></i>
<div class="el-upload__text">将图片拖到此处,或<em>点击上传</em></div>
<div class="el-upload__tip" slot="tip">只能上传jpg/png文件,且不超过5MB</div>
</el-upload>
<!-- 表格 -->
</div>
</template>
<script>
import { dzqmUpload } from '@/api/dzqm'
export default {
name: "dzqm",
data () {
return {
ruleForm: {
dzqm: ""
},
fileList: [], // 已上传文件列表
}
},
methods: {
beforeUpload (file) {
// 上传文件之前的钩子,返回false则停止上传
const isJPGorPNG = file.type === 'image/jpeg' || file.type === 'image/png';
const isLt2M = file.size / 1024 / 1024 < 5;
if (!isJPGorPNG) {
this.$message.error('上传图片只能是 JPG/PNG 格式!');
return false;
}
if (!isLt2M) {
this.$message.error('上传图片大小不能超过 5MB!');
return false;
}
return true;
},
async handleChange (file) {
var formdata = new FormData();
formdata.append("file", file.raw);
dzqmUpload(formdata).then(res => {
console.log(res);
})
}
}
};
</script>
<style scoped lang="scss">
@import "~@/styles/public.scss";
</style>