You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
514 lines
16 KiB
514 lines
16 KiB
/* |
|
* @Descripttion: |
|
* @version: |
|
* @Author: sueRimn |
|
* @Date: 2020-12-11 09:06:03 |
|
* @LastEditors: sueRimn |
|
* @LastEditTime: 2021-02-24 15:37:32 |
|
*/ |
|
import { Component, OnInit, ViewChild, Inject,Input } from '@angular/core'; |
|
import {HttpClient} from '@angular/common/http' |
|
import { MatDialogRef, MatDialog, MAT_DIALOG_DATA } from '@angular/material/dialog'; |
|
import { MatPaginator } from '@angular/material/paginator'; |
|
import { MatTableDataSource } from '@angular/material/table'; |
|
import { PageEvent } from '@angular/material/paginator'; |
|
import { MatSnackBar, MatSnackBarConfig } from '@angular/material/snack-bar'; |
|
import {FormControl} from '@angular/forms'; |
|
import { Router,ActivatedRoute } from '@angular/router'; |
|
import { MatTreeFlatDataSource, MatTreeFlattener } from '@angular/material/tree'; |
|
import { FlatTreeControl } from '@angular/cdk/tree'; |
|
import { TreeService } from '../../http-interceptors/tree.service' |
|
|
|
|
|
@Component({ |
|
selector: 'app-examiner-index', |
|
templateUrl: './examiner-index.component.html', |
|
styleUrls: ['./examiner-index.component.scss'] |
|
}) |
|
export class ExaminerIndexComponent implements OnInit { |
|
|
|
constructor(private router: Router,private activatedRoute: ActivatedRoute,public http: HttpClient,public dialog: MatDialog,public snackBar: MatSnackBar,private tree: TreeService) { } |
|
//displayedColumns: string[] = ['name', 'organization', 'startTime', 'overTime', 'testState', 'operation']; |
|
|
|
ngOnInit(): void { |
|
this.getunitdata(); |
|
this.getOrganizations(); |
|
this.getUnittype(); |
|
this.getAlltabledate(); |
|
this.getProfiles() |
|
} |
|
//获取登录账号的个人资料 |
|
Profiles:any |
|
getProfiles(){ |
|
this.http.get('/api/ExamAccounts/Profiles').subscribe((data:any) => { |
|
console.log(data) |
|
this.Profiles = data |
|
sessionStorage.setItem('creatorData',JSON.stringify(data)) |
|
}) |
|
} |
|
displayedColumns: string[] = ['name','startTime','endTime', 'examzhong','scc']; |
|
tabledataSource:any |
|
accound |
|
helpName//消防救援对名称 |
|
optionId |
|
@ViewChild('son') son; |
|
//分页 |
|
@ViewChild(MatPaginator, {static: true}) |
|
pageEvent: PageEvent; |
|
paginator: MatPaginator; |
|
length:any; //共多少条数据 |
|
pageSize:any; //每页条数 |
|
pageSizeOptions: number[] = [10] //设置每页条数 |
|
PageNumber:any //第几页 |
|
startTime:[] |
|
endTime:[] |
|
allorganizations:any |
|
allunittype:any //获取所有的单位类型 |
|
jscheck:any //辖区中队包含下级 |
|
private _transformer = (node, level: number) => { //初始化tree |
|
return { |
|
expandable: !!node.children && node.children.length > 0, |
|
name: node.name, |
|
level: level, |
|
id: node.id, |
|
parentId: node.parentId, |
|
children: node.children |
|
}; |
|
} |
|
treeControl = new FlatTreeControl<any>(node => node.level, node => node.expandable); |
|
treeFlattener = new MatTreeFlattener(this._transformer, node => node.level, node => node.expandable, node => node.children); |
|
dataSource = new MatTreeFlatDataSource(this.treeControl, this.treeFlattener); |
|
hasChild = (_: number, node: any) => node.expandable; |
|
|
|
//得到当前单位信息 |
|
getunitdata(){ |
|
this.http.get("/api/ExamAccounts/Profiles").subscribe( |
|
(data:any)=>{ |
|
this.organizationName = data.organizationName |
|
} |
|
) |
|
} |
|
organizationName:any //当前单位组织机构名称 |
|
treedata:any //组织机构树型数据 |
|
newArr:any = [] |
|
newallorganizations:any //用于存储在原始数据基础上的每个机构增加children字段 |
|
newallorganizations2:any |
|
//得到当前单位所在组织机构的tree型数据 |
|
getpresentOrganization(){ |
|
this.newallorganizations = this.allorganizations |
|
this.newallorganizations.forEach(item => { |
|
item.children = [] |
|
this.newallorganizations.forEach(element => { |
|
if(element.parentId == item.id){ |
|
item.children.push(element) |
|
} |
|
}); |
|
}); |
|
this.http.get("/api/ExamAccounts/Profiles").subscribe( |
|
(data:any)=>{ |
|
this.organizationName = data.organizationName |
|
if(this.organizationName){ |
|
this.newallorganizations.forEach(item => { |
|
if(item.name == this.organizationName){ |
|
this.dataSource.data = [item] |
|
this.newallorganizations2 = [item] |
|
} |
|
}); |
|
}else{ |
|
this.newallorganizations2 = this.treedata |
|
this.dataSource.data = this.treedata |
|
} |
|
} |
|
) |
|
|
|
} |
|
|
|
|
|
//编辑试卷 |
|
editPaper(item){ |
|
console.log(item) |
|
if(item.status == 2){ |
|
const config = new MatSnackBarConfig(); |
|
config.verticalPosition = 'top'; |
|
config.duration = 3000 |
|
this.snackBar.open('考试结束,不能编辑','确定',config); |
|
}else if(item.status == 1){ |
|
const config = new MatSnackBarConfig(); |
|
config.verticalPosition = 'top'; |
|
config.duration = 3000 |
|
this.snackBar.open('开考中,不能编辑','确定',config); |
|
} |
|
else{ |
|
const dialogRef = this.dialog.open(editorsDia, { |
|
width: '650px', |
|
data: item |
|
}); |
|
/* sessionStorage.setItem("paperId",item.id) |
|
this.router.navigateByUrl("/examiner/create-test-score?pattern=edit") */ |
|
} |
|
} |
|
lookPaper(item){ |
|
sessionStorage.setItem("paperId",item.id) |
|
this.router.navigateByUrl("/examiner/create-test-score?pattern=look") |
|
} |
|
//获得所有组织机构 |
|
getOrganizations(){ |
|
this.http.get('/api/Organizations').subscribe( |
|
(data:any)=>{ |
|
this.allorganizations = data |
|
this.treedata = this.tree.toTree(data); |
|
this.getpresentOrganization(); |
|
} |
|
) |
|
} |
|
|
|
//获得所有单位类型 |
|
getUnittype(){ |
|
this.http.get('/api/BuildingTypes/Simple').subscribe( |
|
data=>{ |
|
this.allunittype = data |
|
} |
|
) |
|
} |
|
|
|
//获得查询支队信息 |
|
help(){ |
|
let paramsdata:any = { |
|
PageNumber: this.PageNumber || '1', |
|
PageSize: this.pageSizeOptions[0], |
|
Sort: null, |
|
SortType: null, |
|
} |
|
//console.log(paramsdata) |
|
this.http.get("/api/Papers",{params:paramsdata}).subscribe((data:any)=>{ |
|
this.tabledataSource=data |
|
console.log(this.tabledataSource) |
|
}) |
|
} |
|
//分页事件 |
|
chagePage(e){ |
|
this.PageNumber = e.pageIndex+1 |
|
this.getAlltabledate() |
|
} |
|
//获取表格信息 |
|
getAlltabledate(){ |
|
let paramsdata:any = { |
|
PageNumber: this.PageNumber || '1', |
|
PageSize: this.pageSizeOptions[0], |
|
OrganizationId: this.jsId || '', |
|
HasChildren:this.jscheck || '', |
|
Sort: null, |
|
SortType: null, |
|
} |
|
this.http.get("/api/Papers",{params:paramsdata}).subscribe((data:any)=>{ |
|
this.tabledataSource=data.items |
|
this.length=data.totalCount |
|
//console.log(this.tabledataSource) |
|
}) |
|
} |
|
//获取消防救援对信息 |
|
getHelp(){ |
|
let paramsdata:any={ |
|
Name:'', |
|
IdentityCard:'', |
|
Phone:'', |
|
RealName:'', |
|
OrganizationId:'', |
|
PageNumber:'', |
|
PageSize:'', |
|
Sort:'', |
|
RoleType:'1', |
|
SortType:'' |
|
} |
|
this.http.get("/api/ExamUsers",{params:paramsdata}).subscribe((data:any)=>{ |
|
this.helpName=data.items |
|
}) |
|
} |
|
|
|
//获取optionid |
|
getoption(){ |
|
var selectIndex =document.getElementById("cars"); |
|
//console.log(selectIndex) |
|
//var activeName_value =document.getElementById("usertype").options[selectIndex].id; |
|
} |
|
//查询按钮 |
|
findClick(){ |
|
const config = new MatSnackBarConfig(); |
|
config.verticalPosition = 'top'; |
|
config.duration = 3000 |
|
let paramsdata:any = { |
|
PageNumber: this.PageNumber || '1', |
|
PageSize: this.pageSizeOptions[0], |
|
OrganizationId: this.jsId || '', |
|
HasChildren:this.jscheck || '', |
|
Sort: null, |
|
SortType: null, |
|
} |
|
if(this.jsId==undefined){ |
|
this.snackBar.open('请输入消防救援队名称','确定',config); |
|
} |
|
else{ |
|
this.http.get(`/api/Papers`,{params:paramsdata}).subscribe((data:any)=>{ |
|
console.log(data) |
|
}) |
|
} |
|
//console.log(this.accound) |
|
console.log(this.jscheck,this.jsId) |
|
this.PageNumber = 1 |
|
this.pageEvent.pageIndex = 0 |
|
this.getAlltabledate() |
|
} |
|
//重置按钮 |
|
Reset(){ |
|
//this.accound=undefined |
|
this.jsId='' |
|
this.js='' |
|
this.jscheck='' |
|
this.getAlltabledate() |
|
} |
|
//删除一套考题 |
|
deleteExam(examid){ |
|
let isTrue = confirm('您确定要删除吗') |
|
if(isTrue){ |
|
const config = new MatSnackBarConfig(); |
|
config.verticalPosition = 'top'; |
|
config.duration = 3000 |
|
this.http.delete(`/api/Papers/${examid}`).subscribe((data:any)=>{ |
|
this.snackBar.open('删除试卷成功','确定',config); |
|
this.getAlltabledate() |
|
}) |
|
} |
|
|
|
|
|
} |
|
//新增考题跳转 |
|
newExamination(){ |
|
//this.router.navigate(['/home/createexam-index/examiner-new-one']) |
|
const dialogRef = this.dialog.open(FinishDia, { |
|
width: '650px', |
|
//data: paperDataInfo |
|
}); |
|
} |
|
//辖区中队div是否显示 |
|
isorganizationbox:boolean = false |
|
js:any //辖区中队输入框 |
|
jsId:any //辖区中队选择的id |
|
stopclose(e){ |
|
e.stopPropagation(); |
|
} |
|
//点击辖区中队树,将选择的辖区中队添加到变量 |
|
add(node) { |
|
this.isorganizationbox = false |
|
this.js = node.name |
|
this.jsId = node.id |
|
} |
|
//关闭辖区中队隐藏框 |
|
closeorganizationbox() { |
|
this.isorganizationbox = false |
|
} |
|
//打开辖区中队隐藏框 |
|
openorganizationbox() { |
|
this.isorganizationbox = true |
|
|
|
} |
|
|
|
//关闭出现的组织机构div |
|
closediv(){ |
|
this.isorganizationbox = false |
|
} |
|
|
|
} |
|
|
|
//创建试题弹窗 |
|
@Component({ |
|
selector: 'finish-dialog', |
|
templateUrl: 'finishDia.html', |
|
styleUrls: ['finishDia.scss'] |
|
}) |
|
export class FinishDia{ |
|
|
|
constructor(private router:Router,private http: HttpClient,public dialog: MatDialog,public snackBar: MatSnackBar,public dialogRef: MatDialogRef<FinishDia>,@Inject(MAT_DIALOG_DATA) public data: any) {} |
|
ngOnInit(): void { |
|
this.getProfiles() |
|
} |
|
//获取登录账号的个人资料 |
|
Profiles:any |
|
getProfiles(){ |
|
this.http.get('/api/ExamAccounts/Profiles').subscribe((data:any) => { |
|
console.log(data) |
|
this.Profiles = data |
|
sessionStorage.setItem('creatorData',JSON.stringify(data)) |
|
}) |
|
} |
|
|
|
|
|
startTime:string//考试开始时间 |
|
endTime:string//考试结束时间 |
|
examName:string//考试名称 |
|
indexid:string//创建考试的id |
|
tabledate |
|
|
|
//弹窗确定点击事件 |
|
onNoClick(): void { |
|
const config = new MatSnackBarConfig(); |
|
config.verticalPosition = 'top'; |
|
config.duration = 3000 |
|
if(this.startTime!=undefined&&this.endTime!=undefined&&this.examName!=undefined){ |
|
if(this.startTime>this.endTime){ |
|
this.snackBar.open('开始时间不能大于结束时间','确定',config); |
|
} |
|
else{ |
|
//截取字符串,得到日期部分"2009-12-02",用split把字符串分隔成数组 |
|
var begin1=this.startTime.substr(0,10).split("-"); |
|
var end1=this.endTime.substr(0,10).split("-"); |
|
//将拆分的数组重新组合,并实例成化新的日期对象 |
|
var date1=new Date(begin1[1] + - + begin1[2] + - + begin1[0]); |
|
var date2=new Date(end1[1] + - + end1[2] + - + end1[0]); |
|
//得到两个日期之间的差值m,以分钟为单位 |
|
var m=Number(Math.abs(Number(date2)-Number(date1))/1000/60); |
|
//小时数和分钟数相加得到总的分钟数 |
|
var min1=parseInt(this.startTime.substr(11,2))*60+parseInt(this.startTime.substr(14,2)); |
|
var min2=parseInt(this.endTime.substr(11,2))*60+parseInt(this.endTime.substr(14,2)); |
|
//两个分钟数相减得到时间部分的差值,以分钟为单位 |
|
var n=min2-min1; |
|
//将日期和时间两个部分计算出来的差值相加,即得到两个时间相减后的分钟数 |
|
var minutes=m+n; |
|
let params = { |
|
id: null, |
|
title: this.examName, |
|
duration: minutes, |
|
modifiedTime: new Date(), |
|
deleted: false, |
|
startTime: this.startTime, |
|
endTime: this.endTime, |
|
organizationId: this.Profiles.organizationId, |
|
creatorId: this.Profiles.id, |
|
paperDataInfo: null |
|
} |
|
|
|
this.http.post('/api/Papers',params).subscribe(data => { |
|
this.snackBar.open('创建成功','确定',config); |
|
this.dialogRef.close(); |
|
//sessionStorage.removeItem("checkedWork") |
|
this.tabledate=data |
|
console.log(this.tabledate) |
|
sessionStorage.setItem("paperId",this.tabledate.id) |
|
this.router.navigate(['/home/createexam-index/examiner-new-one']) //跳转试卷列表页面 |
|
},err => { |
|
this.snackBar.open(err,'确定',config); |
|
}) |
|
} |
|
} |
|
else{ |
|
if(this.startTime==undefined) |
|
this.snackBar.open('请输入开始时间','确定',config); |
|
else if(this.endTime==undefined) |
|
this.snackBar.open('请输入结束时间','确定',config); |
|
else if(this.examName==undefined) |
|
this.snackBar.open('请输入试卷名称','确定',config); |
|
} |
|
|
|
} |
|
|
|
|
|
close(){ |
|
this.dialogRef.close(); |
|
} |
|
} |
|
|
|
//编辑试题弹窗 |
|
@Component({ |
|
selector: 'finish-dialog', |
|
templateUrl: 'editors.html', |
|
styleUrls: ['finishDia.scss'] |
|
}) |
|
export class editorsDia{ |
|
constructor(private router:Router,private http: HttpClient,public dialog: MatDialog,public snackBar: MatSnackBar,public dialogRef: MatDialogRef<editorsDia>,@Inject(MAT_DIALOG_DATA) public datas: any) {} |
|
ngOnInit(): void { |
|
/* this.startTime=this.datas.startTime |
|
this.endTime=this.datas.endTime */ |
|
this.startTime=this.datas.startTime.split("+")[0] |
|
this.endTime=this.datas.endTime.split("+")[0] |
|
this.examName=this.datas.title |
|
console.log(this.datas) |
|
} |
|
//获取登录账号的个人资料 |
|
Profiles:any |
|
getProfiles(){ |
|
this.http.get('/api/ExamAccounts/Profiles').subscribe((data:any) => { |
|
console.log(data) |
|
this.Profiles = data |
|
sessionStorage.setItem('creatorData',JSON.stringify(data)) |
|
}) |
|
} |
|
|
|
|
|
startTime:string//考试开始时间 |
|
endTime:string//考试结束时间 |
|
examName:string//考试名称 |
|
indexid:string//创建考试的id |
|
tabledate |
|
|
|
//弹窗确定点击事件 |
|
onNoClick(): void { |
|
//console.log( this.startTime,this.endTime) |
|
if(this.startTime>this.endTime){ |
|
const config = new MatSnackBarConfig(); |
|
config.verticalPosition = 'top'; |
|
config.duration = 3000 |
|
this.snackBar.open('开始时间不能早于结束时间','确定',config); |
|
}else{ |
|
let body = { |
|
id:this.datas.id, |
|
startTime:this.startTime, |
|
endTime:this.endTime, |
|
title:this.examName |
|
} |
|
let params = { |
|
id: null, |
|
title: this.examName, |
|
duration: this.datas.duration, |
|
modifiedTime: new Date(), |
|
deleted: false, |
|
startTime: this.startTime, |
|
endTime: this.endTime, |
|
organizationId: this.datas.organizationId, |
|
creatorId: this.datas.creatorId, |
|
paperDataInfo: null |
|
} |
|
this.http.put(`/api/Papers/${this.datas.id}`,body).subscribe(data => { |
|
const config = new MatSnackBarConfig(); |
|
config.verticalPosition = 'top'; |
|
config.duration = 3000 |
|
this.snackBar.open('修改名称时间成功','确定',config); |
|
setTimeout(() => { |
|
this.http.get(`/api/Papers/${this.datas.id}`).subscribe((data:any) => { |
|
if (data.paperDataInfo == null || data.paperDataInfo.length == 0) { |
|
this.http.delete(`/api/Papers/${this.datas.id}`).subscribe((data:any) => { |
|
}) |
|
this.http.post('/api/Papers',params).subscribe(data => { |
|
//sessionStorage.removeItem("checkedWork") |
|
sessionStorage.setItem("paperId",this.datas.id) |
|
this.router.navigate(['/home/createexam-index/examiner-new-one']) //跳转试卷列表页面 |
|
},err => { |
|
this.snackBar.open(err,'确定',config); |
|
}) |
|
}else{ |
|
sessionStorage.setItem("paperId",this.datas.id) |
|
this.router.navigateByUrl("/examiner/create-test-score?pattern=edit") |
|
} |
|
}) |
|
|
|
this.dialogRef.close(); |
|
}, 1000); |
|
}) |
|
} |
|
|
|
|
|
} |
|
|
|
|
|
close(){ |
|
this.dialogRef.close(); |
|
} |
|
}
|
|
|