lxScoreShijuan.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474
  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. <!-- 解析 -->
  33. <view v-if="activeSt" class="score-answer-box">
  34. <view class="phone-question-answer-box" v-if="activeSt.stTypeId != 4">
  35. <view class="phone-line-title">答案解析</view>
  36. <view class="btdf-row">本题得分:<text>{{answerRes.score}}</text>分</view>
  37. <view class="zqda-row">正确答案:<text>{{answerRes.result}}</text></view>
  38. <view class="ndda-row">您的答案:<text>{{answerRes.reply}}</text></view>
  39. <view class="dajx-row">答案解析:
  40. <rich-text :nodes="answerRes.answer"></rich-text>
  41. </view>
  42. </view>
  43. <view class="phone-question-answer-box" v-else>
  44. <view class="phone-line-title">答案解析</view>
  45. <view class="btdf-row">本题得分:<text>{{answerRes.score}}</text>分</view>
  46. <view class="zqda-row">正确答案:
  47. <view v-for="(item,index) in answerRes.result">{{`填空${index+1}`}} : {{item}}</view>
  48. </view>
  49. <view class="ndda-row">您的答案:
  50. <view v-for="(item,index) in answerRes.reply"> {{`填空${index+1}`}}: {{item}}</view>
  51. </view>
  52. <view class="dajx-row">答案解析:
  53. <rich-text :nodes="answerRes.answer"></rich-text>
  54. </view>
  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" :animation="false" :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="card-content-box">
  82. <view class="answer-card-content" v-for="(paragraph,paragraphIndex) in questionData"
  83. :key="paragraphIndex">
  84. <view class="paragraph-title">
  85. {{paragraph.name}}
  86. </view>
  87. <view class="paragraph-qa" v-for="(qa,qaIndex) in paragraph.qas" :key="qaIndex"
  88. :class="getQaClass(qa)" @click="answerCardItemClick(qa)">{{qa.onlyNum}}
  89. </view>
  90. </view>
  91. </view>
  92. </view>
  93. </uni-popup>
  94. </view>
  95. </template>
  96. <script setup>
  97. import topCard from "@/components/score/topCard.vue"
  98. import danxuan from "@/components/questions/danxuan.vue";
  99. import duoxuan from "@/components/questions/duoxuan.vue";
  100. import tiankong from "@/components/questions/tiankong.vue";
  101. import panduan from "@/components/questions/panduan.vue";
  102. import {
  103. useQuestionTools
  104. } from "@/components/questions/useQuestionTools.js";
  105. import {
  106. onLoad
  107. } from "@dcloudio/uni-app";
  108. import {
  109. ref,
  110. reactive,
  111. computed
  112. } from "vue"
  113. import * as lxApi from "@/api/lianxi.js"
  114. const {
  115. checkDanxuanReply,
  116. checkDuoxuanReply,
  117. checkPanduanReply,
  118. checkTiankongReply,
  119. getLetterByIndex
  120. } = useQuestionTools();
  121. const hisId = ref(null)
  122. const popupRef = ref(null)
  123. const data = reactive({
  124. lxId: null,
  125. lxName: '',
  126. stTotal: 0,
  127. zyLevelName: '',
  128. userScore: '',
  129. ksScore: 0,
  130. StListForSearch: [],
  131. duanluo: [],
  132. })
  133. const questionData = ref([]);
  134. const progress = reactive({
  135. dlIndex: 0,
  136. dtIndex: 0
  137. })
  138. const dlName = computed(() => {
  139. if (data.StListForSearch && activeSt.value) {
  140. return data.StListForSearch[activeSt.value.onlyNum].paragraphName
  141. } else {
  142. return ''
  143. }
  144. })
  145. const activeSt = computed(() => {
  146. if (questionData.value.length) {
  147. return questionData.value.length && questionData.value[progress.dlIndex].qas[progress.dtIndex];
  148. } else {
  149. return null
  150. }
  151. })
  152. const answerRes = computed(() => {
  153. const qa = activeSt.value;
  154. let score = qa.userScore;
  155. let reply = '';
  156. let result = '';
  157. let answer = qa.answer;
  158. if (qa.stTypeId == 1) {
  159. // 单选题
  160. if (qa.reply && qa.reply.trim() !== '') {
  161. reply = getLetterByIndex(qa.reply)
  162. } else {
  163. reply = '未答'
  164. }
  165. if (qa.result) {
  166. result = getLetterByIndex(qa.result)
  167. } else {
  168. result = '无答案'
  169. }
  170. }
  171. if (qa.stTypeId == 2) {
  172. // 多选题
  173. if (qa.reply && qa.reply.length) {
  174. reply = qa.reply.map(item => {
  175. if (item.trim()) {
  176. return getLetterByIndex(item.trim())
  177. }
  178. }).join(',')
  179. } else {
  180. reply = '未答'
  181. }
  182. if (qa.result) {
  183. result = qa.result.map(item => {
  184. if (item.trim()) {
  185. return getLetterByIndex(item.trim())
  186. }
  187. }).join(',')
  188. } else {
  189. result = '无答案'
  190. }
  191. }
  192. if (qa.stTypeId == 3) {
  193. // 判断题
  194. if (qa.reply === '') {
  195. reply = '未答'
  196. } else if (qa.reply == 0 ) {
  197. reply = '错误'
  198. } else if (qa.reply == 1) {
  199. reply = '正确'
  200. }
  201. if (qa.result == 0) {
  202. result = '错误'
  203. } else if (qa.result == 1) {
  204. result = '正确'
  205. }
  206. }
  207. if (qa.stTypeId == 4) {
  208. let reply = qa.reply || [];
  209. let result = qa.result || [];
  210. // 填空题
  211. return {
  212. score,
  213. reply,
  214. result,
  215. answer
  216. }
  217. } else {
  218. return {
  219. score,
  220. reply,
  221. result,
  222. answer
  223. }
  224. }
  225. })
  226. const isFistStId = computed(() => {
  227. if (data.StListForSearch.length) {
  228. return data.StListForSearch[0].stId == activeSt.value.stId
  229. } else {
  230. return false
  231. }
  232. });
  233. const isLastStId = computed(() => {
  234. if (data.StListForSearch.length) {
  235. return data.StListForSearch[data.StListForSearch.length - 1].stId == activeSt.value.stId
  236. } else {
  237. return false
  238. }
  239. });
  240. onLoad((options) => {
  241. hisId.value = options.hisId;
  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>