Bläddra i källkod

flx:试卷编辑预览问题及BUG

Tang 3 år sedan
förälder
incheckning
630faa88d1

+ 22 - 3
src/components/testPaperPreview/index.vue

@@ -47,6 +47,14 @@
               <span>题目{{ index + 1 }}</span>
               <span>{{ getTypeName(item.type) }}</span>
               <span>分值:{{ item.score }}</span>
+              <el-button
+                size="mini"
+                style="float: right"
+                @click="changeDatas(item)"
+                v-if="type === 2"
+                >修改</el-button
+              >
+              <div style="clear: both"></div>
             </div>
             <div class="dis_flex">
               <span>题目内容:</span>
@@ -151,7 +159,7 @@
         </div>
       </div>
       <span slot="footer" class="dialog-footer">
-        <el-button @click="clears">取 消</el-button>
+        <el-button @click="clears">确 认</el-button>
       </span>
     </el-dialog>
   </div>
@@ -164,6 +172,7 @@ export default {
       diavos: false,
       tableData: [], //题目内容
       topData: {}, //顶部表格数据
+      type: "",
     };
   },
   computed: {
@@ -215,11 +224,11 @@ export default {
      */
     openBox(type, row) {
       const ROWS = JSON.parse(JSON.stringify(row));
-      console.log(type, ROWS);
+      this.type = type;
       if (type === 1) {
         //搜索Id处理数据
         this.$api.obtainbankexam(row).then((res) => {
-            console.log(111)
+          console.log(111);
           this.topData = {
             answerTime: res.data.answerTime,
             answerNum: res.data.answerNum,
@@ -246,9 +255,19 @@ export default {
         this.diavos = true;
       }
     },
+    changeDatas(row) {
+      this.$parent.addClick(row,0,row.index,true)
+    },
     clears() {
       this.diavos = false;
     },
+    changeUploadStatus(data){
+      let index = this.tableData.findIndex(item => {
+        return item.index === data.index
+      })
+      this.$set(this.tableData,index,data)
+      console.log(data)
+    },
     /**
      * 选项转换
      */

+ 33 - 10
src/views/resource/bankManagement/testPaperManagement/addPaper/topicAddPaper/index.vue

@@ -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">
@@ -777,7 +773,9 @@ export default {
           label: "题目内容",
           prop: "content",
           hidden: true,
+          showTooltip: true,
           scope: "editInfoHTMLs",
+          width: "320px",
         },
 
         {
@@ -876,6 +874,7 @@ export default {
           prop: "content",
           hidden: true,
           scope: "editInfoHTMLs",
+          width: "320px",
         },
         {
           label: "发布状态",
@@ -956,6 +955,7 @@ export default {
       copytableData: [],
       localStart: false, //定时器是否已经开始
       pageId: "", //试卷ID
+      uploadStatus: false, //是否同步预览
     };
   },
   computed: {
@@ -1114,7 +1114,7 @@ export default {
     init() {
       this.search();
     },
-    del(v, index) {
+    del(v) {
       this.$alert(
         "确定删除此内容?<br />内容删除后将无法恢复,请慎重考虑",
         "提示",
@@ -1123,6 +1123,9 @@ export default {
         }
       )
         .then(() => {
+          let index = this.tableData.findIndex((item) => {
+            return item.index === v.index;
+          });
           this.tableData.splice(index, 1);
         })
         .catch(() => {
@@ -1249,7 +1252,7 @@ export default {
     getRowKeys(row) {
       return row.questionId;
     },
-    addClick(v, int, indexZB) {
+    addClick(v, int, indexZB,uploadStatus) {
       var self = this;
       if (v === undefined) {
         self.statusPop = 1;
@@ -1283,11 +1286,19 @@ export default {
           self.activeExam = [];
         });
       } else {
+        if (uploadStatus) {
+          this.uploadStatus = true;
+        } else {
+          this.uploadStatus = false;
+        }
+        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
@@ -1561,14 +1572,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) => {
@@ -1579,7 +1596,13 @@ 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);
+            if (this.uploadStatus) {
+              this.$refs.testPaperPreview.changeUploadStatus(data);
+            }
             // this.$api.editbankquestion(data).then((res) => {
             self.$message.success("修改成功");
             self.innerVisiblePaperTopic = false;

+ 35 - 16
src/views/resource/bankManagement/testPaperManagement/editPaper/topicEditPaper/index.vue

@@ -7,7 +7,6 @@
         :navText="navText"
         @addClick="openActiveBox"
         :loading="loading"
-        @editInfo="editInfo"
         @emitData="emitData"
       >
         <template slot="customize">
@@ -18,14 +17,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">
@@ -782,6 +777,7 @@ export default {
           prop: "content",
           hidden: true,
           scope: "editInfoHTMLs",
+          showTooltip: true,
           width: "320px",
         },
 
@@ -970,6 +966,7 @@ export default {
       copytableData: [],
       localStart: false, //定时器是否已经开始
       pageId: "", //试卷ID
+      uploadStatus: false, //是否同步预览
     };
   },
   computed: {
@@ -1141,17 +1138,16 @@ export default {
       });
     },
     // --------------------------分割线---------------------------
-    editInfo(v) {
-      this.addClick(v, 0);
-    },
     search(v) {
       this.loading = true;
       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;
@@ -1164,7 +1160,7 @@ export default {
     // init() {
     //   this.search();
     // },
-    del(v, index) {
+    del(v) {
       this.$alert(
         "确定删除此内容?<br />内容删除后将无法恢复,请慎重考虑",
         "提示",
@@ -1173,6 +1169,9 @@ export default {
         }
       )
         .then(() => {
+          let index = this.tableData.findIndex((item) => {
+            return item.index === v.index;
+          });
           this.tableData.splice(index, 1);
         })
         .catch(() => {
@@ -1300,7 +1299,7 @@ export default {
     getRowKeys(row) {
       return row.questionId;
     },
-    addClick(v, int, indexZB) {
+    addClick(v, int, indexZB, uploadStatus) {
       var self = this;
       if (v === undefined) {
         self.statusPop = 1;
@@ -1334,12 +1333,20 @@ export default {
           self.activeExam = [];
         });
       } else {
-        self.tableData[indexZB].diff = true;
+        if (uploadStatus) {
+          this.uploadStatus = true;
+        } else {
+          this.uploadStatus = false;
+        }
+        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
@@ -1615,14 +1622,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) => {
@@ -1633,7 +1646,13 @@ 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);
+            if(this.uploadStatus){
+              this.$refs.testPaperPreview.changeUploadStatus(data)
+            }
             // this.$api.editbankquestion(data).then((res) => {
             self.$message.success("修改成功");
             self.innerVisiblePaperTopic = false;

+ 10 - 2
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 =

+ 1 - 0
src/views/resource/bankManagement/topicManagement/index.vue

@@ -353,6 +353,7 @@ export default {
           prop: "content",
           hidden: true,
           scope: "editInfoHTML",
+          showTooltip: true,
           width: "280px",
         },
         {