index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598
  1. <template>
  2. <div class="bank-report">
  3. <Header></Header>
  4. <section class="section">
  5. <div class="container">
  6. <div
  7. class="section__header section__header--warm"
  8. v-if="examData.doType == 2 && reportdata.reportStatus === null"
  9. >
  10. <div class="title">
  11. <span class="icon">X</span>
  12. 测试未通过
  13. </div>
  14. <div class="desc" v-if="reportdata.doTime">
  15. 总时间:{{ $tools.secondToTime(reportdata.examTime) }}
  16. <span class="note"
  17. >答题时长:{{
  18. $tools.secondToTime(reportdata.doTime, false)
  19. }}</span
  20. >
  21. </div>
  22. </div>
  23. <div
  24. class="section__header section__header--success"
  25. v-if="examData.doType == 2 && reportdata.reportStatus === 1"
  26. >
  27. <div class="title">
  28. <span class="icon">✔</span>
  29. 测试通过
  30. </div>
  31. <div class="desc" v-if="reportdata.doTime">
  32. 总时间:{{ $tools.secondToTime(reportdata.examTime) }}
  33. <span class="note"
  34. >答题时长:{{
  35. $tools.secondToTime(reportdata.doTime, false)
  36. }}</span
  37. >
  38. </div>
  39. </div>
  40. <template v-else>
  41. <div class="section__header" v-if="reportdata.doTime">
  42. <div class="desc">
  43. 总时间:{{ $tools.secondToTime(reportdata.examTime) }}
  44. <span class="note"
  45. >答题时长:{{
  46. $tools.secondToTime(reportdata.doTime, false)
  47. }}</span
  48. >
  49. </div>
  50. </div>
  51. </template>
  52. <div class="section__body">
  53. <div class="section__body__content">
  54. <div class="left-box">
  55. <div class="left-box__in">
  56. <div class="title">
  57. 试卷得分
  58. <span class="note">(客观题)</span>
  59. </div>
  60. <div class="desc" style="margin-top:70px;">{{ reportdata.performance }}</div>
  61. <div class="other">满分{{ reportdata.totalScore }}</div>
  62. </div>
  63. <!-- <div class="left-box__in left-box__in--bottom">
  64. <div class="title">
  65. 试卷得分
  66. <span class="note">(客观题+主观题)</span>
  67. </div>
  68. <div class="desc">
  69. {{ reportdata.performance + reportdata.score }}
  70. </div>
  71. <div class="other">满分{{ reportdata.totalScore }}</div>
  72. </div> -->
  73. </div>
  74. <div class="right-box">
  75. <div class="right-box__in">
  76. <div class="title">
  77. 正确率
  78. <span class="note">(客观题)</span>
  79. </div>
  80. <div class="desc">
  81. {{
  82. ((reportdata.rightQuestionNum /
  83. (reportdata.rightQuestionNum + wrongRecordWrongNum) ||
  84. 0) *
  85. 100)
  86. | toFixed(0)
  87. }}%
  88. </div>
  89. <!-- <div class="other">满分{{ reportdata.totalScore }}</div> -->
  90. </div>
  91. <div class="right-box__in right-box__in--bottom">
  92. <div class="child">
  93. <div class="child__title child__title--success">
  94. {{ reportdata.rightQuestionNum }}
  95. </div>
  96. <div class="child__desc">正确题数</div>
  97. </div>
  98. <div class="child child---right">
  99. <div class="child__title child__title--warm">
  100. {{ wrongRecordWrongNum }}
  101. </div>
  102. <div class="child__desc">错误题数</div>
  103. </div>
  104. </div>
  105. </div>
  106. </div>
  107. </div>
  108. <div class="section__footer">
  109. <el-button type="primary" @click="back" class="btn"
  110. >返回列表</el-button
  111. >
  112. <el-button
  113. type="primary"
  114. class="btn"
  115. v-if="nextExamId"
  116. @click="backBank"
  117. >练习下一节</el-button
  118. >
  119. <el-button type="primary" class="btn" @click="doRepeat(reportdata)"
  120. >重新做题</el-button
  121. >
  122. <el-button
  123. type="primary"
  124. class="btn"
  125. @click="wrongExplain(reportdata)"
  126. >错题解析</el-button
  127. >
  128. <el-button type="primary" class="btn" @click="allExplain(reportdata)"
  129. >全部解析</el-button
  130. >
  131. </div>
  132. </div>
  133. </section>
  134. <ToolBar></ToolBar>
  135. <Footer></Footer>
  136. </div>
  137. </template>
  138. <script>
  139. import Footer from "@/components/footer/index";
  140. import Header from "@/components/header/index";
  141. import ToolBar from "@/components/toolbar/index";
  142. import { mapGetters } from "vuex";
  143. export default {
  144. name: "BankExplain",
  145. components: {
  146. Footer,
  147. Header,
  148. ToolBar,
  149. },
  150. data() {
  151. return {
  152. wrongRecordWrongNum: 0,
  153. nextExamId: "",
  154. examData: {},
  155. reportdata: {},
  156. goodsId: 0,
  157. chapterId: 0,
  158. moduleId: 0,
  159. examId: 0,
  160. recordId: 0,
  161. orderGoodsId: "",
  162. };
  163. },
  164. computed: {
  165. ...mapGetters(["examResult"]),
  166. },
  167. async mounted() {
  168. this.chapterId = this.$route.query.chapterId;
  169. this.moduleId = this.$route.query.moduleId;
  170. this.examId = this.$route.query.examId;
  171. this.recordId = this.$route.query.recordId;
  172. this.orderGoodsId = this.$route.query.orderGoodsId || "";
  173. this.goodsId = this.$route.params.goodsId;
  174. this.examWrongRecordWrongNum();
  175. this.bankExamNextExam();
  176. await this.bankExam();
  177. await this.examReport();
  178. },
  179. methods: {
  180. back() {
  181. this.$router.replace({
  182. path: "/person-center/my-bank/bank-detail/" + this.goodsId,
  183. query: {
  184. orderGoodsId: this.orderGoodsId,
  185. },
  186. });
  187. },
  188. /**
  189. * 去做题
  190. */
  191. async doRepeat(reportdata) {
  192. // await this.getDetail(reportdata.goodsId);
  193. let count = await this.examRecordCount(
  194. reportdata.examId,
  195. reportdata.goodsId
  196. );
  197. let answerNum = await this.getExamDetail(reportdata.examId);
  198. //超过答题次数
  199. if (answerNum > 0 && count >= answerNum) {
  200. this.$message({
  201. type: "warning",
  202. message: "该试卷只能答题" + answerNum + "次!",
  203. });
  204. return;
  205. }
  206. this.$router.replace({
  207. path: "/bank-exam/" + reportdata.goodsId,
  208. query: {
  209. orderGoodsId: this.orderGoodsId,
  210. examId: reportdata.examId,
  211. moduleId: reportdata.moduleId || 0,
  212. chapterId: reportdata.chapterId || 0,
  213. },
  214. });
  215. },
  216. /**
  217. * @param {Object} exam_id
  218. * 获取试卷可以做的次数
  219. */
  220. getExamDetail(exam_id) {
  221. return new Promise((resolve) => {
  222. this.$request.getExamDetail(exam_id).then((res) => {
  223. resolve(res.data.answerNum);
  224. });
  225. });
  226. },
  227. /**
  228. * 查询试卷历史做题次数
  229. */
  230. examRecordCount(examId, goodsId) {
  231. return new Promise((resolve) => {
  232. this.$request
  233. .examRecordCount({
  234. examId: examId,
  235. goodsId: goodsId,
  236. })
  237. .then((res) => {
  238. resolve(res.data);
  239. });
  240. });
  241. },
  242. getDetail(goodsId) {
  243. return new Promise((resolve) => {
  244. this.$request
  245. .orderInfo({
  246. orderGoodsId: this.orderGoodsId,
  247. })
  248. .then((res) => {
  249. this.goodsData = res.data;
  250. resolve();
  251. });
  252. });
  253. },
  254. examWrongRecordWrongNum() {
  255. return new Promise((resolve) => {
  256. this.$request.examWrongRecordWrongNum(this.recordId).then((res) => {
  257. this.wrongRecordWrongNum = res.data || 0;
  258. resolve();
  259. });
  260. });
  261. },
  262. backBank() {
  263. this.$router.replace({
  264. path: "/bank-exam/" + this.goodsId,
  265. query: {
  266. orderGoodsId: this.orderGoodsId,
  267. examId: this.nextExamId,
  268. moduleId: this.moduleId || 0,
  269. chapterId: this.chapterId || 0,
  270. },
  271. });
  272. },
  273. bankExamNextExam() {
  274. this.$request
  275. .bankExamNextExam({
  276. chapterExamId: this.chapterId,
  277. examId: this.examId,
  278. goodsId: this.goodsId,
  279. orderGoodsId: this.orderGoodsId,
  280. moduleExamId: this.moduleId,
  281. })
  282. .then((res) => {
  283. this.nextExamId = res.data.examId;
  284. })
  285. .catch((err) => {
  286. this.nextExamId = "";
  287. });
  288. },
  289. bankExam() {
  290. return new Promise((resolve) => {
  291. this.$request.bankExam(this.examId).then((res) => {
  292. this.examData = res.data;
  293. resolve();
  294. });
  295. });
  296. },
  297. examReport() {
  298. return new Promise((resolve) => {
  299. this.$request.examReport(this.recordId).then((res) => {
  300. this.reportdata = res.data;
  301. resolve();
  302. });
  303. });
  304. },
  305. wrongExplain(reportdata) {
  306. this.$router.push({
  307. path: "/bank-exam-wrong-explain/" + reportdata.recordId,
  308. query: {
  309. examId: reportdata.examId,
  310. moduleId: reportdata.moduleId || 0,
  311. chapterId: reportdata.chapterId || 0,
  312. goodsId: this.goodsId,
  313. },
  314. });
  315. },
  316. allExplain(reportdata) {
  317. this.$router.push({
  318. path: "/bank-exam-all-explain/" + reportdata.recordId,
  319. query: {
  320. examId: reportdata.examId,
  321. moduleId: reportdata.moduleId || 0,
  322. chapterId: reportdata.chapterId || 0,
  323. goodsId: this.goodsId,
  324. },
  325. });
  326. },
  327. },
  328. };
  329. </script>
  330. <!-- Add "scoped" attribute to limit CSS to this component only -->
  331. <style scoped lang="scss">
  332. .bank-report {
  333. .section {
  334. &__header {
  335. height: 120px;
  336. border-radius: 0px;
  337. padding-top: 10px;
  338. &--warm {
  339. background: #fff3f5;
  340. .title {
  341. text-align: center;
  342. font-size: 18px;
  343. font-family: Microsoft YaHei;
  344. font-weight: bold;
  345. color: #ff3b30;
  346. .icon {
  347. vertical-align: middle;
  348. display: inline-block;
  349. width: 48px;
  350. height: 58px;
  351. text-align: center;
  352. line-height: 58px;
  353. background: #ff3b30;
  354. color: #fff;
  355. font-size: 30px;
  356. }
  357. }
  358. }
  359. &--success {
  360. background: #f8fef9;
  361. .title {
  362. text-align: center;
  363. font-size: 18px;
  364. font-family: Microsoft YaHei;
  365. font-weight: bold;
  366. color: #34c759;
  367. .icon {
  368. vertical-align: middle;
  369. display: inline-block;
  370. width: 48px;
  371. height: 58px;
  372. text-align: center;
  373. line-height: 58px;
  374. background: #34c759;
  375. color: #fff;
  376. font-size: 30px;
  377. }
  378. }
  379. }
  380. .desc {
  381. margin-top: 20px;
  382. text-align: center;
  383. font-size: 14px;
  384. font-family: Microsoft YaHei;
  385. font-weight: 400;
  386. color: #333333;
  387. .note {
  388. font-size: 14px;
  389. font-family: Microsoft YaHei;
  390. font-weight: 400;
  391. color: #999999;
  392. }
  393. }
  394. }
  395. &__body {
  396. width: 100%;
  397. height: 305px;
  398. border-bottom: 1px solid #eee;
  399. &__content {
  400. width: 100%;
  401. height: 100%;
  402. display: flex;
  403. align-items: center;
  404. justify-content: center;
  405. .left-box {
  406. width: 300px;
  407. height: 240px;
  408. background: #ffffff;
  409. border: 1px solid #eeeeee;
  410. border-radius: 8px;
  411. display: flex;
  412. flex-direction: column;
  413. margin: 0 10px;
  414. &__in {
  415. flex: 1;
  416. border-bottom: 1px solid #eee;
  417. padding: 5px 18px;
  418. .title {
  419. font-size: 14px;
  420. font-family: Microsoft YaHei;
  421. font-weight: 400;
  422. color: #333333;
  423. line-height: 24px;
  424. .note {
  425. color: #999;
  426. }
  427. }
  428. .desc {
  429. margin-top: 20px;
  430. font-size: 48px;
  431. font-family: Microsoft YaHei;
  432. font-weight: 400;
  433. color: #333333;
  434. line-height: 24px;
  435. text-align: center;
  436. }
  437. .other {
  438. margin-top: 14px;
  439. font-size: 14px;
  440. font-family: Microsoft YaHei;
  441. font-weight: 400;
  442. color: #999999;
  443. line-height: 24px;
  444. text-align: center;
  445. }
  446. &--bottom {
  447. border: 0;
  448. }
  449. }
  450. }
  451. .right-box {
  452. margin: 0 10px;
  453. display: flex;
  454. width: 300px;
  455. height: 240px;
  456. background: #ffffff;
  457. border: 1px solid #eeeeee;
  458. border-radius: 8px;
  459. flex-direction: column;
  460. &__in {
  461. flex: 1;
  462. border-bottom: 1px solid #eee;
  463. padding: 5px 18px;
  464. .title {
  465. font-size: 14px;
  466. font-family: Microsoft YaHei;
  467. font-weight: 400;
  468. color: #333333;
  469. line-height: 24px;
  470. .note {
  471. color: #999;
  472. }
  473. }
  474. .desc {
  475. margin-top: 20px;
  476. font-size: 48px;
  477. font-family: Microsoft YaHei;
  478. font-weight: 400;
  479. color: #333333;
  480. line-height: 24px;
  481. text-align: center;
  482. }
  483. .other {
  484. margin-top: 14px;
  485. font-size: 14px;
  486. font-family: Microsoft YaHei;
  487. font-weight: 400;
  488. color: #999999;
  489. line-height: 24px;
  490. text-align: center;
  491. }
  492. &--bottom {
  493. padding: 0;
  494. border: 0;
  495. height: 100%;
  496. display: flex;
  497. .child {
  498. flex: 1;
  499. height: 100%;
  500. border-right: 1px solid #eee;
  501. padding: 5px 18px;
  502. &--right {
  503. border: 0;
  504. }
  505. &__title {
  506. margin-top: 20px;
  507. font-size: 36px;
  508. font-family: Microsoft YaHei;
  509. font-weight: 400;
  510. color: #34c759;
  511. line-height: 24px;
  512. text-align: center;
  513. &--success {
  514. color: #34c759;
  515. }
  516. &--warm {
  517. color: #ff3b30;
  518. }
  519. }
  520. &__desc {
  521. margin-top: 10px;
  522. font-size: 14px;
  523. font-family: Microsoft YaHei;
  524. font-weight: 400;
  525. color: #999999;
  526. line-height: 24px;
  527. text-align: center;
  528. }
  529. }
  530. }
  531. }
  532. }
  533. }
  534. }
  535. &__footer {
  536. display: flex;
  537. align-items: center;
  538. justify-content: center;
  539. padding: 40px 0;
  540. .btn {
  541. cursor: pointer;
  542. width: 140px;
  543. height: 32px;
  544. padding: 0;
  545. border-radius: 16px;
  546. text-align: center;
  547. line-height: 30px;
  548. font-size: 12px;
  549. margin: 0 4px;
  550. }
  551. }
  552. }
  553. }
  554. </style>