提交者
Gitee
!604 修复小屏幕上修改头像界面布局错位的问题
Merge pull request !604 from 也曾为你、像超人/master
正在显示
2 个修改的文件
包含
459 行增加
和
445 行删除
| 1 | - /** | ||
| 2 | - * 通用css样式布局处理 | ||
| 3 | - * Copyright (c) 2019 ruoyi | ||
| 4 | - */ | ||
| 5 | - | ||
| 6 | - /** 基础通用 **/ | ||
| 7 | -.pt5 { | ||
| 8 | - padding-top: 5px; | ||
| 9 | -} | ||
| 10 | -.pr5 { | ||
| 11 | - padding-right: 5px; | ||
| 12 | -} | ||
| 13 | -.pb5 { | ||
| 14 | - padding-bottom: 5px; | ||
| 15 | -} | ||
| 16 | -.mt5 { | ||
| 17 | - margin-top: 5px; | ||
| 18 | -} | ||
| 19 | -.mr5 { | ||
| 20 | - margin-right: 5px; | ||
| 21 | -} | ||
| 22 | -.mb5 { | ||
| 23 | - margin-bottom: 5px; | ||
| 24 | -} | ||
| 25 | -.mb8 { | ||
| 26 | - margin-bottom: 8px; | ||
| 27 | -} | ||
| 28 | -.ml5 { | ||
| 29 | - margin-left: 5px; | ||
| 30 | -} | ||
| 31 | -.mt10 { | ||
| 32 | - margin-top: 10px; | ||
| 33 | -} | ||
| 34 | -.mr10 { | ||
| 35 | - margin-right: 10px; | ||
| 36 | -} | ||
| 37 | -.mb10 { | ||
| 38 | - margin-bottom: 10px; | ||
| 39 | -} | ||
| 40 | -.ml10 { | ||
| 41 | - margin-left: 10px; | ||
| 42 | -} | ||
| 43 | -.mt20 { | ||
| 44 | - margin-top: 20px; | ||
| 45 | -} | ||
| 46 | -.mr20 { | ||
| 47 | - margin-right: 20px; | ||
| 48 | -} | ||
| 49 | -.mb20 { | ||
| 50 | - margin-bottom: 20px; | ||
| 51 | -} | ||
| 52 | -.ml20 { | ||
| 53 | - margin-left: 20px; | ||
| 54 | -} | ||
| 55 | - | ||
| 56 | -.h1, .h2, .h3, .h4, .h5, .h6, h1, h2, h3, h4, h5, h6 { | ||
| 57 | - font-family: inherit; | ||
| 58 | - font-weight: 500; | ||
| 59 | - line-height: 1.1; | ||
| 60 | - color: inherit; | ||
| 61 | -} | ||
| 62 | - | ||
| 63 | -.el-dialog:not(.is-fullscreen) { | ||
| 64 | - margin-top: 6vh !important; | ||
| 65 | -} | ||
| 66 | - | ||
| 67 | -.el-dialog__wrapper.scrollbar .el-dialog .el-dialog__body { | ||
| 68 | - overflow: auto; | ||
| 69 | - overflow-x: hidden; | ||
| 70 | - max-height: 70vh; | ||
| 71 | - padding: 10px 20px 0; | ||
| 72 | -} | ||
| 73 | - | ||
| 74 | -.el-table { | ||
| 75 | - .el-table__header-wrapper, .el-table__fixed-header-wrapper { | ||
| 76 | - th { | ||
| 77 | - word-break: break-word; | ||
| 78 | - background-color: #f8f8f9; | ||
| 79 | - color: #515a6e; | ||
| 80 | - height: 40px; | ||
| 81 | - font-size: 13px; | ||
| 82 | - } | ||
| 83 | - } | ||
| 84 | - .el-table__body-wrapper { | ||
| 85 | - .el-button [class*="el-icon-"] + span { | ||
| 86 | - margin-left: 1px; | ||
| 87 | - } | ||
| 88 | - } | ||
| 89 | -} | ||
| 90 | - | ||
| 91 | -/** 表单布局 **/ | ||
| 92 | -.form-header { | ||
| 93 | - font-size:15px; | ||
| 94 | - color:#6379bb; | ||
| 95 | - border-bottom:1px solid #ddd; | ||
| 96 | - margin:8px 10px 25px 10px; | ||
| 97 | - padding-bottom:5px | ||
| 98 | -} | ||
| 99 | - | ||
| 100 | -/** 表格布局 **/ | ||
| 101 | -.pagination-container { | ||
| 102 | - position: relative; | ||
| 103 | - height: 25px; | ||
| 104 | - margin-bottom: 10px; | ||
| 105 | - margin-top: 15px; | ||
| 106 | - padding: 10px 20px !important; | ||
| 107 | -} | ||
| 108 | - | ||
| 109 | -/* tree border */ | ||
| 110 | -.tree-border { | ||
| 111 | - margin-top: 5px; | ||
| 112 | - border: 1px solid #e5e6e7; | ||
| 113 | - background: #FFFFFF none; | ||
| 114 | - border-radius:4px; | ||
| 115 | -} | ||
| 116 | - | ||
| 117 | -.pagination-container .el-pagination { | ||
| 118 | - right: 0; | ||
| 119 | - position: absolute; | ||
| 120 | -} | ||
| 121 | - | ||
| 122 | -@media ( max-width : 768px) { | ||
| 123 | - .pagination-container .el-pagination > .el-pagination__jump { | ||
| 124 | - display: none !important; | ||
| 125 | - } | ||
| 126 | - .pagination-container .el-pagination > .el-pagination__sizes { | ||
| 127 | - display: none !important; | ||
| 128 | - } | ||
| 129 | -} | ||
| 130 | - | ||
| 131 | -.el-table .fixed-width .el-button--mini { | ||
| 132 | - padding-left: 0; | ||
| 133 | - padding-right: 0; | ||
| 134 | - width: inherit; | ||
| 135 | -} | ||
| 136 | - | ||
| 137 | -/** 表格更多操作下拉样式 */ | ||
| 138 | -.el-table .el-dropdown-link { | ||
| 139 | - cursor: pointer; | ||
| 140 | - color: #409EFF; | ||
| 141 | - margin-left: 5px; | ||
| 142 | -} | ||
| 143 | - | ||
| 144 | -.el-table .el-dropdown, .el-icon-arrow-down { | ||
| 145 | - font-size: 12px; | ||
| 146 | -} | ||
| 147 | - | ||
| 148 | -.el-tree-node__content > .el-checkbox { | ||
| 149 | - margin-right: 8px; | ||
| 150 | -} | ||
| 151 | - | ||
| 152 | -.list-group-striped > .list-group-item { | ||
| 153 | - border-left: 0; | ||
| 154 | - border-right: 0; | ||
| 155 | - border-radius: 0; | ||
| 156 | - padding-left: 0; | ||
| 157 | - padding-right: 0; | ||
| 158 | -} | ||
| 159 | - | ||
| 160 | -.list-group { | ||
| 161 | - padding-left: 0px; | ||
| 162 | - list-style: none; | ||
| 163 | -} | ||
| 164 | - | ||
| 165 | -.list-group-item { | ||
| 166 | - border-bottom: 1px solid #e7eaec; | ||
| 167 | - border-top: 1px solid #e7eaec; | ||
| 168 | - margin-bottom: -1px; | ||
| 169 | - padding: 11px 0px; | ||
| 170 | - font-size: 13px; | ||
| 171 | -} | ||
| 172 | - | ||
| 173 | -.pull-right { | ||
| 174 | - float: right !important; | ||
| 175 | -} | ||
| 176 | - | ||
| 177 | -.el-card__header { | ||
| 178 | - padding: 14px 15px 7px; | ||
| 179 | - min-height: 40px; | ||
| 180 | -} | ||
| 181 | - | ||
| 182 | -.el-card__body { | ||
| 183 | - padding: 15px 20px 20px 20px; | ||
| 184 | -} | ||
| 185 | - | ||
| 186 | -.card-box { | ||
| 187 | - padding-right: 15px; | ||
| 188 | - padding-left: 15px; | ||
| 189 | - margin-bottom: 10px; | ||
| 190 | -} | ||
| 191 | - | ||
| 192 | -/* button color */ | ||
| 193 | -.el-button--cyan.is-active, | ||
| 194 | -.el-button--cyan:active { | ||
| 195 | - background: #20B2AA; | ||
| 196 | - border-color: #20B2AA; | ||
| 197 | - color: #FFFFFF; | ||
| 198 | -} | ||
| 199 | - | ||
| 200 | -.el-button--cyan:focus, | ||
| 201 | -.el-button--cyan:hover { | ||
| 202 | - background: #48D1CC; | ||
| 203 | - border-color: #48D1CC; | ||
| 204 | - color: #FFFFFF; | ||
| 205 | -} | ||
| 206 | - | ||
| 207 | -.el-button--cyan { | ||
| 208 | - background-color: #20B2AA; | ||
| 209 | - border-color: #20B2AA; | ||
| 210 | - color: #FFFFFF; | ||
| 211 | -} | ||
| 212 | - | ||
| 213 | -/* text color */ | ||
| 214 | -.text-navy { | ||
| 215 | - color: #1ab394; | ||
| 216 | -} | ||
| 217 | - | ||
| 218 | -.text-primary { | ||
| 219 | - color: inherit; | ||
| 220 | -} | ||
| 221 | - | ||
| 222 | -.text-success { | ||
| 223 | - color: #1c84c6; | ||
| 224 | -} | ||
| 225 | - | ||
| 226 | -.text-info { | ||
| 227 | - color: #23c6c8; | ||
| 228 | -} | ||
| 229 | - | ||
| 230 | -.text-warning { | ||
| 231 | - color: #f8ac59; | ||
| 232 | -} | ||
| 233 | - | ||
| 234 | -.text-danger { | ||
| 235 | - color: #ed5565; | ||
| 236 | -} | ||
| 237 | - | ||
| 238 | -.text-muted { | ||
| 239 | - color: #888888; | ||
| 240 | -} | ||
| 241 | - | ||
| 242 | -/* image */ | ||
| 243 | -.img-circle { | ||
| 244 | - border-radius: 50%; | ||
| 245 | -} | ||
| 246 | - | ||
| 247 | -.img-lg { | ||
| 248 | - width: 120px; | ||
| 249 | - height: 120px; | ||
| 250 | -} | ||
| 251 | - | ||
| 252 | -.avatar-upload-preview { | ||
| 253 | - position: absolute; | ||
| 254 | - top: 50%; | ||
| 255 | - transform: translate(50%, -50%); | ||
| 256 | - width: 200px; | ||
| 257 | - height: 200px; | ||
| 258 | - border-radius: 50%; | ||
| 259 | - box-shadow: 0 0 4px #ccc; | ||
| 260 | - overflow: hidden; | ||
| 261 | -} | ||
| 262 | - | ||
| 263 | -/* 拖拽列样式 */ | ||
| 264 | -.sortable-ghost{ | ||
| 265 | - opacity: .8; | ||
| 266 | - color: #fff!important; | ||
| 267 | - background: #42b983!important; | ||
| 268 | -} | ||
| 269 | - | ||
| 270 | -.top-right-btn { | ||
| 271 | - position: relative; | ||
| 272 | - float: right; | ||
| 273 | -} | 1 | + /** |
| 2 | + * 通用css样式布局处理 | ||
| 3 | + * Copyright (c) 2019 ruoyi | ||
| 4 | + */ | ||
| 5 | + | ||
| 6 | + /** 基础通用 **/ | ||
| 7 | +.pt5 { | ||
| 8 | + padding-top: 5px; | ||
| 9 | +} | ||
| 10 | +.pr5 { | ||
| 11 | + padding-right: 5px; | ||
| 12 | +} | ||
| 13 | +.pb5 { | ||
| 14 | + padding-bottom: 5px; | ||
| 15 | +} | ||
| 16 | +.mt5 { | ||
| 17 | + margin-top: 5px; | ||
| 18 | +} | ||
| 19 | +.mr5 { | ||
| 20 | + margin-right: 5px; | ||
| 21 | +} | ||
| 22 | +.mb5 { | ||
| 23 | + margin-bottom: 5px; | ||
| 24 | +} | ||
| 25 | +.mb8 { | ||
| 26 | + margin-bottom: 8px; | ||
| 27 | +} | ||
| 28 | +.ml5 { | ||
| 29 | + margin-left: 5px; | ||
| 30 | +} | ||
| 31 | +.mt10 { | ||
| 32 | + margin-top: 10px; | ||
| 33 | +} | ||
| 34 | +.mr10 { | ||
| 35 | + margin-right: 10px; | ||
| 36 | +} | ||
| 37 | +.mb10 { | ||
| 38 | + margin-bottom: 10px; | ||
| 39 | +} | ||
| 40 | +.ml10 { | ||
| 41 | + margin-left: 10px; | ||
| 42 | +} | ||
| 43 | +.mt20 { | ||
| 44 | + margin-top: 20px; | ||
| 45 | +} | ||
| 46 | +.mr20 { | ||
| 47 | + margin-right: 20px; | ||
| 48 | +} | ||
| 49 | +.mb20 { | ||
| 50 | + margin-bottom: 20px; | ||
| 51 | +} | ||
| 52 | +.ml20 { | ||
| 53 | + margin-left: 20px; | ||
| 54 | +} | ||
| 55 | + | ||
| 56 | +.h1, .h2, .h3, .h4, .h5, .h6, h1, h2, h3, h4, h5, h6 { | ||
| 57 | + font-family: inherit; | ||
| 58 | + font-weight: 500; | ||
| 59 | + line-height: 1.1; | ||
| 60 | + color: inherit; | ||
| 61 | +} | ||
| 62 | + | ||
| 63 | +.el-dialog:not(.is-fullscreen) { | ||
| 64 | + margin-top: 6vh !important; | ||
| 65 | +} | ||
| 66 | + | ||
| 67 | +.el-dialog__wrapper.scrollbar .el-dialog .el-dialog__body { | ||
| 68 | + overflow: auto; | ||
| 69 | + overflow-x: hidden; | ||
| 70 | + max-height: 70vh; | ||
| 71 | + padding: 10px 20px 0; | ||
| 72 | +} | ||
| 73 | + | ||
| 74 | +.el-table { | ||
| 75 | + .el-table__header-wrapper, .el-table__fixed-header-wrapper { | ||
| 76 | + th { | ||
| 77 | + word-break: break-word; | ||
| 78 | + background-color: #f8f8f9; | ||
| 79 | + color: #515a6e; | ||
| 80 | + height: 40px; | ||
| 81 | + font-size: 13px; | ||
| 82 | + } | ||
| 83 | + } | ||
| 84 | + .el-table__body-wrapper { | ||
| 85 | + .el-button [class*="el-icon-"] + span { | ||
| 86 | + margin-left: 1px; | ||
| 87 | + } | ||
| 88 | + } | ||
| 89 | +} | ||
| 90 | + | ||
| 91 | +/** 表单布局 **/ | ||
| 92 | +.form-header { | ||
| 93 | + font-size:15px; | ||
| 94 | + color:#6379bb; | ||
| 95 | + border-bottom:1px solid #ddd; | ||
| 96 | + margin:8px 10px 25px 10px; | ||
| 97 | + padding-bottom:5px | ||
| 98 | +} | ||
| 99 | + | ||
| 100 | +/** 表格布局 **/ | ||
| 101 | +.pagination-container { | ||
| 102 | + position: relative; | ||
| 103 | + height: 25px; | ||
| 104 | + margin-bottom: 10px; | ||
| 105 | + margin-top: 15px; | ||
| 106 | + padding: 10px 20px !important; | ||
| 107 | +} | ||
| 108 | + | ||
| 109 | +/* tree border */ | ||
| 110 | +.tree-border { | ||
| 111 | + margin-top: 5px; | ||
| 112 | + border: 1px solid #e5e6e7; | ||
| 113 | + background: #FFFFFF none; | ||
| 114 | + border-radius:4px; | ||
| 115 | +} | ||
| 116 | + | ||
| 117 | +.pagination-container .el-pagination { | ||
| 118 | + right: 0; | ||
| 119 | + position: absolute; | ||
| 120 | +} | ||
| 121 | + | ||
| 122 | +@media ( max-width : 768px) { | ||
| 123 | + .pagination-container .el-pagination > .el-pagination__jump { | ||
| 124 | + display: none !important; | ||
| 125 | + } | ||
| 126 | + .pagination-container .el-pagination > .el-pagination__sizes { | ||
| 127 | + display: none !important; | ||
| 128 | + } | ||
| 129 | +} | ||
| 130 | + | ||
| 131 | +.el-table .fixed-width .el-button--mini { | ||
| 132 | + padding-left: 0; | ||
| 133 | + padding-right: 0; | ||
| 134 | + width: inherit; | ||
| 135 | +} | ||
| 136 | + | ||
| 137 | +/** 表格更多操作下拉样式 */ | ||
| 138 | +.el-table .el-dropdown-link { | ||
| 139 | + cursor: pointer; | ||
| 140 | + color: #409EFF; | ||
| 141 | + margin-left: 5px; | ||
| 142 | +} | ||
| 143 | + | ||
| 144 | +.el-table .el-dropdown, .el-icon-arrow-down { | ||
| 145 | + font-size: 12px; | ||
| 146 | +} | ||
| 147 | + | ||
| 148 | +.el-tree-node__content > .el-checkbox { | ||
| 149 | + margin-right: 8px; | ||
| 150 | +} | ||
| 151 | + | ||
| 152 | +.list-group-striped > .list-group-item { | ||
| 153 | + border-left: 0; | ||
| 154 | + border-right: 0; | ||
| 155 | + border-radius: 0; | ||
| 156 | + padding-left: 0; | ||
| 157 | + padding-right: 0; | ||
| 158 | +} | ||
| 159 | + | ||
| 160 | +.list-group { | ||
| 161 | + padding-left: 0px; | ||
| 162 | + list-style: none; | ||
| 163 | +} | ||
| 164 | + | ||
| 165 | +.list-group-item { | ||
| 166 | + border-bottom: 1px solid #e7eaec; | ||
| 167 | + border-top: 1px solid #e7eaec; | ||
| 168 | + margin-bottom: -1px; | ||
| 169 | + padding: 11px 0px; | ||
| 170 | + font-size: 13px; | ||
| 171 | +} | ||
| 172 | + | ||
| 173 | +.pull-right { | ||
| 174 | + float: right !important; | ||
| 175 | +} | ||
| 176 | + | ||
| 177 | +.el-card__header { | ||
| 178 | + padding: 14px 15px 7px; | ||
| 179 | + min-height: 40px; | ||
| 180 | +} | ||
| 181 | + | ||
| 182 | +.el-card__body { | ||
| 183 | + padding: 15px 20px 20px 20px; | ||
| 184 | +} | ||
| 185 | + | ||
| 186 | +.card-box { | ||
| 187 | + padding-right: 15px; | ||
| 188 | + padding-left: 15px; | ||
| 189 | + margin-bottom: 10px; | ||
| 190 | +} | ||
| 191 | + | ||
| 192 | +/* button color */ | ||
| 193 | +.el-button--cyan.is-active, | ||
| 194 | +.el-button--cyan:active { | ||
| 195 | + background: #20B2AA; | ||
| 196 | + border-color: #20B2AA; | ||
| 197 | + color: #FFFFFF; | ||
| 198 | +} | ||
| 199 | + | ||
| 200 | +.el-button--cyan:focus, | ||
| 201 | +.el-button--cyan:hover { | ||
| 202 | + background: #48D1CC; | ||
| 203 | + border-color: #48D1CC; | ||
| 204 | + color: #FFFFFF; | ||
| 205 | +} | ||
| 206 | + | ||
| 207 | +.el-button--cyan { | ||
| 208 | + background-color: #20B2AA; | ||
| 209 | + border-color: #20B2AA; | ||
| 210 | + color: #FFFFFF; | ||
| 211 | +} | ||
| 212 | + | ||
| 213 | +/* text color */ | ||
| 214 | +.text-navy { | ||
| 215 | + color: #1ab394; | ||
| 216 | +} | ||
| 217 | + | ||
| 218 | +.text-primary { | ||
| 219 | + color: inherit; | ||
| 220 | +} | ||
| 221 | + | ||
| 222 | +.text-success { | ||
| 223 | + color: #1c84c6; | ||
| 224 | +} | ||
| 225 | + | ||
| 226 | +.text-info { | ||
| 227 | + color: #23c6c8; | ||
| 228 | +} | ||
| 229 | + | ||
| 230 | +.text-warning { | ||
| 231 | + color: #f8ac59; | ||
| 232 | +} | ||
| 233 | + | ||
| 234 | +.text-danger { | ||
| 235 | + color: #ed5565; | ||
| 236 | +} | ||
| 237 | + | ||
| 238 | +.text-muted { | ||
| 239 | + color: #888888; | ||
| 240 | +} | ||
| 241 | + | ||
| 242 | +/* image */ | ||
| 243 | +.img-circle { | ||
| 244 | + border-radius: 50%; | ||
| 245 | +} | ||
| 246 | + | ||
| 247 | +.img-lg { | ||
| 248 | + width: 120px; | ||
| 249 | + height: 120px; | ||
| 250 | +} | ||
| 251 | + | ||
| 252 | +.avatar-upload-preview { | ||
| 253 | + position: relative; | ||
| 254 | + top: 50%; | ||
| 255 | + left: 50%; | ||
| 256 | + transform: translate(-50%, -50%); | ||
| 257 | + width: 200px; | ||
| 258 | + height: 200px; | ||
| 259 | + border-radius: 50%; | ||
| 260 | + box-shadow: 0 0 4px #ccc; | ||
| 261 | + overflow: hidden; | ||
| 262 | +} | ||
| 263 | + | ||
| 264 | +/* 拖拽列样式 */ | ||
| 265 | +.sortable-ghost{ | ||
| 266 | + opacity: .8; | ||
| 267 | + color: #fff!important; | ||
| 268 | + background: #42b983!important; | ||
| 269 | +} | ||
| 270 | + | ||
| 271 | +.top-right-btn { | ||
| 272 | + position: relative; | ||
| 273 | + float: right; | ||
| 274 | +} |
| 1 | -<template> | ||
| 2 | - <div> | ||
| 3 | - <div class="user-info-head" @click="editCropper()"><img v-bind:src="options.img" title="点击上传头像" class="img-circle img-lg" /></div> | ||
| 4 | - <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body @opened="modalOpened" @close="closeDialog"> | ||
| 5 | - <el-row> | ||
| 6 | - <el-col :xs="24" :md="12" :style="{height: '350px'}"> | ||
| 7 | - <vue-cropper | ||
| 8 | - ref="cropper" | ||
| 9 | - :img="options.img" | ||
| 10 | - :info="true" | ||
| 11 | - :autoCrop="options.autoCrop" | ||
| 12 | - :autoCropWidth="options.autoCropWidth" | ||
| 13 | - :autoCropHeight="options.autoCropHeight" | ||
| 14 | - :fixedBox="options.fixedBox" | ||
| 15 | - @realTime="realTime" | ||
| 16 | - v-if="visible" | ||
| 17 | - /> | ||
| 18 | - </el-col> | ||
| 19 | - <el-col :xs="24" :md="12" :style="{height: '350px'}"> | ||
| 20 | - <div class="avatar-upload-preview"> | ||
| 21 | - <img :src="previews.url" :style="previews.img" /> | ||
| 22 | - </div> | ||
| 23 | - </el-col> | ||
| 24 | - </el-row> | ||
| 25 | - <br /> | ||
| 26 | - <el-row> | ||
| 27 | - <el-col :lg="2" :md="2"> | ||
| 28 | - <el-upload action="#" :http-request="requestUpload" :show-file-list="false" :before-upload="beforeUpload"> | ||
| 29 | - <el-button size="small"> | ||
| 30 | - 选择 | ||
| 31 | - <i class="el-icon-upload el-icon--right"></i> | ||
| 32 | - </el-button> | ||
| 33 | - </el-upload> | ||
| 34 | - </el-col> | ||
| 35 | - <el-col :lg="{span: 1, offset: 2}" :md="2"> | ||
| 36 | - <el-button icon="el-icon-plus" size="small" @click="changeScale(1)"></el-button> | ||
| 37 | - </el-col> | ||
| 38 | - <el-col :lg="{span: 1, offset: 1}" :md="2"> | ||
| 39 | - <el-button icon="el-icon-minus" size="small" @click="changeScale(-1)"></el-button> | ||
| 40 | - </el-col> | ||
| 41 | - <el-col :lg="{span: 1, offset: 1}" :md="2"> | ||
| 42 | - <el-button icon="el-icon-refresh-left" size="small" @click="rotateLeft()"></el-button> | ||
| 43 | - </el-col> | ||
| 44 | - <el-col :lg="{span: 1, offset: 1}" :md="2"> | ||
| 45 | - <el-button icon="el-icon-refresh-right" size="small" @click="rotateRight()"></el-button> | ||
| 46 | - </el-col> | ||
| 47 | - <el-col :lg="{span: 2, offset: 6}" :md="2"> | ||
| 48 | - <el-button type="primary" size="small" @click="uploadImg()">提 交</el-button> | ||
| 49 | - </el-col> | ||
| 50 | - </el-row> | ||
| 51 | - </el-dialog> | ||
| 52 | - </div> | ||
| 53 | -</template> | ||
| 54 | - | ||
| 55 | -<script> | ||
| 56 | -import store from "@/store"; | ||
| 57 | -import { VueCropper } from "vue-cropper"; | ||
| 58 | -import { uploadAvatar } from "@/api/system/user"; | ||
| 59 | - | ||
| 60 | -export default { | ||
| 61 | - components: { VueCropper }, | ||
| 62 | - props: { | ||
| 63 | - user: { | ||
| 64 | - type: Object | ||
| 65 | - } | ||
| 66 | - }, | ||
| 67 | - data() { | ||
| 68 | - return { | ||
| 69 | - // 是否显示弹出层 | ||
| 70 | - open: false, | ||
| 71 | - // 是否显示cropper | ||
| 72 | - visible: false, | ||
| 73 | - // 弹出层标题 | ||
| 74 | - title: "修改头像", | ||
| 75 | - options: { | ||
| 76 | - img: store.getters.avatar, //裁剪图片的地址 | ||
| 77 | - autoCrop: true, // 是否默认生成截图框 | ||
| 78 | - autoCropWidth: 200, // 默认生成截图框宽度 | ||
| 79 | - autoCropHeight: 200, // 默认生成截图框高度 | ||
| 80 | - fixedBox: true // 固定截图框大小 不允许改变 | ||
| 81 | - }, | ||
| 82 | - previews: {} | ||
| 83 | - }; | ||
| 84 | - }, | ||
| 85 | - methods: { | ||
| 86 | - // 编辑头像 | ||
| 87 | - editCropper() { | ||
| 88 | - this.open = true; | ||
| 89 | - }, | ||
| 90 | - // 打开弹出层结束时的回调 | ||
| 91 | - modalOpened() { | ||
| 92 | - this.visible = true; | ||
| 93 | - }, | ||
| 94 | - // 覆盖默认的上传行为 | ||
| 95 | - requestUpload() { | ||
| 96 | - }, | ||
| 97 | - // 向左旋转 | ||
| 98 | - rotateLeft() { | ||
| 99 | - this.$refs.cropper.rotateLeft(); | ||
| 100 | - }, | ||
| 101 | - // 向右旋转 | ||
| 102 | - rotateRight() { | ||
| 103 | - this.$refs.cropper.rotateRight(); | ||
| 104 | - }, | ||
| 105 | - // 图片缩放 | ||
| 106 | - changeScale(num) { | ||
| 107 | - num = num || 1; | ||
| 108 | - this.$refs.cropper.changeScale(num); | ||
| 109 | - }, | ||
| 110 | - // 上传预处理 | ||
| 111 | - beforeUpload(file) { | ||
| 112 | - if (file.type.indexOf("image/") == -1) { | ||
| 113 | - this.$modal.msgError("文件格式错误,请上传图片类型,如:JPG,PNG后缀的文件。"); | ||
| 114 | - } else { | ||
| 115 | - const reader = new FileReader(); | ||
| 116 | - reader.readAsDataURL(file); | ||
| 117 | - reader.onload = () => { | ||
| 118 | - this.options.img = reader.result; | ||
| 119 | - }; | ||
| 120 | - } | ||
| 121 | - }, | ||
| 122 | - // 上传图片 | ||
| 123 | - uploadImg() { | ||
| 124 | - this.$refs.cropper.getCropBlob(data => { | ||
| 125 | - let formData = new FormData(); | ||
| 126 | - formData.append("avatarfile", data); | ||
| 127 | - uploadAvatar(formData).then(response => { | ||
| 128 | - this.open = false; | ||
| 129 | - this.options.img = process.env.VUE_APP_BASE_API + response.imgUrl; | ||
| 130 | - store.commit('SET_AVATAR', this.options.img); | ||
| 131 | - this.$modal.msgSuccess("修改成功"); | ||
| 132 | - this.visible = false; | ||
| 133 | - }); | ||
| 134 | - }); | ||
| 135 | - }, | ||
| 136 | - // 实时预览 | ||
| 137 | - realTime(data) { | ||
| 138 | - this.previews = data; | ||
| 139 | - }, | ||
| 140 | - // 关闭窗口 | ||
| 141 | - closeDialog() { | ||
| 142 | - this.options.img = store.getters.avatar | ||
| 143 | - this.visible = false; | ||
| 144 | - } | ||
| 145 | - } | ||
| 146 | -}; | ||
| 147 | -</script> | ||
| 148 | -<style scoped lang="scss"> | ||
| 149 | -.user-info-head { | ||
| 150 | - position: relative; | ||
| 151 | - display: inline-block; | ||
| 152 | - height: 120px; | ||
| 153 | -} | ||
| 154 | - | ||
| 155 | -.user-info-head:hover:after { | ||
| 156 | - content: '+'; | ||
| 157 | - position: absolute; | ||
| 158 | - left: 0; | ||
| 159 | - right: 0; | ||
| 160 | - top: 0; | ||
| 161 | - bottom: 0; | ||
| 162 | - color: #eee; | ||
| 163 | - background: rgba(0, 0, 0, 0.5); | ||
| 164 | - font-size: 24px; | ||
| 165 | - font-style: normal; | ||
| 166 | - -webkit-font-smoothing: antialiased; | ||
| 167 | - -moz-osx-font-smoothing: grayscale; | ||
| 168 | - cursor: pointer; | ||
| 169 | - line-height: 110px; | ||
| 170 | - border-radius: 50%; | ||
| 171 | -} | ||
| 172 | -</style> | ||
| 1 | +<template> | ||
| 2 | + <div> | ||
| 3 | + <div class="user-info-head" @click="editCropper()"><img v-bind:src="options.img" title="点击上传头像" class="img-circle img-lg" /></div> | ||
| 4 | + <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body @opened="modalOpened" @close="closeDialog"> | ||
| 5 | + <el-row> | ||
| 6 | + <el-col :xs="24" :md="12" :style="{height: '350px'}"> | ||
| 7 | + <vue-cropper | ||
| 8 | + ref="cropper" | ||
| 9 | + :img="options.img" | ||
| 10 | + :info="true" | ||
| 11 | + :autoCrop="options.autoCrop" | ||
| 12 | + :autoCropWidth="options.autoCropWidth" | ||
| 13 | + :autoCropHeight="options.autoCropHeight" | ||
| 14 | + :fixedBox="options.fixedBox" | ||
| 15 | + @realTime="realTime" | ||
| 16 | + v-if="visible" | ||
| 17 | + /> | ||
| 18 | + </el-col> | ||
| 19 | + <el-col :xs="24" :md="12" :style="{height: '350px'}"> | ||
| 20 | + <div class="avatar-upload-preview"> | ||
| 21 | + <img :src="previews.url" :style="previews.img" /> | ||
| 22 | + </div> | ||
| 23 | + </el-col> | ||
| 24 | + </el-row> | ||
| 25 | + <br /> | ||
| 26 | + <el-row> | ||
| 27 | + <el-col :lg="2" :sm="3" :xs="3"> | ||
| 28 | + <el-upload action="#" :http-request="requestUpload" :show-file-list="false" :before-upload="beforeUpload"> | ||
| 29 | + <el-button size="small"> | ||
| 30 | + 选择 | ||
| 31 | + <i class="el-icon-upload el-icon--right"></i> | ||
| 32 | + </el-button> | ||
| 33 | + </el-upload> | ||
| 34 | + </el-col> | ||
| 35 | + <el-col :lg="{span: 1, offset: 2}" :sm="2" :xs="2"> | ||
| 36 | + <el-button icon="el-icon-plus" size="small" @click="changeScale(1)"></el-button> | ||
| 37 | + </el-col> | ||
| 38 | + <el-col :lg="{span: 1, offset: 1}" :sm="2" :xs="2"> | ||
| 39 | + <el-button icon="el-icon-minus" size="small" @click="changeScale(-1)"></el-button> | ||
| 40 | + </el-col> | ||
| 41 | + <el-col :lg="{span: 1, offset: 1}" :sm="2" :xs="2"> | ||
| 42 | + <el-button icon="el-icon-refresh-left" size="small" @click="rotateLeft()"></el-button> | ||
| 43 | + </el-col> | ||
| 44 | + <el-col :lg="{span: 1, offset: 1}" :sm="2" :xs="2"> | ||
| 45 | + <el-button icon="el-icon-refresh-right" size="small" @click="rotateRight()"></el-button> | ||
| 46 | + </el-col> | ||
| 47 | + <el-col :lg="{span: 2, offset: 6}" :sm="2" :xs="2"> | ||
| 48 | + <el-button type="primary" size="small" @click="uploadImg()">提 交</el-button> | ||
| 49 | + </el-col> | ||
| 50 | + </el-row> | ||
| 51 | + </el-dialog> | ||
| 52 | + </div> | ||
| 53 | +</template> | ||
| 54 | + | ||
| 55 | +<script> | ||
| 56 | +import store from "@/store"; | ||
| 57 | +import { VueCropper } from "vue-cropper"; | ||
| 58 | +import { uploadAvatar } from "@/api/system/user"; | ||
| 59 | +import { debounce } from '@/utils' | ||
| 60 | + | ||
| 61 | +export default { | ||
| 62 | + components: { VueCropper }, | ||
| 63 | + props: { | ||
| 64 | + user: { | ||
| 65 | + type: Object | ||
| 66 | + } | ||
| 67 | + }, | ||
| 68 | + data() { | ||
| 69 | + return { | ||
| 70 | + // 是否显示弹出层 | ||
| 71 | + open: false, | ||
| 72 | + // 是否显示cropper | ||
| 73 | + visible: false, | ||
| 74 | + // 弹出层标题 | ||
| 75 | + title: "修改头像", | ||
| 76 | + options: { | ||
| 77 | + img: store.getters.avatar, //裁剪图片的地址 | ||
| 78 | + autoCrop: true, // 是否默认生成截图框 | ||
| 79 | + autoCropWidth: 200, // 默认生成截图框宽度 | ||
| 80 | + autoCropHeight: 200, // 默认生成截图框高度 | ||
| 81 | + fixedBox: true // 固定截图框大小 不允许改变 | ||
| 82 | + }, | ||
| 83 | + previews: {}, | ||
| 84 | + resizeHandler: null | ||
| 85 | + }; | ||
| 86 | + }, | ||
| 87 | + methods: { | ||
| 88 | + // 编辑头像 | ||
| 89 | + editCropper() { | ||
| 90 | + this.open = true; | ||
| 91 | + }, | ||
| 92 | + // 打开弹出层结束时的回调 | ||
| 93 | + modalOpened() { | ||
| 94 | + this.visible = true; | ||
| 95 | + if (!this.resizeHandler) { | ||
| 96 | + this.resizeHandler = debounce(() => { | ||
| 97 | + this.refresh() | ||
| 98 | + }, 100) | ||
| 99 | + } | ||
| 100 | + window.addEventListener("resize", this.resizeHandler) | ||
| 101 | + }, | ||
| 102 | + // 刷新组件 | ||
| 103 | + refresh() { | ||
| 104 | + this.$refs.cropper.refresh(); | ||
| 105 | + }, | ||
| 106 | + // 覆盖默认的上传行为 | ||
| 107 | + requestUpload() { | ||
| 108 | + }, | ||
| 109 | + // 向左旋转 | ||
| 110 | + rotateLeft() { | ||
| 111 | + this.$refs.cropper.rotateLeft(); | ||
| 112 | + }, | ||
| 113 | + // 向右旋转 | ||
| 114 | + rotateRight() { | ||
| 115 | + this.$refs.cropper.rotateRight(); | ||
| 116 | + }, | ||
| 117 | + // 图片缩放 | ||
| 118 | + changeScale(num) { | ||
| 119 | + num = num || 1; | ||
| 120 | + this.$refs.cropper.changeScale(num); | ||
| 121 | + }, | ||
| 122 | + // 上传预处理 | ||
| 123 | + beforeUpload(file) { | ||
| 124 | + if (file.type.indexOf("image/") == -1) { | ||
| 125 | + this.$modal.msgError("文件格式错误,请上传图片类型,如:JPG,PNG后缀的文件。"); | ||
| 126 | + } else { | ||
| 127 | + const reader = new FileReader(); | ||
| 128 | + reader.readAsDataURL(file); | ||
| 129 | + reader.onload = () => { | ||
| 130 | + this.options.img = reader.result; | ||
| 131 | + }; | ||
| 132 | + } | ||
| 133 | + }, | ||
| 134 | + // 上传图片 | ||
| 135 | + uploadImg() { | ||
| 136 | + this.$refs.cropper.getCropBlob(data => { | ||
| 137 | + let formData = new FormData(); | ||
| 138 | + formData.append("avatarfile", data); | ||
| 139 | + uploadAvatar(formData).then(response => { | ||
| 140 | + this.open = false; | ||
| 141 | + this.options.img = process.env.VUE_APP_BASE_API + response.imgUrl; | ||
| 142 | + store.commit('SET_AVATAR', this.options.img); | ||
| 143 | + this.$modal.msgSuccess("修改成功"); | ||
| 144 | + this.visible = false; | ||
| 145 | + }); | ||
| 146 | + }); | ||
| 147 | + }, | ||
| 148 | + // 实时预览 | ||
| 149 | + realTime(data) { | ||
| 150 | + this.previews = data; | ||
| 151 | + }, | ||
| 152 | + // 关闭窗口 | ||
| 153 | + closeDialog() { | ||
| 154 | + this.options.img = store.getters.avatar | ||
| 155 | + this.visible = false; | ||
| 156 | + window.removeEventListener("resize", this.resizeHandler) | ||
| 157 | + } | ||
| 158 | + } | ||
| 159 | +}; | ||
| 160 | +</script> | ||
| 161 | +<style scoped lang="scss"> | ||
| 162 | +.user-info-head { | ||
| 163 | + position: relative; | ||
| 164 | + display: inline-block; | ||
| 165 | + height: 120px; | ||
| 166 | +} | ||
| 167 | + | ||
| 168 | +.user-info-head:hover:after { | ||
| 169 | + content: '+'; | ||
| 170 | + position: absolute; | ||
| 171 | + left: 0; | ||
| 172 | + right: 0; | ||
| 173 | + top: 0; | ||
| 174 | + bottom: 0; | ||
| 175 | + color: #eee; | ||
| 176 | + background: rgba(0, 0, 0, 0.5); | ||
| 177 | + font-size: 24px; | ||
| 178 | + font-style: normal; | ||
| 179 | + -webkit-font-smoothing: antialiased; | ||
| 180 | + -moz-osx-font-smoothing: grayscale; | ||
| 181 | + cursor: pointer; | ||
| 182 | + line-height: 110px; | ||
| 183 | + border-radius: 50%; | ||
| 184 | +} | ||
| 185 | +</style> |
-
请 注册 或 登录 后发表评论