From 8e2a474600f06aa2460c5f07a5ddbee54d574225 Mon Sep 17 00:00:00 2001 From: xzg <4727863@qq.com> Date: Mon, 2 Sep 2024 10:00:58 +0800 Subject: [PATCH] =?UTF-8?q?=E5=95=86=E5=B8=82=E9=85=8D=E7=AD=BE=E6=94=B6?= =?UTF-8?q?=E5=A4=8D=E6=A0=B8=E5=A2=9E=E5=8A=A0=E5=9B=BE=E7=89=87=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../distributionDeliveryListedt.vue | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/src/views/distribution/deliverylist/distributionDeliveryListedt.vue b/src/views/distribution/deliverylist/distributionDeliveryListedt.vue index d0e86ae0..916618ec 100644 --- a/src/views/distribution/deliverylist/distributionDeliveryListedt.vue +++ b/src/views/distribution/deliverylist/distributionDeliveryListedt.vue @@ -5224,6 +5224,46 @@ export default { this.dialogImageUrlE = uploadFile.url; this.dialogVisibleE = true; }, + + // 校验图片 +isValidImageUrl(url) { + // 直接检查 URL 是否以 blob: 开头 + return typeof url === 'string' && !url.startsWith('blob:'); +}, + +checkImageUrls(row) { + const invalidImages = []; // 用于存储无效图片的名称 + + // 遍历 row.map 中的每个键 + for (const photoKey in row.map) { + const photoArray = row.map[photoKey]; + // 遍历每个 photo 数组中的对象 + for (const photoObj of photoArray) { + const url = photoObj.urlRoute; + console.log(url, 'url'); + + const isValid = this.isValidImageUrl(url); + if (!isValid) { + invalidImages.push(photoObj.name); // 如果URL无效,将name加入无效图片数组 + } + } + } + + if (invalidImages.length > 0) { + invalidImages.forEach(item=>{ + ElMessage({ + message: `图片名称为:${item}存在问题,请删除图片重新上传或者刷新页面重试`, + type: 'warning', + }) + }) + console.log(`图片名称为: ${invalidImages.join(', ')}存在问题,请删除图片重新上传,或刷新页面重新尝试`); + return false; + } else { + return true; + } +}, + + // 复核签收确认弹窗 submitForm() { // 取消上门照片规则 @@ -5301,6 +5341,18 @@ export default { pushPhotoToRow(this.FragilePhotos, 'photo_3'); pushPhotoToRow(this.HomePhotos, 'photo_4'); pushPhotoToRow(this.SignForPhotos, 'photo_5'); + // 测试数据 + // row.map.photo_5.push({ + // name: "03add918888d36ce0d566da120510840.png", + // reservationId: "1829120012682530818", + // type: "photo_2", + // urlRoute: "blob:http://192.168.3.13:2888/d236a3be-e565-4122-b573-7fe4c5f07525" + // }) + const result = this.checkImageUrls(row); + console.log(`图片校验 ${result}`); + if(!result){ + return + } this.TCloading = true; //禁止确定 this.signBox = false; if (this.signtitle === '图片上传') {