examTask.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. <!-- 考试任务 -->
  2. <template>
  3. <view class="examTask-component">
  4. <view class="card">
  5. <view class="card-header">
  6. <view class="header-left">
  7. <view class="card-title">考试任务</view>
  8. <view class="header-subtitle">待完成的学习考试任务</view>
  9. </view>
  10. <text class="header-link" @click="goToPage('1')">更多 ›</text>
  11. </view>
  12. <view class="card-body">
  13. <view class="for-max-box" @click="goToPage('2',item)"
  14. v-for="(item,index) in onlineExamList" :key="index">
  15. <view class="left-box">
  16. <view>{{item.examName}}</view>
  17. <view>待完成</view>
  18. </view>
  19. <view class="right-box">›</view>
  20. </view>
  21. <view v-if="!onlineExamList[0]" class="empty-tip">暂无考试任务</view>
  22. </view>
  23. </view>
  24. <!-- 考试承诺书弹窗 -->
  25. <uni-popup ref="preExamDialog" type="center" :mask-click="false">
  26. <view class="pre-exam-dialog">
  27. <view class="dialog-header">
  28. <text class="dialog-title">考试承诺书</text>
  29. </view>
  30. <view class="dialog-body">
  31. <scroll-view scroll-y class="content-scroll">
  32. <richTextPdf ref="richTextPdf" :content="richTextHtml" />
  33. </scroll-view>
  34. </view>
  35. <view class="dialog-footer">
  36. <view v-if="preButtonType" class="btn btn-border" @click="downloadCommitment">下载</view>
  37. <view class="btn btn-primary" @click="confirmCommitment">确认</view>
  38. </view>
  39. </view>
  40. </uni-popup>
  41. </view>
  42. </template>
  43. <script>
  44. import {
  45. examUserExamStudyTaskList,
  46. } from '@/pages_safetyEducationExamination/api/index.js'
  47. import {
  48. goToExamPage,
  49. confirmCommitmentAndStart,
  50. startFormalExam,
  51. } from '@/pages_safetyEducationExamination/utils/index.js'
  52. import richTextPdf from '@/pages_safetyEducationExamination/component/richTextPdf.vue'
  53. export default {
  54. components: {
  55. richTextPdf
  56. },
  57. data() {
  58. return {
  59. onlineExamList: [],
  60. // 承诺书相关
  61. preButtonType: false,
  62. richTextHtml: '',
  63. preData: null,
  64. itemData:{},
  65. }
  66. },
  67. mounted() {
  68. // this.loadTaskList();
  69. },
  70. methods: {
  71. resetMethod(){
  72. this.loadTaskList();
  73. },
  74. goToPage(type, item) {
  75. if (type == 1) {
  76. uni.navigateTo({ url: '/pages_safetyEducationExamination/views/exam/index' });
  77. return;
  78. }else{
  79. this.$set(this,'itemData',item);
  80. goToExamPage(item, {
  81. openCommitmentDialog: (examItem) => {
  82. this.preButtonType = examItem.commitmentPrintEnabled == 1;
  83. this.richTextHtml = examItem.commitmentContent;
  84. this.preData = examItem;
  85. this.$refs.preExamDialog.open();
  86. },
  87. });
  88. }
  89. },
  90. // 下载承诺书
  91. downloadCommitment() {
  92. uni.showToast({ title: '正在下载,请耐心等候', icon: 'none' });
  93. this.$refs.richTextPdf.downloadPDF();
  94. },
  95. // 确认承诺书
  96. async confirmCommitment() {
  97. await confirmCommitmentAndStart(this.preData, () => {
  98. this.$refs.preExamDialog.close();
  99. startFormalExam(this.itemData);
  100. });
  101. },
  102. // 获取任务列表
  103. async loadTaskList() {
  104. try {
  105. const { data } = await examUserExamStudyTaskList({ page: 1, pageSize: 1, examStatus: 2, isSpecialExam: false });
  106. if (data.code === 200) {
  107. this.$set(this, 'onlineExamList', data.data.records);
  108. }
  109. } catch (e) { console.error('获取考试任务失败', e); }
  110. },
  111. },
  112. }
  113. </script>
  114. <style lang="stylus" scoped>
  115. .examTask-component {
  116. margin: 0 32rpx 32rpx;
  117. .card {
  118. background: #fff;
  119. border-radius: 24rpx;
  120. overflow: hidden;
  121. margin-bottom: 24rpx;
  122. box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.03);
  123. border: 1px solid #dde3ed;
  124. }
  125. .card-header {
  126. padding: 20rpx 28rpx;
  127. display: flex;
  128. justify-content: space-between;
  129. align-items: center;
  130. .card-title {
  131. font-size: 28rpx;
  132. color: #333;
  133. }
  134. .header-subtitle{
  135. margin-top:10rpx;
  136. font-size:22rpx;
  137. color:#8896a7;
  138. }
  139. .header-link {
  140. padding:10rpx 20rpx;
  141. font-size: 24rpx;
  142. color: #1857d4;
  143. }
  144. }
  145. .card-body {
  146. padding: 0 28rpx 24rpx;
  147. .for-max-box:nth-child(1){
  148. margin-top:0;
  149. }
  150. .for-max-box{
  151. margin-top:20rpx;
  152. display: flex;
  153. background-color:#f4f6fa;
  154. padding: 20rpx 24rpx;
  155. border-radius: 16rpx;
  156. .left-box{
  157. flex:1;
  158. view:nth-child(1){
  159. font-size:26rpx;
  160. margin-bottom:4rpx;
  161. }
  162. view:nth-child(2){
  163. font-size:22rpx;
  164. color:#8896a7;
  165. }
  166. }
  167. .right-box{
  168. line-height:60rpx;
  169. font-size:40rpx;
  170. color:#8896a7;
  171. }
  172. }
  173. .empty-tip{
  174. text-align: center;
  175. line-height:40rpx;
  176. color:#8896a7;
  177. font-size:24rpx;
  178. }
  179. }
  180. }
  181. // 承诺书弹窗样式
  182. .pre-exam-dialog {
  183. width: 600rpx;
  184. max-height: 80vh;
  185. background: #fff;
  186. border-radius: 20rpx;
  187. overflow: hidden;
  188. }
  189. .dialog-header {
  190. padding: 32rpx;
  191. border-bottom: 1rpx solid #eee;
  192. .dialog-title {
  193. font-size: 32rpx;
  194. font-weight: 600;
  195. color: #333;
  196. }
  197. }
  198. .dialog-body {
  199. height: 800rpx;
  200. overflow: hidden;
  201. .content-scroll {
  202. height: 100%;
  203. }
  204. }
  205. .dialog-footer {
  206. display: flex;
  207. gap: 20rpx;
  208. padding: 24rpx 32rpx;
  209. border-top: 1rpx solid #eee;
  210. .btn {
  211. flex: 1;
  212. height: 72rpx;
  213. line-height: 72rpx;
  214. text-align: center;
  215. font-size: 28rpx;
  216. border-radius: 12rpx;
  217. }
  218. .btn-border {
  219. background: #fff;
  220. color: #1857d4;
  221. border: 1rpx solid #1857d4;
  222. }
  223. .btn-primary {
  224. background: #1857d4;
  225. color: #fff;
  226. }
  227. }
  228. </style>