Bläddra i källkod

章节树删除

natasha 3 år sedan
förälder
incheckning
04205d0192
2 ändrade filer med 16 tillägg och 9 borttagningar
  1. 12 9
      src/components/Adult/inputModules/Catelog.vue
  2. 4 0
      src/views/adultInput.vue

+ 12 - 9
src/components/Adult/inputModules/Catelog.vue

@@ -470,22 +470,23 @@ export default {
         .then((res) => {
           this.loading = false;
           this.handleData(res, 0);
-          this.treeData = JSON.parse(JSON.stringify(res.nodes));
-          this.oldLists = JSON.parse(JSON.stringify(res.nodes));
-          this.changeTreeData(res.nodes);
+          let nodesData = res.nodes ? res.nodes : []
+          this.treeData = JSON.parse(JSON.stringify(nodesData));
+          this.oldLists = JSON.parse(JSON.stringify(nodesData));
+          this.changeTreeData(nodesData);
 
           _this.$nextTick(() => {
             _this.foldAll();
             if (this.type) {
               this.curINdexArr = this.curIndex.split("-");
               this.handleFold(res, 0);
-              this.treeData = JSON.parse(JSON.stringify(res.nodes));
-              this.changeTreeData(res.nodes);
+              this.treeData = JSON.parse(JSON.stringify(nodesData));
+              this.changeTreeData(nodesData);
             } else if (this.bookLevel) {
               this.curINdexArr = this.bookLevel.split("-");
               this.handleFold(res, 0);
-              this.treeData = JSON.parse(JSON.stringify(res.nodes));
-              this.changeTreeData(res.nodes);
+              this.treeData = JSON.parse(JSON.stringify(nodesData));
+              this.changeTreeData(nodesData);
             }
           });
         })
@@ -559,8 +560,10 @@ export default {
                 type: "success",
                 message: "删除成功!",
               });
-              this.activeIndex = "";
-              this.emptyQustion();
+              if(this.currentTreeID==data.id){
+                  this.activeIndex = "";
+                  this.emptyQustion();
+              }
             })
             .catch(() => {
               this.loading = false;

+ 4 - 0
src/views/adultInput.vue

@@ -11,6 +11,7 @@
           :change-id="changeId"
           :change-tree-data="changeTreeData"
           :current-tree-i-d="currentTreeID"
+          :emptyQustion="emptyQustion"
         />
       </div>
       <div v-if="currentTreeID" class="Book-content">
@@ -1682,6 +1683,9 @@ export default {
       //   }
       // }
     },
+    emptyQustion() {
+        this.currentTreeID = ''
+    },
   }, // 如果页面有keep-alive缓存功能,这个函数会触发
 };
 </script>