lxScoreShijuan.vue 12 KB

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