|
|
|
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 { ActivatedRoute } from '@angular/router';
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'app-examination-details',
|
|
|
|
templateUrl: './examination-details.component.html',
|
|
|
|
styleUrls: ['./examination-details.component.scss']
|
|
|
|
})
|
|
|
|
export class ExaminationDetailsComponent implements OnInit {
|
|
|
|
|
|
|
|
constructor(public http:HttpClient,public dialog: MatDialog,public snackBar: MatSnackBar,public route:ActivatedRoute) { }
|
|
|
|
|
|
|
|
async ngOnInit(): Promise<void> {
|
|
|
|
await this.getTestInfo()
|
|
|
|
this.getUnitPlans()//将试卷的预案考题放进数据中
|
|
|
|
}
|
|
|
|
|
|
|
|
paperData:any //试卷信息
|
|
|
|
paperCompanyData:any = []; //考生具体考卷
|
|
|
|
selectPaper:any = {id:null}; //选择当前考卷
|
|
|
|
selectPaperType:string = '1'; //选择当前考卷内容
|
|
|
|
|
|
|
|
//获取考卷
|
|
|
|
async getTestInfo () {
|
|
|
|
let id = this.route.snapshot.queryParams.paperId
|
|
|
|
await new Promise((resolve, reject) => {
|
|
|
|
this.http.get(`/api/Papers/${id}`).subscribe((data:any)=>{
|
|
|
|
this.paperData = data
|
|
|
|
this.paperData.paperDataInfo.forEach(element => {
|
|
|
|
element.adjoinData? element.adjoinData = JSON.parse(element.adjoinData) : null
|
|
|
|
element.basicInfoData? element.basicInfoData = JSON.parse(element.basicInfoData) : null
|
|
|
|
element.facilityData? element.facilityData = JSON.parse(element.facilityData) : null
|
|
|
|
element.functionalDivisionData? element.functionalDivisionData = JSON.parse(element.functionalDivisionData) : null
|
|
|
|
element.importLocationData? element.importLocationData = JSON.parse(element.importLocationData) : null
|
|
|
|
});
|
|
|
|
this.paperCompanyData = JSON.parse( JSON.stringify(data.paperDataInfo) ) //具体考卷
|
|
|
|
this.selectPaper = this.paperCompanyData[0] || {id:null} //当前选择考卷
|
|
|
|
this.handlePaperData()
|
|
|
|
resolve()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//处理考卷 数据格式
|
|
|
|
handlePaperData () {
|
|
|
|
console.log(this.selectPaper)
|
|
|
|
}
|
|
|
|
|
|
|
|
//切换 选择考卷
|
|
|
|
togglePaper (e) {
|
|
|
|
if (this.selectPaper.id != e.id) {
|
|
|
|
this.selectPaper = e
|
|
|
|
this.handlePaperData()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//切换 选择考卷内容
|
|
|
|
togglePaperType (e) {
|
|
|
|
if (this.selectPaperType != e) {
|
|
|
|
this.selectPaperType = e
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//获得单位预案设定
|
|
|
|
async getUnitPlans(){
|
|
|
|
for (let index = 0; index < this.paperCompanyData.length; index++) {
|
|
|
|
const item = this.paperCompanyData[index];
|
|
|
|
let params = {
|
|
|
|
paperId : item.paperId,
|
|
|
|
companyId : item.companyInfo.id
|
|
|
|
}
|
|
|
|
await new Promise((resolve,reject)=>{
|
|
|
|
this.http.get(`/api/PaperPlans`,{params:params}).subscribe(data => {
|
|
|
|
item.planList = []
|
|
|
|
item.planList = data
|
|
|
|
resolve()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
this.calculateScore()
|
|
|
|
}
|
|
|
|
examScore:any = 0//整个试卷的总分
|
|
|
|
//计算分数
|
|
|
|
calculateScore(){
|
|
|
|
let examScore = 0
|
|
|
|
let examScore2 = 0
|
|
|
|
this.paperCompanyData.forEach(item => {
|
|
|
|
//计算每个单位基本信息部分总分
|
|
|
|
item.score = item.basicInfoScore + item.adjoinScore + item.importLocationScore + item.functionalDivisionScore + item.facilityScore
|
|
|
|
//计算整个试卷基本信息总分
|
|
|
|
examScore += item.score
|
|
|
|
//计算整个试卷预案试题总分
|
|
|
|
let x = 0
|
|
|
|
if(item.planList){
|
|
|
|
item.planList.forEach(i => {
|
|
|
|
x += i.score
|
|
|
|
})
|
|
|
|
}
|
|
|
|
item.planScore = x
|
|
|
|
examScore2 += x
|
|
|
|
})
|
|
|
|
//计算总分
|
|
|
|
this.examScore = examScore + examScore2
|
|
|
|
console.log(678,this.paperCompanyData)
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//交卷
|
|
|
|
uploadPaper () {
|
|
|
|
console.log('交卷')
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|