question_record.vue 9.0 KB

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