From afd9d570a4ea411358a88e7d469f05dbbacb29cd Mon Sep 17 00:00:00 2001 From: zhouxueli <2841188632@qq.com> Date: Tue, 18 Mar 2025 10:06:21 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=8C=E6=89=8B=E8=BD=A6=E4=BA=A4=E6=98=93?= =?UTF-8?q?=EF=BC=8C=E7=BC=93=E5=AD=98=E9=97=AE=E9=A2=98,=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E7=85=A7=E7=89=87=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/secondHandCar/carSource.vue | 20 ++++++++----- .../components/upload-common.vue | 30 ++++++++----------- 2 files changed, 26 insertions(+), 24 deletions(-) diff --git a/src/views/secondHandCar/carSource.vue b/src/views/secondHandCar/carSource.vue index d3957a97..38b583bb 100644 --- a/src/views/secondHandCar/carSource.vue +++ b/src/views/secondHandCar/carSource.vue @@ -225,7 +225,6 @@ export default { this.vehicleAnglePhotoList=[{url:res.data?.vehicleAnglePhoto}] } let carSourceFormInfo=localStorage.getItem("carSourceFormInfo") ? JSON.parse(localStorage.getItem("carSourceFormInfo")) : '' - // console.log("carSourceFormInfo",carSourceFormInfo) if(!carSourceFormInfo){ return } @@ -242,22 +241,29 @@ export default { if(this.form.vehicleAnglePhoto){ this.vehicleAnglePhotoList=[{url:this.form.vehicleAnglePhoto}] } + console.log("carSourceFormInfo",carSourceFormInfo) if(carSourceFormInfo.otherImgSrc0){ + this.otherImgSrc.push(carSourceFormInfo.otherImgSrc0) this.otherImgSrcList.push({url:carSourceFormInfo.otherImgSrc0}) } if(carSourceFormInfo.otherImgSrc1){ + this.otherImgSrc.push(carSourceFormInfo.otherImgSrc1) this.otherImgSrcList.push({url:carSourceFormInfo.otherImgSrc1}) } if(carSourceFormInfo.otherImgSrc2){ + this.otherImgSrc.push(carSourceFormInfo.otherImgSrc2) this.otherImgSrcList.push({url:carSourceFormInfo.otherImgSrc2}) } if(carSourceFormInfo.otherImgSrc3){ + this.otherImgSrc.push(carSourceFormInfo.otherImgSrc3) this.otherImgSrcList.push({url:carSourceFormInfo.otherImgSrc3}) } if(carSourceFormInfo.otherImgSrc4){ + this.otherImgSrc.push(carSourceFormInfo.otherImgSrc4) this.otherImgSrcList.push({url:carSourceFormInfo.otherImgSrc4}) } if(carSourceFormInfo.otherImgSrc5){ + this.otherImgSrc.push(carSourceFormInfo.otherImgSrc5) this.otherImgSrcList.push({url:carSourceFormInfo.otherImgSrc5}) } console.log("--",this.vehicleLicensePhotoList,this.vehicleAnglePhotoList,this.otherImgSrcList) @@ -277,12 +283,12 @@ export default { viewPrivacy(){ let data={ form:this.form,radio:this.radio,areaName:this.areaName, - otherImgSrc0:this.otherImgSrcList?.length==1 ? this.otherImgSrcList[0] : '', - otherImgSrc1:this.otherImgSrcList?.length==2 ? this.otherImgSrcList[1] : '', - otherImgSrc2:this.otherImgSrcList?.length==3 ? this.otherImgSrcList[2] : '', - otherImgSrc3:this.otherImgSrcList?.length==4 ? this.otherImgSrcList[3] : '', - otherImgSrc4:this.otherImgSrcList?.length==5 ? this.otherImgSrcList[4] : '', - otherImgSrc5:this.otherImgSrcList?.length==6 ? this.otherImgSrcList[5] : '', + otherImgSrc0: this.otherImgSrc[0], + otherImgSrc1: this.otherImgSrc[1], + otherImgSrc2:this.otherImgSrc[2], + otherImgSrc3:this.otherImgSrc[3], + otherImgSrc4:this.otherImgSrc[4], + otherImgSrc5:this.otherImgSrc[5], } localStorage.setItem("carSourceFormInfo",JSON.stringify(data)) this.$router.push({ name: "privacyComponent"}) diff --git a/src/views/secondHandCar/components/upload-common.vue b/src/views/secondHandCar/components/upload-common.vue index f7ff44de..bd9e4b48 100644 --- a/src/views/secondHandCar/components/upload-common.vue +++ b/src/views/secondHandCar/components/upload-common.vue @@ -40,24 +40,24 @@ export default { }, data() { return { - filesList: '', + filesList: [], } }, - mounted() { - this.filesList = this.files || []; // 确保 filesList 是数组 - }, watch: { files: { - immediate: true, // 立即执行一次 + immediate: true, + deep:true, handler(newVal) { - this.filesList = newVal || []; // 同步更新 filesList + this.$nextTick(() => { + this.filesList = newVal || []; + }) }, }, filesList: { handler(newVal) { this.$emit("update:files", newVal); }, - deep: true, // 深度监听 + deep: true, }, }, computed: { @@ -78,29 +78,25 @@ export default { const images = this.filesList.map(file => file.url || file.content); // 所有图片的 URL ImagePreview({ images, - startPosition: detail.index, // 从当前点击的图片开始预览 + startPosition: detail.index, closeable: true, onClose: () => {} }); }, async deleteHandle(file, detail) { - // console.log("file, detail", file, detail); - this.filesList = this.filesList.filter((item) => item !== file); - // console.log("this.filesList =", this.filesList) - // 根据 text 的不同,通知父组件删除对应的数据 + this.filesList = this.filesList.filter((item, i) => i !== detail.index); if (this.text === "行驶证照片") { - this.$emit("delete1"); // 通知父组件删除行驶证数据 + this.$emit("delete1"); } else if (this.text === "车辆45度照") { - this.$emit("delete2"); // 通知父组件删除车辆45度照数据 + this.$emit("delete2"); } else { - // console.log("delete3", file) - this.$emit("delete3", file, detail.index); // 通知父组件删除其他照片数据 + console.log("file, detail", file, detail) + this.$emit("delete3", file, detail.index); } return true; }, async handleFileRead(file) { const formData = new FormData(); - // console.log("file.file",file.file) if(!file.file){ this.$toast('获取文件失败,请重新上传') }