index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546
  1. <template>
  2. <div class="bank-record">
  3. <div class="bank-record__header">
  4. <div class="title" v-if="false">做题记录</div>
  5. <div class="content">
  6. <el-select
  7. clearable
  8. @change="reGetExamRecordList"
  9. v-model="param.goodsId"
  10. placeholder="请选择"
  11. >
  12. <el-option
  13. clearable
  14. v-for="item in list"
  15. :key="item.goodsId"
  16. :label="item.goodsName"
  17. :value="item.goodsId"
  18. >
  19. </el-option>
  20. </el-select>
  21. <el-select
  22. @change="reGetExamRecordList"
  23. v-model="param.paperId"
  24. placeholder="请选择"
  25. >
  26. <el-option
  27. v-for="item in list1"
  28. :key="item.paperId"
  29. :label="item.paperName"
  30. :value="item.paperId"
  31. >
  32. </el-option>
  33. </el-select>
  34. </div>
  35. </div>
  36. <div class="bank-record__body">
  37. <div class="bank-item" v-for="(record, index) in recordList" :key="index">
  38. <div class="bank-item__header">
  39. <div class="note" v-if="record.paperName">{{ record.paperName }}</div>
  40. {{ record.examName }}
  41. </div>
  42. <div class="bank-item__body">
  43. <div class="list">
  44. <div class="exam-item">
  45. <div class="exam-item__body">
  46. <div class="text">
  47. <span class="title">{{
  48. $tools.timestampToTime(record.updateTime, false)
  49. }}</span>
  50. <span class="desc"
  51. >总{{ record.totalQuestionNum }}题/对{{
  52. record.rightQuestionNum
  53. }}题</span
  54. >
  55. </div>
  56. <div class="btns-wrap">
  57. <div class="btns">
  58. <el-button
  59. type="primary"
  60. class="btn"
  61. @click="
  62. go('/bank-exam-continue/' + record.goodsId, {
  63. recordId: record.recordId,
  64. examId: record.examId,
  65. chapterId: record.chapterExamId,
  66. moduleId: record.moduleExamId,
  67. orderGoodsId: record.orderGoodsId,
  68. })
  69. "
  70. v-if="record.status == 0 && record.historyExamJson"
  71. >继续答题</el-button
  72. >
  73. <div class="btn-line">
  74. <div
  75. class="btn-line__in"
  76. @click="doRepeat(record)"
  77. v-if="
  78. record.status == 1 && record.paperName != '随机练习'
  79. "
  80. >
  81. <div>重新做题</div>
  82. </div>
  83. <div
  84. class="btn-line__in"
  85. @click="
  86. go(
  87. record.doMode === 3
  88. ? '/bank-exam-all-explain/' + record.recordId
  89. : '/bank-exam-explain/' + record.goodsId,
  90. {
  91. simulateStatus: record.doMode === 3 ? 1 : 0,
  92. examId: record.examId,
  93. chapterId:
  94. record.courseType == 2
  95. ? record.chapterId
  96. : record.chapterExamId,
  97. moduleId:
  98. record.courseType == 2
  99. ? record.moduleId
  100. : record.moduleExamId,
  101. orderGoodsId: record.orderGoodsId,
  102. examType:
  103. record.paperName == '随机练习' ? 2 : undefined,
  104. goodsId: record.goodsId,
  105. courseType: record.courseType,
  106. }
  107. )
  108. "
  109. v-if="record.status == 1"
  110. >
  111. <div>解析</div>
  112. </div>
  113. <div
  114. class="btn-line__in"
  115. v-if="record.status == 1"
  116. @click="doReport(record)"
  117. >
  118. <div>做题报告</div>
  119. </div>
  120. <div class="btn-line__in" @click="moreRecords(record)">
  121. <div>更多记录</div>
  122. </div>
  123. </div>
  124. </div>
  125. </div>
  126. </div>
  127. </div>
  128. </div>
  129. </div>
  130. </div>
  131. </div>
  132. <div class="bank-record__footer">
  133. <div class="pagination">
  134. <el-pagination
  135. @current-change="currentChange"
  136. background
  137. layout="prev, pager, next"
  138. :total="total"
  139. :pager-count="5"
  140. :page-size="param.pageSize"
  141. >
  142. </el-pagination>
  143. </div>
  144. </div>
  145. </div>
  146. </template>
  147. <script>
  148. export default {
  149. name: "BankRecord",
  150. data() {
  151. return {
  152. list1: [],
  153. list: [],
  154. param: {
  155. pageNum: 1,
  156. pageSize: 5,
  157. goodsId: "",
  158. paperId: "",
  159. },
  160. recordList: [],
  161. total: 0,
  162. simulateStatus: "",
  163. };
  164. },
  165. mounted() {
  166. this.listGoodsUserQuestion();
  167. this.examaperList();
  168. this.getExamRecordList();
  169. },
  170. methods: {
  171. reGetExamRecordList() {
  172. this.param.pageNum = 1;
  173. this.getExamRecordList();
  174. },
  175. examaperList() {
  176. this.$request.examaperList().then((res) => {
  177. this.list1 = res.rows;
  178. this.list1.unshift({
  179. paperId: "",
  180. paperName: "全部试卷类型",
  181. });
  182. });
  183. },
  184. listGoodsUserQuestion() {
  185. this.$request.listGoodsUserQuestion().then((res) => {
  186. this.list = res.rows;
  187. this.list.unshift({
  188. goodsId: "",
  189. goodsName: "全部题库记录",
  190. });
  191. });
  192. },
  193. go(path, query) {
  194. this.$router.push({
  195. path,
  196. query,
  197. });
  198. },
  199. moreRecords(record) {
  200. let queryData = {};
  201. if (record.courseType == 2) {
  202. queryData = {
  203. examId: record.examId,
  204. gradeId: record.gradeId,
  205. chapterId: record.chapterId,
  206. moduleId: record.moduleId,
  207. courseId: record.courseId,
  208. sectionId: record.sectionId,
  209. courseType: record.courseType,
  210. };
  211. this.$router.push({
  212. path: "/person-center/record-list/" + record.goodsId,
  213. query: queryData,
  214. });
  215. } else {
  216. queryData = {
  217. examId: record.examId,
  218. chapterId: record.chapterExamId,
  219. moduleId: record.moduleExamId,
  220. recordId: record.recordId,
  221. courseType: record.courseType,
  222. };
  223. this.$router.push({
  224. path: "/person-center/record-list/" + record.goodsId,
  225. query: queryData,
  226. });
  227. }
  228. },
  229. currentChange(e) {
  230. this.param.pageNum = e;
  231. this.getExamRecordList();
  232. },
  233. getExamRecordList() {
  234. this.$request.examRecordGroupList(this.param).then((res) => {
  235. this.recordList = res.rows;
  236. this.total = res.total;
  237. });
  238. },
  239. async doRepeat(section) {
  240. console.log("section:", section);
  241. let count = 0;
  242. if (section.courseType == 2) {
  243. count = await this.bankRecordDoNum(section);
  244. } else {
  245. count = await this.examRecordCount(section.examId);
  246. }
  247. console.log("已做的次数", count);
  248. let answerNum = await this.getExamDetail(section.examId);
  249. //超过答题次数
  250. if (answerNum > 0 && count >= answerNum) {
  251. this.$message({
  252. type: "warning",
  253. message: "该试卷只能答题" + answerNum + "次!",
  254. });
  255. return;
  256. }
  257. this.$confirm(`是否清空答案重做?`, "提示", {
  258. confirmButtonText: "重做",
  259. cancelButtonText: "查看上次",
  260. closeOnClickModal: false,
  261. closeOnPressEscape: false,
  262. distinguishCancelAndClose: false,
  263. showClose: false,
  264. })
  265. .then((_) => {
  266. if (section.courseType == 2) {
  267. this.$router.push({
  268. path: "/course-exam/" + section.goodsId,
  269. query: {
  270. courseId: section.courseId,
  271. gradeId: section.gradeId || 0,
  272. moduleId: section.moduleId || 0,
  273. sectionId: section.sectionId || 0,
  274. examId: section.examId,
  275. type: section.type, // 模块卷类型
  276. chapterId: section.chapterId || 0,
  277. orderGoodsId: section.orderGoodsId,
  278. },
  279. });
  280. } else {
  281. this.$router.push({
  282. path: "/bank-exam/" + section.goodsId,
  283. query: {
  284. simulateStatus: this.simulateStatus || 0,
  285. orderGoodsId: section.orderGoodsId,
  286. examId: section.examId,
  287. moduleId: section.moduleExamId || 0,
  288. chapterId: section.chapterExamId || 0,
  289. },
  290. });
  291. }
  292. })
  293. .catch((_) => {
  294. this.$router.push({
  295. path: "/bank-exam-all-explain/" + section.recordId,
  296. query: {
  297. simulateStatus: this.simulateStatus || 0,
  298. examId: section.examId,
  299. moduleId: section.moduleExamId || 0,
  300. chapterId: section.chapterExamId || 0,
  301. goodsId: section.goodsId,
  302. orderGoodsId: section.orderGoodsId,
  303. courseType: section.courseType,
  304. },
  305. });
  306. });
  307. },
  308. /**
  309. * 获取视频试卷已做的次数
  310. */
  311. bankRecordDoNum(section) {
  312. return new Promise((resolve) => {
  313. this.$request
  314. .bankRecordDoNum({
  315. goodsId: section.goodsId,
  316. gradeId: section.gradeId,
  317. chapterId: section.chapterId || 0,
  318. courseId: section.courseId,
  319. moduleId: section.moduleId || 0,
  320. examId: section.examId,
  321. })
  322. .then((res) => {
  323. resolve(res.data);
  324. });
  325. });
  326. },
  327. /**
  328. * 查询试卷历史做题次数
  329. */
  330. examRecordCount(examId) {
  331. return new Promise((resolve) => {
  332. this.$request
  333. .examRecordCount({
  334. examId: examId,
  335. goodsId: this.id,
  336. })
  337. .then((res) => {
  338. resolve(res.data);
  339. });
  340. });
  341. },
  342. /**
  343. * @param {Object} exam_id
  344. * 获取试卷可以做的次数
  345. */
  346. getExamDetail(exam_id) {
  347. return new Promise((resolve) => {
  348. this.$request.getExamDetail(exam_id).then((res) => {
  349. this.simulateStatus = res.data.simulateStatus;
  350. resolve(res.data.answerNum);
  351. });
  352. });
  353. },
  354. doReport(record) {
  355. if (record.courseType == 2) {
  356. this.$router.push({
  357. path: "/course-report",
  358. query: {
  359. examId: record.examId,
  360. recordId: record.recordId,
  361. type: record.type, //type:1章卷,2节卷,3模块卷
  362. },
  363. });
  364. } else {
  365. this.$router.push({
  366. path: "/bank-report/" + record.goodsId,
  367. query: {
  368. chapterId: record.chapterExamId,
  369. moduleId: record.moduleExamId,
  370. examId: record.examId,
  371. recordId: record.recordId,
  372. orderGoodsId: record.orderGoodsId,
  373. examType: record.paperName == "随机练习" ? 2 : undefined,
  374. },
  375. });
  376. }
  377. // go('/bank-report/' + record.goodsId, {
  378. // chapterId: record.chapterExamId,
  379. // moduleId: record.moduleExamId,
  380. // examId: record.examId,
  381. // recordId: record.recordId,
  382. // orderGoodsId: record.orderGoodsId,
  383. // })
  384. },
  385. },
  386. };
  387. </script>
  388. <!-- Add "scoped" attribute to limit CSS to this component only -->
  389. <style scoped lang="scss">
  390. .bank-record {
  391. &__header {
  392. .title {
  393. height: 56px;
  394. line-height: 56px;
  395. }
  396. .content {
  397. padding-top: 10px;
  398. margin: 0px 0px 10px;
  399. }
  400. border-bottom: 1px solid #eee;
  401. }
  402. &__body {
  403. .bank-item {
  404. margin-top: 24px;
  405. &__header {
  406. height: 32px;
  407. line-height: 32px;
  408. .note {
  409. display: inline-block;
  410. margin-right: 15px;
  411. width: 80px;
  412. height: 32px;
  413. line-height: 32px;
  414. background: #3f8dfd;
  415. text-align: center;
  416. color: #fff;
  417. font-size: 16px;
  418. border-radius: 8px 0 8px 0;
  419. }
  420. }
  421. &__body {
  422. .list {
  423. .exam-item {
  424. height: 65px;
  425. background: #fafbfc;
  426. border-radius: 8px;
  427. overflow: hidden;
  428. line-height: 65px;
  429. border-top: 1px solid #eee;
  430. position: relative;
  431. &__body {
  432. .text {
  433. .title {
  434. margin-left: 24px;
  435. font-size: 16px;
  436. font-family: Microsoft YaHei;
  437. font-weight: 400;
  438. color: #333333;
  439. }
  440. .desc {
  441. margin-left: 24px;
  442. color: #666;
  443. font-size: 16px;
  444. }
  445. }
  446. .btns-wrap {
  447. display: table;
  448. position: absolute;
  449. right: 0;
  450. top: 0;
  451. height: 100%;
  452. margin-right: 20px;
  453. .btns {
  454. display: table-cell;
  455. vertical-align: middle;
  456. text-align: center;
  457. .btn {
  458. cursor: pointer;
  459. width: 122px;
  460. height: 32px;
  461. padding: 0;
  462. border-radius: 16px;
  463. display: inline-block;
  464. text-align: center;
  465. line-height: 32px;
  466. vertical-align: middle;
  467. /deep/ span {
  468. font-size: 16px;
  469. }
  470. }
  471. .btn-line {
  472. margin: 0 10px;
  473. overflow: hidden;
  474. vertical-align: middle;
  475. display: inline-block;
  476. background: #ffffff;
  477. border: 1px solid #3f8dfd;
  478. border-radius: 30px;
  479. font-size: 0;
  480. line-height: 0;
  481. &__in {
  482. cursor: pointer;
  483. display: inline-block;
  484. padding: 7px 0;
  485. color: #3f8dfd;
  486. > div {
  487. text-align: center;
  488. font-size: 16px;
  489. line-height: 16px;
  490. width: 96px;
  491. height: 16px;
  492. border-right: 1px solid #3f8dfd;
  493. }
  494. &:nth-last-of-type(1) {
  495. > div {
  496. border: 0;
  497. }
  498. }
  499. &:hover {
  500. background: #3f8dfd;
  501. color: #fff;
  502. }
  503. }
  504. }
  505. }
  506. }
  507. }
  508. }
  509. }
  510. }
  511. }
  512. }
  513. &__footer {
  514. .pagination {
  515. padding: 30px 0;
  516. text-align: center;
  517. }
  518. }
  519. }
  520. </style>