考核考试系统
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.

67 lines
1.9 KiB

import { Component, OnInit, Inject } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import {MatDialogRef} from '@angular/material/dialog';
import {FormControl} from '@angular/forms';
import { MatSnackBar, MatSnackBarConfig } from '@angular/material/snack-bar';
@Component({
selector: 'addenterpriseuser',
templateUrl: './addenterpriseuser.component.html',
styleUrls: ['./enterpriseuser.component.scss']
})
export class AddTeacher {
toppings = new FormControl();
constructor(private http: HttpClient,public dialogRef: MatDialogRef<AddTeacher>,public snackBar: MatSnackBar) {}
errmsg:any; //捕获错误信息
detachmentPosts: any = []//支队职务列表
brigadePosts: any = []//大队职务列表
RescueStationPosts: any = []//救援站职务列表
ngOnInit(): void {
this.getAllPosts()
}
//获得所有职务
getAllPosts(){
this.http.get("/api/Posts").subscribe( (data:any) =>{
data.forEach(item => {
if(item.name.indexOf("支队级") != -1){
this.detachmentPosts.push(item)
}else if(item.name.indexOf("大队级") != -1){
this.brigadePosts.push(item)
}else{
this.RescueStationPosts.push(item)
}
});
})
}
//提交创建表单
onSubmit (e) {
let date = new Date()
let postsArr = this.toppings.value
let postsObj = []
postsArr.forEach((item) => {
postsObj.push({id:item, name:""})
})
let body = {
name : e.idNumber,
realName : e.realName,
roleType : 1,
enabled : true,
creationTime : date,
posts : postsObj
}
this.http.post("/api/Users",body).subscribe( data => {
this.dialogRef.close(data);
},err=>{
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open(err,'确定',config);
})
}
}