examTask.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  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="true">
  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" :examId="richTextExamId" />
  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. richTextExamId:'',
  64. preData: null,
  65. itemData:{},
  66. }
  67. },
  68. mounted() {
  69. // this.loadTaskList();
  70. },
  71. methods: {
  72. resetMethod(){
  73. this.loadTaskList();
  74. },
  75. goToPage(type, item) {
  76. if (type == 1) {
  77. uni.navigateTo({ url: '/pages_safetyEducationExamination/views/exam/index' });
  78. return;
  79. }else{
  80. this.$set(this,'itemData',item);
  81. goToExamPage(item, {
  82. openCommitmentDialog: (examItem) => {
  83. this.preButtonType = examItem.commitmentPrintEnabled == 1;
  84. this.richTextHtml = examItem.commitmentContent;
  85. this.richTextExamId = examItem.examId;
  86. this.preData = examItem;
  87. this.$refs.preExamDialog.open();
  88. },
  89. });
  90. }
  91. },
  92. // 下载承诺书
  93. downloadCommitment() {
  94. uni.showToast({ title: '正在下载,请耐心等候', icon: 'none' });
  95. this.$refs.richTextPdf.downloadPDF();
  96. },
  97. // 确认承诺书
  98. async confirmCommitment() {
  99. let self = this;
  100. await confirmCommitmentAndStart(this.preData, () => {
  101. this.$refs.preExamDialog.close();
  102. setTimeout(function(){
  103. startFormalExam(self.itemData);
  104. },500);
  105. });
  106. },
  107. // 获取任务列表
  108. async loadTaskList() {
  109. try {
  110. const { data } = await examUserExamStudyTaskList({ page: 1, pageSize: 1, examStatus: 2, isSpecialExam: false });
  111. if (data.code === 200) {
  112. this.$set(this, 'onlineExamList', data.data.records);
  113. }
  114. } catch (e) { console.error('获取考试任务失败', e); }
  115. },
  116. },
  117. }
  118. </script>
  119. <style lang="stylus" scoped>
  120. .examTask-component {
  121. margin: 0 32rpx 32rpx;
  122. .card {
  123. background: #fff;
  124. border-radius: 24rpx;
  125. overflow: hidden;
  126. margin-bottom: 24rpx;
  127. box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.03);
  128. border: 1px solid #dde3ed;
  129. }
  130. .card-header {
  131. padding: 20rpx 28rpx;
  132. display: flex;
  133. justify-content: space-between;
  134. align-items: center;
  135. .card-title {
  136. font-size: 28rpx;
  137. color: #333;
  138. }
  139. .header-subtitle{
  140. margin-top:10rpx;
  141. font-size:22rpx;
  142. color:#8896a7;
  143. }
  144. .header-link {
  145. padding:10rpx 20rpx;
  146. font-size: 24rpx;
  147. color: #1857d4;
  148. }
  149. }
  150. .card-body {
  151. padding: 0 28rpx 24rpx;
  152. .for-max-box:nth-child(1){
  153. margin-top:0;
  154. }
  155. .for-max-box{
  156. margin-top:20rpx;
  157. display: flex;
  158. background-color:#f4f6fa;
  159. padding: 20rpx 24rpx;
  160. border-radius: 16rpx;
  161. .left-box{
  162. flex:1;
  163. view:nth-child(1){
  164. font-size:26rpx;
  165. margin-bottom:4rpx;
  166. }
  167. view:nth-child(2){
  168. font-size:22rpx;
  169. color:#8896a7;
  170. }
  171. }
  172. .right-box{
  173. line-height:60rpx;
  174. font-size:40rpx;
  175. color:#8896a7;
  176. }
  177. }
  178. .empty-tip{
  179. text-align: center;
  180. line-height:40rpx;
  181. color:#8896a7;
  182. font-size:24rpx;
  183. }
  184. }
  185. }
  186. // 承诺书弹窗样式
  187. .pre-exam-dialog {
  188. width: 600rpx;
  189. max-height: 80vh;
  190. background: #fff;
  191. border-radius: 20rpx;
  192. overflow: hidden;
  193. }
  194. .dialog-header {
  195. padding: 32rpx;
  196. border-bottom: 1rpx solid #eee;
  197. .dialog-title {
  198. font-size: 32rpx;
  199. font-weight: 600;
  200. color: #333;
  201. }
  202. }
  203. .dialog-body {
  204. height: 800rpx;
  205. overflow: hidden;
  206. .content-scroll {
  207. height: 100%;
  208. }
  209. }
  210. .dialog-footer {
  211. display: flex;
  212. gap: 20rpx;
  213. padding: 24rpx 32rpx;
  214. border-top: 1rpx solid #eee;
  215. .btn {
  216. flex: 1;
  217. height: 72rpx;
  218. line-height: 72rpx;
  219. text-align: center;
  220. font-size: 28rpx;
  221. border-radius: 12rpx;
  222. }
  223. .btn-border {
  224. background: #fff;
  225. color: #1857d4;
  226. border: 1rpx solid #1857d4;
  227. }
  228. .btn-primary {
  229. background: #1857d4;
  230. color: #fff;
  231. }
  232. }
  233. </style>