specialExam.vue 6.7 KB

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