lxScoreShijuan.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460
  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 handleBack() {
  274. const pages = getCurrentPages();
  275. if (pages.length>1) {
  276. uni.navigateBack()
  277. } else {
  278. // uni.redirectTo({
  279. // url: "/pages/client/Lianxi/list"
  280. // })
  281. history.back();
  282. }
  283. }
  284. function formatDuanluoList() {
  285. let uIndex = 0; // 试题num
  286. let iDuanluo = 0; // 段落num
  287. let result = [];
  288. for (const duanluo of data.duanluo) {
  289. let paragraph = {
  290. qas: [],
  291. };
  292. paragraph.name = duanluo.name;
  293. let iQa = 0; // 当前试题序号
  294. let order = 0; // 当前题型中第几题
  295. for (const iDanxuan of duanluo.danxuan) {
  296. iDanxuan.type = 'danxuan';
  297. iDanxuan.marked = false;
  298. iDanxuan.onlyNum = uIndex + 1;
  299. iDanxuan.order = order;
  300. iDanxuan.iQa = iQa;
  301. paragraph.qas.push(iDanxuan);
  302. uIndex++;
  303. order++;
  304. iQa++;
  305. data.StListForSearch.push({
  306. stId: iDanxuan.stId,
  307. paragraphName: paragraph.name,
  308. dlIndex: iDuanluo,
  309. dtIndex: iDanxuan.iQa,
  310. num: iDanxuan.onlyNum
  311. })
  312. }
  313. order = 0;
  314. for (const iDuoxuan of duanluo.duoxuan) {
  315. iDuoxuan.type = 'duoxuan';
  316. iDuoxuan.marked = false;
  317. iDuoxuan.onlyNum = uIndex + 1;
  318. iDuoxuan.order = order;
  319. paragraph.qas.push(iDuoxuan);
  320. iDuoxuan.iQa = iQa;
  321. uIndex++;
  322. order++;
  323. iQa++;
  324. data.StListForSearch.push({
  325. stId: iDuoxuan.stId,
  326. paragraphName: paragraph.name,
  327. dlIndex: iDuanluo,
  328. dtIndex: iDuoxuan.iQa,
  329. num: iDuoxuan.onlyNum
  330. })
  331. }
  332. order = 0;
  333. for (const iPanduan of duanluo.panduan) {
  334. iPanduan.type = 'panduan';
  335. iPanduan.marked = false;
  336. iPanduan.onlyNum = uIndex + 1;
  337. iPanduan.order = order;
  338. paragraph.qas.push(iPanduan);
  339. iPanduan.iQa = iQa;
  340. uIndex++;
  341. order++;
  342. iQa++;
  343. data.StListForSearch.push({
  344. stId: iPanduan.stId,
  345. paragraphName: paragraph.name,
  346. dlIndex: iDuanluo,
  347. dtIndex: iPanduan.iQa,
  348. num: iPanduan.onlyNum
  349. })
  350. }
  351. order = 0;
  352. for (const iTiankong of duanluo.tiankong) {
  353. iTiankong.type = 'tiankong';
  354. iTiankong.marked = false;
  355. iTiankong.onlyNum = uIndex + 1;
  356. iTiankong.order = order;
  357. paragraph.qas.push(iTiankong);
  358. iTiankong.iQa = iQa;
  359. uIndex++;
  360. order++;
  361. iQa++;
  362. data.StListForSearch.push({
  363. stId: iTiankong.stId,
  364. paragraphName: paragraph.name,
  365. dlIndex: iDuanluo,
  366. dtIndex: iTiankong.iQa,
  367. num: iTiankong.onlyNum
  368. })
  369. }
  370. iDuanluo++;
  371. questionData.value.push(paragraph)
  372. }
  373. }
  374. function handlePrev() {
  375. const qa = data.StListForSearch.find(item => item.stId == activeSt.value.stId);
  376. const index = qa.num - 1;
  377. if (index > 0) {
  378. const result = data.StListForSearch[index - 1];
  379. progress.dlIndex = result.dlIndex;
  380. progress.dtIndex = result.dtIndex
  381. }
  382. }
  383. function handleNext() {
  384. const qa = data.StListForSearch.find(item => item.stId == activeSt.value.stId);
  385. const index = qa.num - 1;
  386. if (index < data.StListForSearch.length) {
  387. const result = data.StListForSearch[index + 1];
  388. progress.dlIndex = result.dlIndex;
  389. progress.dtIndex = result.dtIndex
  390. }
  391. }
  392. function initPage() {
  393. lxApi.getClientLianxiChengjiView({
  394. hisId: hisId.value
  395. }).then(res => {
  396. const {
  397. duanluoList,
  398. lxName,
  399. zyLevelName,
  400. userScore,
  401. ksScore
  402. } = res.data;
  403. data.lxName = lxName;
  404. data.zyLevelName = zyLevelName;
  405. data.userScore = userScore;
  406. data.ksScore = ksScore;
  407. data.duanluo = duanluoList;
  408. formatDuanluoList();
  409. })
  410. }
  411. function handlePopupBack() {
  412. popupRef.value.close()
  413. }
  414. function handleOpenCard() {
  415. popupRef.value.open('bottom')
  416. }
  417. </script>
  418. <style>
  419. </style>