[fix 83992] 上传头像大小限制

This commit is contained in:
danshihao
2024-04-25 15:01:04 +08:00
parent 60fdaf1c71
commit 237865db97
3 changed files with 21 additions and 2 deletions
+10
View File
@@ -160,8 +160,18 @@ export default {
this.$message.warning('请上传图片') this.$message.warning('请上传图片')
return false return false
} }
// 限制文件大小
if (file.size > this.global.maxUploadFileSize) {
this.$message.warning('最大上传图片20MB')
return false
}
}, },
handleChange (info) { handleChange (info) {
// 限制文件大小
if (info.file.size > this.global.maxUploadFileSize) {
info.fileList.pop()
return
}
this.picUrl = false this.picUrl = false
let fileList = info.fileList let fileList = info.fileList
// update-begin-author:wangshuai date:20201022 for:LOWCOD-969 判断number是否大于0和是否多选,返回选定的元素。 // update-begin-author:wangshuai date:20201022 for:LOWCOD-969 判断number是否大于0和是否多选,返回选定的元素。
+2 -1
View File
@@ -78,7 +78,8 @@ Viewer.setDefaults({
toolbar: false toolbar: false
}) })
Vue.prototype.global = { Vue.prototype.global = {
emptyLine: '—' emptyLine: '—',
maxUploadFileSize: 1024 * 1024 * 20 // 上传文件最大20MB
} }
SSO.init(() => { SSO.init(() => {
main() main()
+9 -1
View File
@@ -9,7 +9,11 @@
<!-- :number="1"--> <!-- :number="1"-->
<!-- uploadLimitHideBtn--> <!-- uploadLimitHideBtn-->
<!-- accept='.png,.PNG,.jpg,.JPG'></j-image-upload>--> <!-- accept='.png,.PNG,.jpg,.JPG'></j-image-upload>-->
<van-uploader class="upload-avatar" v-model="fileList" max-count="1"></van-uploader> <van-uploader class="upload-avatar"
:max-size="global.maxUploadFileSize"
@oversize="onOversize"
v-model="fileList"
max-count="1"></van-uploader>
</div> </div>
</a-form-item> </a-form-item>
<a-form-item label="用户名称"> <a-form-item label="用户名称">
@@ -44,6 +48,7 @@ import { queryDepartTreeList } from '@api/api'
import DictPicker from '@comp/vant/DictPicker' import DictPicker from '@comp/vant/DictPicker'
import SelectPicker from '@comp/vant/SelectPicker' import SelectPicker from '@comp/vant/SelectPicker'
import { getAction, getFileAccessHttpUrl } from '@api/manage' import { getAction, getFileAccessHttpUrl } from '@api/manage'
import { Toast } from 'vant'
export default { export default {
name: 'Mine', name: 'Mine',
components: { SelectPicker, DictPicker }, components: { SelectPicker, DictPicker },
@@ -83,6 +88,9 @@ export default {
this.getUserDeparts(this.model.id) this.getUserDeparts(this.model.id)
}, },
methods: { methods: {
onOversize () {
Toast('最大上传图片20MB')
},
// 获取用户部门 // 获取用户部门
getUserDeparts (userid) { getUserDeparts (userid) {
const that = this const that = this