|
|
|
@ -2,7 +2,7 @@ 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', |
|
|
|
@ -12,7 +12,7 @@ import {FormControl} from '@angular/forms';
|
|
|
|
|
export class AddEnterpriserUser { |
|
|
|
|
|
|
|
|
|
toppings = new FormControl(); |
|
|
|
|
constructor(private http: HttpClient,public dialogRef: MatDialogRef<AddEnterpriserUser>) {} |
|
|
|
|
constructor(private http: HttpClient,public dialogRef: MatDialogRef<AddEnterpriserUser>,public snackBar: MatSnackBar) {} |
|
|
|
|
errmsg:any; //捕获错误信息
|
|
|
|
|
detachmentPosts: any = []//支队职务列表
|
|
|
|
|
brigadePosts: any = []//大队职务列表
|
|
|
|
@ -24,7 +24,6 @@ export class AddEnterpriserUser {
|
|
|
|
|
//获得所有职务
|
|
|
|
|
getAllPosts(){ |
|
|
|
|
this.http.get("/api/Posts").subscribe( (data:any) =>{ |
|
|
|
|
console.log(123,data) |
|
|
|
|
data.forEach(item => { |
|
|
|
|
if(item.name.indexOf("支队级") != -1){ |
|
|
|
|
this.detachmentPosts.push(item) |
|
|
|
@ -46,7 +45,6 @@ export class AddEnterpriserUser {
|
|
|
|
|
postsArr.forEach((item) => { |
|
|
|
|
postsObj.push({id:item, name:""}) |
|
|
|
|
}) |
|
|
|
|
// console.log(666,postsObj)
|
|
|
|
|
let body = { |
|
|
|
|
name : e.idNumber, |
|
|
|
|
realName : e.realName, |
|
|
|
@ -55,9 +53,13 @@ export class AddEnterpriserUser {
|
|
|
|
|
creationTime : date, |
|
|
|
|
posts : postsObj |
|
|
|
|
} |
|
|
|
|
// console.log(date)
|
|
|
|
|
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); |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|