Browse Source

修改预览的上一页下一页 未完 合并data

秦鹏 3 năm trước cách đây
mục cha
commit
9278a73381

+ 76 - 10
src/components/Adult/Preview.vue

@@ -174,7 +174,13 @@ export default {
     SentenceSort,
     Checkbox,
   },
-  props: ["context", "fatherName"],
+  props: [
+    "context",
+    "fatherName",
+    "currentTreeID",
+    "FatherTreeData",
+    "changeId",
+  ],
   data() {
     return {
       contextData: null,
@@ -235,15 +241,43 @@ export default {
         }
       }
     },
-
     // 上一页
     handleNNPEprev() {
       const _this = this;
       if (_this.queIndex == 0) {
-        this.$message({
-          message: "已经是第一题",
-          type: "success",
+        let data = {};
+        _this.FatherTreeData.forEach((item, itemIndex) => {
+          if (item.children) {
+            item.children.forEach((it, childrenIndex) => {
+              if (itemIndex < 1 && childrenIndex < 1) {
+                this.$message({
+                  message: "已经是第一题",
+                  type: "success",
+                });
+              } else if (it.id == _this.currentTreeID) {
+                data.fatherName = item.children[childrenIndex - 1].fatherName;
+                data.id = item.children[childrenIndex - 1].id;
+                data.name = item.children[childrenIndex - 1].name;
+              }
+            });
+          } else {
+            if (itemIndex < 1) {
+              this.$message({
+                message: "已经是第一题",
+                type: "success",
+              });
+            } else if (item.id == _this.currentTreeID) {
+              {
+                data.fatherName =
+                  _this.FatherTreeData[itemIndex - 1].fatherName;
+                data.id = _this.FatherTreeData[itemIndex - 1].id;
+                data.name = _this.FatherTreeData[itemIndex - 1].name;
+              }
+            }
+          }
         });
+        _this.queIndex = 0;
+        _this.changeId(data.id, data.name, data.fatherName);
       } else {
         _this.queIndex = _this.queIndex - 1;
         _this.watchIndex = _this.queIndex + new Date().getTime();
@@ -254,10 +288,42 @@ export default {
     handleNNPEnext() {
       const _this = this;
       if (_this.queIndex == _this.queTotal - 1) {
-        this.$message({
-          message: "已经是最后一题",
-          type: "success",
-        });
+          let data = {};
+          _this.FatherTreeData.forEach((item, itemIndex) => {
+            if (item.children) {
+              item.children.forEach((it, childrenIndex) => {
+                if (
+                  itemIndex == _this.FatherTreeData.length - 1 &&
+                  childrenIndex == item.children.length - 1
+                ) {
+                  this.$message({
+                    message: "已经是最后一题",
+                    type: "success",
+                  });
+                } else if (it.id == _this.currentTreeID) {
+                  data.fatherName = item.children[childrenIndex + 1].fatherName;
+                  data.id = item.children[childrenIndex + 1].id;
+                  data.name = item.children[childrenIndex + 1].name;
+                }
+              });
+            } else {
+              if (itemIndex == _this.FatherTreeData.length - 1) {
+                this.$message({
+                  message: "已经是最后一题",
+                  type: "success",
+                });
+              } else if (item.id == _this.currentTreeID) {
+                {
+                  data.fatherName =
+                    _this.FatherTreeData[itemIndex + 1].fatherName;
+                  data.id = _this.FatherTreeData[itemIndex + 1].id;
+                  data.name = _this.FatherTreeData[itemIndex + 1].name;
+                }
+              }
+            }
+          });
+          _this.queIndex = 0;
+          _this.changeId(data.id, data.name, data.fatherName);
       } else {
         _this.queIndex = _this.queIndex + 1;
         _this.watchIndex = _this.queIndex + new Date().getTime();
@@ -346,7 +412,7 @@ export default {
       border-radius: 8px;
       padding: 12px 8px;
       &.NNPE-tableList-hasBg {
-        background: #F7F7F7;
+        background: #f7f7f7;
         border: 1px solid rgba(0, 0, 0, 0.1);
         box-sizing: border-box;
         border-radius: 8px;

+ 0 - 1
src/components/Adult/common/data3.js

@@ -137,7 +137,6 @@ let fnData = [{
             type: 'singleRowInput',
             name: "单行文本题",
             title: "",
-
             con: [{
                 con: '',
                 annotation: "", //注释

+ 17 - 2
src/components/Adult/inputModules/Catelog.vue

@@ -142,7 +142,13 @@ export default {
   components: {
     Tree: Tree.mixPlugins([Fold, Draggable]),
   },
-  props: ["changeId", "emptyQustion", "bookLevel", "bookNodeIndex"],
+  props: [
+    "changeId",
+    "emptyQustion",
+    "bookLevel",
+    "bookNodeIndex",
+    "changeTreeData",
+  ],
   data() {
     return {
       treeData: [],
@@ -252,6 +258,7 @@ export default {
             this.isDragFlag = false;
             // 移动后只有这一个节点 不对
             this.treeData = this.oldLists;
+            this.changeTreeData(this.oldLists);
             this.$message({
               type: "warning",
               message: "不能跨级移动!",
@@ -268,6 +275,8 @@ export default {
               } else {
                 // if (item.pid === 'undefined')
                 this.treeData = this.oldLists;
+                this.changeTreeData(this.oldLists);
+
                 this.isDragFlag = false;
                 this.$message({
                   type: "warning",
@@ -284,6 +293,8 @@ export default {
                 // this.treeData.lists = list;
               } else {
                 this.treeData = this.oldLists;
+                this.changeTreeData(this.oldLists);
+
                 this.isDragFlag = false;
                 this.$message({
                   type: "warning",
@@ -424,16 +435,20 @@ export default {
           this.handleData(res, 0);
           this.treeData = JSON.parse(JSON.stringify(res.nodes));
           this.oldLists = JSON.parse(JSON.stringify(res.nodes));
+          this.changeTreeData(res.nodes);
+
           _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);
             } 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);
             }
           });
         })
@@ -479,7 +494,7 @@ export default {
     handleNodeClick(data) {
       console.log(data);
       this.activeIndex = data.id;
-      this.changeId(data.id, data.name,data.fatherName);
+      this.changeId(data.id, data.name, data.fatherName);
     },
     remove(data, index) {
       this.curIndex = data.level_index;

+ 14 - 1
src/views/adultInput3.vue

@@ -9,6 +9,7 @@
           :book-level="bookLevel"
           :book-node-index="bookIndex"
           :change-id="changeId"
+          :changeTreeData="changeTreeData"
         />
       </div>
       <div class="Book-content" v-if="currentTreeID">
@@ -493,6 +494,10 @@
           :context="context"
           :que-index="queIndex"
           :fatherName="fatherName"
+          :currentTreeID="currentTreeID"
+          :FatherTreeData="FatherTreeData"
+          :change-id="changeId"
+
         />
       </div>
       <span slot="footer" class="dialog-footer">
@@ -644,6 +649,7 @@ export default {
       fatherName: "",
       module_type: "",
       tmInde: "",
+      FatherTreeData: null,
     };
   },
   computed: {
@@ -659,9 +665,16 @@ export default {
       }
     },
   },
-  watch: {},
+  watch: {
+    FatherTreeData(val, oldval) {
+      console.log(val);
+    },
+  },
   //方法集合
   methods: {
+    changeTreeData(val){
+      this.FatherTreeData = JSON.parse(JSON.stringify(val))
+    },
     // 随意插入模板获取位置
     changeSite(x, y) {
       this.bgControlX = x;