@ -1,7 +1,7 @@
import { HttpClient } from '@angular/common/http' ;
import { Component , OnInit } from '@angular/core' ;
import { MatDialog } from '@angular/material/dialog' ;
import { MatSnackBar } from '@angular/material/snack-bar' ;
import { MatSnackBar , MatSnackBarConfig } from '@angular/material/snack-bar' ;
import { ActivatedRoute } from '@angular/router' ;
import { CanvasShareDataService } from 'src/app/canvas-share-data.service' ;
@ -24,11 +24,33 @@ export class ExaminationDetailsComponent implements OnInit {
paperCompanyData :any = [ ] ; //考生具体考卷
selectPaper :any = { id :null } ; //选择当前考卷
selectPaperType :string = '1' ; //选择当前考卷内容 基本信息/作战部署
surplusTime :number = 3600 ; //考试剩余时间
//倒计时 处理时间格式
formatDate ( e ) {
let hours = parseInt ( ( e . date / ( 1000 * 60 * 60 ) ) . toString ( ) )
var minutes = parseInt ( ( ( e . date % ( 1000 * 60 * 60 ) ) / ( 1000 * 60 ) ) . toString ( ) ) ;
var seconds = ( e . date % ( 1000 * 60 ) ) / 1000 ;
return ` ${ hours } : ${ minutes } : ${ seconds } `
}
//基本信息表格 是否展示当前行
rowIsShow ( children , tag ) {
let isShow :boolean = false
children . forEach ( element = > {
element . result == tag ? isShow = true : null
} ) ;
return isShow
}
//获取考卷
async getTestInfo ( ) {
await new Promise ( ( resolve , reject ) = > {
this . http . get ( ` /api/Papers/ ${ this . paperId } ` ) . subscribe ( ( data :any ) = > {
let now = ( new Date ( ) ) . getTime ( )
let endTime = ( new Date ( data . endTime ) ) . getTime ( )
let surplusTime = Math . floor ( ( endTime - now ) / 1000 ) ; //考试剩余时间
surplusTime >= 0 ? this . surplusTime = surplusTime : this.surplusTime = 0
this . paperData = data
this . paperData . paperDataInfo . forEach ( element = > {
element . adjoinData ? element . adjoinData = JSON . parse ( element . adjoinData ) : null
@ -39,23 +61,28 @@ export class ExaminationDetailsComponent implements OnInit {
} ) ;
this . paperCompanyData = JSON . parse ( JSON . stringify ( data . paperDataInfo ) ) //具体考卷
this . selectPaper = this . paperCompanyData [ 0 ] || { id :null } //当前选择考卷
this . handlePaperData ( )
resolve ( 1 )
} )
} )
}
//处理考卷 数据格式
handlePaperData ( ) {
console . log ( this . selectPaper )
}
//切换 选择考卷
togglePaper ( e ) {
if ( this . selectPaper . id != e . id ) {
this . selectPaper = e
this . handlePaperData ( )
console . log ( this . selectPaper )
}
}
//考试倒计时
handleEvent ( e ) {
if ( e . left == 600000 ) { //距离考试结束 剩余10分钟
const config = new MatSnackBarConfig ( ) ;
config . verticalPosition = 'top' ;
config . duration = 5000
this . snackBar . open ( '注: 距离考试结束还剩10分钟!' , '确定' , config ) ;
} else if ( e . left == 0 ) { //考试结束
this . uploadPaper ( ) //交卷
}
}
@ -107,18 +134,55 @@ export class ExaminationDetailsComponent implements OnInit {
} )
//计算总分
this . examScore = examScore + examScore2
console . log ( 678 , this . paperCompanyData )
}
//交卷
uploadPaper ( ) {
console . log ( this . paperCompanyData )
// let body = {
// id: this.route.snapshot.queryParams.examId,
// // name: null,
// // serverTime: null,
// // startTime: null,
// // endTime: null,
// // deadline: null,
// // isMarked: null,
// // totalScore: null,
// // examineeId: null,
// // examineeName: null,
// // paperId: null,
// // paperEndTime: null,
// examinationDataInfo: []
// }
// let uploadPaper = JSON.parse( JSON.stringify(this.paperCompanyData) )
// uploadPaper.forEach(element => {
// delete element.score
// delete element.planScore
// delete element.planList
// delete element.id
// delete element.paperId
// element.examinationId = this.route.snapshot.queryParams.examId
// element.adjoinData = JSON.stringify( element.adjoinData || [] )
// element.basicInfoData = JSON.stringify( element.basicInfoData || [] )
// element.facilityData = JSON.stringify( element.facilityData || [] )
// element.functionalDivisionData = JSON.stringify( element.functionalDivisionData || [] )
// element.importLocationData = JSON.stringify( element.importLocationData || [] )
// });
// console.log(body)
// body.examinationDataInfo = uploadPaper
// this.http.put(`/api/Examinations/UpdateExaminationData/${this.route.snapshot.queryParams.examId}`,body).subscribe(data=>{
// console.log(data)
// })
const config = new MatSnackBarConfig ( ) ;
config . verticalPosition = 'top' ;
config . duration = 3000
this . snackBar . open ( '试卷提交成功! 本页面即将关闭' , '确定' , config ) ;
// window.setTimeout(()=>{
// window.close()
// },10000)
}
//进入作战部署 考卷
enterExam ( item ) {
console . log ( item )
console . log ( this . selectPaper )
sessionStorage . setItem ( 'companyName' , this . selectPaper . companyInfo . name )
sessionStorage . setItem ( 'planId' , item . planComponentId )
sessionStorage . setItem ( 'buildingTypeId' , this . selectPaper . companyInfo . buildingTypes [ 0 ] . id )