specialExam.vue 6.8 KB

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