specialExam.vue 6.8 KB

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