Browse Source

批次复制

Michael Wang 4 years ago
parent
commit
2150b91dc6

+ 4 - 0
src/api/exam.js

@@ -25,6 +25,10 @@ export function toggleEnableExam({ id, enable }) {
   return httpApp.post("/api/admin/exam/toggle", { id, enable });
   return httpApp.post("/api/admin/exam/toggle", { id, enable });
 }
 }
 
 
+export function copyExam({ sourceId, name, code }) {
+  return httpApp.post("/api/admin/exam/copy", { sourceId, name, code });
+}
+
 export function saveExam({
 export function saveExam({
   id = "",
   id = "",
   breakExpireSeconds = 0,
   breakExpireSeconds = 0,

+ 10 - 5
src/features/examwork/ExamManagement/ExamEdit.vue

@@ -167,8 +167,8 @@
             >
             >
             <h2>监考直播</h2>
             <h2>监考直播</h2>
             <el-form-item label="是否开启考生端监考直播">
             <el-form-item label="是否开启考生端监考直播">
-              <el-radio v-model="form.monitorProxy" :label="1">是</el-radio>
-              <el-radio v-model="form.monitorProxy" :label="0">否</el-radio>
+              <el-radio v-model="form.monitorProxy" :label="true">是</el-radio>
+              <el-radio v-model="form.monitorProxy" :label="false">否</el-radio>
             </el-form-item>
             </el-form-item>
             <el-form-item v-if="form.monitorProxy" label="是否需要视频转录">
             <el-form-item v-if="form.monitorProxy" label="是否需要视频转录">
               <el-radio v-model="form.monitorRecord" :label="1">是</el-radio>
               <el-radio v-model="form.monitorRecord" :label="1">是</el-radio>
@@ -246,6 +246,9 @@ export default {
           this.form.monitorVideoSource = [];
           this.form.monitorVideoSource = [];
           this.form.monitorRecord = 0;
           this.form.monitorRecord = 0;
         }
         }
+        if (this.form.monitorVideoSource === null) {
+          this.form.monitorVideoSource = [];
+        }
       },
       },
     },
     },
   },
   },
@@ -254,6 +257,7 @@ export default {
       const res = await getExamDetail({ id: this.examId });
       const res = await getExamDetail({ id: this.examId });
       this.form = { ...this.form, ...res.data.data.records };
       this.form = { ...this.form, ...res.data.data.records };
       this.form.startEndTimeProxy = [this.form.startTime, this.form.endTime];
       this.form.startEndTimeProxy = [this.form.startTime, this.form.endTime];
+      this.form.monitorProxy = !!this.form.monitorVideoSource;
     }
     }
   },
   },
   data() {
   data() {
@@ -288,7 +292,7 @@ export default {
         inProcessLivenessVerify: 0,
         inProcessLivenessVerify: 0,
         inProcessLivenessFixedRange: [],
         inProcessLivenessFixedRange: [],
         inProcessLivenessJudgePolicy: "ALL",
         inProcessLivenessJudgePolicy: "ALL",
-        monitorProxy: 0,
+        monitorProxy: false,
         monitorRecord: 0,
         monitorRecord: 0,
         monitorVideoSource: [],
         monitorVideoSource: [],
         ipAllow: "",
         ipAllow: "",
@@ -296,8 +300,9 @@ export default {
     };
     };
   },
   },
   methods: {
   methods: {
-    save() {
-      saveExam(this.form);
+    async save() {
+      await saveExam(this.form);
+      this.$notify({ title: "保存成功", type: "success" });
     },
     },
     cancel() {},
     cancel() {},
   },
   },

+ 26 - 6
src/features/examwork/ExamManagement/ExamManagement.vue

@@ -12,9 +12,10 @@
       </el-form-item>
       </el-form-item>
       <el-button @click="searchForm">查询</el-button>
       <el-button @click="searchForm">查询</el-button>
       <el-button @click="add">新增</el-button>
       <el-button @click="add">新增</el-button>
+      <el-button @click="copy">复制</el-button>
     </el-form>
     </el-form>
 
 
-    <el-table :data="tableData" stripe style="width: 100%;">
+    <el-table ref="table" :data="tableData" stripe style="width: 100%;">
       <el-table-column type="selection" width="40" />
       <el-table-column type="selection" width="40" />
       <el-table-column width="55" label="ID">
       <el-table-column width="55" label="ID">
         <span slot-scope="scope">{{ scope.row.id }}</span>
         <span slot-scope="scope">{{ scope.row.id }}</span>
@@ -90,7 +91,7 @@
 <script>
 <script>
 import StateSelect from "@/components/StateSelect";
 import StateSelect from "@/components/StateSelect";
 import ExamTypeSelect from "@/components/ExamTypeSelect";
 import ExamTypeSelect from "@/components/ExamTypeSelect";
-import { searchExams, toggleEnableExam } from "@/api/exam";
+import { searchExams, toggleEnableExam, copyExam } from "@/api/exam";
 
 
 export default {
 export default {
   name: "ExamManagement",
   name: "ExamManagement",
@@ -111,9 +112,9 @@ export default {
       currentPage: 1,
       currentPage: 1,
       pageSize: 10,
       pageSize: 10,
       total: 10,
       total: 10,
+      selected: null,
     };
     };
   },
   },
-  async created() {},
   methods: {
   methods: {
     async searchForm() {
     async searchForm() {
       const res = await searchExams({
       const res = await searchExams({
@@ -140,10 +141,29 @@ export default {
     edit(exam) {
     edit(exam) {
       this.$router.push("/exam/edit/" + exam.id);
       this.$router.push("/exam/edit/" + exam.id);
     },
     },
-    async toggleEnableExam(user) {
+    async toggleEnableExam(exam) {
       await toggleEnableExam({
       await toggleEnableExam({
-        id: user.id,
-        enable: user.enable === 0 ? 1 : 0,
+        id: exam.id,
+        enable: exam.enable === 0 ? 1 : 0,
+      });
+      this.searchForm();
+    },
+    async copy() {
+      console.log(this.$refs.table.selection);
+      let rows = this.$refs.table.selection;
+      if (rows.length === 0) {
+        this.$notify({ type: "warning", title: "请选择一个批次" });
+        return;
+      }
+      if (rows.length > 1) {
+        this.$notify({ type: "warning", title: "请仅选择一个批次" });
+        return;
+      }
+      const exam = rows[0];
+      await copyExam({
+        sourceId: exam.id,
+        code: exam.code,
+        name: exam.name,
       });
       });
       this.searchForm();
       this.searchForm();
     },
     },