|
|
|
@ -2,7 +2,7 @@ import { Component, OnInit, Inject } from '@angular/core';
|
|
|
|
|
import { HttpClient, HttpHeaders } from '@angular/common/http'; |
|
|
|
|
import { MatDialog, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; |
|
|
|
|
import { MatSnackBar, MatSnackBarConfig } from '@angular/material/snack-bar'; |
|
|
|
|
import { Router,ActivatedRoute } from '@angular/router' |
|
|
|
|
import { Router, ActivatedRoute } from '@angular/router' |
|
|
|
|
|
|
|
|
|
@Component({ |
|
|
|
|
selector: 'app-function-partition', |
|
|
|
@ -11,7 +11,7 @@ import { Router,ActivatedRoute } from '@angular/router'
|
|
|
|
|
}) |
|
|
|
|
export class FunctionPartitionComponent implements OnInit { |
|
|
|
|
|
|
|
|
|
constructor(private router:Router,private route:ActivatedRoute,private http:HttpClient,public dialog: MatDialog,public snackBar: MatSnackBar) { } |
|
|
|
|
constructor(private router: Router, private route: ActivatedRoute, private http: HttpClient, public dialog: MatDialog, public snackBar: MatSnackBar) { } |
|
|
|
|
|
|
|
|
|
ngOnInit(): void { |
|
|
|
|
this.companyId = this.unitId |
|
|
|
@ -20,49 +20,54 @@ export class FunctionPartitionComponent implements OnInit {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
displayedColumns: string[] = ['checked', 'region', 'measure', 'situation']; |
|
|
|
|
unitId:any = sessionStorage.getItem('companyId') |
|
|
|
|
unitId: any = sessionStorage.getItem('companyId') |
|
|
|
|
|
|
|
|
|
companyId:any; //单位编号
|
|
|
|
|
companyFunctionalZoning:any=[]; //所有单位功能分区属性
|
|
|
|
|
selectFunctionalZoning:any=[]; //选中的单位功能分区属性
|
|
|
|
|
companyId: any; //单位编号
|
|
|
|
|
companyFunctionalZoning: any = []; //所有单位功能分区属性
|
|
|
|
|
selectFunctionalZoning: any = []; //选中的单位功能分区属性
|
|
|
|
|
|
|
|
|
|
//获得所有单位功能分区属性
|
|
|
|
|
getAllCompany () { |
|
|
|
|
getAllCompany() { |
|
|
|
|
let companyId = this.unitId |
|
|
|
|
this.http.get('/api/CompanyFunctionalDivisions',{params:{ |
|
|
|
|
companyId:companyId |
|
|
|
|
}}).subscribe((data:any)=>{ |
|
|
|
|
this.http.get('/api/CompanyFunctionalDivisions', { |
|
|
|
|
params: { |
|
|
|
|
companyId: companyId |
|
|
|
|
} |
|
|
|
|
}).subscribe((data: any) => { |
|
|
|
|
this.companyFunctionalZoning = data |
|
|
|
|
console.log(this.companyFunctionalZoning) |
|
|
|
|
this.selectFunctionalZoning = [] |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//新建单位功能分区属性
|
|
|
|
|
addCompany () { |
|
|
|
|
addCompany() { |
|
|
|
|
let companyId = this.route.snapshot.queryParams.id |
|
|
|
|
let data = {companyId:companyId, region:'', area:0, details:''} |
|
|
|
|
let data = { companyId: companyId, region: '', area: 0, details: '' } |
|
|
|
|
this.companyFunctionalZoning.push(data) |
|
|
|
|
this.preservation() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//保存单位功能分区属性
|
|
|
|
|
preservation () { |
|
|
|
|
preservation() { |
|
|
|
|
let companyId = this.unitId |
|
|
|
|
if (this.companyFunctionalZoning.length) { |
|
|
|
|
this.http.post('/api/CompanyFunctionalDivisions/Batch',this.companyFunctionalZoning,{params:{ |
|
|
|
|
companyId:companyId |
|
|
|
|
}}).subscribe(data=>{ |
|
|
|
|
this.http.post('/api/CompanyFunctionalDivisions/Batch', this.companyFunctionalZoning, { |
|
|
|
|
params: { |
|
|
|
|
companyId: companyId |
|
|
|
|
} |
|
|
|
|
}).subscribe(data => { |
|
|
|
|
this.getAllCompany() |
|
|
|
|
const config = new MatSnackBarConfig(); |
|
|
|
|
config.verticalPosition = 'top'; |
|
|
|
|
config.duration = 3000 |
|
|
|
|
this.snackBar.open('数据更新成功','确定',config); |
|
|
|
|
this.snackBar.open('数据更新成功', '确定', config); |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//单位功能分区checked选择
|
|
|
|
|
changeCompany (ele,e) { |
|
|
|
|
changeCompany(ele, e) { |
|
|
|
|
if (e.checked) { |
|
|
|
|
this.selectFunctionalZoning.push(ele.id) |
|
|
|
|
} else { |
|
|
|
@ -71,23 +76,26 @@ export class FunctionPartitionComponent implements OnInit {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//删除单位功能分区属性
|
|
|
|
|
delete () { |
|
|
|
|
delete() { |
|
|
|
|
let companyId = this.unitId |
|
|
|
|
if (this.selectFunctionalZoning.length) { |
|
|
|
|
let isDelete = confirm('您确定要删除吗') |
|
|
|
|
if (isDelete) { |
|
|
|
|
this.http.post('/api/CompanyFunctionalDivisions/Batch',this.companyFunctionalZoning,{params:{ |
|
|
|
|
companyId:companyId |
|
|
|
|
}}).subscribe(data=>{ |
|
|
|
|
this.http.post('/api/CompanyFunctionalDivisions/Batch', this.companyFunctionalZoning, { |
|
|
|
|
params: { |
|
|
|
|
companyId: companyId |
|
|
|
|
} |
|
|
|
|
}).subscribe(data => { |
|
|
|
|
const options = { |
|
|
|
|
headers: new HttpHeaders({'Content-Type': 'application/json',}), |
|
|
|
|
body:this.selectFunctionalZoning} |
|
|
|
|
this.http.delete(`/api/CompanyFunctionalDivisions/Batch`,options).subscribe(data=>{ |
|
|
|
|
headers: new HttpHeaders({ 'Content-Type': 'application/json', }), |
|
|
|
|
body: this.selectFunctionalZoning |
|
|
|
|
} |
|
|
|
|
this.http.delete(`/api/CompanyFunctionalDivisions/Batch`, options).subscribe(data => { |
|
|
|
|
this.getAllCompany() |
|
|
|
|
const config = new MatSnackBarConfig(); |
|
|
|
|
config.verticalPosition = 'top'; |
|
|
|
|
config.duration = 3000 |
|
|
|
|
this.snackBar.open('数据更新成功','确定',config); |
|
|
|
|
this.snackBar.open('数据更新成功', '确定', config); |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
@ -95,7 +103,7 @@ export class FunctionPartitionComponent implements OnInit {
|
|
|
|
|
const config = new MatSnackBarConfig(); |
|
|
|
|
config.verticalPosition = 'top'; |
|
|
|
|
config.duration = 3000 |
|
|
|
|
this.snackBar.open('请选择单位功能分区','确定',config); |
|
|
|
|
this.snackBar.open('请选择单位功能分区', '确定', config); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -104,16 +112,18 @@ export class FunctionPartitionComponent implements OnInit {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//建筑功能分区↓
|
|
|
|
|
allBuilding:any = []; //所有建筑
|
|
|
|
|
allBuildingFunctionalZoning:any = []; //所有建筑的功能分区
|
|
|
|
|
selectBuildingFunctionalZoning:any = []; //选中的建筑的功能分区
|
|
|
|
|
allBuilding: any = []; //所有建筑
|
|
|
|
|
allBuildingFunctionalZoning: any = []; //所有建筑的功能分区
|
|
|
|
|
selectBuildingFunctionalZoning: any = []; //选中的建筑的功能分区
|
|
|
|
|
|
|
|
|
|
//获得所有建筑
|
|
|
|
|
getAllBuilding () { |
|
|
|
|
getAllBuilding() { |
|
|
|
|
let companyId = this.unitId |
|
|
|
|
this.http.get(`/api/Buildings`,{params:{ |
|
|
|
|
companyId:companyId |
|
|
|
|
}}).subscribe((data:any)=>{ |
|
|
|
|
this.http.get(`/api/Buildings`, { |
|
|
|
|
params: { |
|
|
|
|
companyId: companyId |
|
|
|
|
} |
|
|
|
|
}).subscribe((data: any) => { |
|
|
|
|
if (data.length) { |
|
|
|
|
this.allBuilding = data |
|
|
|
|
this.allBuilding.forEach(element => { //为每个建筑添加一个 功能分区对象
|
|
|
|
@ -125,55 +135,57 @@ export class FunctionPartitionComponent implements OnInit {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//获得所有建筑的功能分区
|
|
|
|
|
getAllBuildingFunctionalZoning () { |
|
|
|
|
getAllBuildingFunctionalZoning() { |
|
|
|
|
this.selectBuildingFunctionalZoning = [] |
|
|
|
|
this.allBuildingFunctionalZoning = [] |
|
|
|
|
this.allBuilding.forEach(element => { |
|
|
|
|
let data={buildingId: element.id} |
|
|
|
|
this.http.get(`/api/BuildingFunctionalDivisions`,{params:data}).subscribe((data:any)=>{ |
|
|
|
|
let data = { buildingId: element.id } |
|
|
|
|
this.http.get(`/api/BuildingFunctionalDivisions`, { params: data }).subscribe((data: any) => { |
|
|
|
|
if (data.length) { |
|
|
|
|
element.functionalZoning = data |
|
|
|
|
this.selectBuildingFunctionalZoning.push([]) //拥有建筑功能分区的提前push空数组
|
|
|
|
|
this.allBuildingFunctionalZoning.push(element) } |
|
|
|
|
this.allBuildingFunctionalZoning.push(element) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
}); |
|
|
|
|
console.log(this.allBuilding) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//封装函数刷新当前建筑功能分区
|
|
|
|
|
updateCurrent (e,index) { |
|
|
|
|
let data= {buildingId: e.id} |
|
|
|
|
this.http.get(`/api/BuildingFunctionalDivisions`,{params:data}).subscribe((data:any)=>{ |
|
|
|
|
updateCurrent(e, index) { |
|
|
|
|
let data = { buildingId: e.id } |
|
|
|
|
this.http.get(`/api/BuildingFunctionalDivisions`, { params: data }).subscribe((data: any) => { |
|
|
|
|
this.selectBuildingFunctionalZoning[index] = [] |
|
|
|
|
this.allBuildingFunctionalZoning[index].functionalZoning = data |
|
|
|
|
const config = new MatSnackBarConfig(); |
|
|
|
|
config.verticalPosition = 'top'; |
|
|
|
|
config.duration = 3000 |
|
|
|
|
this.snackBar.open('数据更新成功','确定',config); |
|
|
|
|
this.snackBar.open('数据更新成功', '确定', config); |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//创建建筑功能分区
|
|
|
|
|
addPartition () { |
|
|
|
|
addPartition() { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//创建建筑功能分区属性
|
|
|
|
|
addBuilding (e,index) { |
|
|
|
|
let data = {buildingId:e.id, region:'', area:0, details:''} |
|
|
|
|
this.http.post('/api/BuildingFunctionalDivisions',data).subscribe(data=>{ |
|
|
|
|
this.preservationBuilding(e,index) |
|
|
|
|
addBuilding(e, index) { |
|
|
|
|
let data = { buildingId: e.id, region: '', area: 0, details: '' } |
|
|
|
|
this.http.post('/api/BuildingFunctionalDivisions', data).subscribe(data => { |
|
|
|
|
this.preservationBuilding(e, index) |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//保存建筑功能分区属性
|
|
|
|
|
preservationBuilding (e,index) { |
|
|
|
|
let data ={buildingId:e.id} |
|
|
|
|
this.http.post(`/api/BuildingFunctionalDivisions/Batch`,this.allBuildingFunctionalZoning[index].functionalZoning,{params:data}).subscribe(data=>{ |
|
|
|
|
this.updateCurrent(e,index) |
|
|
|
|
preservationBuilding(e, index) { |
|
|
|
|
let data = { buildingId: e.id } |
|
|
|
|
this.http.post(`/api/BuildingFunctionalDivisions/Batch`, this.allBuildingFunctionalZoning[index].functionalZoning, { params: data }).subscribe(data => { |
|
|
|
|
this.updateCurrent(e, index) |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//建筑功能分区checked选择
|
|
|
|
|
changeBuilding (ele,e,index) { |
|
|
|
|
changeBuilding(ele, e, index) { |
|
|
|
|
if (e.checked) { |
|
|
|
|
this.selectBuildingFunctionalZoning[index].push(ele.id) |
|
|
|
|
} else { |
|
|
|
@ -182,25 +194,27 @@ export class FunctionPartitionComponent implements OnInit {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//删除建筑功能分区
|
|
|
|
|
deleteBuilding (e,index) { |
|
|
|
|
deleteBuilding(e, index) { |
|
|
|
|
if (this.selectBuildingFunctionalZoning[index].length) { |
|
|
|
|
let isDelete = confirm('您确定要删除吗') |
|
|
|
|
if (isDelete) { |
|
|
|
|
let data ={buildingId:e.id} |
|
|
|
|
this.http.post(`/api/BuildingFunctionalDivisions/Batch`,this.allBuildingFunctionalZoning[index].functionalZoning,{params:data}).subscribe(data=>{ |
|
|
|
|
let data = { buildingId: e.id } |
|
|
|
|
this.http.post(`/api/BuildingFunctionalDivisions/Batch`, this.allBuildingFunctionalZoning[index].functionalZoning, { params: data }).subscribe(data => { |
|
|
|
|
const options = { |
|
|
|
|
headers: new HttpHeaders({'Content-Type': 'application/json',}), |
|
|
|
|
body:this.selectBuildingFunctionalZoning[index], |
|
|
|
|
params:{buildingId:e.id}} |
|
|
|
|
this.http.delete(`/api/BuildingFunctionalDivisions/Batch`,options).subscribe(data=>{ |
|
|
|
|
this.selectBuildingFunctionalZoning[index].forEach((element,newIndex) => { |
|
|
|
|
this.allBuildingFunctionalZoning[index].functionalZoning.splice(this.allBuildingFunctionalZoning[index].functionalZoning.findIndex(item=>item.id==element),1) |
|
|
|
|
if (newIndex==this.selectBuildingFunctionalZoning[index].length-1) { |
|
|
|
|
headers: new HttpHeaders({ 'Content-Type': 'application/json', }), |
|
|
|
|
body: this.selectBuildingFunctionalZoning[index], |
|
|
|
|
params: { buildingId: e.id } |
|
|
|
|
} |
|
|
|
|
this.http.delete(`/api/BuildingFunctionalDivisions/Batch`, options).subscribe(data => { |
|
|
|
|
this.selectBuildingFunctionalZoning[index].forEach((element, newIndex) => { |
|
|
|
|
this.allBuildingFunctionalZoning[index].functionalZoning.splice(this.allBuildingFunctionalZoning[index].functionalZoning.findIndex(item => item.id == element), 1) |
|
|
|
|
if (newIndex == this.selectBuildingFunctionalZoning[index].length - 1) { |
|
|
|
|
if (this.allBuildingFunctionalZoning[index].functionalZoning.length) { |
|
|
|
|
this.updateCurrent(e,index) |
|
|
|
|
this.updateCurrent(e, index) |
|
|
|
|
} else { |
|
|
|
|
this.selectBuildingFunctionalZoning.splice(index,1) |
|
|
|
|
this.allBuildingFunctionalZoning.splice(index,1)} |
|
|
|
|
this.selectBuildingFunctionalZoning.splice(index, 1) |
|
|
|
|
this.allBuildingFunctionalZoning.splice(index, 1) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
@ -212,7 +226,7 @@ export class FunctionPartitionComponent implements OnInit {
|
|
|
|
|
const config = new MatSnackBarConfig(); |
|
|
|
|
config.verticalPosition = 'top'; |
|
|
|
|
config.duration = 3000 |
|
|
|
|
this.snackBar.open('请选择建筑功能分区','确定',config); |
|
|
|
|
this.snackBar.open('请选择建筑功能分区', '确定', config); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|