specialExam.vue 6.6 KB

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