lxScoreShijuan.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474
  1. <template>
  2. <view class="phone-score-page">
  3. <!-- 导航区域 -->
  4. <customNavbarVue :title="data.lxName" :show-back-btn="true" @back="handleBack"></customNavbarVue>
  5. <!-- 上方区域 -->
  6. <topCard @openCard="handleOpenCard" :name="data.lxName" :zyLevelName="data.zyLevelName"
  7. :userScore="data.userScore" :Score="data.ksScore"></topCard>
  8. <!-- 段落 -->
  9. <view class="score-shiti-content">
  10. <!-- 试题区域 -->
  11. <view v-if="activeSt">
  12. <template v-if="activeSt.stTypeId == 1">
  13. <!-- 单选 -->
  14. <danxuan :question="activeSt" :key="activeSt.stId"></danxuan>
  15. </template>
  16. <template v-if="activeSt.stTypeId == 2">
  17. <!-- 多选 -->
  18. <duoxuan :question="activeSt" :key="activeSt.stId"></duoxuan>
  19. </template>
  20. <template v-if="activeSt.stTypeId == 3">
  21. <!-- 判断 -->
  22. <panduan :question="activeSt" :key="activeSt.stId"></panduan>
  23. </template>
  24. <template v-if="activeSt.stTypeId == 4">
  25. <!-- 填空 -->
  26. <tiankong :question="activeSt" :key="activeSt.stId"></tiankong>
  27. </template>
  28. </view>
  29. <!-- 解析 -->
  30. <view v-if="activeSt" class="score-answer-box">
  31. <view class="phone-question-answer-box" v-if="activeSt.stTypeId != 4">
  32. <view class="phone-line-title">答案解析</view>
  33. <view class="btdf-row">本题得分:<text>{{answerRes.score}}</text>分</view>
  34. <view class="zqda-row">正确答案:<text>{{answerRes.result}}</text></view>
  35. <view class="ndda-row">您的答案:<text>{{answerRes.reply}}</text></view>
  36. <view class="dajx-row">答案解析:
  37. <rich-text :nodes="answerRes.answer"></rich-text>
  38. </view>
  39. </view>
  40. <view class="phone-question-answer-box" v-else>
  41. <view class="phone-line-title">答案解析</view>
  42. <view class="btdf-row">本题得分:<text>{{answerRes.score}}</text>分</view>
  43. <view class="zqda-row">正确答案:
  44. <view v-for="(item,index) in answerRes.result">{{`填空${index+1}`}} : {{item}}</view>
  45. </view>
  46. <view class="ndda-row">您的答案:
  47. <view v-for="(item,index) in answerRes.reply"> {{`填空${index+1}`}}: {{item}}</view>
  48. </view>
  49. <view class="dajx-row">答案解析:
  50. <rich-text :nodes="answerRes.answer"></rich-text>
  51. </view>
  52. </view>
  53. </view>
  54. </view>
  55. <!-- 上下按钮 -->
  56. <view class="score-bottom-box" v-if="activeSt">
  57. <view @click="handleOpenCard" class="score-num-box">
  58. <icon class="score-num-icon" :style="{ backgroundImage: 'url(' + data.imgsArr.shitiNumIcon + ')' }"></icon>
  59. <text class="active-num" @click="handleOpenCard"><i></i>
  60. {{activeSt && activeSt.onlyNum||0}}/{{data.StListForSearch.length}}</text>
  61. </view>
  62. <view>
  63. <button type="default" size="mini" hover-class="none" class="phone-green-btn score-answer-btn"
  64. @click="handlePrev" v-if="!isFistStId">上一题</button>
  65. <button type="default" size="mini" hover-class="none" class="phone-green-btn score-answer-btn"
  66. @click="handleNext" v-if="!isLastStId">下一题</button>
  67. <button type="default" size="mini" hover-class="none" class="phone-green-btn score-answer-btn"
  68. @click="handleBack" v-if="isLastStId">完成</button>
  69. </view>
  70. </view>
  71. <!-- 答题卡 -->
  72. <uni-popup ref="popupRef" background-color="#fff" :animation="false" :is-mask-click="false" :mask-click="false">
  73. <view class="answer-card-popup">
  74. <customNavbarVue title="答题卡" :show-back-btn="true" @back="handlePopupBack"></customNavbarVue>
  75. <view class="card-content-box">
  76. <view class="answer-card-content" v-for="(paragraph,paragraphIndex) in questionData"
  77. :key="paragraphIndex">
  78. <view class="paragraph-title">
  79. {{paragraph.name}}
  80. </view>
  81. <view class="paragraph-qa" v-for="(qa,qaIndex) in paragraph.qas" :key="qaIndex"
  82. :class="getQaClass(qa)" @click="answerCardItemClick(qa)">{{qa.onlyNum}}
  83. </view>
  84. </view>
  85. </view>
  86. </view>
  87. </uni-popup>
  88. </view>
  89. </template>
  90. <script setup>
  91. import cacheManager from '@/utils/cacheManager.js';
  92. import topCard from "@/components/score/topCard.vue"
  93. import danxuan from "@/components/questions/danxuan.vue";
  94. import duoxuan from "@/components/questions/duoxuan.vue";
  95. import tiankong from "@/components/questions/tiankong.vue";
  96. import panduan from "@/components/questions/panduan.vue";
  97. import {
  98. useQuestionTools
  99. } from "@/components/questions/useQuestionTools.js";
  100. import customNavbarVue from "@/components/custom-navbar/custom-navbar.vue";
  101. import {
  102. onLoad
  103. } from "@dcloudio/uni-app";
  104. import {
  105. ref,
  106. reactive,
  107. computed
  108. } from "vue"
  109. import * as lxApi from "@/api/lianxi.js"
  110. const {
  111. checkDanxuanReply,
  112. checkDuoxuanReply,
  113. checkPanduanReply,
  114. checkTiankongReply,
  115. getLetterByIndex
  116. } = useQuestionTools();
  117. const hisId = ref(null)
  118. const popupRef = ref(null)
  119. const data = reactive({
  120. lxId: null,
  121. lxName: '',
  122. stTotal: 0,
  123. zyLevelName: '',
  124. userScore: '',
  125. ksScore: 0,
  126. StListForSearch: [],
  127. duanluo: [],
  128. imgsArr: {
  129. shitiNumIcon: '',
  130. },
  131. })
  132. const questionData = ref([]);
  133. const progress = reactive({
  134. dlIndex: 0,
  135. dtIndex: 0
  136. })
  137. const dlName = computed(() => {
  138. if (data.StListForSearch && activeSt.value) {
  139. return data.StListForSearch[activeSt.value.onlyNum].paragraphName
  140. } else {
  141. return ''
  142. }
  143. })
  144. const activeSt = computed(() => {
  145. if (questionData.value.length) {
  146. return questionData.value.length && questionData.value[progress.dlIndex].qas[progress.dtIndex];
  147. } else {
  148. return null
  149. }
  150. })
  151. const answerRes = computed(() => {
  152. const qa = activeSt.value;
  153. let score = qa.userScore;
  154. let reply = '';
  155. let result = '';
  156. let answer = qa.answer;
  157. if (qa.stTypeId == 1) {
  158. // 单选题
  159. if (qa.reply && qa.reply.trim() !== '') {
  160. reply = getLetterByIndex(qa.reply)
  161. } else {
  162. reply = '未答'
  163. }
  164. if (qa.result) {
  165. result = getLetterByIndex(qa.result)
  166. } else {
  167. result = '无答案'
  168. }
  169. }
  170. if (qa.stTypeId == 2) {
  171. // 多选题
  172. if (qa.reply && qa.reply.length) {
  173. reply = qa.reply.map(item => {
  174. if (item.trim()) {
  175. return getLetterByIndex(item.trim())
  176. }
  177. }).join(',')
  178. } else {
  179. reply = '未答'
  180. }
  181. if (qa.result) {
  182. result = qa.result.map(item => {
  183. if (item.trim()) {
  184. return getLetterByIndex(item.trim())
  185. }
  186. }).join(',')
  187. } else {
  188. result = '无答案'
  189. }
  190. }
  191. if (qa.stTypeId == 3) {
  192. // 判断题
  193. if (qa.reply === '') {
  194. reply = '未答'
  195. } else if (qa.reply == 0 ) {
  196. reply = '错误'
  197. } else if (qa.reply == 1) {
  198. reply = '正确'
  199. }
  200. if (qa.result == 0) {
  201. result = '错误'
  202. } else if (qa.result == 1) {
  203. result = '正确'
  204. }
  205. }
  206. if (qa.stTypeId == 4) {
  207. let reply = qa.reply || [];
  208. let result = qa.result || [];
  209. // 填空题
  210. return {
  211. score,
  212. reply,
  213. result,
  214. answer
  215. }
  216. } else {
  217. return {
  218. score,
  219. reply,
  220. result,
  221. answer
  222. }
  223. }
  224. })
  225. const isFistStId = computed(() => {
  226. if (data.StListForSearch.length) {
  227. return data.StListForSearch[0].stId == activeSt.value.stId
  228. } else {
  229. return false
  230. }
  231. });
  232. const isLastStId = computed(() => {
  233. if (data.StListForSearch.length) {
  234. return data.StListForSearch[data.StListForSearch.length - 1].stId == activeSt.value.stId
  235. } else {
  236. return false
  237. }
  238. });
  239. onLoad((options) => {
  240. hisId.value = options.hisId;
  241. data.imgsArr.shitiNumIcon = cacheManager.get('projectImg').shiti_num_icon;
  242. initPage()
  243. })
  244. function getQaClass(qa) {
  245. if (qa.marked && qa.marked === true) {
  246. return 'paragraph-qa-block-mark';
  247. } else {
  248. if (qa.stTypeId == 1) {
  249. if (checkDanxuanReply(qa)) {
  250. return 'paragraph-qa-block-done';
  251. } else {
  252. return 'paragraph-qa-block-init';
  253. }
  254. } else if (qa.stTypeId == 2) {
  255. if (checkDuoxuanReply(qa)) {
  256. return 'paragraph-qa-block-done';
  257. } else {
  258. return 'paragraph-qa-block-init';
  259. }
  260. } else if (qa.stTypeId == 3) {
  261. if (checkPanduanReply(qa)) {
  262. return 'paragraph-qa-block-done';
  263. } else {
  264. return 'paragraph-qa-block-init';
  265. }
  266. } else if (qa.stTypeId == 4) {
  267. if (checkTiankongReply(qa)) {
  268. return 'paragraph-qa-block-done';
  269. } else {
  270. return 'paragraph-qa-block-init';
  271. }
  272. }
  273. }
  274. }
  275. function skipQuestion(dlIndex, dtIndex) {
  276. progress.dlIndex = dlIndex;
  277. progress.dtIndex = dtIndex;
  278. handlePopupBack()
  279. }
  280. function answerCardItemClick(qa) {
  281. const actQa = data.StListForSearch.find(item => item.stId == qa.stId);
  282. skipQuestion(actQa.dlIndex, actQa.dtIndex)
  283. }
  284. function handleBack() {
  285. const pages = getCurrentPages();
  286. if (pages.length>1) {
  287. uni.navigateBack()
  288. } else {
  289. // uni.redirectTo({
  290. // url: "/pages/client/Lianxi/list"
  291. // })
  292. history.back();
  293. }
  294. }
  295. function formatDuanluoList() {
  296. let uIndex = 0; // 试题num
  297. let iDuanluo = 0; // 段落num
  298. let result = [];
  299. for (const duanluo of data.duanluo) {
  300. let paragraph = {
  301. qas: [],
  302. };
  303. paragraph.name = duanluo.name;
  304. let iQa = 0; // 当前试题序号
  305. let order = 0; // 当前题型中第几题
  306. for (const iDanxuan of duanluo.danxuan) {
  307. iDanxuan.type = 'danxuan';
  308. iDanxuan.marked = false;
  309. iDanxuan.onlyNum = uIndex + 1;
  310. iDanxuan.order = order;
  311. iDanxuan.iQa = iQa;
  312. paragraph.qas.push(iDanxuan);
  313. uIndex++;
  314. order++;
  315. iQa++;
  316. data.StListForSearch.push({
  317. stId: iDanxuan.stId,
  318. paragraphName: paragraph.name,
  319. dlIndex: iDuanluo,
  320. dtIndex: iDanxuan.iQa,
  321. num: iDanxuan.onlyNum
  322. })
  323. }
  324. order = 0;
  325. for (const iDuoxuan of duanluo.duoxuan) {
  326. iDuoxuan.type = 'duoxuan';
  327. iDuoxuan.marked = false;
  328. iDuoxuan.onlyNum = uIndex + 1;
  329. iDuoxuan.order = order;
  330. paragraph.qas.push(iDuoxuan);
  331. iDuoxuan.iQa = iQa;
  332. uIndex++;
  333. order++;
  334. iQa++;
  335. data.StListForSearch.push({
  336. stId: iDuoxuan.stId,
  337. paragraphName: paragraph.name,
  338. dlIndex: iDuanluo,
  339. dtIndex: iDuoxuan.iQa,
  340. num: iDuoxuan.onlyNum
  341. })
  342. }
  343. order = 0;
  344. for (const iPanduan of duanluo.panduan) {
  345. iPanduan.type = 'panduan';
  346. iPanduan.marked = false;
  347. iPanduan.onlyNum = uIndex + 1;
  348. iPanduan.order = order;
  349. paragraph.qas.push(iPanduan);
  350. iPanduan.iQa = iQa;
  351. uIndex++;
  352. order++;
  353. iQa++;
  354. data.StListForSearch.push({
  355. stId: iPanduan.stId,
  356. paragraphName: paragraph.name,
  357. dlIndex: iDuanluo,
  358. dtIndex: iPanduan.iQa,
  359. num: iPanduan.onlyNum
  360. })
  361. }
  362. order = 0;
  363. for (const iTiankong of duanluo.tiankong) {
  364. iTiankong.type = 'tiankong';
  365. iTiankong.marked = false;
  366. iTiankong.onlyNum = uIndex + 1;
  367. iTiankong.order = order;
  368. paragraph.qas.push(iTiankong);
  369. iTiankong.iQa = iQa;
  370. uIndex++;
  371. order++;
  372. iQa++;
  373. data.StListForSearch.push({
  374. stId: iTiankong.stId,
  375. paragraphName: paragraph.name,
  376. dlIndex: iDuanluo,
  377. dtIndex: iTiankong.iQa,
  378. num: iTiankong.onlyNum
  379. })
  380. }
  381. iDuanluo++;
  382. questionData.value.push(paragraph)
  383. }
  384. }
  385. function handlePrev() {
  386. const qa = data.StListForSearch.find(item => item.stId == activeSt.value.stId);
  387. const index = qa.num - 1;
  388. if (index > 0) {
  389. const result = data.StListForSearch[index - 1];
  390. progress.dlIndex = result.dlIndex;
  391. progress.dtIndex = result.dtIndex
  392. }
  393. }
  394. function handleNext() {
  395. const qa = data.StListForSearch.find(item => item.stId == activeSt.value.stId);
  396. const index = qa.num - 1;
  397. if (index < data.StListForSearch.length) {
  398. const result = data.StListForSearch[index + 1];
  399. progress.dlIndex = result.dlIndex;
  400. progress.dtIndex = result.dtIndex
  401. }
  402. }
  403. function initPage() {
  404. lxApi.getClientLianxiChengjiView({
  405. hisId: hisId.value
  406. }).then(res => {
  407. const {
  408. duanluoList,
  409. lxName,
  410. zyLevelName,
  411. userScore,
  412. ksScore
  413. } = res.data;
  414. data.lxName = lxName;
  415. data.zyLevelName = zyLevelName;
  416. data.userScore = userScore;
  417. data.ksScore = ksScore;
  418. data.duanluo = duanluoList;
  419. formatDuanluoList();
  420. })
  421. }
  422. function handlePopupBack() {
  423. popupRef.value.close()
  424. }
  425. function handleOpenCard() {
  426. popupRef.value.open('top')
  427. }
  428. </script>
  429. <style>
  430. </style>