From a3cc0d240ee750fa23d6a7772346cc6bc1023bae Mon Sep 17 00:00:00 2001
From: 黄何裕 <1053952480@qq.com>
Date: 星期五, 12 七月 2024 11:51:55 +0800
Subject: [PATCH] 考试操作加时和交卷

---
 src/views/exam/components/answer-time/index.vue |   28 ++++++++++++++++------------
 src/views/train/data-list/index.vue             |    6 +++---
 src/views/exam/index.vue                        |   17 +++++++++++++----
 3 files changed, 32 insertions(+), 19 deletions(-)

diff --git a/src/views/exam/components/answer-time/index.vue b/src/views/exam/components/answer-time/index.vue
index 9aa8742..67ac431 100644
--- a/src/views/exam/components/answer-time/index.vue
+++ b/src/views/exam/components/answer-time/index.vue
@@ -1,5 +1,7 @@
 <template>
-  <div class="time-container flex justify-center text-white items-center shadow-md">
+  <div
+    class="time-container flex justify-center text-white items-center shadow-md"
+  >
     <el-icon class="mr-1 text-xl" size="24"><Timer /></el-icon>
     <div class="label mr-1">鍓╀綑鏃堕棿:</div>
     <el-countdown :value="time" @finish="timeFinish" />
@@ -7,23 +9,26 @@
 </template>
 
 <script setup>
-import {ref} from 'vue';
-import dayjs from 'dayjs';
-import { storeToRefs } from 'pinia';
-import { Timer } from '@element-plus/icons-vue';
-import { useExamStore } from '@/store/index.js';
+import { ref, defineExpose } from "vue";
+import dayjs from "dayjs";
+import { storeToRefs } from "pinia";
+import { Timer } from "@element-plus/icons-vue";
+import { useExamStore } from "@/store/index.js";
 
 const examStore = useExamStore();
 const { examInfo } = storeToRefs(examStore);
 
-const emit = defineEmits(['timeOut']);
+const emit = defineEmits(["timeOut"]);
 
 const time = ref(dayjs().valueOf() + examInfo.value.suggestTime * 1000 * 60);
 
 const timeFinish = () => {
-  emit('timeOut');
-}
-
+  emit("timeOut");
+};
+const addTime = (data) => {
+  time.value = time.value + data * 1000;
+};
+defineExpose({ addTime });
 </script>
 
 <style lang="scss" scoped>
@@ -32,10 +37,9 @@
   border-radius: 100px;
   padding: 10px 0;
   background-color: rgba($color: #86d7f7, $alpha: 0.3);
-
 }
 
 :deep(.el-statistic__number) {
   color: #ffffff;
 }
-</style>
\ No newline at end of file
+</style>
diff --git a/src/views/exam/index.vue b/src/views/exam/index.vue
index 2b3ea60..bd858ed 100644
--- a/src/views/exam/index.vue
+++ b/src/views/exam/index.vue
@@ -7,7 +7,7 @@
           <div class="title-container text-3xl font-semibold text-white mr-8">
             {{ examInfo.examName }}
           </div>
-          <AnswerTime @timeOut="timeOut"></AnswerTime>
+          <AnswerTime @timeOut="timeOut" ref="answerTime"></AnswerTime>
 
           <div class="return-container grow flex justify-end">
             <el-button type="danger" size="large" circle @click="closeClick">
@@ -176,8 +176,13 @@
 const submitDialog = ref(false);
 const timeDialog = ref(false);
 
+// const { status, message, error, connect, disconnect, sendMessage } = useWebScoket({
+//   url: 'wss://42.193.1.25:8000/websocket/' + userInfo.value.id,
+//   heartBeatData: 'ping'
+// });
+
 const { status, message, error, connect, disconnect, sendMessage } = useWebScoket({
-  url: 'wss://42.193.1.25:8000/websocket/' + userInfo.value.id,
+  url: '//192.168.3.64:8000/websocket/' + userInfo.value.id,
   heartBeatData: 'ping'
 });
 
@@ -288,9 +293,13 @@
   });
   examStore.setProgress(progress);
 });
-
+const answerTime = ref()
 watch(() => message.value, (msg) => {
-  console.log(msg);
+  if(msg.commend=="delayed"){
+    answerTime.value.addTime(msg.data.addTimeM)
+  }else if(msg.commend=="forceSubmit"){
+    confirmSubmit()
+  }
 });
 
 
diff --git a/src/views/train/data-list/index.vue b/src/views/train/data-list/index.vue
index 0c53999..977a7bc 100644
--- a/src/views/train/data-list/index.vue
+++ b/src/views/train/data-list/index.vue
@@ -51,7 +51,7 @@
     default: () => [],
   },
 });
-
+const userId = JSON.parse(localStorage.getItem('user')).userInfo.id
 const itemClick = (item) => {
   classMeet(item.id)
     .then((res) => {
@@ -63,8 +63,8 @@
           query: {
             meetName: item.meetName,
             id: item.id,
-            userName: userInfo.value?.realName + "_" + item.id || "",
-            userCode: userInfo.value?.phone + "_" + item.id || "",
+            userName: userInfo.value?.realName + "_" + userId || "",
+            userCode: userInfo.value?.phone + "_" + userId || "",
           },
         });
         window.open(path.href, "_blank");

--
Gitblit v1.8.0