Tang hace 3 años
padre
commit
797be2aa06

+ 34 - 11
src/views/resource/bankManagement/testPaperManagement/addPaper/topicAddPaper/index.vue

@@ -14,7 +14,7 @@
         @editInfo="editInfo"
         @emitData="emitData"
       >
-      <template slot="customize">
+        <template slot="customize">
           <el-button size="medium" @click="dialogDRword = true" type="success"
             >Word批量导入</el-button
           >
@@ -22,14 +22,10 @@
         <template slot="btn" slot-scope="props">
           <el-button
             type="text"
-            @click="addClick(props.scope.row, 0, props.scope.$index)"
+            @click="addClick(props.scope.row, 0, props.scope.row.index)"
             >编辑</el-button
           >
-          <el-button
-            type="text"
-            @click="del(props.scope.row, props.scope.$index)"
-            >删除</el-button
-          >
+          <el-button type="text" @click="del(props.scope.row)">删除</el-button>
         </template>
       </table-list>
       <div class="centerStys">
@@ -688,7 +684,14 @@ import questionBank from "@/components/questionBank";
 import wordPop from "../../editPaper/topicEditPaper/wordPop.vue";
 export default {
   name: "TopicAddPaper",
-  components: { searchBoxNew, pagination, tableList, busIns, questionBank,wordPop },
+  components: {
+    searchBoxNew,
+    pagination,
+    tableList,
+    busIns,
+    questionBank,
+    wordPop,
+  },
   data() {
     return {
       dialogDRword: false,
@@ -1062,8 +1065,9 @@ export default {
       this.$api
         .inquirebankexamquestionList({ examId: this.$route.query.id })
         .then((res) => {
-          res.data.map((item) => {
+          res.data.map((item,index) => {
             item.optionsList = JSON.parse(item.jsonStr);
+            item.index = index
           });
           this.copytableData = JSON.parse(JSON.stringify(res.data));
           this.tableData = res.data;
@@ -1166,12 +1170,18 @@ export default {
 
       if (this.tableData.length) {
         let maxIndex = 0;
+        let childrenIndex = 0;
         this.tableData.forEach((item) => {
           if (item.sort > maxIndex) {
             maxIndex = item.sort;
           }
+          if (item.index > childrenIndex) {
+            childrenIndex = item.index;
+          }
         });
         this.activeLists.forEach((item, index) => {
+          childrenIndex++
+          item.index = childrenIndex
           item.sort = maxIndex + index + 1;
           item.optionsList = JSON.parse(item.jsonStr);
           item.partScore = 0;
@@ -1179,6 +1189,7 @@ export default {
         });
       } else {
         this.activeLists.forEach((item, index) => {
+          item.index = index
           item.sort = index + 1;
           item.optionsList = JSON.parse(item.jsonStr);
           item.partScore = 0;
@@ -1246,11 +1257,14 @@ export default {
           self.activeExam = [];
         });
       } else {
+        let newIndex = self.tableData.findIndex((item) => {
+          return item.index === indexZB;
+        });
         self.innerVisiblePaperTopic = true;
         self.showHide = true;
         self.statusPop = int;
         var vres = JSON.parse(JSON.stringify(v));
-        self.indexZB = indexZB;
+        self.indexZB = newIndex;
         if (vres.knowledgeIds) {
           var a = [];
           vres.knowledgeIds
@@ -1524,14 +1538,20 @@ export default {
             data.status = 1;
             if (this.tableData.length) {
               let maxIndex = 0;
+              let childrenIndex = 0;
               this.tableData.forEach((item) => {
                 if (item.sort > maxIndex) {
                   maxIndex = item.sort;
                 }
+                if (item.index > childrenIndex) {
+                  childrenIndex = item.index;
+                }
               });
               data.sort = maxIndex + 1;
+              data.index = childrenIndex + 1;
             } else {
               data.sort = 1;
+              data.index = 0;
             }
             this.tableData.push(data);
             // this.$api.addbankquestion(data).then((res) => {
@@ -1542,7 +1562,10 @@ export default {
             // });
           }
           if (this.statusPop === 0) {
-            this.tableData.splice(this.indexZB, 1, data);
+            let indexy = this.tableData.findIndex((item) => {
+              return item.index === this.indexZB;
+            });
+            this.tableData.splice(indexy, 1, data);
             // this.$api.editbankquestion(data).then((res) => {
             self.$message.success("修改成功");
             self.innerVisiblePaperTopic = false;

+ 31 - 11
src/views/resource/bankManagement/testPaperManagement/editPaper/topicEditPaper/index.vue

@@ -18,14 +18,10 @@
         <template slot="btn" slot-scope="props">
           <el-button
             type="text"
-            @click="addClick(props.scope.row, 0, props.scope.$index)"
+            @click="addClick(props.scope.row, 0, props.scope.row.index)"
             >编辑</el-button
           >
-          <el-button
-            type="text"
-            @click="del(props.scope.row, props.scope.$index)"
-            >删除</el-button
-          >
+          <el-button type="text" @click="del(props.scope.row)">删除</el-button>
         </template>
       </table-list>
       <div class="centerStys">
@@ -1119,9 +1115,11 @@ export default {
       this.$api
         .inquirebankexamquestionList({ examId: this.$route.query.id })
         .then((res) => {
-          res.data.map((item) => {
+          res.data.forEach((item, index) => {
             item.optionsList = JSON.parse(item.jsonStr);
+            item.index = index;
           });
+          console.log(res.data);
           this.copytableData = JSON.parse(JSON.stringify(res.data));
           this.boxtableDataPags = JSON.parse(JSON.stringify(res.data));
           this.tableData = res.data;
@@ -1134,7 +1132,7 @@ export default {
     // init() {
     //   this.search();
     // },
-    del(v, index) {
+    del(v) {
       this.$alert(
         "确定删除此内容?<br />内容删除后将无法恢复,请慎重考虑",
         "提示",
@@ -1143,6 +1141,9 @@ export default {
         }
       )
         .then(() => {
+          let index = this.tableData.findIndex((item) => {
+            return item.index === v.index;
+          });
           this.tableData.splice(index, 1);
         })
         .catch(() => {
@@ -1223,12 +1224,18 @@ export default {
 
       if (this.tableData.length) {
         let maxIndex = 0;
+        let childrenIndex = 0;
         this.tableData.forEach((item) => {
           if (item.sort > maxIndex) {
             maxIndex = item.sort;
           }
+          if (item.index > childrenIndex) {
+            childrenIndex = item.index
+          }
         });
         this.activeLists.forEach((item, index) => {
+          childrenIndex++
+          item.index = childrenIndex
           item.sort = maxIndex + index + 1;
           item.optionsList = JSON.parse(item.jsonStr);
           item.partScore = 0;
@@ -1237,6 +1244,7 @@ export default {
         });
       } else {
         this.activeLists.forEach((item, index) => {
+          item.index = index
           item.sort = index + 1;
           item.optionsList = JSON.parse(item.jsonStr);
           item.partScore = 0;
@@ -1304,12 +1312,15 @@ export default {
           self.activeExam = [];
         });
       } else {
-        self.tableData[indexZB].diff = true;
+        let newIndex = self.tableData.findIndex((item) => {
+          return item.index === indexZB;
+        });
+        self.tableData[newIndex].diff = true;
         self.innerVisiblePaperTopic = true;
         self.showHide = true;
         self.statusPop = int;
         var vres = JSON.parse(JSON.stringify(v));
-        self.indexZB = indexZB;
+        self.indexZB = newIndex;
         if (vres.knowledgeIds) {
           var a = [];
           vres.knowledgeIds
@@ -1585,14 +1596,20 @@ export default {
 
             if (this.tableData.length) {
               let maxIndex = 0;
+              let childrenIndex = 0;
               this.tableData.forEach((item) => {
                 if (item.sort > maxIndex) {
                   maxIndex = item.sort;
                 }
+                if (item.index > childrenIndex) {
+                  childrenIndex = item.index;
+                }
               });
               data.sort = maxIndex + 1;
+              data.index = childrenIndex + 1;
             } else {
               data.sort = 1;
+              data.index = 0;
             }
             this.tableData.push(data);
             // this.$api.addbankquestion(data).then((res) => {
@@ -1603,7 +1620,10 @@ export default {
             // });
           }
           if (this.statusPop === 0) {
-            this.tableData.splice(this.indexZB, 1, data);
+            let indexy = this.tableData.findIndex((item) => {
+              return item.index === this.indexZB;
+            });
+            this.tableData.splice(indexy, 1, data);
             // this.$api.editbankquestion(data).then((res) => {
             self.$message.success("修改成功");
             self.innerVisiblePaperTopic = false;

+ 11 - 3
src/views/resource/bankManagement/testPaperManagement/editPaper/topicEditPaper/wordPop.vue

@@ -109,17 +109,25 @@ export default {
             let numList = self.$parent.$parent.tableData;
             if (numList.length) {
               let numIndex = 0;
+              let childrenIndex = 0;
               numList.forEach((items) => {
                 if (items.sort > numIndex) {
                   numIndex = items.sort;
                 }
+                if (items.index > childrenIndex) {
+                  childrenIndex = items.index;
+                }
               });
               res.data.forEach((items, indexs) => {
-                items.sort = 1 + numIndex++;
+                numIndex++
+                childrenIndex++
+                items.sort = numIndex;
+                items.index = childrenIndex;
               });
             } else {
               res.data.forEach((items, indexs) => {
-                items.sort = 1 + indexs++;
+                items.sort = 1 + indexs;
+                items.index = indexs;
               });
             }
             self.$parent.$parent.tableData =
@@ -234,4 +242,4 @@ export default {
     margin: 5px 0px;
   }
 }
-</style>
+</style>