pad端六熟悉
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.
 
 
 
 

77 lines
2.2 KiB

import { Component, OnInit, Inject } from '@angular/core';
import {MatTreeFlatDataSource, MatTreeFlattener} from '@angular/material/tree';
import {FlatTreeControl} from '@angular/cdk/tree';
import { HttpClient } from '@angular/common/http';
import {MatDialog, MatDialogRef, MAT_DIALOG_DATA} from '@angular/material/dialog';
import {FormControl} from '@angular/forms';
import { MatSnackBar } from '@angular/material/snack-bar';
@Component({
selector: 'addhouseinfo',
templateUrl: './addhouseinfo.component.html',
styleUrls: ['./basicinfo.component.scss']
})
export class AddHouseInfo {
myControl = new FormControl();
//注入MatDialogRef,可以用来关闭对话框
//要访问对话框组件中的数据,必须使用MAT_DIALOG_DATA注入令牌
constructor(private http: HttpClient,public dialogRef: MatDialogRef<AddHouseInfo>,@Inject(MAT_DIALOG_DATA) public data) {}
allunittype:any
onNoClick(): void {
this.dialogRef.close();
}
ngOnInit(): void {
// console.log(this.data)
this.getallunittype()
}
getallunittype(){
this.http.get("/api/BuildingTypes/Simple").subscribe(data=>{
this.allunittype = data
})
}
onSubmit(value){
this.http.get("/api/Buildings",{
params:{
companyId:this.data.unitId
}
}).subscribe((data:any)=>{
this.data.allBuildings = data
let order
if(data.length == 0){
order = 0
}else{
order = data[data.length - 1].order + 1
}
let buildingTypename = ""
this.allunittype.forEach(item => {
if(item.id == value.unittype){
buildingTypename = item.name
}
});
this.http.post("/api/Buildings",{
id: "",
name: value.name,
order: order,
enabled: true,
companyId: this.data.unitinfo.id,
buildingTypes: [
{
id: value.unittype,
name: buildingTypename
}
]
},{params:{
companyId : this.data.unitId
}}).subscribe(data=>{
this.dialogRef.close(data);
})
})
}
}