|
|
|
@ -6,15 +6,15 @@
|
|
|
|
|
* @LastEditors: sueRimn |
|
|
|
|
* @LastEditTime: 2020-12-24 10:49:54 |
|
|
|
|
*/ |
|
|
|
|
import { Component, OnInit, ViewChild, Inject,Input } from '@angular/core'; |
|
|
|
|
import {HttpClient} from '@angular/common/http' |
|
|
|
|
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 { 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' |
|
|
|
@ -26,16 +26,16 @@ import { TreeService } from '../../http-interceptors/tree.service'
|
|
|
|
|
}) |
|
|
|
|
export class StudentIndexComponent implements OnInit { |
|
|
|
|
|
|
|
|
|
constructor(private router: Router,private activatedRoute: ActivatedRoute,public http: HttpClient,public dialog: MatDialog,public snackBar: MatSnackBar,private tree: TreeService) { } |
|
|
|
|
constructor(private router: Router, private activatedRoute: ActivatedRoute, public http: HttpClient, public dialog: MatDialog, public snackBar: MatSnackBar, private tree: TreeService) { } |
|
|
|
|
|
|
|
|
|
ngOnInit(): void { |
|
|
|
|
this.getAlltabledate() |
|
|
|
|
this.tableInterval=setInterval(()=>this.getAlltabledate(),60000) |
|
|
|
|
this.tableInterval = setInterval(() => this.getAlltabledate(), 60000) |
|
|
|
|
//this.gettime("2020-12-22T18:40:00+08:00","2020-12-22T18:39:00+08:00")
|
|
|
|
|
//this.idtime=setInterval(()=>this.newjsq(),1000)
|
|
|
|
|
//this.newjsq()
|
|
|
|
|
} |
|
|
|
|
ngOnDestroy (){ |
|
|
|
|
ngOnDestroy() { |
|
|
|
|
clearInterval(this.idtime) |
|
|
|
|
clearInterval(this.tableInterval) |
|
|
|
|
} |
|
|
|
@ -44,59 +44,59 @@ export class StudentIndexComponent implements OnInit {
|
|
|
|
|
tableInterval |
|
|
|
|
|
|
|
|
|
//分页
|
|
|
|
|
@ViewChild(MatPaginator, {static: true})
|
|
|
|
|
@ViewChild(MatPaginator, { static: true }) |
|
|
|
|
pageEvent: PageEvent; |
|
|
|
|
paginator: MatPaginator; |
|
|
|
|
length:any; //共多少条数据
|
|
|
|
|
pageSize:any; //每页条数
|
|
|
|
|
length: any; //共多少条数据
|
|
|
|
|
pageSize: any; //每页条数
|
|
|
|
|
pageSizeOptions: number[] = [10] //设置每页条数
|
|
|
|
|
PageNumber:any //第几页
|
|
|
|
|
startTime:[] |
|
|
|
|
endTime:[] |
|
|
|
|
PageNumber: any //第几页
|
|
|
|
|
startTime: [] |
|
|
|
|
endTime: [] |
|
|
|
|
tabledataSource//表格数据
|
|
|
|
|
timecha |
|
|
|
|
|
|
|
|
|
//分页事件
|
|
|
|
|
chagePage(e){ |
|
|
|
|
this.PageNumber = e.pageIndex+1 |
|
|
|
|
chagePage(e) { |
|
|
|
|
this.PageNumber = e.pageIndex + 1 |
|
|
|
|
this.getAlltabledate() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//获取表格信息
|
|
|
|
|
getAlltabledate(){ |
|
|
|
|
let paramsdata:any = { |
|
|
|
|
getAlltabledate() { |
|
|
|
|
let paramsdata: any = { |
|
|
|
|
PageNumber: this.PageNumber || '1', |
|
|
|
|
PageSize: this.pageSizeOptions[0], |
|
|
|
|
PageSize: this.pageSizeOptions[0], |
|
|
|
|
Sort: null, |
|
|
|
|
SortType: null, |
|
|
|
|
Status:1 |
|
|
|
|
Status: 1 |
|
|
|
|
} |
|
|
|
|
this.http.get("/api/Papers",{params:paramsdata}).subscribe((data:any)=>{ |
|
|
|
|
this.tabledataSource=data.items |
|
|
|
|
this.length=data.totalCount |
|
|
|
|
this.http.get("/api/Papers", { params: paramsdata }).subscribe((data: any) => { |
|
|
|
|
this.tabledataSource = data.items |
|
|
|
|
this.length = data.totalCount |
|
|
|
|
//console.log(this.tabledataSource)
|
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
//计时器
|
|
|
|
|
jishi(startTime,endTime){ |
|
|
|
|
jishi(startTime, endTime) { |
|
|
|
|
//startTime=new Date
|
|
|
|
|
var nowtime = new Date(startTime), //获取开始时间
|
|
|
|
|
endtime = new Date(endTime); //定义结束时间
|
|
|
|
|
var jieshu=nowtime.getTime() |
|
|
|
|
setInterval(()=>{jieshu--}) |
|
|
|
|
//console.log(endtime.getSeconds()-1)
|
|
|
|
|
var lefttime = jieshu - nowtime.getTime(), //距离结束时间的毫秒数
|
|
|
|
|
leftd = Math.floor(lefttime/(1000*60*60*24)), //计算天数
|
|
|
|
|
lefth = Math.floor(lefttime/(1000*60*60)), //计算小时数
|
|
|
|
|
leftm = Math.floor(lefttime/(1000*60)%60), //计算分钟数
|
|
|
|
|
lefts = Math.floor(lefttime/1000%60); //计算秒数
|
|
|
|
|
this.timecha=lefth+":"+leftm+":"+lefts |
|
|
|
|
|
|
|
|
|
if(this.timecha=='0:0:0'){ |
|
|
|
|
this.timecha="已结束" |
|
|
|
|
clearInterval(this.idtime) |
|
|
|
|
} |
|
|
|
|
console.log(this.timecha) |
|
|
|
|
endtime = new Date(endTime); //定义结束时间
|
|
|
|
|
var jieshu = nowtime.getTime() |
|
|
|
|
setInterval(() => { jieshu-- }) |
|
|
|
|
//console.log(endtime.getSeconds()-1)
|
|
|
|
|
var lefttime = jieshu - nowtime.getTime(), //距离结束时间的毫秒数
|
|
|
|
|
leftd = Math.floor(lefttime / (1000 * 60 * 60 * 24)), //计算天数
|
|
|
|
|
lefth = Math.floor(lefttime / (1000 * 60 * 60)), //计算小时数
|
|
|
|
|
leftm = Math.floor(lefttime / (1000 * 60) % 60), //计算分钟数
|
|
|
|
|
lefts = Math.floor(lefttime / 1000 % 60); //计算秒数
|
|
|
|
|
this.timecha = lefth + ":" + leftm + ":" + lefts |
|
|
|
|
|
|
|
|
|
if (this.timecha == '0:0:0') { |
|
|
|
|
this.timecha = "已结束" |
|
|
|
|
clearInterval(this.idtime) |
|
|
|
|
} |
|
|
|
|
console.log(this.timecha) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -106,56 +106,61 @@ export class StudentIndexComponent implements OnInit {
|
|
|
|
|
time_end |
|
|
|
|
//time_now_server=new Date("2020-12-22T18:30:00+08:00").getTime();//开始的时间
|
|
|
|
|
time_now_server |
|
|
|
|
time_now_client=new Date().getTime(); |
|
|
|
|
time_now_client = new Date().getTime(); |
|
|
|
|
//time_server_client=this.time_now_server-this.time_now_client;
|
|
|
|
|
time_server_client |
|
|
|
|
str_time="" |
|
|
|
|
str_time = "" |
|
|
|
|
|
|
|
|
|
gettime(endtime,stearttime){ |
|
|
|
|
this.time_end=new Date(endtime).getTime() |
|
|
|
|
this.time_now_server=new Date(stearttime).getTime() |
|
|
|
|
this.time_server_client=this.time_now_server-this.time_now_client |
|
|
|
|
this.idtime=setInterval(()=>this.newtimer(),1000) |
|
|
|
|
gettime(endtime, stearttime) { |
|
|
|
|
this.time_end = new Date(endtime).getTime() |
|
|
|
|
this.time_now_server = new Date(stearttime).getTime() |
|
|
|
|
this.time_server_client = this.time_now_server - this.time_now_client |
|
|
|
|
this.idtime = setInterval(() => this.newtimer(), 1000) |
|
|
|
|
} |
|
|
|
|
//新计时器
|
|
|
|
|
newtimer(){ |
|
|
|
|
newtimer() { |
|
|
|
|
var time_distance; |
|
|
|
|
var int_day,int_hour,int_minute,int_second; |
|
|
|
|
var time_now=new Date().getTime(); |
|
|
|
|
time_now=time_now+this.time_server_client; |
|
|
|
|
time_distance=this.time_end-time_now; |
|
|
|
|
if(time_distance>0){ |
|
|
|
|
int_day=Math.floor(time_distance/86400000) |
|
|
|
|
time_distance-=int_day*86400000; |
|
|
|
|
int_hour=Math.floor(time_distance/3600000) |
|
|
|
|
time_distance-=int_hour*3600000; |
|
|
|
|
int_minute=Math.floor(time_distance/60000) |
|
|
|
|
time_distance-=int_minute*60000; |
|
|
|
|
int_second=Math.floor(time_distance/1000) |
|
|
|
|
if(int_hour<10) |
|
|
|
|
int_hour="0"+int_hour; |
|
|
|
|
if(int_minute<10) |
|
|
|
|
int_minute="0"+int_minute; |
|
|
|
|
if(int_second<10) |
|
|
|
|
int_second="0"+int_second; |
|
|
|
|
this.str_time=int_hour+":"+int_minute+":"+int_second; |
|
|
|
|
if(this.str_time=="00:00:00") |
|
|
|
|
{this.str_time="已结束"} |
|
|
|
|
var int_day, int_hour, int_minute, int_second; |
|
|
|
|
var time_now = new Date().getTime(); |
|
|
|
|
time_now = time_now + this.time_server_client; |
|
|
|
|
time_distance = this.time_end - time_now; |
|
|
|
|
if (time_distance > 0) { |
|
|
|
|
int_day = Math.floor(time_distance / 86400000) |
|
|
|
|
time_distance -= int_day * 86400000; |
|
|
|
|
int_hour = Math.floor(time_distance / 3600000) |
|
|
|
|
time_distance -= int_hour * 3600000; |
|
|
|
|
int_minute = Math.floor(time_distance / 60000) |
|
|
|
|
time_distance -= int_minute * 60000; |
|
|
|
|
int_second = Math.floor(time_distance / 1000) |
|
|
|
|
if (int_hour < 10) |
|
|
|
|
int_hour = "0" + int_hour; |
|
|
|
|
if (int_minute < 10) |
|
|
|
|
int_minute = "0" + int_minute; |
|
|
|
|
if (int_second < 10) |
|
|
|
|
int_second = "0" + int_second; |
|
|
|
|
this.str_time = int_hour + ":" + int_minute + ":" + int_second; |
|
|
|
|
if (this.str_time == "00:00:00") { this.str_time = "已结束" } |
|
|
|
|
//console.log(this.str_time)
|
|
|
|
|
}else{ |
|
|
|
|
} else { |
|
|
|
|
//timer=timer;
|
|
|
|
|
clearTimeout(this.timerID) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//参加考试
|
|
|
|
|
takeTest (e) { |
|
|
|
|
takeTest(e) { |
|
|
|
|
console.log(e) |
|
|
|
|
let body = { |
|
|
|
|
name: e.title, |
|
|
|
|
paperId: e.id, |
|
|
|
|
} |
|
|
|
|
this.http.post('/api/Examinations',body).subscribe((data:any)=>{ |
|
|
|
|
this.http.post('/api/Examinations', body).subscribe((data: any) => { |
|
|
|
|
window.open(`/examinationDetails?paperId=${e.id}&examId=${data.id}`) |
|
|
|
|
}, err => { |
|
|
|
|
const config = new MatSnackBarConfig(); |
|
|
|
|
config.verticalPosition = 'top'; |
|
|
|
|
config.duration = 3000 |
|
|
|
|
this.snackBar.open(err, '确定', config); |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|