lxScoreShijuan.vue 11 KB

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