question_record.vue 9.1 KB

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