specialExam.vue 6.6 KB

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