用户信息
Showing
2 changed files
with
59 additions
and
26 deletions
This diff is collapsed.
Click to expand it.
... | @@ -2,32 +2,45 @@ | ... | @@ -2,32 +2,45 @@ |
2 | <div class="from-clues"> | 2 | <div class="from-clues"> |
3 | <!-- 表单部分 --> | 3 | <!-- 表单部分 --> |
4 | <div class="from-clues-header"> | 4 | <div class="from-clues-header"> |
5 | <el-form :model="ruleForm" label-width="80px"> | 5 | <el-form :model="ruleForm" label-width="100px"> |
6 | <el-row> | 6 | <el-row> |
7 | <el-col :span="5"> | 7 | <el-col :span="6"> |
8 | <el-form-item label="电子签名"> | 8 | <el-form-item label="用户名称:"> |
9 | <el-input v-model="ruleForm.dzqm"></el-input> | 9 | {{ruleForm.name}} |
10 | </el-form-item> | 10 | </el-form-item> |
11 | </el-col> | 11 | </el-col> |
12 | <el-col :span="19" class="btnColRight"> | 12 | <el-col :span="6"> |
13 | <el-form-item> | 13 | <el-form-item label="组织机构:"> |
14 | <el-button type="primary" native-type="submit">查询</el-button> | 14 | {{ruleForm.organizationName}} |
15 | </el-form-item> | ||
16 | </el-col> | ||
17 | <el-col :span="6"> | ||
18 | <el-form-item label="部门:"> | ||
19 | {{ruleForm.departmentName}} | ||
20 | </el-form-item> | ||
21 | </el-col> | ||
22 | </el-row> | ||
23 | <el-row> | ||
24 | <el-col :span="24"> | ||
25 | <el-form-item label="签名路径:"> | ||
26 | <img :src="ruleForm.dzqmurl" class="signature-image"> | ||
15 | </el-form-item> | 27 | </el-form-item> |
16 | </el-col> | 28 | </el-col> |
17 | </el-row> | 29 | </el-row> |
18 | </el-form> | 30 | </el-form> |
19 | </div> | 31 | </div> |
32 | |||
20 | <el-upload | 33 | <el-upload |
21 | class="upload-demo" | 34 | class="upload-demo" |
22 | action="" | 35 | action="" |
23 | :limit="1" | 36 | :limit="1" |
24 | multiple | 37 | multiple |
38 | :key="key" | ||
25 | :auto-upload="false" | 39 | :auto-upload="false" |
26 | accept=".jpg, .png" | 40 | accept=".jpg, .png, .jpeg" |
27 | :on-change="handleChange" | 41 | :on-change="handleChange" |
28 | :before-upload="beforeUpload" | 42 | :before-upload="beforeUpload" |
29 | :file-list="fileList" | 43 | :show-file-list="false" |
30 | list-type="picture" | ||
31 | drag> | 44 | drag> |
32 | <i class="el-icon-upload"></i> | 45 | <i class="el-icon-upload"></i> |
33 | <div class="el-upload__text">将图片拖到此处,或<em>点击上传</em></div> | 46 | <div class="el-upload__text">将图片拖到此处,或<em>点击上传</em></div> |
... | @@ -38,36 +51,51 @@ | ... | @@ -38,36 +51,51 @@ |
38 | </template> | 51 | </template> |
39 | <script> | 52 | <script> |
40 | import { dzqmUpload } from '@/api/dzqm' | 53 | import { dzqmUpload } from '@/api/dzqm' |
54 | import { getUserInfo } from '@/api/user' | ||
41 | export default { | 55 | export default { |
42 | name: "dzqm", | 56 | name: "dzqm", |
43 | data () { | 57 | data () { |
44 | return { | 58 | return { |
45 | ruleForm: { | 59 | ruleForm: {}, |
46 | dzqm: "" | 60 | key: 0, |
47 | }, | ||
48 | fileList: [], // 已上传文件列表 | ||
49 | } | 61 | } |
50 | }, | 62 | }, |
63 | mounted () { | ||
64 | this.getUserInfo() | ||
65 | }, | ||
51 | methods: { | 66 | methods: { |
67 | async getUserInfo () { | ||
68 | let res = await getUserInfo() | ||
69 | this.ruleForm = res.result | ||
70 | }, | ||
52 | beforeUpload (file) { | 71 | beforeUpload (file) { |
53 | // 上传文件之前的钩子,返回false则停止上传 | 72 | this.files = file; |
54 | const isJPGorPNG = file.type === 'image/jpeg' || file.type === 'image/png'; | 73 | const allowedExtensions = ['jpg', 'jpeg', 'png']; |
55 | const isLt2M = file.size / 1024 / 1024 < 5; | 74 | const maxFileSizeMB = 5; |
56 | if (!isJPGorPNG) { | 75 | |
57 | this.$message.error('上传图片只能是 JPG/PNG 格式!'); | 76 | const extension = allowedExtensions.includes(file.name.split('.').pop().toLowerCase()); |
58 | return false; | 77 | const isLt5M = file.size / 1024 / 1024 < maxFileSizeMB; |
59 | } | 78 | |
60 | if (!isLt2M) { | 79 | if (!extension) { |
61 | this.$message.error('上传图片大小不能超过 5MB!'); | 80 | this.$message.warning('上传模板只能是 jpg、jpeg、png 格式!'); |
62 | return false; | 81 | } else if (!isLt5M) { |
82 | this.$message.warning(`上传模板大小不能超过 ${maxFileSizeMB}MB!`); | ||
63 | } | 83 | } |
64 | return true; | 84 | |
85 | return extension && isLt5M; | ||
65 | }, | 86 | }, |
66 | async handleChange (file) { | 87 | async handleChange (file) { |
67 | var formdata = new FormData(); | 88 | var formdata = new FormData(); |
68 | formdata.append("file", file.raw); | 89 | formdata.append("file", file.raw); |
69 | dzqmUpload(formdata).then(res => { | 90 | dzqmUpload(formdata).then(res => { |
70 | console.log(res); | 91 | if (res.code == 200) { |
92 | this.$message({ | ||
93 | message: '上传成功!', | ||
94 | type: 'success' | ||
95 | }) | ||
96 | this.key++ | ||
97 | this.ruleForm.dzqmurl = res.message | ||
98 | } | ||
71 | }) | 99 | }) |
72 | } | 100 | } |
73 | } | 101 | } |
... | @@ -75,5 +103,10 @@ | ... | @@ -75,5 +103,10 @@ |
75 | </script> | 103 | </script> |
76 | <style scoped lang="scss"> | 104 | <style scoped lang="scss"> |
77 | @import "~@/styles/public.scss"; | 105 | @import "~@/styles/public.scss"; |
106 | .signature-image { | ||
107 | width: 100%; | ||
108 | max-height: 360px; | ||
109 | object-fit: contain; | ||
110 | } | ||
78 | </style> | 111 | </style> |
79 | 112 | ||
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
-
Please register or sign in to post a comment