xiatian 4 ani în urmă
părinte
comite
f46fd874dc
1 a modificat fișierele cu 67 adăugiri și 0 ștergeri
  1. 67 0
      src/modules/questions/views/EditPaper.vue

+ 67 - 0
src/modules/questions/views/EditPaper.vue

@@ -185,6 +185,20 @@
               >编辑
             </el-button>
 
+            <el-button
+              v-if="showUp(paperDetail)"
+              size="small"
+              @click="movePaperDetail(paperDetail, 'up')"
+              >上移
+            </el-button>
+
+            <el-button
+              v-if="showDown(paperDetail)"
+              size="small"
+              @click="movePaperDetail(paperDetail, 'down')"
+              >下移
+            </el-button>
+
             <el-button
               size="small"
               type="danger"
@@ -949,6 +963,59 @@ export default {
     };
   },
   methods: {
+    movePaperDetail(detail, vector) {
+      let vectorStr = vector == "up" ? "上移" : "下移";
+      this.$alert("您确定" + vectorStr + "吗?", "提示", {
+        confirmButtonText: "确定",
+        callback: (action) => {
+          if (action == "confirm") {
+            this.loading = true;
+            this.$http
+              .put(
+                QUESTION_API +
+                  "/paperDetail/" +
+                  this.paperId +
+                  "/" +
+                  detail.id +
+                  "/" +
+                  vector
+              )
+              .then(() => {
+                this.initPaper();
+                this.loading = true;
+                this.$notify({
+                  message: vectorStr + "成功",
+                  type: "success",
+                });
+                this.loading = false;
+              });
+          }
+        },
+      });
+    },
+    showUp(detail) {
+      if (this.paper.paperDetails.length <= 1) {
+        return false;
+      }
+      if (detail.id != this.paper.paperDetails[0].id) {
+        return true;
+      } else {
+        return false;
+      }
+    },
+    showDown(detail) {
+      if (this.paper.paperDetails.length <= 1) {
+        return false;
+      }
+      if (
+        detail.id !=
+        this.paper.paperDetails[this.paper.paperDetails.length - 1].id
+      ) {
+        return true;
+      } else {
+        return false;
+      }
+    },
     downAnswerTemplate() {
       var key = this.user.key;
       var token = this.user.token;