Browse Source

日常开发

linxuxiang 5 tháng trước cách đây
mục cha
commit
6dcd232263
1 tập tin đã thay đổi với 60 bổ sung21 xóa
  1. 60 21
      src/views/train/run.vue

+ 60 - 21
src/views/train/run.vue

@@ -107,13 +107,16 @@
     <!-- <div>当前状态:({{ examState == 3 ? "初始化完成" : examState == 40 ? "创建测试" : examState == 41 ? "正在人脸识别":examState ==43 ? "停止人脸识别" : examState == 42 ? "正在测试" : "请初始化" }})</div> -->
     <div class="footerBtn">
       <template v-if="needStart">
-        <div class="btn" @click="getOpenOneTestAndStartFace" v-if="examState == 3 || examState == 40">开始识别</div>
         <div class="btn" @click="getChooseStudent()" v-if="examState == 41 && isLongRun">检录</div>
-        <div class="btn" @click="getStopFace" v-if="examState == 41">停止识别</div>
-        <div class="btn startBtn" @click="getStartOneTest" v-if="examState == 43">开始测试</div>
+        <!-- <div class="btn" @click="getStopFace" v-if="examState == 41">停止识别</div> -->
+        <!-- <div class="btn startBtn" @click="getStartOneTest" v-if="examState == 43">开始测试</div> -->
       </template>
-      <template v-else> </template>
-      <div class="btn" @click="getConfirmEnd" v-if="examState == 42">{{ isLongRun ? '结 束' : '下一组' }}</div>
+      <template v-else>
+      </template>
+      <div class="btn startBtn" @click="getStopFaceStartOneTest" v-if="examState == 41 || examState == 43">开始测试</div>
+      <div class="btn" @click="getOpenOneTestAndStartFace" v-if="(examState == 3 || examState == 40) && resultId">下一组
+      </div>
+      <div class="btn" @click="getConfirmEnd" v-if="examState == 42">结 束</div>
       <div class="btn" @click="getAgain" v-if="showTestAgain">再测一次</div>
       <div class="btn" @click="getRetestFace" v-if="examState == 43">重新识别</div>
     </div>
@@ -348,8 +351,10 @@ const getFaceConfirmOnly = (data?: any) => {
 const getRetestFace = () => {
   proxy?.$modal.confirm("确定重新识别吗?").then(() => {
     if (needStart.value == false) {
-      //自动流程项目重新识别直接返回3
-      closeOneTest();
+      // //自动流程项目重新识别直接返回3
+      // closeOneTest();
+      cleanData();
+      startFace();
     } else {
       //手动流程项目重新识别43返回41,42返回3
       if (examState.value == 43) {
@@ -363,6 +368,16 @@ const getRetestFace = () => {
   });
 };
 
+/**
+ * 停止人脸并开始测试
+*/
+const getStopFaceStartOneTest = async () => {
+  if (examState.value == 41) {
+    await getStopFace()
+  }
+  await getStartOneTest();
+};
+
 /**
  * 开始测试
 */
@@ -379,7 +394,6 @@ const getStartOneTest = () => {
   }
   //停止播报;
   speckCancel()
-
   //和工作站搭配时差版
   //提前发送开始的时间
   let advanceTime = 1000;
@@ -398,16 +412,14 @@ const getStartOneTest = () => {
     //显示再测一次按钮
     showTestAgain.value = true;
     //计时项目才开
-    if (needStart.value == true) {
-      //时间为0的为正计时,大于0的为倒计时
-      if (time.value.testTime == 0) {
-        getCounting("+");
-      } else {
-        getCounting("-");
-      }
+    if (needStart.value == true) { }
+    //时间为0的为正计时,大于0的为倒计时
+    if (time.value.testTime == 0) {
+      getCounting("+");
     } else {
-      speckText("请开始测试");
+      getCounting("-");
     }
+
   }, myTime)
 
   // 立即开版本
@@ -435,6 +447,7 @@ const getAgain = async () => {
   let txt = '是否再测一次?'
   await proxy?.$modal.confirm(txt);
   getClearTimer();
+  speckCancel()//停止播报;
   let loading = ElLoading.service({ text: '请稍等...', background: 'rgba(0, 0, 0, 0.8)', customClass: `sports ${parameter.value.project}` });
   //预存测试人员
   let student = faceStudentList.value.map((item: any) => {
@@ -471,8 +484,10 @@ const getAgain = async () => {
  * 确认退出
 */
 const getConfirmEnd = async () => {
-  let txt = isLongRun.value ? '是否结束' : '是否开始下一组?'
+  let txt = '是否结束'
   await proxy?.$modal.confirm(txt);
+  getClearTimer();//清除计时器
+  speckCancel()//停止播报;
   let loading = ElLoading.service({ text: '请稍等...', background: 'rgba(0, 0, 0, 0.8)', customClass: `sports ${parameter.value.project}` });
   //测试中
   if (examState.value == 42) {
@@ -483,7 +498,6 @@ const getConfirmEnd = async () => {
     await closeOneTest();
   }
   if (!isLongRun.value) {
-    //重新走一次流程
     await openOneTest();
     await startFace();
   }
@@ -509,8 +523,8 @@ const confirmExit = () => {
 */
 const getExit = () => {
   getClearTimer();//清除计时器
-  examEnds();//通知工作站关闭
   speckCancel()//停止播报;
+  examEnds();//通知工作站关闭
   window.onbeforeunload = null;//移除事件处理器
   router.push({ path: '/' });//跳转
 };
@@ -672,6 +686,29 @@ const cleanData = () => {
 const initProject = () => {
   //停止计时
   getClearTimer("countdownTimer");
+  time.value.countdownNum = 0;
+  if (!resultId.value) {
+    getOpenOneTestAndStartFace();
+  }
+  //自动项目定时进入下一步
+  //if (!needStart.value) {
+  //let time = 0;
+  //控制新建测试的时间,第一次快,之后就慢
+  // if (!resultId.value) {
+  // getOpenOneTestAndStartFace();
+  // }
+  // if (!resultId.value) {
+  //   time = 1000;
+  // } else {
+  //   time = 10000;
+  // }
+  // setTimeout(() => {
+  //   //再加一个判断以免和再测一次冲突
+  //   if (examState.value == 3) {
+  //     getOpenOneTestAndStartFace();
+  //   }
+  // }, time)
+  //}
 };
 
 /**
@@ -846,7 +883,9 @@ onBeforeMount(() => {
     isLongRun.value = true
   }
   //需要开始按钮的项目
-  needStart.value = true;
+  if (isLongRun.value) {
+    needStart.value = true;
+  }
   //加载WS
   initWs({ parameter: parameter.value, testTime: time.value.testTime }, (data: any) => {
     getMessage(data);
@@ -1022,7 +1061,7 @@ $waiPadding: 6.51rem;
 
             span {
               font: 1.5rem;
-              margin-left: 5px;
+              margin: 0 5px;
             }
 
             i {