|
@@ -45,9 +45,12 @@
|
|
|
<script>
|
|
<script>
|
|
|
import {
|
|
import {
|
|
|
examUserExamStudyTaskList,
|
|
examUserExamStudyTaskList,
|
|
|
- examUserExamStart,
|
|
|
|
|
- examUserExamCommitmentConfirm,
|
|
|
|
|
} from '@/pages_safetyEducationExamination/api/index.js'
|
|
} from '@/pages_safetyEducationExamination/api/index.js'
|
|
|
|
|
+ import {
|
|
|
|
|
+ goToExamPage,
|
|
|
|
|
+ confirmCommitmentAndStart,
|
|
|
|
|
+ startFormalExam,
|
|
|
|
|
+ } from '@/pages_safetyEducationExamination/utils/index.js'
|
|
|
import richTextPdf from '@/pages_safetyEducationExamination/component/richTextPdf.vue'
|
|
import richTextPdf from '@/pages_safetyEducationExamination/component/richTextPdf.vue'
|
|
|
|
|
|
|
|
export default {
|
|
export default {
|
|
@@ -58,197 +61,51 @@
|
|
|
return {
|
|
return {
|
|
|
onlineExamList: [],
|
|
onlineExamList: [],
|
|
|
// 承诺书相关
|
|
// 承诺书相关
|
|
|
- preExamDialogType: false,
|
|
|
|
|
preButtonType: false,
|
|
preButtonType: false,
|
|
|
richTextHtml: '',
|
|
richTextHtml: '',
|
|
|
preData: null,
|
|
preData: null,
|
|
|
|
|
+ itemData:{},
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
- created() {
|
|
|
|
|
-
|
|
|
|
|
- },
|
|
|
|
|
mounted() {
|
|
mounted() {
|
|
|
- this.examUserExamStudyTaskList();
|
|
|
|
|
|
|
+ this.loadTaskList();
|
|
|
},
|
|
},
|
|
|
methods: {
|
|
methods: {
|
|
|
- goToPage(type,item){
|
|
|
|
|
- if(type == 1){
|
|
|
|
|
- //考试列表
|
|
|
|
|
- uni.navigateTo({
|
|
|
|
|
- url: '/pages_safetyEducationExamination/views/exam/index',
|
|
|
|
|
- });
|
|
|
|
|
- }else if(type == 2){
|
|
|
|
|
- //开始考试相关业务
|
|
|
|
|
- if(item.conditionType == 1){
|
|
|
|
|
- if(item.examStudy&&item.courseId){
|
|
|
|
|
- //学习课程
|
|
|
|
|
- let obj = {
|
|
|
|
|
- courseId: item.courseId,
|
|
|
|
|
- examId: item.examId,
|
|
|
|
|
- }
|
|
|
|
|
- //等待后续逻辑
|
|
|
|
|
- }else{
|
|
|
|
|
- //学时要求
|
|
|
|
|
- if(item.knowledgePointIds){
|
|
|
|
|
- //学时知识点
|
|
|
|
|
- uni.navigateTo({
|
|
|
|
|
- url: `/pages_safetyEducationExamination/views/studyHourTask/index?knowledgePointId=${item.knowledgePointIds}`,
|
|
|
|
|
- });
|
|
|
|
|
- }else{
|
|
|
|
|
- //无知识点要求
|
|
|
|
|
- uni.navigateTo({
|
|
|
|
|
- url: '/pages_safetyEducationExamination/views/study/index',
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }else if(item.conditionType == 2){
|
|
|
|
|
- //学习课程
|
|
|
|
|
- let obj = {
|
|
|
|
|
- courseId: item.courseId,
|
|
|
|
|
- examId: item.examId,
|
|
|
|
|
- }
|
|
|
|
|
- //等待后续逻辑
|
|
|
|
|
- }else if(item.conditionType == 3){
|
|
|
|
|
- //模拟考试
|
|
|
|
|
- if(item.mockExamId){
|
|
|
|
|
- let obj = {
|
|
|
|
|
- examId: item.examId,
|
|
|
|
|
- attemptId: item.mockExamId,
|
|
|
|
|
- }
|
|
|
|
|
- //等待后续逻辑
|
|
|
|
|
- }else{
|
|
|
|
|
- this.examUserExamStart({examId:item.examId,examScene:2});
|
|
|
|
|
- }
|
|
|
|
|
- }else if(item.conditionType == 4){
|
|
|
|
|
- //开始考试
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- },
|
|
|
|
|
- //模拟考试获取试卷
|
|
|
|
|
- async examUserExamStart(obj) {
|
|
|
|
|
- try {
|
|
|
|
|
- const { data } = await examUserExamStart(obj);
|
|
|
|
|
- if (data.code === 200) {
|
|
|
|
|
- let obj = {
|
|
|
|
|
- examId: item.examId,
|
|
|
|
|
- attemptId: response.data.attemptId,
|
|
|
|
|
- }
|
|
|
|
|
- //等待后续逻辑
|
|
|
|
|
- }
|
|
|
|
|
- } catch (e) { console.error('模拟考试获取试卷失败', e); }
|
|
|
|
|
- },
|
|
|
|
|
- //开始考试判断是否有承诺书
|
|
|
|
|
- setRichExamData(item){
|
|
|
|
|
- if(item.commitmentEnabled == 1 && !item.commitmentConfirmed){
|
|
|
|
|
- //富文本弹窗考试承诺书
|
|
|
|
|
- this.preButtonType = item.commitmentPrintEnabled == 1;
|
|
|
|
|
- this.richTextHtml = item.commitmentContent;
|
|
|
|
|
- this.preData = item;
|
|
|
|
|
- this.$refs.preExamDialog.open();
|
|
|
|
|
|
|
+ goToPage(type, item) {
|
|
|
|
|
+ if (type == 1) {
|
|
|
|
|
+ uni.navigateTo({ url: '/pages_safetyEducationExamination/views/exam/index' });
|
|
|
|
|
+ return;
|
|
|
}else{
|
|
}else{
|
|
|
- if(item.attemptId){
|
|
|
|
|
- //上次考试未完成继续考试
|
|
|
|
|
- let obj = {
|
|
|
|
|
- attemptId: item.attemptId,
|
|
|
|
|
- type: '1',
|
|
|
|
|
- examKind:item.examKind,
|
|
|
|
|
- }
|
|
|
|
|
- //等待后续逻辑
|
|
|
|
|
- }else{
|
|
|
|
|
- //开始新考试
|
|
|
|
|
- this.startNewExam(item);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ 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() {
|
|
downloadCommitment() {
|
|
|
- uni.showToast({
|
|
|
|
|
- title: '正在下载,请耐心等候',
|
|
|
|
|
- icon: 'none'
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ uni.showToast({ title: '正在下载,请耐心等候', icon: 'none' });
|
|
|
this.$refs.richTextPdf.downloadPDF();
|
|
this.$refs.richTextPdf.downloadPDF();
|
|
|
},
|
|
},
|
|
|
// 确认承诺书
|
|
// 确认承诺书
|
|
|
async confirmCommitment() {
|
|
async confirmCommitment() {
|
|
|
- if (this.preData.attemptId) {
|
|
|
|
|
- await this.confirmAndStart(this.preData.attemptId);
|
|
|
|
|
- } else {
|
|
|
|
|
- try {
|
|
|
|
|
- const { data } = await examUserExamStart({
|
|
|
|
|
- examId: this.preData.examId,
|
|
|
|
|
- examScene: 1
|
|
|
|
|
- });
|
|
|
|
|
- if (data.code === 200 && data.data.attemptId) {
|
|
|
|
|
- await this.confirmAndStart(data.data.attemptId);
|
|
|
|
|
- } else {
|
|
|
|
|
- uni.showToast({
|
|
|
|
|
- title: data.message || '开始考试失败',
|
|
|
|
|
- icon: 'none'
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
- } catch (e) {
|
|
|
|
|
- console.error('开始考试失败', e);
|
|
|
|
|
- uni.showToast({
|
|
|
|
|
- title: '开始考试失败',
|
|
|
|
|
- icon: 'none'
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- },
|
|
|
|
|
- // 确认承诺并开始考试
|
|
|
|
|
- async confirmAndStart(attemptId) {
|
|
|
|
|
- try {
|
|
|
|
|
- const { data } = await examUserExamCommitmentConfirm({ attemptId });
|
|
|
|
|
- if (data.code === 200) {
|
|
|
|
|
- this.$refs.preExamDialog.close();
|
|
|
|
|
- // 跳转到考试页面
|
|
|
|
|
- let obj = {
|
|
|
|
|
- examId: this.preData.examId,
|
|
|
|
|
- attemptId: attemptId,
|
|
|
|
|
- type: '1',
|
|
|
|
|
- examKind: this.preData.examKind,
|
|
|
|
|
- };
|
|
|
|
|
- // 等待后续逻辑:跳转到答题页面
|
|
|
|
|
- uni.showToast({
|
|
|
|
|
- title: '已确认承诺书',
|
|
|
|
|
- icon: 'success'
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
- } catch (e) {
|
|
|
|
|
- console.error('确认承诺书失败', e);
|
|
|
|
|
- uni.showToast({
|
|
|
|
|
- title: '确认失败',
|
|
|
|
|
- icon: 'none'
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
- },
|
|
|
|
|
- //开始考试
|
|
|
|
|
- async examUserExamStart(item) {
|
|
|
|
|
- try {
|
|
|
|
|
- let obj = {examId:item.examId,examScene:1};
|
|
|
|
|
- const { data } = await examUserExamStart(obj);
|
|
|
|
|
- if (data.code === 200) {
|
|
|
|
|
- let obj = {
|
|
|
|
|
- examId: item.examId,
|
|
|
|
|
- attemptId: data.data.attemptId,
|
|
|
|
|
- type: '1',
|
|
|
|
|
- examKind:item.examKind,
|
|
|
|
|
- }
|
|
|
|
|
- //等待后续逻辑
|
|
|
|
|
- }
|
|
|
|
|
- } catch (e) { console.error('开始考试失败', e); }
|
|
|
|
|
- },
|
|
|
|
|
- // 开始新考试
|
|
|
|
|
- async startNewExam(item) {
|
|
|
|
|
- await this.examUserExamStart(item);
|
|
|
|
|
|
|
+ await confirmCommitmentAndStart(this.preData, () => {
|
|
|
|
|
+ this.$refs.preExamDialog.close();
|
|
|
|
|
+ startFormalExam(this.itemData);
|
|
|
|
|
+ });
|
|
|
},
|
|
},
|
|
|
- //获取任务列表
|
|
|
|
|
- async examUserExamStudyTaskList() {
|
|
|
|
|
|
|
+ // 获取任务列表
|
|
|
|
|
+ async loadTaskList() {
|
|
|
try {
|
|
try {
|
|
|
- let obj = { page: 1, pageSize: 1, examStatus: 2, isSpecialExam: false };
|
|
|
|
|
- const { data } = await examUserExamStudyTaskList(obj);
|
|
|
|
|
|
|
+ const { data } = await examUserExamStudyTaskList({ page: 1, pageSize: 1, examStatus: 2, isSpecialExam: false });
|
|
|
if (data.code === 200) {
|
|
if (data.code === 200) {
|
|
|
- this.$set(this,'onlineExamList',data.data.records);
|
|
|
|
|
|
|
+ this.$set(this, 'onlineExamList', data.data.records);
|
|
|
}
|
|
}
|
|
|
} catch (e) { console.error('获取考试任务失败', e); }
|
|
} catch (e) { console.error('获取考试任务失败', e); }
|
|
|
},
|
|
},
|