Przeglądaj źródła

feat: 试卷锁定

zhangjie 7 miesięcy temu
rodzic
commit
10ee048f38
1 zmienionych plików z 41 dodań i 1 usunięć
  1. 41 1
      src/modules/questions/views/GenPaper.vue

+ 41 - 1
src/modules/questions/views/GenPaper.vue

@@ -185,9 +185,21 @@
           prop="updateTime"
         >
         </el-table-column>
-        <el-table-column label="操作" width="180" fixed="right">
+        <el-table-column label="锁定状态" width="90">
+          <template slot-scope="scope">
+            <span>{{ scope.row.locked ? "锁定" : "" }}</span>
+          </template>
+        </el-table-column>
+        <el-table-column label="操作" width="220" fixed="right">
           <template slot-scope="scope">
             <div class="operate_left">
+              <el-button
+                size="medium"
+                type="text"
+                class="normal"
+                @click="lockPaper(scope.row)"
+                >{{ scope.row.locked ? "解锁" : "锁定" }}</el-button
+              >
               <el-button
                 size="medium"
                 type="text"
@@ -842,6 +854,34 @@ export default {
         );
       });
     },
+    async lockPaper(row) {
+      const action = row.locked ? "解锁" : "锁定";
+      const result = await this.$confirm(`确定要${action}试卷吗?`, "提示", {
+        type: "warning",
+      }).catch(() => {});
+      if (result !== "confirm") return;
+
+      const locked = !row.locked;
+      let res = true;
+      await this.$httpWithMsg
+        .post(
+          QUESTION_API + "/paper/lock/",
+          {},
+          {
+            params: {
+              id: row.id,
+              locked,
+            },
+          }
+        )
+        .catch(() => {
+          res = false;
+        });
+      if (!res) return;
+
+      row.locked = locked;
+      this.$message.success("操作成功!");
+    },
     selectChange(row) {
       this.selectedPaperIds = [];
       row.forEach((element) => {