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 === '图片上传') {