xiatian před 3 roky
rodič
revize
62894acac8
1 změnil soubory, kde provedl 197 přidání a 3 odebrání
  1. 197 3
      src/modules/questions/views/EditPaper.vue

+ 197 - 3
src/modules/questions/views/EditPaper.vue

@@ -267,13 +267,56 @@
                   @click="editQues(paperDetailUnit, paperDetailUnit.question)"
                   >编辑
                 </el-button>
+                <el-button
+                  v-if="showUnitUp(paperDetail, paperDetailUnit.id)"
+                  size="small"
+                  @click="
+                    movePaperDetailUnit(
+                      paperDetail.id,
+                      paperDetailUnit.id,
+                      'up'
+                    )
+                  "
+                  >上移
+                </el-button>
 
+                <el-button
+                  v-if="showUnitDown(paperDetail, paperDetailUnit.id)"
+                  size="small"
+                  @click="
+                    movePaperDetailUnit(
+                      paperDetail.id,
+                      paperDetailUnit.id,
+                      'down'
+                    )
+                  "
+                  >下移
+                </el-button>
                 <el-button
                   type="danger"
                   size="small"
                   @click="deleteQues(paperDetailUnit)"
                   >删除
                 </el-button>
+                <el-button
+                  v-show="
+                    isNested(paperDetailUnit.questionType) &&
+                    showSubButtons[detailIndex + '-' + unitIndex]
+                  "
+                  size="small"
+                  icon="el-icon-arrow-up"
+                  @click.stop="hideSubContent(detailIndex + '-' + unitIndex)"
+                ></el-button>
+
+                <el-button
+                  v-show="
+                    isNested(paperDetailUnit.questionType) &&
+                    !showSubButtons[detailIndex + '-' + unitIndex]
+                  "
+                  size="small"
+                  icon="el-icon-arrow-down"
+                  @click.stop="showSubContent(detailIndex + '-' + unitIndex)"
+                ></el-button>
               </div>
 
               <div class="quesBody">
@@ -329,7 +372,10 @@
               </div>
             </div>
             <div style="flex-basis: 100%"></div>
-            <div class="sub-ques-main-div">
+            <div
+              v-show="showSubQuestions[detailIndex + '-' + unitIndex]"
+              class="sub-ques-main-div"
+            >
               <div
                 v-for="(subQuestion, subIndex) in paperDetailUnit.question
                   .subQuestions"
@@ -361,6 +407,31 @@
                       @click="editQues(paperDetailUnit, subQuestion)"
                       >编辑
                     </el-button>
+                    <el-button
+                      v-if="showUnitSubUp(paperDetailUnit, subQuestion.id)"
+                      size="small"
+                      @click="
+                        movePaperDetailUnitSub(
+                          paperDetailUnit.id,
+                          subQuestion.id,
+                          'up'
+                        )
+                      "
+                      >上移
+                    </el-button>
+
+                    <el-button
+                      v-if="showUnitSubDown(paperDetailUnit, subQuestion.id)"
+                      size="small"
+                      @click="
+                        movePaperDetailUnitSub(
+                          paperDetailUnit.id,
+                          subQuestion.id,
+                          'down'
+                        )
+                      "
+                      >下移
+                    </el-button>
                   </div>
 
                   <div class="quesBody">
@@ -1140,6 +1211,8 @@ export default {
       examRemark: "",
       showQuestions: [],
       showButtons: [],
+      showSubQuestions: {},
+      showSubButtons: {},
     };
   },
   computed: {
@@ -1243,6 +1316,111 @@ export default {
       }
       return true;
     },
