lushixing 3 weeks ago
parent
commit
57a2665b33
1 changed files with 9 additions and 17 deletions
  1. 9 17
      src/views/design-agent/feature-mod-index.vue

+ 9 - 17
src/views/design-agent/feature-mod-index.vue

@@ -727,6 +727,8 @@ export default {
               this.swiper.update()
               const lastIndex = this.ruleForm.imageList.length - 1
               this.swiper.slideTo(lastIndex, 300) // 平滑滚动到最后
+            } else {
+              this.initSwiper()
             }
           })
         }
@@ -738,7 +740,7 @@ export default {
         }
       }
     },
-    imgUploadDel(groupIndex, itemIndex) {
+    imgUploadDel(itemIndex) {
       //删除
       this.$confirm("确定要删除吗?", "提示", {
         confirmButtonText: "确定",
@@ -751,6 +753,12 @@ export default {
         } else {
           this.ruleForm.imageUrl = ''
         }
+        if (this.ruleForm.imageList.length == 0) {
+          if (this.swiper) {
+            this.swiper.destroy(true, true)  // 完全销毁 Swiper
+            this.swiper = null
+          }
+        }
         
         this.$notify({
           title: "成功",
@@ -852,22 +860,6 @@ export default {
         }
       })
     },
-    delImageList(url) {
-      if (this.ruleForm.imageList.includes(url)) {
-        this.ruleForm.imageList.forEach((acc, index) => {
-          if (url == acc) {
-            this.ruleForm.imageList.splice(index, 1);
-          }
-        })
-        this.$nextTick(() => {
-          if (this.swiper) {
-            this.swiper.update()
-          } else {
-            this.initSwiper()
-          }
-        })
-      }
-    },
     handleProductRepo() {
       this.$refs.productRepoModal && this.$refs.productRepoModal.show(this.ruleForm.imageList);
     }