| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243 |
- <!-- 考试任务 -->
- <template>
- <view class="examTask-component">
- <view class="card">
- <view class="card-header">
- <view class="header-left">
- <view class="card-title">考试任务</view>
- <view class="header-subtitle">待完成的学习考试任务</view>
- </view>
- <text class="header-link" @click="goToPage('1')">更多 ›</text>
- </view>
- <view class="card-body">
- <view class="for-max-box" @click="goToPage('2',item)"
- v-for="(item,index) in onlineExamList" :key="index">
- <view class="left-box">
- <view>{{item.examName}}</view>
- <view>待完成</view>
- </view>
- <view class="right-box">›</view>
- </view>
- <view v-if="!onlineExamList[0]" class="empty-tip">暂无考试任务</view>
- </view>
- </view>
- <!-- 考试承诺书弹窗 -->
- <uni-popup ref="preExamDialog" type="center" :mask-click="false">
- <view class="pre-exam-dialog">
- <view class="dialog-header">
- <text class="dialog-title">考试承诺书</text>
- </view>
- <view class="dialog-body">
- <scroll-view scroll-y class="content-scroll">
- <richTextPdf ref="richTextPdf" :content="richTextHtml" />
- </scroll-view>
- </view>
- <view class="dialog-footer">
- <view v-if="preButtonType" class="btn btn-border" @click="downloadCommitment">下载</view>
- <view class="btn btn-primary" @click="confirmCommitment">确认</view>
- </view>
- </view>
- </uni-popup>
- </view>
- </template>
- <script>
- import {
- examUserExamStudyTaskList,
- } from '@/pages_safetyEducationExamination/api/index.js'
- import {
- goToExamPage,
- confirmCommitmentAndStart,
- startFormalExam,
- } from '@/pages_safetyEducationExamination/utils/index.js'
- import richTextPdf from '@/pages_safetyEducationExamination/component/richTextPdf.vue'
- export default {
- components: {
- richTextPdf
- },
- data() {
- return {
- onlineExamList: [],
- // 承诺书相关
- preButtonType: false,
- richTextHtml: '',
- preData: null,
- itemData:{},
- }
- },
- mounted() {
- this.loadTaskList();
- },
- methods: {
- goToPage(type, item) {
- if (type == 1) {
- uni.navigateTo({ url: '/pages_safetyEducationExamination/views/exam/index' });
- return;
- }else{
- this.$set(this,'itemData',item);
- goToExamPage(item, {
- openCommitmentDialog: (examItem) => {
- this.preButtonType = examItem.commitmentPrintEnabled == 1;
- this.richTextHtml = examItem.commitmentContent;
- this.preData = examItem;
- this.$refs.preExamDialog.open();
- },
- });
- }
-
- },
- // 下载承诺书
- downloadCommitment() {
- uni.showToast({ title: '正在下载,请耐心等候', icon: 'none' });
- this.$refs.richTextPdf.downloadPDF();
- },
- // 确认承诺书
- async confirmCommitment() {
- await confirmCommitmentAndStart(this.preData, () => {
- this.$refs.preExamDialog.close();
- startFormalExam(this.itemData);
- });
- },
- // 获取任务列表
- async loadTaskList() {
- try {
- const { data } = await examUserExamStudyTaskList({ page: 1, pageSize: 1, examStatus: 2, isSpecialExam: false });
- if (data.code === 200) {
- this.$set(this, 'onlineExamList', data.data.records);
- }
- } catch (e) { console.error('获取考试任务失败', e); }
- },
- },
- }
- </script>
- <style lang="stylus" scoped>
- .examTask-component {
- margin: 0 32rpx 32rpx;
- .card {
- background: #fff;
- border-radius: 24rpx;
- overflow: hidden;
- margin-bottom: 24rpx;
- box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.03);
- border: 1px solid #dde3ed;
- }
- .card-header {
- padding: 20rpx 28rpx;
- display: flex;
- justify-content: space-between;
- align-items: center;
- .card-title {
- font-size: 28rpx;
- color: #333;
- }
- .header-subtitle{
- margin-top:10rpx;
- font-size:22rpx;
- color:#8896a7;
- }
- .header-link {
- padding:10rpx 20rpx;
- font-size: 24rpx;
- color: #1857d4;
- }
- }
- .card-body {
- padding: 0 28rpx 24rpx;
- .for-max-box:nth-child(1){
- margin-top:0;
- }
- .for-max-box{
- margin-top:20rpx;
- display: flex;
- background-color:#f4f6fa;
- padding: 20rpx 24rpx;
- border-radius: 16rpx;
- .left-box{
- flex:1;
- view:nth-child(1){
- font-size:26rpx;
- margin-bottom:4rpx;
- }
- view:nth-child(2){
- font-size:22rpx;
- color:#8896a7;
- }
- }
- .right-box{
- line-height:60rpx;
- font-size:40rpx;
- color:#8896a7;
- }
- }
- .empty-tip{
- text-align: center;
- line-height:40rpx;
- color:#8896a7;
- font-size:24rpx;
- }
- }
- }
- // 承诺书弹窗样式
- .pre-exam-dialog {
- width: 600rpx;
- max-height: 80vh;
- background: #fff;
- border-radius: 20rpx;
- overflow: hidden;
- }
- .dialog-header {
- padding: 32rpx;
- border-bottom: 1rpx solid #eee;
- .dialog-title {
- font-size: 32rpx;
- font-weight: 600;
- color: #333;
- }
- }
- .dialog-body {
- height: 800rpx;
- overflow: hidden;
- .content-scroll {
- height: 100%;
- }
- }
- .dialog-footer {
- display: flex;
- gap: 20rpx;
- padding: 24rpx 32rpx;
- border-top: 1rpx solid #eee;
- .btn {
- flex: 1;
- height: 72rpx;
- line-height: 72rpx;
- text-align: center;
- font-size: 28rpx;
- border-radius: 12rpx;
- }
- .btn-border {
- background: #fff;
- color: #1857d4;
- border: 1rpx solid #1857d4;
- }
- .btn-primary {
- background: #1857d4;
- color: #fff;
- }
- }
- </style>
|