+    movePaperDetailUnitSub(unitid, subid, vector) {
+      let vectorStr = vector == "up" ? "上移" : "下移";
+      this.$alert("您确定" + vectorStr + "吗?", "提示", {
+        confirmButtonText: "确定",
+        callback: (action) => {
+          if (action == "confirm") {
+            this.loading = true;
+            this.$http
+              .put(
+                QUESTION_API +
+                  "/paperDetailUnit/sub/" +
+                  unitid +
+                  "/" +
+                  subid +
+                  "/" +
+                  vector
+              )
+              .then(() => {
+                this.initPaper();
+                this.loading = true;
+                this.$notify({
+                  message: vectorStr + "成功",
+                  type: "success",
+                });
+                this.loading = false;
+              });
+          }
+        },
+      });
+    },
+    showUnitSubDown(unit, subid) {
+      if (unit.question.subQuestions.length <= 1) {
+        return false;
+      }
+      if (
+        subid !=
+        unit.question.subQuestions[unit.question.subQuestions.length - 1].id
+      ) {
+        return true;
+      } else {
+        return false;
+      }
+    },
+    showUnitSubUp(unit, subid) {
+      if (unit.question.subQuestions.length <= 1) {
+        return false;
+      }
+      if (subid != unit.question.subQuestions[0].id) {
+        return true;
+      } else {
+        return false;
+      }
+    },
+    movePaperDetailUnit(detailId, unitid, vector) {
+      let vectorStr = vector == "up" ? "上移" : "下移";
+      this.$alert("您确定" + vectorStr + "吗?", "提示", {
+        confirmButtonText: "确定",
+        callback: (action) => {
+          if (action == "confirm") {
+            this.loading = true;
+            this.$http
+              .put(
+                QUESTION_API +
+                  "/paperDetailUnit/" +
+                  detailId +
+                  "/" +
+                  unitid +
+                  "/" +
+                  vector
+              )
+              .then(() => {
+                this.initPaper();
+                this.loading = true;
+                this.$notify({
+                  message: vectorStr + "成功",
+                  type: "success",
+                });
+                this.loading = false;
+              });
+          }
+        },
+      });
+    },
+    showUnitDown(detail, unitid) {
+      if (detail.paperDetailUnits.length <= 1) {
+        return false;
+      }
+      if (
+        unitid != detail.paperDetailUnits[detail.paperDetailUnits.length - 1].id
+      ) {
+        return true;
+      } else {
+        return false;
+      }
+    },
+    showUnitUp(detail, unitid) {
+      if (detail.paperDetailUnits.length <= 1) {
+        return false;
+      }
+      if (unitid != detail.paperDetailUnits[0].id) {
+        return true;
+      } else {
+        return false;
+      }
+    },
     movePaperDetail(detail, vector) {
       let vectorStr = vector == "up" ? "上移" : "下移";
       this.$alert("您确定" + vectorStr + "吗?", "提示", {
@@ -1356,16 +1534,26 @@ export default {
     },
     //隐藏大题下的所有小题
     hideContent(index) {
-      console.log("up");
       this.showQuestions[index].is_show = false;
       this.showButtons[index].up = false;
     },
     //展开大题下所有小题
     showContent(index) {
-      console.log("down");
       this.showQuestions[index].is_show = true;
       this.showButtons[index].up = true;
     },
+    //隐藏大题下的所有小题
+    hideSubContent(index) {
+      this.showSubQuestions[index] = false;
+      this.showSubButtons[index] = false;
+      this.$forceUpdate();
+    },
+    //展开大题下所有小题
+    showSubContent(index) {
+      this.showSubQuestions[index] = true;
+      this.showSubButtons[index] = true;
+      this.$forceUpdate();
+    },
     quesMouseOver(index) {
       document.getElementById(index).style.visibility = "visible";
     },
@@ -1435,6 +1623,7 @@ export default {
           this.initCourseProperty(this.paper.course.code);
           //将所有小题分为公开和非公开
           if (this.paper.paperDetails && this.paper.paperDetails.length > 0) {
+            let dindx = 0;
             for (let paperDetil of this.paper.paperDetails) {
               this.showQuestions.push({ is_show: true });
               this.showButtons.push({ up: true });
@@ -1444,7 +1633,10 @@ export default {
                 paperDetil.paperDetailUnits &&
                 paperDetil.paperDetailUnits.length > 0
               ) {
+                let uindx = 0;
                 for (let paperDetilUt of paperDetil.paperDetailUnits) {
+                  this.showSubQuestions[dindx + "-" + uindx] = true;
+                  this.showSubButtons[dindx + "-" + uindx] = true;
                   if (!this.isNested(paperDetilUt.question.questionType)) {
                     //非套题
                     if (paperDetilUt.question.publicity) {
@@ -1462,8 +1654,10 @@ export default {
                       }
                     }
                   }
+                  uindx++;
                 }
               }
+              dindx++;
             }
           }
           setTimeout(() => {