From 649734255f44f6c8843cc2a3924cbf48ba8b6f5b Mon Sep 17 00:00:00 2001 From: qb <1191961160@qq.com> Date: Mon, 26 Aug 2024 10:21:08 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=9B=BE=E7=89=87=E4=B8=8A?= =?UTF-8?q?=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../aftersalesWorkOrderInfoEnxt.vue | 16 +++++++++----- .../aftersalesWorkOrderInfoTemp.vue | 16 +++++++++----- .../aftersalesWorkOrdermodifyTemp.vue | 16 +++++++++----- src/views/aftersales/customerService.vue | 16 +++++++++----- src/views/basic/pda/basicPdatt.vue | 16 +++++++++----- .../warehouse/basicdataWarehouse.vue | 22 +++++++++++-------- src/views/datadetail/ToolUpdate.vue | 16 +++++++++----- .../artery/directGoMarketDetails.vue | 16 +++++++++----- 8 files changed, 90 insertions(+), 44 deletions(-) diff --git a/src/views/aftersales/aftersalesWorkOrderInfoEnxt.vue b/src/views/aftersales/aftersalesWorkOrderInfoEnxt.vue index 48d4511d..349bbd7c 100644 --- a/src/views/aftersales/aftersalesWorkOrderInfoEnxt.vue +++ b/src/views/aftersales/aftersalesWorkOrderInfoEnxt.vue @@ -917,13 +917,19 @@ const ImgSuccess = (response, uploadFile) => { // 上传图片规则 const beforeAvatarUpload = async rawFile => { - if (rawFile.type !== 'image/png') { - ElMessage.error('图片格式只能为image/png!'); - return false; - } else if (rawFile.size / 1024 / 1024 > 2) { - ElMessage.error('图片大小不能大于2MB!'); + const _nameArr = rawFile.name.split('.'); + + if (_nameArr.length === 0) { + ElMessage.warning('异常类型文件'); return false; } + + const _name = _nameArr[_nameArr.length - 1]; + + const _whiteArr = ['png', 'jpg', 'jpeg']; + + if (!_whiteArr.includes(_name.toLocaleLowerCase())) + return ElMessage.warning('请上传png、jpg、jpeg的类型图片'); const res = await compressImageBlob(rawFile); return res; }; diff --git a/src/views/aftersales/aftersalesWorkOrderInfoTemp.vue b/src/views/aftersales/aftersalesWorkOrderInfoTemp.vue index 18cbc655..3ef7a285 100644 --- a/src/views/aftersales/aftersalesWorkOrderInfoTemp.vue +++ b/src/views/aftersales/aftersalesWorkOrderInfoTemp.vue @@ -892,13 +892,19 @@ const ButtonPermissions = computed(() => { // 上传图片规则 const beforeAvatarUpload = async rawFile => { - if (rawFile.type !== 'image/png') { - ElMessage.error('图片格式只能为image/png!'); - return false; - } else if (rawFile.size / 1024 / 1024 > 2) { - ElMessage.error('图片大小不能大于2MB!'); + const _nameArr = rawFile.name.split('.'); + + if (_nameArr.length === 0) { + ElMessage.warning('异常类型文件'); return false; } + + const _name = _nameArr[_nameArr.length - 1]; + + const _whiteArr = ['png', 'jpg', 'jpeg']; + + if (!_whiteArr.includes(_name.toLocaleLowerCase())) + return ElMessage.warning('请上传png、jpg、jpeg的类型图片'); const res = await compressImageBlob(rawFile); return res; }; diff --git a/src/views/aftersales/aftersalesWorkOrdermodifyTemp.vue b/src/views/aftersales/aftersalesWorkOrdermodifyTemp.vue index 1246ff14..977e5471 100644 --- a/src/views/aftersales/aftersalesWorkOrdermodifyTemp.vue +++ b/src/views/aftersales/aftersalesWorkOrdermodifyTemp.vue @@ -1012,13 +1012,19 @@ const ImgSuccess = (response, uploadFile) => { // 上传图片规则 const beforeAvatarUpload = async rawFile => { - if (rawFile.type !== 'image/png') { - ElMessage.error('图片格式只能为image/png!'); - return false; - } else if (rawFile.size / 1024 / 1024 > 2) { - ElMessage.error('图片大小不能大于2MB!'); + const _nameArr = rawFile.name.split('.'); + + if (_nameArr.length === 0) { + ElMessage.warning('异常类型文件'); return false; } + + const _name = _nameArr[_nameArr.length - 1]; + + const _whiteArr = ['png', 'jpg', 'jpeg']; + + if (!_whiteArr.includes(_name.toLocaleLowerCase())) + return ElMessage.warning('请上传png、jpg、jpeg的类型图片'); const res = await compressImageBlob(rawFile); return res; }; diff --git a/src/views/aftersales/customerService.vue b/src/views/aftersales/customerService.vue index 46c2b6fd..ba420c91 100644 --- a/src/views/aftersales/customerService.vue +++ b/src/views/aftersales/customerService.vue @@ -216,13 +216,19 @@ const messagesendFn = () => { console.log(Mydata.value, '参数'); }; const beforeAvatarUpload = async rawFile => { - if (rawFile.type !== 'image/png') { - ElMessage.error('图片格式只能为image/png!'); - return false; - } else if (rawFile.size / 1024 / 1024 > 2) { - ElMessage.error('图片大小不能大于2MB!'); + const _nameArr = rawFile.name.split('.'); + + if (_nameArr.length === 0) { + ElMessage.warning('异常类型文件'); return false; } + + const _name = _nameArr[_nameArr.length - 1]; + + const _whiteArr = ['png', 'jpg', 'jpeg']; + + if (!_whiteArr.includes(_name.toLocaleLowerCase())) + return ElMessage.warning('请上传png、jpg、jpeg的类型图片'); const res = await compressImageBlob(rawFile); return res; }; diff --git a/src/views/basic/pda/basicPdatt.vue b/src/views/basic/pda/basicPdatt.vue index 63c446ae..96e5a7df 100644 --- a/src/views/basic/pda/basicPdatt.vue +++ b/src/views/basic/pda/basicPdatt.vue @@ -789,13 +789,19 @@ const ImgSuccess: UploadProps['onSuccess'] = (response, uploadFile) => { }; // 上传图片规则 const beforeAvatarUpload: UploadProps['beforeUpload'] = async rawFile => { - if (rawFile.type !== 'image/png') { - ElMessage.error('图片格式只能为image/png!'); - return false; - } else if (rawFile.size / 1024 / 1024 > 2) { - ElMessage.error('图片大小不能大于2MB!'); + const _nameArr = rawFile.name.split('.'); + + if (_nameArr.length === 0) { + ElMessage.warning('异常类型文件'); return false; } + + const _name = _nameArr[_nameArr.length - 1]; + + const _whiteArr = ['png', 'jpg', 'jpeg']; + + if (!_whiteArr.includes(_name.toLocaleLowerCase())) + return ElMessage.warning('请上传png、jpg、jpeg的类型图片'); const res = await compressImageBlob(rawFile); return res; }; diff --git a/src/views/basicdata/warehouse/warehouse/basicdataWarehouse.vue b/src/views/basicdata/warehouse/warehouse/basicdataWarehouse.vue index e9b4a93a..424463c3 100644 --- a/src/views/basicdata/warehouse/warehouse/basicdataWarehouse.vue +++ b/src/views/basicdata/warehouse/warehouse/basicdataWarehouse.vue @@ -90,7 +90,7 @@ - + @@ -456,7 +456,6 @@ const rules = reactive({ addressInfo: [{ required: true, message: '请选择仓库地区', trigger: 'change' }], department: [{ required: true, message: '请选择所属部门', trigger: 'change' }], warehouseAddress: [{ required: true, message: '请选择仓库地址', trigger: 'change' }], - }); const Topquery = ref({}); //顶部搜索参数 const newlyaddload = ref(false); //新增弹窗 @@ -465,8 +464,7 @@ const department = ref(); const Addform = ref({}); //表格新增数据表单 const WarehouseType = ref([]); //仓库类型 const FireProtection = ref([]); //消防等级 -const Isprotection = ref([ -]); //是否具有消防等级 +const Isprotection = ref([]); //是否具有消防等级 const WarehouseStructureList = ref([]); //仓库结构 const Iselevated = ref([ { @@ -917,13 +915,19 @@ const view = value => { GetDetails(value); //获取详情 }; const beforeAvatarUpload = async rawFile => { - if (rawFile.type !== 'image/png') { - ElMessage.error('图片格式只能为image/png!'); - return false; - } else if (rawFile.size / 1024 / 1024 > 2) { - ElMessage.error('图片大小不能大于2MB!'); + const _nameArr = rawFile.name.split('.'); + + if (_nameArr.length === 0) { + ElMessage.warning('异常类型文件'); return false; } + + const _name = _nameArr[_nameArr.length - 1]; + + const _whiteArr = ['png', 'jpg', 'jpeg']; + + if (!_whiteArr.includes(_name.toLocaleLowerCase())) + return ElMessage.warning('请上传png、jpg、jpeg的类型图片'); const res = await compressImageBlob(rawFile); return res; }; diff --git a/src/views/datadetail/ToolUpdate.vue b/src/views/datadetail/ToolUpdate.vue index 03902b02..35e62cf3 100644 --- a/src/views/datadetail/ToolUpdate.vue +++ b/src/views/datadetail/ToolUpdate.vue @@ -301,13 +301,19 @@ const handleAvatarSuccess: UploadProps['onSuccess'] = (response, uploadFile) => }; // 上传图片规则 const beforeAvatarUpload: UploadProps['beforeUpload'] = async rawFile => { - if (rawFile.type !== 'image/png') { - ElMessage.error('图片格式只能为image/png!'); - return false; - } else if (rawFile.size / 1024 / 1024 > 2) { - ElMessage.error('图片大小不能大于2MB!'); + const _nameArr = rawFile.name.split('.'); + + if (_nameArr.length === 0) { + ElMessage.warning('异常类型文件'); return false; } + + const _name = _nameArr[_nameArr.length - 1]; + + const _whiteArr = ['png', 'jpg', 'jpeg']; + + if (!_whiteArr.includes(_name.toLocaleLowerCase())) + return ElMessage.warning('请上传png、jpg、jpeg的类型图片'); const res = await compressImageBlob(rawFile); return res; }; diff --git a/src/views/distribution/artery/directGoMarketDetails.vue b/src/views/distribution/artery/directGoMarketDetails.vue index be95acee..206a5ad6 100644 --- a/src/views/distribution/artery/directGoMarketDetails.vue +++ b/src/views/distribution/artery/directGoMarketDetails.vue @@ -984,13 +984,19 @@ const handleZeroSubmit = async () => { // 上传图片规则 const beforeAvatarUpload: UploadProps['beforeUpload'] = async rawFile => { - if (rawFile.type !== 'image/png') { - ElMessage.error('图片格式只能为image/png!'); - return false; - } else if (rawFile.size / 1024 / 1024 > 2) { - ElMessage.error('图片大小不能大于2MB!'); + const _nameArr = rawFile.name.split('.'); + + if (_nameArr.length === 0) { + ElMessage.warning('异常类型文件'); return false; } + + const _name = _nameArr[_nameArr.length - 1]; + + const _whiteArr = ['png', 'jpg', 'jpeg']; + + if (!_whiteArr.includes(_name.toLocaleLowerCase())) + return ElMessage.warning('请上传png、jpg、jpeg的类型图片'); const res = await compressImageBlob(rawFile); return res; };