exam.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818
  1. <template>
  2. <view class="phone-kaoshi-page">
  3. <!-- 导航区域 -->
  4. <customNavbarVue :title="data.ksName" :show-back-btn="true" @back="handleBack"></customNavbarVue>
  5. <!-- 第一行 -->
  6. <view class="kaoshi-page-title">
  7. <view v-if="activeSt" class="title-types">{{dlName}}</view>
  8. <!-- 倒计时 -->
  9. <view v-if="!!data.endSecond">
  10. <uni-countdown :show-day="false" :showHour="true" :showMinute="true" :second="data.endSecond"
  11. @timeup="onTimeUp" :start="startCountDown"></uni-countdown>
  12. </view>
  13. </view>
  14. <view class="kaoshi-shiti-content">
  15. <!-- 内容区域 -->
  16. <!-- 试题区域 -->
  17. <view v-if="activeSt">
  18. <template v-if="activeSt.stTypeId == 1">
  19. <!-- 单选 -->
  20. <danxuan :question="activeSt" :key="activeSt.stId" @change="handleSave1"></danxuan>
  21. </template>
  22. <template v-if="activeSt.stTypeId == 2">
  23. <!-- 多选 -->
  24. <duoxuan :question="activeSt" :key="activeSt.stId" @change="handleSave1"></duoxuan>
  25. </template>
  26. <template v-if="activeSt.stTypeId == 3">
  27. <!-- 判断 -->
  28. <panduan :question="activeSt" :key="activeSt.stId" @change="handleSave1"></panduan>
  29. </template>
  30. <template v-if="activeSt.stTypeId == 4">
  31. <!-- 填空 -->
  32. <tiankong :question="activeSt" :key="activeSt.stId" @change="handleSave1"></tiankong>
  33. </template>
  34. </view>
  35. </view>
  36. <view class="kaoshi-bottom-box">
  37. <button class="phone-green-btn bj-btn" hover-class="none" type="default" size="mini"
  38. @click="handleBiaoji">{{activeSt && activeSt.marked ? '取标':'标记'}}</button>
  39. <view @click="showAnswerCard" class="shiti-num-box">
  40. <icon class="shiti-num-icon" :style="{ backgroundImage: 'url(' + data.imgsArr.shitiNumIcon + ')' }">
  41. </icon>
  42. <text
  43. class="active-num">{{activeSt ? activeSt.onlyNum: 0}}</text>/<text>{{data.StListForSearch.length}}</text>
  44. </view>
  45. <button class="phone-green-btn save-btn" hover-class="none" type="default" size="mini"
  46. @click="handleSave(true)">保存</button>
  47. </view>
  48. <template v-if="activeSt">
  49. <button type="default" size="mini" hover-class="none" class="phone-green-btn ks-btn-prev"
  50. @click="handlePrev" v-if="!isFistStId">上一题</button>
  51. <button type="default" size="mini" hover-class="none" class="phone-green-btn ks-btn-next"
  52. @click="handleNext" v-if="!isLastStId">下一题</button>
  53. <button type="default" size="mini" hover-class="none" class="phone-green-btn ks-btn-next"
  54. @click="handleJiaojuan" v-if="isLastStId">交卷</button>
  55. </template>
  56. <!-- 答题卡 -->
  57. <uni-popup ref="popupRef" background-color="#fff" :animation="false" :is-mask-click="false" :mask-click="false">
  58. <view class="answer-card-popup">
  59. <customNavbarVue title="答题卡" :show-back-btn="true" @back="handlePopupBack"></customNavbarVue>
  60. <view class="card-content-box">
  61. <view class="answer-card-content" v-for="(paragraph,paragraphIndex) in questionData"
  62. :key="paragraphIndex">
  63. <view class="paragraph-title">
  64. {{paragraph.name}}
  65. </view>
  66. <view class="paragraph-qa" v-for="(qa,qaIndex) in paragraph.qas" :key="qaIndex"
  67. :class="getQaClass(qa)" @click="answerCardItemClick(qa)">{{qa.onlyNum}}
  68. </view>
  69. </view>
  70. </view>
  71. </view>
  72. </uni-popup>
  73. <!-- 摄像头 -->
  74. <template v-if="data.zhuapai && data.zhuapai > 0">
  75. <!-- 抓拍 -->
  76. <zhuapaiVue ref="zhuapaiRef" @error="zpError" @success="zpSuccess" key="2" @progress="onProgress">
  77. </zhuapaiVue>
  78. </template>
  79. <!-- 交卷确认 -->
  80. <answerQueren ref="answerQrRef" @confirm="handleQuerenConfirm"></answerQueren>
  81. <!-- 考试得分 -->
  82. <submitScoreVue ref="subScoreRef" @confirm="handleScoreConfirm" @close="handleScoreClose"
  83. @goIndex="handleBack('index')"></submitScoreVue>
  84. <!-- 切屏确认弹窗 -->
  85. <qiepingDlVue ref="qiepingDlRef" :content="messageContent" title="注意" okBtn="知道了"></qiepingDlVue>
  86. </view>
  87. </template>
  88. <script setup>
  89. import cacheManager from '@/utils/cacheManager.js';
  90. import {
  91. ref,
  92. reactive,
  93. computed,
  94. watch,
  95. nextTick,
  96. } from "vue";
  97. import zhuapaiVue from "@/components/zhuapaiConfirm/zhuapai.vue";
  98. import zhuapaiConfirm from "@/components/zhuapaiConfirm/index.vue";
  99. import answerQueren from "@/components/zhuapaiConfirm/answerQueren.vue";
  100. import submitScoreVue from "@/components/zhuapaiConfirm/submitScore.vue";
  101. import customNavbarVue from "@/components/custom-navbar/custom-navbar.vue";
  102. import {
  103. onLoad,
  104. onShow,
  105. onHide
  106. } from "@dcloudio/uni-app";
  107. import * as ksApi from "@/api/kaoshi.js"
  108. import danxuan from "@/components/questions/danxuan.vue";
  109. import duoxuan from "@/components/questions/duoxuan.vue";
  110. import tiankong from "@/components/questions/tiankong.vue";
  111. import panduan from "@/components/questions/panduan.vue";
  112. import {
  113. useQuestionTools
  114. } from "@/components/questions/useQuestionTools.js";
  115. import {
  116. useKaoShiCache
  117. } from "./examTools"
  118. import qiepingDlVue from "@/components/dialog/qiepingDl.vue";
  119. import {
  120. useQiePing
  121. } from "@/utils/useQieping.js"
  122. const {
  123. checkDanxuanReply,
  124. checkDuoxuanReply,
  125. checkPanduanReply,
  126. checkTiankongReply,
  127. getLetterByIndex
  128. } = useQuestionTools();
  129. const {
  130. saveCacheKs,
  131. getCacheKs,
  132. removeCacheKs,
  133. removeCacheKsOther
  134. } = useKaoShiCache();
  135. const {
  136. init: qiepingInit
  137. } = useQiePing();
  138. function onceImmediate(func, coolDownTime) {
  139. let canRun = true; // 状态标志:是否允许执行函数
  140. let timeoutId = null;
  141. return function(...args) {
  142. const context = this;
  143. // 如果允许执行
  144. if (canRun) {
  145. // 立即执行一次
  146. func.apply(context, args);
  147. // 立即将状态设置为“不可执行”
  148. canRun = false;
  149. // 设置一个定时器,在冷却时间结束后重置状态
  150. timeoutId = setTimeout(() => {
  151. canRun = true;
  152. timeoutId = null; // 清除定时器ID引用
  153. }, coolDownTime);
  154. }
  155. // 如果不允许执行,则什么也不做,忽略此次调用
  156. };
  157. }
  158. const handleBack = onceImmediate((index) => {
  159. if (index) {
  160. uni.redirectTo({
  161. url: `/pages/client/ShouYe/shouye`
  162. })
  163. return;
  164. }
  165. const pages = getCurrentPages();
  166. if (pages.length > 1) {
  167. uni.navigateBack()
  168. } else {
  169. history.back();
  170. }
  171. }, 8000)
  172. onLoad((option) => {
  173. data.ksId = option.ksId;
  174. data.zhuapai = option.zhuapai;
  175. data.userKaozhengId = option.userKaozhengId;
  176. data.from = option.from;
  177. data.imgsArr.shitiNumIcon = cacheManager.get('projectImg').shiti_num_icon;
  178. setTimeout(() => {
  179. initKaoshi();
  180. }, 1000)
  181. /* if (data.zhuapai && data.zhuapai != 0) {
  182. // 考试前确认摄像头
  183. nextTick(() => {
  184. initBeforKaoshi();
  185. })
  186. } else {
  187. initKaoshi();
  188. } */
  189. })
  190. const popupRef = ref(null)
  191. const zhuapaiRef = ref(null)
  192. const qiepingRef = ref(null)
  193. const zhuapaiConfirmRef = ref(null)
  194. const answerQrRef = ref(null);
  195. const startCountDown = ref(false);
  196. const subScoreRef = ref(null);
  197. const messageContent = ref('');
  198. const qiepingDlRef = ref(null);
  199. const timer1 = ref(null);
  200. const data = reactive({
  201. ksId: null,
  202. operId: null,
  203. ksName: '',
  204. stTotal: 0,
  205. stScore: 0,
  206. biaoji: {},
  207. endSecond: 0,
  208. pageSize: 0,
  209. toggleScreenFlag: 0,
  210. toggleScreenSecond: 0,
  211. zhuapai: 0,
  212. duanluo: [],
  213. StListForSearch: [],
  214. from: '',
  215. hisId: '',
  216. userKaozhengId: '',
  217. imgsArr: {
  218. shitiNumIcon: '',
  219. },
  220. })
  221. const markDB = ref([]);
  222. const questionData = ref([]);
  223. const progress = reactive({
  224. dlIndex: 0,
  225. dtIndex: 0
  226. })
  227. const dlName = computed(() => {
  228. if (data.StListForSearch && activeSt.value) {
  229. return data.StListForSearch[activeSt.value.onlyNum - 1].paragraphName
  230. } else {
  231. return ''
  232. }
  233. })
  234. watch(() => data.duanluo, (newVal) => {
  235. // 计算已答试题数量
  236. }, {
  237. deep: true
  238. })
  239. const activeSt = computed(() => {
  240. if (questionData.value.length) {
  241. return questionData.value.length && questionData.value[progress.dlIndex].qas[progress.dtIndex];
  242. } else {
  243. return null
  244. }
  245. })
  246. const isFistStId = computed(() => {
  247. if (data.StListForSearch.length) {
  248. return data.StListForSearch[0].stId == activeSt.value.stId
  249. } else {
  250. return false
  251. }
  252. });
  253. const isLastStId = computed(() => {
  254. if (data.StListForSearch.length) {
  255. return data.StListForSearch[data.StListForSearch.length - 1].stId == activeSt.value.stId
  256. } else {
  257. return false
  258. }
  259. });
  260. function handleScoreClose() {
  261. handleBack()
  262. }
  263. // 考试得分相关 start
  264. function handleScoreConfirm() {
  265. uni.redirectTo({
  266. url: `/pages/client/Chengji/ksScoreShijuan?hisId=${data.hisId}&from=kaoshi`
  267. })
  268. }
  269. // 考试得分相关 end
  270. function handleSave1() {
  271. const result = []
  272. questionData.value.forEach(dl => {
  273. dl.qas.forEach(st => {
  274. const opt = {
  275. stId: st.stId,
  276. reply: st.reply,
  277. }
  278. result.push(opt)
  279. })
  280. })
  281. // 保存试题答案
  282. saveCacheKs(data.operId, {
  283. replyList: result,
  284. position: {
  285. dlIndex: progress.dlIndex,
  286. dtIndex: progress.dtIndex
  287. }
  288. })
  289. }
  290. // 保存相关
  291. function handleSave(showToast) {
  292. if (timer1.value) {
  293. uni.showToast({
  294. title: '请勿连续保存',
  295. icon: 'none'
  296. })
  297. return
  298. }
  299. timer1.value = setTimeout(() => {
  300. clearTimeout(timer1.value);
  301. }, 10 * 1000);
  302. console.log(questionData.value)
  303. const result = []
  304. const option = {
  305. force: false,
  306. operId: data.operId,
  307. replyList: []
  308. }
  309. questionData.value.forEach(dl => {
  310. dl.qas.forEach(st => {
  311. const opt = {
  312. stId: st.stId,
  313. reply: st.reply,
  314. }
  315. result.push(opt)
  316. option.replyList.push(opt)
  317. })
  318. })
  319. // 保存试题答案
  320. saveCacheKs(data.operId, {
  321. replyList: result,
  322. position: {
  323. dlIndex: progress.dlIndex,
  324. dtIndex: progress.dtIndex
  325. }
  326. })
  327. // 保存答题进度
  328. ksApi.getClientKsSave(option).then(res => {
  329. if (res.data && showToast) {
  330. uni.showToast({
  331. title: '保存成功',
  332. })
  333. }
  334. })
  335. }
  336. // 交卷相关功能 start
  337. function checkJiaojuan() {
  338. const result = []
  339. let count = 0;
  340. let total = 0;
  341. questionData.value.forEach(dl => {
  342. dl.qas.forEach(st => {
  343. const opt = {
  344. stId: st.stId,
  345. reply: st.reply,
  346. stTypeId: st.stTypeId
  347. }
  348. result.push(opt)
  349. })
  350. })
  351. result.forEach(item => {
  352. total++;
  353. if (item.stTypeId == 1 && !checkDanxuanReply(item)) {
  354. count++;
  355. }
  356. if (item.stTypeId == 2 && !checkDuoxuanReply(item)) {
  357. count++;
  358. }
  359. if (item.stTypeId == 3 && !checkPanduanReply(item)) {
  360. count++;
  361. }
  362. if (item.stTypeId == 4 && !checkTiankongReply(item)) {
  363. count++;
  364. }
  365. })
  366. return {
  367. total,
  368. count,
  369. }
  370. }
  371. function handleJiaojuan() {
  372. const result = checkJiaojuan()
  373. console.log(result)
  374. if (result.count) {
  375. // 提示
  376. answerQrRef.value.showDialog({
  377. answercartsCount: result.total - result.count,
  378. answercartsTotal: result.total,
  379. })
  380. } else {
  381. handleSubmit()
  382. }
  383. }
  384. function handleQuerenConfirm() {
  385. handleSubmit()
  386. }
  387. function handleSubmit(force = false) {
  388. const result = {
  389. force,
  390. operId: data.operId,
  391. replyList: []
  392. };
  393. console.log(questionData.value)
  394. // uni.showLoading({
  395. // title: '提交中'
  396. // })
  397. questionData.value.forEach(dl => {
  398. dl.qas.forEach(st => {
  399. const opt = {
  400. stId: st.stId,
  401. reply: st.reply
  402. }
  403. result.replyList.push(opt)
  404. })
  405. })
  406. ksApi.getClientKsSubmit(result).then(res => {
  407. if (res.code == 0) {
  408. subScoreRef.value.showDialog(res.data);
  409. data.hisId = res.data.hisId;
  410. // 清空缓存
  411. removeCacheKs(data.operId);
  412. }
  413. }).finally(err => {
  414. zhuapaiRef.value && zhuapaiRef.value.stopFrameListener();
  415. // uni.hideLoading()
  416. })
  417. }
  418. function onTimeUp() {
  419. handleSubmit();
  420. }
  421. // 交卷相关功能 end
  422. // 切屏功能 start
  423. function qiepingToast(count) {
  424. messageContent.value = `已离开${count}次。${data.toggleScreenFlag}次将自动交卷!`
  425. qiepingDlRef.value.handleShow()
  426. }
  427. function forceSubmit() {
  428. // 强制交卷
  429. console.log('强制交卷')
  430. handleSubmit(true)
  431. }
  432. function qpZhuapai() {
  433. // 重新开启抓拍
  434. zhuapaiRef.value && zhuapaiRef.value.showVideoBtn();
  435. }
  436. // 切屏功能 end
  437. // 摄像头抓拍相关功能 start
  438. function zpSuccess() {}
  439. function zpError() {
  440. uni.showToast({
  441. title: '抓拍图片异常',
  442. icon: 'none',
  443. duration: 3000,
  444. mask: true, // 防止触摸穿透
  445. complete: handleBack
  446. })
  447. }
  448. // 摄像头抓拍相关功能 end
  449. // 摄像头确认相关功能 start
  450. function onProgress() {
  451. uni.showToast({
  452. icon: 'none',
  453. title: '摄像头运行环境异常,请重新进入考试',
  454. duration: 3000,
  455. mask: true, // 防止触摸穿透
  456. complete: handleBack
  457. })
  458. }
  459. function zpConfirmSuccess() {
  460. initKaoshi();
  461. }
  462. function zpConfirmError() {
  463. handleBack()
  464. }
  465. function zpConfirmCancel() {
  466. handleBack()
  467. }
  468. // 摄像头确认相关功能 end
  469. function getQaClass(qa) {
  470. if (qa.marked && qa.marked === true) {
  471. return 'paragraph-qa-block-mark';
  472. } else {
  473. if (qa.stTypeId == 1) {
  474. if (checkDanxuanReply(qa)) {
  475. return 'paragraph-qa-block-done';
  476. } else {
  477. return 'paragraph-qa-block-init';
  478. }
  479. } else if (qa.stTypeId == 2) {
  480. if (checkDuoxuanReply(qa)) {
  481. return 'paragraph-qa-block-done';
  482. } else {
  483. return 'paragraph-qa-block-init';
  484. }
  485. } else if (qa.stTypeId == 3) {
  486. if (checkPanduanReply(qa)) {
  487. return 'paragraph-qa-block-done';
  488. } else {
  489. return 'paragraph-qa-block-init';
  490. }
  491. } else if (qa.stTypeId == 4) {
  492. if (checkTiankongReply(qa)) {
  493. return 'paragraph-qa-block-done';
  494. } else {
  495. return 'paragraph-qa-block-init';
  496. }
  497. }
  498. }
  499. }
  500. function skipQuestion(dlIndex, dtIndex) {
  501. progress.dlIndex = dlIndex;
  502. progress.dtIndex = dtIndex;
  503. handlePopupBack()
  504. }
  505. function answerCardItemClick(qa) {
  506. const actQa = data.StListForSearch.find(item => item.stId == qa.stId);
  507. skipQuestion(actQa.dlIndex, actQa.dtIndex)
  508. }
  509. /*function handleBack () {
  510. const pages = getCurrentPages();
  511. if (pages.length > 1) {
  512. uni.navigateBack()
  513. } else {
  514. history.back();
  515. }
  516. }*/
  517. function showAnswerCard() {
  518. popupRef.value.open('top')
  519. }
  520. function handlePopupBack() {
  521. popupRef.value && popupRef.value.close()
  522. }
  523. function handlePrev() {
  524. const qa = data.StListForSearch.find(item => item.stId == activeSt.value.stId);
  525. const index = qa.onlyNum - 1;
  526. if (index > 0) {
  527. const result = data.StListForSearch[index - 1];
  528. progress.dlIndex = result.dlIndex;
  529. progress.dtIndex = result.dtIndex
  530. }
  531. }
  532. function handleNext() {
  533. const qa = data.StListForSearch.find(item => item.stId == activeSt.value.stId);
  534. const index = qa.onlyNum - 1;
  535. if (index < data.StListForSearch.length) {
  536. const result = data.StListForSearch[index + 1];
  537. progress.dlIndex = result.dlIndex;
  538. progress.dtIndex = result.dtIndex
  539. }
  540. }
  541. function formatDuanluoList(dlData) {
  542. let uIndex = 0; // 试题onlyNum
  543. let iDuanluo = 0; // 段落onlyNum
  544. let result = [];
  545. for (const duanluo of data.duanluo) {
  546. let paragraph = {
  547. qas: [],
  548. };
  549. paragraph.name = duanluo.name;
  550. let iQa = 0; // 当前试题序号
  551. let order = 0; // 当前题型中第几题
  552. for (const iDanxuan of duanluo.danxuan) {
  553. iDanxuan.type = 'danxuan';
  554. iDanxuan.marked = data.biaoji[iDanxuan.stId] ? true : false;
  555. iDanxuan.onlyNum = uIndex + 1;
  556. iDanxuan.order = order;
  557. iDanxuan.iQa = iQa;
  558. paragraph.qas.push(iDanxuan);
  559. uIndex++;
  560. order++;
  561. iQa++;
  562. data.StListForSearch.push({
  563. stId: iDanxuan.stId,
  564. paragraphName: paragraph.name,
  565. dlIndex: iDuanluo,
  566. dtIndex: iDanxuan.iQa,
  567. onlyNum: iDanxuan.onlyNum
  568. })
  569. }
  570. order = 0;
  571. for (const iDuoxuan of duanluo.duoxuan) {
  572. iDuoxuan.type = 'duoxuan';
  573. iDuoxuan.marked = data.biaoji[iDuoxuan.stId] ? true : false;
  574. iDuoxuan.onlyNum = uIndex + 1;
  575. iDuoxuan.order = order;
  576. paragraph.qas.push(iDuoxuan);
  577. iDuoxuan.iQa = iQa;
  578. iDuoxuan.reply = [];
  579. uIndex++;
  580. order++;
  581. iQa++;
  582. data.StListForSearch.push({
  583. stId: iDuoxuan.stId,
  584. paragraphName: paragraph.name,
  585. dlIndex: iDuanluo,
  586. dtIndex: iDuoxuan.iQa,
  587. onlyNum: iDuoxuan.onlyNum
  588. })
  589. }
  590. order = 0;
  591. for (const iPanduan of duanluo.panduan) {
  592. iPanduan.type = 'panduan';
  593. iPanduan.marked = data.biaoji[iPanduan.stId] ? true : false;
  594. iPanduan.onlyNum = uIndex + 1;
  595. iPanduan.order = order;
  596. paragraph.qas.push(iPanduan);
  597. iPanduan.iQa = iQa;
  598. uIndex++;
  599. order++;
  600. iQa++;
  601. data.StListForSearch.push({
  602. stId: iPanduan.stId,
  603. paragraphName: paragraph.name,
  604. dlIndex: iDuanluo,
  605. dtIndex: iPanduan.iQa,
  606. onlyNum: iPanduan.onlyNum
  607. })
  608. }
  609. order = 0;
  610. for (const iTiankong of duanluo.tiankong) {
  611. iTiankong.type = 'tiankong';
  612. iTiankong.marked = data.biaoji[iTiankong.stId] ? true : false;
  613. iTiankong.onlyNum = uIndex + 1;
  614. iTiankong.order = order;
  615. paragraph.qas.push(iTiankong);
  616. iTiankong.iQa = iQa;
  617. iTiankong.reply = new Array(iTiankong.count).fill('');;
  618. uIndex++;
  619. order++;
  620. iQa++;
  621. data.StListForSearch.push({
  622. stId: iTiankong.stId,
  623. paragraphName: paragraph.name,
  624. dlIndex: iDuanluo,
  625. dtIndex: iTiankong.iQa,
  626. onlyNum: iTiankong.onlyNum
  627. })
  628. }
  629. iDuanluo++;
  630. questionData.value.push(paragraph)
  631. console.log('1', questionData.value)
  632. console.log('2', data.StListForSearch)
  633. }
  634. }
  635. function handleBiaoji() {
  636. activeSt.value.marked = !activeSt.value.marked;
  637. data.biaoji[activeSt.value.stId] = activeSt.value.marked
  638. ksApi.getClientKaoshiBiaoji({
  639. operId: data.operId,
  640. biaoji: JSON.stringify(data.biaoji)
  641. }).catch(err => {
  642. handleBack()
  643. })
  644. }
  645. function formatKaoshiData() {
  646. const historyData = getCacheKs(data.operId);
  647. if (historyData) {
  648. const {
  649. replyList,
  650. position
  651. } = historyData;
  652. if (replyList) {
  653. questionData.value.forEach(dl => {
  654. dl.qas.forEach(st => {
  655. st.reply = replyList.find(item => item.stId == st.stId).reply
  656. })
  657. })
  658. }
  659. if (position) {
  660. progress.dlIndex = position.dlIndex;
  661. progress.dtIndex = position.dtIndex;
  662. }
  663. }
  664. }
  665. // 摄像头确认初始化
  666. function initBeforKaoshi() {
  667. zhuapaiConfirmRef.value.showDialog()
  668. }
  669. function initKaoshi() {
  670. ksApi.getClientKsStart({
  671. ksId: data.ksId,
  672. userKaozhengId: data.userKaozhengId
  673. }).then(res => {
  674. const {
  675. ksId,
  676. operId,
  677. ksName,
  678. stTotal,
  679. stScore,
  680. biaoji,
  681. endSecond,
  682. pageSize,
  683. toggleScreenFlag,
  684. toggleScreenSecond,
  685. zhuapai,
  686. duanluoList
  687. } = res.data;
  688. data.ksId = ksId;
  689. data.operId = operId;
  690. data.ksName = ksName;
  691. data.stTotal = stTotal;
  692. data.stScore = stScore;
  693. data.biaoji = biaoji ? JSON.parse(biaoji) : {};
  694. data.endSecond = endSecond;
  695. data.pageSize = pageSize;
  696. data.toggleScreenFlag = toggleScreenFlag;
  697. data.toggleScreenSecond = toggleScreenSecond;
  698. data.zhuapai = zhuapai;
  699. data.duanluo = duanluoList;
  700. formatDuanluoList(data.duanluo);
  701. // 设置缓存
  702. formatKaoshiData();
  703. // 设置抓拍监听
  704. removeCacheKsOther(operId)
  705. /* if (data.zhuapai && data.zhuapai > 0) {
  706. zhuapaiRef.value.init({
  707. zhuapai: zhuapai,
  708. operId: operId
  709. });
  710. } */
  711. // 设置切屏
  712. qiepingInit({
  713. zhuapaiFlag: !!data.zhuapai,
  714. toggleScreenFlag: toggleScreenFlag,
  715. toggleScreenSecond: toggleScreenSecond,
  716. ksId: data.ksId
  717. }, {
  718. zhuapai: qpZhuapai,
  719. forceSubmit,
  720. qiepingToast
  721. })
  722. uni.setNavigationBarTitle({
  723. title: data.ksName
  724. });
  725. startCountDown.value = true;
  726. }).catch(err => {
  727. handleBack()
  728. })
  729. }
  730. </script>