Просмотр исходного кода

【我的素材】调通删除功能

任一存 4 лет назад
Родитель
Сommit
437eddb18b

+ 8 - 1
src/views/material/audio/index.vue

@@ -213,7 +213,14 @@ export default {
         ok: () => {
           delMaterial(item.id, () => {
             this.$msg.success("删除成功");
-            this.getMaterialList();
+            const index = this.list.findIndex((eachItem) => {
+              return eachItem.id === item.id
+            })
+            if (index >= 0) {
+              this.list.splice(index, 1)
+            } else {
+              console.error('在素材列表里没找到要删除的那一项!');
+            }
           });
         },
       });

+ 8 - 1
src/views/material/image/index.vue

@@ -216,7 +216,14 @@ export default {
         ok: () => {
           delMaterial(item.id, () => {
             this.$msg.success("删除成功");
-            this.getMaterialList();
+            const index = this.list.findIndex((eachItem) => {
+              return eachItem.id === item.id
+            })
+            if (index >= 0) {
+              this.list.splice(index, 1)
+            } else {
+              console.error('在素材列表里没找到要删除的那一项!');
+            }
           });
         },
       });

+ 8 - 1
src/views/material/pano/index.vue

@@ -321,7 +321,14 @@ export default {
         ok: () => {
           delMaterial(item.id, () => {
             this.$msg.success("删除成功");
-            this.getMaterialList();
+            const index = this.list.findIndex((eachItem) => {
+              return eachItem.id === item.id
+            })
+            if (index >= 0) {
+              this.list.splice(index, 1)
+            } else {
+              console.error('在素材列表里没找到要删除的那一项!');
+            }
           });
         },
       });

+ 8 - 1
src/views/material/video/index.vue

@@ -210,7 +210,14 @@ export default {
         ok: () => {
           delMaterial(item.id, () => {
             this.$msg.success("删除成功");
-            this.getMaterialList();
+            const index = this.list.findIndex((eachItem) => {
+              return eachItem.id === item.id
+            })
+            if (index >= 0) {
+              this.list.splice(index, 1)
+            } else {
+              console.error('在素材列表里没找到要删除的那一项!');
+            }
           });
         },
       });