Browse Source

[新增]新增保存创建的试卷

master
邵佳豪 4 years ago
parent
commit
1b2316a316
  1. 31
      src/app/examiner/create-test-score/create-test-score.component.ts
  2. 2
      src/app/examiner/create-test-score/finishDialog.html

31
src/app/examiner/create-test-score/create-test-score.component.ts

@ -9,6 +9,7 @@ import { DisabledTimeFn, DisabledTimePartial } from 'ng-zorro-antd/date-picker';
import getISOWeek from 'date-fns/getISOWeek';
import setHours from 'date-fns/setHours';
import { NzFormatEmitEvent, NzTreeComponent } from 'ng-zorro-antd/tree';
import { Router } from '@angular/router';
@Component({
selector: 'app-create-test-score',
templateUrl: './create-test-score.component.html',
@ -16,7 +17,7 @@ import { NzFormatEmitEvent, NzTreeComponent } from 'ng-zorro-antd/tree';
})
export class CreateTestScoreComponent implements OnInit {
constructor(public dialog: MatDialog,private http: HttpClient,public snackBar: MatSnackBar) { }
constructor(private router:Router,public dialog: MatDialog,private http: HttpClient,public snackBar: MatSnackBar) { }
selectedTab:number = 1 //选中的选项卡
selectTab(index){
this.selectedTab = index
@ -1009,8 +1010,8 @@ export class CreateTestScoreComponent implements OnInit {
let paperDataInfo = []
copyDatas.forEach((item,key) =>{
paperDataInfo[key] = {}
paperDataInfo[key].id = ''
paperDataInfo[key].paperId = ''
paperDataInfo[key].id = null
paperDataInfo[key].paperId = null
paperDataInfo[key].companyId = item.id
paperDataInfo[key].basicInfoData = JSON.stringify(item.basicInfoNodes)
paperDataInfo[key].basicInfoScore = item.basicInfoScore
@ -1034,6 +1035,7 @@ export class CreateTestScoreComponent implements OnInit {
dialogRef.afterClosed().subscribe(result => {
console.log('The dialog was closed');
this.router.navigate(['/home/createexam-index']) //跳转试卷列表页面
});
}
//上一步
@ -1152,14 +1154,14 @@ export class FinishDialog{
startTime:string//考试开始时间
endTime:string//考试结束时间
examType:string//考试类型
examName:string//考试名称
//弹窗确定点击事件
onNoClick(): void {
//this.dialogRef.close();
console.log(this.examType)
const config = new MatSnackBarConfig();
if(this.startTime!=undefined&&this.endTime!=undefined&&this.examType!=undefined){
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);
}
@ -1179,11 +1181,11 @@ export class FinishDialog{
var n=min2-min1;
//将日期和时间两个部分计算出来的差值相加,即得到两个时间相减后的分钟数
var minutes=m+n;
// this.dialogRef.close();
console.log(this.startTime,this.endTime)
let params = {
id: '',
title: '宇宙试卷',
id: null,
title: this.examName,
duration: minutes,
modifiedTime: new Date(),
deleted: false,
@ -1194,7 +1196,10 @@ export class FinishDialog{
paperDataInfo: this.data
}
this.http.post('/api/Papers',params).subscribe(data => {
console.log("创建成功了")
this.snackBar.open('创建成功','确定',config);
this.dialogRef.close();
},err => {
this.snackBar.open(err,'确定',config);
})
}
}
@ -1203,8 +1208,8 @@ export class FinishDialog{
this.snackBar.open('请输入开始时间','确定',config);
else if(this.endTime==undefined)
this.snackBar.open('请输入结束时间','确定',config);
else if(this.examType==undefined)
this.snackBar.open('请输入试卷类型','确定',config);
else if(this.examName==undefined)
this.snackBar.open('请输入试卷名称','确定',config);
}
}

2
src/app/examiner/create-test-score/finishDialog.html

@ -9,7 +9,7 @@
<div class="box">
<div class="diaone">
<div><label>请填写试卷类型:</label></div>
<div><input placeholder="请填写" [(ngModel)]="examType"></div>
<div><input placeholder="请填写" [(ngModel)]="examName"></div>
</div>
<div class="diatwo">
<div class="starttime">

Loading…
Cancel
Save