question_record.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402
  1. <template>
  2. <view>
  3. <view class="tabs">
  4. <view class="tab" :class="{ active: index == 1 }" data-index="1" @click="tab">全部题库记录</view>
  5. <view class="tab" :class="{ active: index == 2 }" data-index="2" @click="tab">全部试卷类型</view>
  6. </view>
  7. <view class="record">
  8. <view class="item" v-for="record in recordList">
  9. <view class="note">{{ record.paperName }}</view>
  10. <view class="title">{{ record.examName }}</view>
  11. <view class="desc">
  12. <view>
  13. <image src="/static/icon/wk_icon2.png"></image>
  14. <text>{{ $method.timestampToTime(record.updateTime, false) }}</text>
  15. </view>
  16. <view>
  17. <image src="/static/icon/wk_icon2.png"></image>
  18. <text>总共 {{ record.totalQuestionNum }} 题 做对 {{ record.rightQuestionNum }} 题</text>
  19. </view>
  20. </view>
  21. <view class="btns">
  22. <view class="btn" v-if="record.status == 1" @click="doRepeat(record.examId, record.goodsId, record.moduleExamId, record.chapterExamId)">重做</view>
  23. <navigator
  24. :url="
  25. '/pages2/bank/questionBankExplain?explain=1&id=' +
  26. record.examId +
  27. '&goodsid=' +
  28. record.goodsId +
  29. '&moduleId=' +
  30. record.moduleExamId +
  31. '&chapterId=' +
  32. record.chapterExamId +
  33. ''
  34. "
  35. >
  36. <view class="btn" v-if="record.status == 1">解析</view>
  37. </navigator>
  38. <navigator :url="'/pages2/bank/question_report?id=' + record.recordId"><view class="btn" v-if="record.status == 1">报告</view></navigator>
  39. <navigator
  40. :url="
  41. '/pages2/bank/questionBankExplain?continue=1&recordId=' +
  42. record.recordId +
  43. '&id=' +
  44. record.examId +
  45. '&goodsid=' +
  46. record.goodsId +
  47. '&moduleId=' +
  48. record.moduleExamId +
  49. '&chapterId=' +
  50. record.chapterExamId +
  51. ''
  52. "
  53. >
  54. <view class="btn" v-if="record.status == 0 && record.historyExamJson">继续</view>
  55. </navigator>
  56. </view>
  57. </view>
  58. </view>
  59. <view class="modal" v-if="index == 1">
  60. <view class="content">
  61. <view class="top" :class="activeIndex === 0 ? 'activesty' : ''" @click="testClick(3)">全部题库记录</view>
  62. <view class="list">
  63. <view class="item" :class="activeIndex == listItem.goodsId ? 'activesty' : ''" v-for="listItem in list" @click="testClick(listItem)">
  64. {{ listItem.goodsName }}
  65. </view>
  66. </view>
  67. </view>
  68. <view class="modal_wrap" @click="index = 0"></view>
  69. </view>
  70. <view class="modal" v-if="index == 2">
  71. <view class="content">
  72. <view class="top" :class="typeIndex === 0 ? 'activesty' : ''" @click="paperClick(3)">全部试卷类型</view>
  73. <view class="list">
  74. <view class="item" :class="typeIndex == listItem.paperId ? 'activesty' : ''" v-for="listItem in list1" @click="paperClick(listItem)">{{ listItem.paperName }}</view>
  75. </view>
  76. </view>
  77. <view class="modal_wrap" @click="index = 0"></view>
  78. </view>
  79. </view>
  80. </template>
  81. <script>
  82. export default {
  83. data() {
  84. return {
  85. index: 0,
  86. list: [],
  87. list1: [],
  88. recordList: [],
  89. goodsData: {},
  90. param: {
  91. pageNum: 1,
  92. pageSize: 10
  93. },
  94. total: 0,
  95. activeIndex: 0,
  96. typeIndex:0,
  97. };
  98. },
  99. onLoad(option) {
  100. },
  101. onPullDownRefresh() {
  102. let that = this;
  103. this.param = {
  104. pageNum: 1,
  105. pageSize: 10
  106. };
  107. this.getExamRecordList();
  108. setTimeout(function() {
  109. uni.stopPullDownRefresh();
  110. }, 500);
  111. },
  112. onReachBottom() {
  113. if (this.recordList.length < this.total) {
  114. this.param.pageNum++;
  115. this.getExamRecordList();
  116. }
  117. },
  118. onShow() {
  119. this.listGoodsUserQuestion();
  120. this.examaperList();
  121. this.getExamRecordList();
  122. },
  123. methods: {
  124. getExamRecordList() {
  125. if (this.param.pageNum == 1) {
  126. this.recordList = [];
  127. }
  128. this.$api.examRecordList(this.param).then(res => {
  129. this.recordList.push.apply(this.recordList, res.data.rows);
  130. this.total = res.data.total;
  131. });
  132. },
  133. /**
  134. * 去做题
  135. */
  136. async doRepeat(id, goodsId, moduleId = 0, chapterId = 0) {
  137. await this.getDetail(goodsId);
  138. let count = await this.examRecordCount(id,goodsId);
  139. let answerNum = await this.getExamDetail(id);
  140. //超过答题次数
  141. if (answerNum > 0 && count >= answerNum) {
  142. this.$u.toast('该试卷只能答题' + answerNum + '次!');
  143. return;
  144. }
  145. uni.navigateTo({
  146. url: '/pages2/bank/questionBank?id=' + id + '&goodsid=' + goodsId + '&moduleId=' + moduleId + '&chapterId=' + chapterId + ''
  147. });
  148. },
  149. /**
  150. * @param {Object} exam_id
  151. * 获取试卷可以做的次数
  152. */
  153. getExamDetail(exam_id) {
  154. return new Promise(resolve => {
  155. this.$api.getExamDetail(exam_id).then(res => {
  156. resolve(res.data.data.answerNum);
  157. });
  158. });
  159. },
  160. /**
  161. * 查询试卷历史做题次数
  162. */
  163. examRecordCount(examId,goodsId) {
  164. return new Promise(resolve => {
  165. this.$api
  166. .examRecordCount({
  167. examId: examId,
  168. goodsId: goodsId
  169. })
  170. .then(res => {
  171. resolve(res.data.data);
  172. });
  173. });
  174. },
  175. getDetail(id) {
  176. return new Promise(resolve => {
  177. this.$api.goodsDetail(id).then(res => {
  178. this.goodsData = res.data.data;
  179. resolve();
  180. });
  181. });
  182. },
  183. testClick(item) {
  184. if (item === 3) {
  185. this.index = 0;
  186. this.activeIndex = 0;
  187. this.param.goodsId = '';
  188. this.param.pageNum = 1;
  189. this.getExamRecordList();
  190. } else {
  191. this.index = 0;
  192. this.activeIndex = item.goodsId;
  193. this.param.goodsId = item.goodsId;
  194. this.param.pageNum = 1;
  195. this.getExamRecordList();
  196. }
  197. },
  198. paperClick(item) {
  199. if (item === 3) {
  200. this.index = 0;
  201. this.typeIndex = 0;
  202. this.param.paperId = '';
  203. this.param.pageNum = 1;
  204. this.getExamRecordList();
  205. } else {
  206. this.index = 0;
  207. this.typeIndex = item.paperId;
  208. this.param.paperId = item.paperId;
  209. this.param.pageNum = 1;
  210. this.getExamRecordList();
  211. }
  212. },
  213. tab(e) {
  214. this.index = e.currentTarget.dataset.index;
  215. console.log(this.index);
  216. },
  217. examaperList() {
  218. this.$api.examaperList({}).then(res => {
  219. this.list1 = res.data.rows;
  220. });
  221. },
  222. listGoodsUserQuestion() {
  223. this.$api.listGoodsUserQuestion({}).then(res => {
  224. this.list = res.data.rows;
  225. });
  226. }
  227. }
  228. };
  229. </script>
  230. <style>
  231. page {
  232. background: #eaeef1;
  233. }
  234. </style>
  235. <style lang="scss" scope>
  236. .tabs {
  237. position: fixed;
  238. left: 0;
  239. width: 100%;
  240. top: 0;
  241. display: flex;
  242. z-index: 10;
  243. .tab {
  244. flex: 1;
  245. height: 80rpx;
  246. text-align: center;
  247. line-height: 80rpx;
  248. background: #ffffff;
  249. font-size: 32rpx;
  250. color: #999999;
  251. &.active {
  252. color: #333333;
  253. }
  254. }
  255. }
  256. .record {
  257. margin-top: 80rpx;
  258. padding: 16rpx 8rpx;
  259. -moz-column-count: 2; /* Firefox */
  260. -webkit-column-count: 2; /* Safari 和 Chrome */
  261. column-count: 2;
  262. -moz-column-gap: 16rpx;
  263. -webkit-column-gap: 16rpx;
  264. column-gap: 16rpx;
  265. .item {
  266. margin-bottom: 16rpx;
  267. -moz-page-break-inside: avoid;
  268. -webkit-column-break-inside: avoid;
  269. break-inside: avoid;
  270. background: #ffffff;
  271. border-radius: 16rpx;
  272. padding: 65rpx 20rpx 22rpx;
  273. position: relative;
  274. overflow: hidden;
  275. .note {
  276. color: #fff;
  277. position: absolute;
  278. left: 0;
  279. top: 0;
  280. // width: 112rpx;
  281. padding: 0rpx 10rpx;
  282. height: 40rpx;
  283. text-align: center;
  284. line-height: 40rpx;
  285. background: linear-gradient(0deg, #4facfe, #007aff);
  286. border-radius: 16rpx 0px 16rpx 0rpx;
  287. }
  288. .title {
  289. font-size: 32rpx;
  290. color: #333333;
  291. font-weight: bold;
  292. }
  293. .desc {
  294. margin-top: 26rpx;
  295. view {
  296. margin: 16rpx 0;
  297. image {
  298. width: 23rpx;
  299. height: 24rpx;
  300. }
  301. text {
  302. margin-left: 15rpx;
  303. font-size: 24rpx;
  304. color: #999999;
  305. line-height: 36rpx;
  306. }
  307. }
  308. }
  309. .btns {
  310. margin-top: 26rpx;
  311. display: flex;
  312. justify-content: space-around;
  313. .btn {
  314. width: 100rpx;
  315. height: 48rpx;
  316. line-height: 48rpx;
  317. text-align: center;
  318. color: #007aff;
  319. background: #ffffff;
  320. border: 1rpx solid #007aff;
  321. border-radius: 16rpx;
  322. }
  323. }
  324. }
  325. }
  326. .modal {
  327. position: fixed;
  328. left: 0;
  329. width: 100%;
  330. top: 80rpx;
  331. bottom: 0;
  332. .content {
  333. position: relative;
  334. z-index: 10;
  335. background: #fff;
  336. padding: 8rpx 12rpx 20rpx;
  337. display: flex;
  338. flex-wrap: wrap;
  339. .top {
  340. margin: 0 auto;
  341. width: 726rpx;
  342. height: 80rpx;
  343. background: #f5f5f5;
  344. color: #666666;
  345. border-radius: 16rpx;
  346. text-align: center;
  347. line-height: 80rpx;
  348. font-size: 32rpx;
  349. }
  350. .list {
  351. margin-top: 16rpx;
  352. display: flex;
  353. flex-wrap: wrap;
  354. justify-content: space-between;
  355. .item {
  356. padding: 25rpx 20rpx;
  357. width: 49%;
  358. background: #f5f5f5;
  359. border-radius: 16rpx;
  360. font-size: 32rpx;
  361. color: #666666;
  362. margin: 8rpx 0;
  363. }
  364. }
  365. }
  366. .modal_wrap {
  367. position: absolute;
  368. left: 0;
  369. width: 100%;
  370. top: 0;
  371. height: 100%;
  372. background: rgba(0, 0, 0, 0.3);
  373. }
  374. }
  375. .activesty {
  376. background: #007aff !important;
  377. color: #fff !important;
  378. }
  379. </style>