lxScoreShijuan.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469
  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"></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 topCard from "@/components/score/topCard.vue"
  92. import danxuan from "@/components/questions/danxuan.vue";
  93. import duoxuan from "@/components/questions/duoxuan.vue";
  94. import tiankong from "@/components/questions/tiankong.vue";
  95. import panduan from "@/components/questions/panduan.vue";
  96. import {
  97. useQuestionTools
  98. } from "@/components/questions/useQuestionTools.js";
  99. import customNavbarVue from "@/components/custom-navbar/custom-navbar.vue";
  100. import {
  101. onLoad
  102. } from "@dcloudio/uni-app";
  103. import {
  104. ref,
  105. reactive,
  106. computed
  107. } from "vue"
  108. import * as lxApi from "@/api/lianxi.js"
  109. const {
  110. checkDanxuanReply,
  111. checkDuoxuanReply,
  112. checkPanduanReply,
  113. checkTiankongReply,
  114. getLetterByIndex
  115. } = useQuestionTools();
  116. const hisId = ref(null)
  117. const popupRef = ref(null)
  118. const data = reactive({
  119. lxId: null,
  120. lxName: '',
  121. stTotal: 0,
  122. zyLevelName: '',
  123. userScore: '',
  124. ksScore: 0,
  125. StListForSearch: [],
  126. duanluo: [],
  127. })
  128. const questionData = ref([]);
  129. const progress = reactive({
  130. dlIndex: 0,
  131. dtIndex: 0
  132. })
  133. const dlName = computed(() => {
  134. if (data.StListForSearch && activeSt.value) {
  135. return data.StListForSearch[activeSt.value.onlyNum].paragraphName
  136. } else {
  137. return ''
  138. }
  139. })
  140. const activeSt = computed(() => {
  141. if (questionData.value.length) {
  142. return questionData.value.length && questionData.value[progress.dlIndex].qas[progress.dtIndex];
  143. } else {
  144. return null
  145. }
  146. })
  147. const answerRes = computed(() => {
  148. const qa = activeSt.value;
  149. let score = qa.userScore;
  150. let reply = '';
  151. let result = '';
  152. let answer = qa.answer;
  153. if (qa.stTypeId == 1) {
  154. // 单选题
  155. if (qa.reply && qa.reply.trim() !== '') {
  156. reply = getLetterByIndex(qa.reply)
  157. } else {
  158. reply = '未答'
  159. }
  160. if (qa.result) {
  161. result = getLetterByIndex(qa.result)
  162. } else {
  163. result = '无答案'
  164. }
  165. }
  166. if (qa.stTypeId == 2) {
  167. // 多选题
  168. if (qa.reply && qa.reply.length) {
  169. reply = qa.reply.map(item => {
  170. if (item.trim()) {
  171. return getLetterByIndex(item.trim())
  172. }
  173. }).join(',')
  174. } else {
  175. reply = '未答'
  176. }
  177. if (qa.result) {
  178. result = qa.result.map(item => {
  179. if (item.trim()) {
  180. return getLetterByIndex(item.trim())
  181. }
  182. }).join(',')
  183. } else {
  184. result = '无答案'
  185. }
  186. }
  187. if (qa.stTypeId == 3) {
  188. // 判断题
  189. if (qa.reply === '') {
  190. reply = '未答'
  191. } else if (qa.reply == 0 ) {
  192. reply = '错误'
  193. } else if (qa.reply == 1) {
  194. reply = '正确'
  195. }
  196. if (qa.result == 0) {
  197. result = '错误'
  198. } else if (qa.result == 1) {
  199. result = '正确'
  200. }
  201. }
  202. if (qa.stTypeId == 4) {
  203. let reply = qa.reply || [];
  204. let result = qa.result || [];
  205. // 填空题
  206. return {
  207. score,
  208. reply,
  209. result,
  210. answer
  211. }
  212. } else {
  213. return {
  214. score,
  215. reply,
  216. result,
  217. answer
  218. }
  219. }
  220. })
  221. const isFistStId = computed(() => {
  222. if (data.StListForSearch.length) {
  223. return data.StListForSearch[0].stId == activeSt.value.stId
  224. } else {
  225. return false
  226. }
  227. });
  228. const isLastStId = computed(() => {
  229. if (data.StListForSearch.length) {
  230. return data.StListForSearch[data.StListForSearch.length - 1].stId == activeSt.value.stId
  231. } else {
  232. return false
  233. }
  234. });
  235. onLoad((options) => {
  236. hisId.value = options.hisId;
  237. initPage()
  238. })
  239. function getQaClass(qa) {
  240. if (qa.marked && qa.marked === true) {
  241. return 'paragraph-qa-block-mark';
  242. } else {
  243. if (qa.stTypeId == 1) {
  244. if (checkDanxuanReply(qa)) {
  245. return 'paragraph-qa-block-done';
  246. } else {
  247. return 'paragraph-qa-block-init';
  248. }
  249. } else if (qa.stTypeId == 2) {
  250. if (checkDuoxuanReply(qa)) {
  251. return 'paragraph-qa-block-done';
  252. } else {
  253. return 'paragraph-qa-block-init';
  254. }
  255. } else if (qa.stTypeId == 3) {
  256. if (checkPanduanReply(qa)) {
  257. return 'paragraph-qa-block-done';
  258. } else {
  259. return 'paragraph-qa-block-init';
  260. }
  261. } else if (qa.stTypeId == 4) {
  262. if (checkTiankongReply(qa)) {
  263. return 'paragraph-qa-block-done';
  264. } else {
  265. return 'paragraph-qa-block-init';
  266. }
  267. }
  268. }
  269. }
  270. function skipQuestion(dlIndex, dtIndex) {
  271. progress.dlIndex = dlIndex;
  272. progress.dtIndex = dtIndex;
  273. handlePopupBack()
  274. }
  275. function answerCardItemClick(qa) {
  276. const actQa = data.StListForSearch.find(item => item.stId == qa.stId);
  277. skipQuestion(actQa.dlIndex, actQa.dtIndex)
  278. }
  279. function handleBack() {
  280. const pages = getCurrentPages();
  281. if (pages.length>1) {
  282. uni.navigateBack()
  283. } else {
  284. // uni.redirectTo({
  285. // url: "/pages/client/Lianxi/list"
  286. // })
  287. history.back();
  288. }
  289. }
  290. function formatDuanluoList() {
  291. let uIndex = 0; // 试题num
  292. let iDuanluo = 0; // 段落num
  293. let result = [];
  294. for (const duanluo of data.duanluo) {
  295. let paragraph = {
  296. qas: [],
  297. };
  298. paragraph.name = duanluo.name;
  299. let iQa = 0; // 当前试题序号
  300. let order = 0; // 当前题型中第几题
  301. for (const iDanxuan of duanluo.danxuan) {
  302. iDanxuan.type = 'danxuan';
  303. iDanxuan.marked = false;
  304. iDanxuan.onlyNum = uIndex + 1;
  305. iDanxuan.order = order;
  306. iDanxuan.iQa = iQa;
  307. paragraph.qas.push(iDanxuan);
  308. uIndex++;
  309. order++;
  310. iQa++;
  311. data.StListForSearch.push({
  312. stId: iDanxuan.stId,
  313. paragraphName: paragraph.name,
  314. dlIndex: iDuanluo,
  315. dtIndex: iDanxuan.iQa,
  316. num: iDanxuan.onlyNum
  317. })
  318. }
  319. order = 0;
  320. for (const iDuoxuan of duanluo.duoxuan) {
  321. iDuoxuan.type = 'duoxuan';
  322. iDuoxuan.marked = false;
  323. iDuoxuan.onlyNum = uIndex + 1;
  324. iDuoxuan.order = order;
  325. paragraph.qas.push(iDuoxuan);
  326. iDuoxuan.iQa = iQa;
  327. uIndex++;
  328. order++;
  329. iQa++;
  330. data.StListForSearch.push({
  331. stId: iDuoxuan.stId,
  332. paragraphName: paragraph.name,
  333. dlIndex: iDuanluo,
  334. dtIndex: iDuoxuan.iQa,
  335. num: iDuoxuan.onlyNum
  336. })
  337. }
  338. order = 0;
  339. for (const iPanduan of duanluo.panduan) {
  340. iPanduan.type = 'panduan';
  341. iPanduan.marked = false;
  342. iPanduan.onlyNum = uIndex + 1;
  343. iPanduan.order = order;
  344. paragraph.qas.push(iPanduan);
  345. iPanduan.iQa = iQa;
  346. uIndex++;
  347. order++;
  348. iQa++;
  349. data.StListForSearch.push({
  350. stId: iPanduan.stId,
  351. paragraphName: paragraph.name,
  352. dlIndex: iDuanluo,
  353. dtIndex: iPanduan.iQa,
  354. num: iPanduan.onlyNum
  355. })
  356. }
  357. order = 0;
  358. for (const iTiankong of duanluo.tiankong) {
  359. iTiankong.type = 'tiankong';
  360. iTiankong.marked = false;
  361. iTiankong.onlyNum = uIndex + 1;
  362. iTiankong.order = order;
  363. paragraph.qas.push(iTiankong);
  364. iTiankong.iQa = iQa;
  365. uIndex++;
  366. order++;
  367. iQa++;
  368. data.StListForSearch.push({
  369. stId: iTiankong.stId,
  370. paragraphName: paragraph.name,
  371. dlIndex: iDuanluo,
  372. dtIndex: iTiankong.iQa,
  373. num: iTiankong.onlyNum
  374. })
  375. }
  376. iDuanluo++;
  377. questionData.value.push(paragraph)
  378. }
  379. }
  380. function handlePrev() {
  381. const qa = data.StListForSearch.find(item => item.stId == activeSt.value.stId);
  382. const index = qa.num - 1;
  383. if (index > 0) {
  384. const result = data.StListForSearch[index - 1];
  385. progress.dlIndex = result.dlIndex;
  386. progress.dtIndex = result.dtIndex
  387. }
  388. }
  389. function handleNext() {
  390. const qa = data.StListForSearch.find(item => item.stId == activeSt.value.stId);
  391. const index = qa.num - 1;
  392. if (index < data.StListForSearch.length) {
  393. const result = data.StListForSearch[index + 1];
  394. progress.dlIndex = result.dlIndex;
  395. progress.dtIndex = result.dtIndex
  396. }
  397. }
  398. function initPage() {
  399. lxApi.getClientLianxiChengjiView({
  400. hisId: hisId.value
  401. }).then(res => {
  402. const {
  403. duanluoList,
  404. lxName,
  405. zyLevelName,
  406. userScore,
  407. ksScore
  408. } = res.data;
  409. data.lxName = lxName;
  410. data.zyLevelName = zyLevelName;
  411. data.userScore = userScore;
  412. data.ksScore = ksScore;
  413. data.duanluo = duanluoList;
  414. formatDuanluoList();
  415. })
  416. }
  417. function handlePopupBack() {
  418. popupRef.value.close()
  419. }
  420. function handleOpenCard() {
  421. popupRef.value.open('top')
  422. }
  423. </script>
  424. <style>
  425. </style>