index.vue 14 KB

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