|
|
|
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 {leftFunctionalDomainComponent,editPlaneFigureComponent} from './leftFunctionalDomain'
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'app-collection-tools',
|
|
|
|
templateUrl: './collection-tools.component.html',
|
|
|
|
styleUrls: ['./collection-tools.component.scss']
|
|
|
|
})
|
|
|
|
export class CollectionToolsComponent implements OnInit {
|
|
|
|
|
|
|
|
constructor(private http:HttpClient,public dialog: MatDialog,public snackBar: MatSnackBar) { }
|
|
|
|
|
|
|
|
selected = 'option1' //图标大小选择框
|
|
|
|
basicInfo:boolean = true //基本信息名称显隐
|
|
|
|
wantToWork:boolean = true //想定作业名称显隐
|
|
|
|
allBuildings //该单位所有建筑
|
|
|
|
beforeOneCheckedBuilding:any = {name:"总平面图"}; //当前点击选择的建筑
|
|
|
|
checkedBuildingIndex:number = -1 //当前点击选择的建筑index
|
|
|
|
isEditPat:boolean = true //当前是否是编辑模式
|
|
|
|
sliderValue:String = "30"//滑竿的值
|
|
|
|
|
|
|
|
ngOnInit(): void {
|
|
|
|
this.getAllLibrary()
|
|
|
|
this.getSitePlan()
|
|
|
|
this.getAllBuildings()
|
|
|
|
}
|
|
|
|
|
|
|
|
//点击基本信息名称
|
|
|
|
basicInfoClick(){
|
|
|
|
this.basicInfo = !this.basicInfo
|
|
|
|
}
|
|
|
|
//点击想定作业名称
|
|
|
|
wantToWorkClick(){
|
|
|
|
this.wantToWork = !this.wantToWork
|
|
|
|
}
|
|
|
|
//进入编辑模式
|
|
|
|
editpat(){
|
|
|
|
this.isEditPat = true
|
|
|
|
let config = new MatSnackBarConfig();
|
|
|
|
config.verticalPosition = 'top';
|
|
|
|
config.duration = 3000
|
|
|
|
this.snackBar.open('进入编辑模式','确定',config);
|
|
|
|
}
|
|
|
|
//进入查看模式
|
|
|
|
lookpat(){
|
|
|
|
this.isEditPat = false
|
|
|
|
let config = new MatSnackBarConfig();
|
|
|
|
config.verticalPosition = 'top';
|
|
|
|
config.duration = 3000
|
|
|
|
this.snackBar.open('进入查看模式','确定',config);
|
|
|
|
}
|
|
|
|
//保存平面图
|
|
|
|
saveSite(){
|
|
|
|
|
|
|
|
}
|
|
|
|
//获得所有的建筑物
|
|
|
|
getAllBuildings(){
|
|
|
|
this.http.get("/api/CompanyAccount/Buildings").subscribe(data=>{
|
|
|
|
this.allBuildings = data
|
|
|
|
})
|
|
|
|
}
|
|
|
|
//创建建筑
|
|
|
|
createBuilding(){
|
|
|
|
let data = this.allBuildings
|
|
|
|
let dialogRef = this.dialog.open(CreateBuilding,{data});
|
|
|
|
dialogRef.afterClosed().subscribe(data=>{
|
|
|
|
if (data == "创建成功") {
|
|
|
|
const config = new MatSnackBarConfig();
|
|
|
|
config.verticalPosition = 'top';
|
|
|
|
config.duration = 3000
|
|
|
|
this.snackBar.open('创建成功','确定',config);
|
|
|
|
this.getAllBuildings()
|
|
|
|
}else if (data == "创建失败") {
|
|
|
|
const config = new MatSnackBarConfig();
|
|
|
|
config.verticalPosition = 'top';
|
|
|
|
config.duration = 3000
|
|
|
|
this.snackBar.open('创建失败','确定',config);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
//选择建筑
|
|
|
|
checkedBuilding(item,index){
|
|
|
|
if (this.checkedBuildingIndex!=index) {
|
|
|
|
this.beforeOneCheckedBuilding = item
|
|
|
|
this.checkedBuildingIndex = index
|
|
|
|
if (index==-1) { //总平面图数据
|
|
|
|
this.getSitePlan()
|
|
|
|
} else { //建筑楼层/区域数据
|
|
|
|
this.getBuildingSitePlan(item)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//编辑建筑
|
|
|
|
editBuilding(e,item){
|
|
|
|
e.stopPropagation();
|
|
|
|
let dialogRef = this.dialog.open(EditBuilding,{data: {item:item}});
|
|
|
|
dialogRef.afterClosed().subscribe(data=>{
|
|
|
|
if (data == "修改成功") {
|
|
|
|
const config = new MatSnackBarConfig();
|
|
|
|
config.verticalPosition = 'top';
|
|
|
|
config.duration = 3000
|
|
|
|
this.snackBar.open('修改成功','确定',config);
|
|
|
|
this.getAllBuildings()
|
|
|
|
}else if (data == "修改失败") {
|
|
|
|
const config = new MatSnackBarConfig();
|
|
|
|
config.verticalPosition = 'top';
|
|
|
|
config.duration = 3000
|
|
|
|
this.snackBar.open('修改失败','确定',config);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
//删除建筑
|
|
|
|
deleteBuilding(e,item){
|
|
|
|
e.stopPropagation();
|
|
|
|
if(confirm("是否删除该建筑") == true){
|
|
|
|
this.http.delete(`/api/CompanyAccount/Buildings/${item.id}`).subscribe(data=>{
|
|
|
|
const config = new MatSnackBarConfig();
|
|
|
|
config.verticalPosition = 'top';
|
|
|
|
config.duration = 3000
|
|
|
|
this.snackBar.open('删除成功','确定',config);
|
|
|
|
this.http.get("/api/CompanyAccount/Buildings").subscribe(data=>{
|
|
|
|
this.allBuildings = data
|
|
|
|
this.beforeOneCheckedBuilding = {name:"总平面图"}
|
|
|
|
this.checkedBuildingIndex = -1
|
|
|
|
this.getSitePlan()
|
|
|
|
})
|
|
|
|
},err=>{
|
|
|
|
const config = new MatSnackBarConfig();
|
|
|
|
config.verticalPosition = 'top';
|
|
|
|
config.duration = 3000
|
|
|
|
this.snackBar.open('删除失败','确定',config);
|
|
|
|
this.getAllBuildings()
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//陈鹏飞↓↓↓
|
|
|
|
//陈鹏飞↓↓↓
|
|
|
|
//陈鹏飞↓↓↓
|
|
|
|
|
|
|
|
toggleExpandPanel:boolean = false; //可展开面板展开或关闭
|
|
|
|
togglePlane:boolean = true; //可展开面板平面图 显隐
|
|
|
|
toggleMaterialBank:boolean = false; //可展开面板素材库 显隐
|
|
|
|
//可展开面板展开或关闭
|
|
|
|
toggle () {
|
|
|
|
this.toggleExpandPanel = !this.toggleExpandPanel
|
|
|
|
}
|
|
|
|
//可展开面板 平面图 展开或关闭
|
|
|
|
togglePlanarGraph () {
|
|
|
|
this.togglePlane = !this.togglePlane
|
|
|
|
}
|
|
|
|
//可展开面板 素材库 展开或关闭
|
|
|
|
toggleMaterial () {
|
|
|
|
this.toggleMaterialBank = !this.toggleMaterialBank
|
|
|
|
}
|
|
|
|
|
|
|
|
sitePlanData:any = []; //总平面图 楼层/区域 数据
|
|
|
|
selectingSitePlan:any; //选中的 平面图 楼层/区域
|
|
|
|
selectSitePlanIndex:number; //选中的 平面图 楼层/区域 index
|
|
|
|
|
|
|
|
//获取总平面图
|
|
|
|
getSitePlan () {
|
|
|
|
this.http.get('/api/CompanyAccount/SitePlans').subscribe(data=>{
|
|
|
|
this.sitePlanData = data
|
|
|
|
this.selectingSitePlan = this.sitePlanData[0] || ''
|
|
|
|
this.selectSitePlanIndex = 0
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
//获取建筑 楼层/区域
|
|
|
|
getBuildingSitePlan (item) {
|
|
|
|
let params = {
|
|
|
|
buildingId: item.id
|
|
|
|
}
|
|
|
|
this.http.get('/api/CompanyAccount/BuildingAreas',{params}).subscribe(data=>{
|
|
|
|
this.sitePlanData = data
|
|
|
|
this.selectingSitePlan = this.sitePlanData[0] || ''
|
|
|
|
this.selectSitePlanIndex = 0
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
//新增平面图 楼层/区域
|
|
|
|
foundPanel (e) {
|
|
|
|
e.stopPropagation()
|
|
|
|
let data = {
|
|
|
|
isBuilding: this.checkedBuildingIndex==-1? false:true,
|
|
|
|
Panel: this.beforeOneCheckedBuilding,
|
|
|
|
order: this.sitePlanData.length? this.sitePlanData[this.sitePlanData.length-1].order+1:0,
|
|
|
|
}
|
|
|
|
let dialogRef = this.dialog.open(leftFunctionalDomainComponent,{data});
|
|
|
|
dialogRef.afterClosed().subscribe(data=>{
|
|
|
|
if (data =='总平面图') {
|
|
|
|
this.renovateLeftMenu(-1,this.beforeOneCheckedBuilding)
|
|
|
|
} else if (data =='建筑') {
|
|
|
|
this.renovateLeftMenu(0,this.beforeOneCheckedBuilding)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
//编辑平面图 楼层/区域
|
|
|
|
editPlaneData (e) {
|
|
|
|
console.log(e)
|
|
|
|
let dialogRef = this.dialog.open(editPlaneFigureComponent);
|
|
|
|
}
|
|
|
|
|
|
|
|
//封装 统一刷新 左侧菜单栏数据
|
|
|
|
renovateLeftMenu (index,item) {
|
|
|
|
if (index==-1) { //总平面图数据
|
|
|
|
this.getSitePlan()
|
|
|
|
} else { //建筑楼层/区域数据
|
|
|
|
this.getBuildingSitePlan(item)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//点击选中 平面图 楼层/区域 时
|
|
|
|
selectSitePlan (item,index) {
|
|
|
|
if (this.selectSitePlanIndex != index) {
|
|
|
|
this.selectingSitePlan = item
|
|
|
|
this.selectSitePlanIndex = index
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//平面图 楼层/区域 替换底图
|
|
|
|
replaceBaseMap (e,item) {
|
|
|
|
e.stopPropagation();
|
|
|
|
let file = e.target.files[0] || null //获取上传的文件
|
|
|
|
let fileSize = file.size || null //上传文件的总大小
|
|
|
|
let maxSize = 5 * 1024 * 1024 //5MB一个分片
|
|
|
|
|
|
|
|
if (file && fileSize<=maxSize) { //上传文件<=5MB时
|
|
|
|
let formData = new FormData()
|
|
|
|
formData.append("file",file)
|
|
|
|
this.http.post(`/api/Objects/WebPlan2D/${sessionStorage.getItem('companyId')}`,formData).subscribe((data:any)=>{
|
|
|
|
this.renovateBaseMap(data.objectName,item)
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
const config = new MatSnackBarConfig();
|
|
|
|
config.verticalPosition = 'top';
|
|
|
|
config.duration = 3000
|
|
|
|
this.snackBar.open('上传底图需小于5MB','确定',config);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//封装 替换底图 function
|
|
|
|
renovateBaseMap (e,item) {
|
|
|
|
item.imageUrl = '/api/Objects/WebPlan2D/' + e
|
|
|
|
if (this.checkedBuildingIndex ==-1) { //总平面图
|
|
|
|
this.http.put(`/api/CompanyAccount/SitePlans/${item.id}`,item).subscribe(data=>{
|
|
|
|
this.renovateSitePlan()
|
|
|
|
const config = new MatSnackBarConfig();
|
|
|
|
config.verticalPosition = 'top';
|
|
|
|
config.duration = 3000
|
|
|
|
this.snackBar.open('上传底图成功','确定',config);
|
|
|
|
})
|
|
|
|
} else { //楼层/区域
|
|
|
|
this.http.put(`/api/CompanyAccount/BuildingAreas/${item.id}`,item).subscribe(data=>{
|
|
|
|
this.renovateBuilding()
|
|
|
|
const config = new MatSnackBarConfig();
|
|
|
|
config.verticalPosition = 'top';
|
|
|
|
config.duration = 3000
|
|
|
|
this.snackBar.open('上传底图成功','确定',config);
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//封装 刷新总平面图 数据
|
|
|
|
renovateSitePlan () {
|
|
|
|
this.http.get('/api/CompanyAccount/SitePlans').subscribe(data=>{
|
|
|
|
this.sitePlanData = data
|
|
|
|
this.selectingSitePlan = this.sitePlanData[this.selectSitePlanIndex]
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
//封装 刷新 楼层/区域 数据
|
|
|
|
renovateBuilding () {
|
|
|
|
let params = {
|
|
|
|
buildingId: this.beforeOneCheckedBuilding.id
|
|
|
|
}
|
|
|
|
this.http.get('/api/CompanyAccount/BuildingAreas',{params}).subscribe(data=>{
|
|
|
|
this.sitePlanData = data
|
|
|
|
this.selectingSitePlan = this.sitePlanData[this.selectSitePlanIndex]
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
allLibrary:any = []; //所有素材库 + 素材
|
|
|
|
selectLibrary:any; //选中的素材库
|
|
|
|
selectImage:any; //选中的素材库图片
|
|
|
|
selectImageIndex:number; //选中的素材库图片index
|
|
|
|
|
|
|
|
//获取素材库
|
|
|
|
getAllLibrary () {
|
|
|
|
this.http.get('/api/AssetLibraries?tag=input').subscribe((data:any)=>{
|
|
|
|
data.forEach(element => {
|
|
|
|
element.images = []
|
|
|
|
});
|
|
|
|
this.allLibrary = data
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
//素材库展开面板展开时
|
|
|
|
opened (e) {
|
|
|
|
if (!e.images.length) { //当前素材库没加载素材时
|
|
|
|
this.http.get(`/api/Assets?libraryId=${e.id}`).subscribe((data:any)=>{
|
|
|
|
e.images = data
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//点击选中素材库图片时
|
|
|
|
selectImg (item,items,index) {
|
|
|
|
this.selectLibrary = item.name
|
|
|
|
this.selectImage = items
|
|
|
|
this.selectImageIndex = index
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//创建建筑
|
|
|
|
@Component({
|
|
|
|
selector: 'app-createBuilding',
|
|
|
|
templateUrl: './createBuilding.html',
|
|
|
|
styleUrls: ['./collection-tools.component.scss']
|
|
|
|
})
|
|
|
|
export class CreateBuilding {
|
|
|
|
|
|
|
|
constructor(private http:HttpClient,public dialog: MatDialog,public dialogRef: MatDialogRef<CreateBuilding>,@Inject(MAT_DIALOG_DATA) public data) { }
|
|
|
|
|
|
|
|
allBuildingType:any//所有的建筑类型
|
|
|
|
selected:any; //选中的建筑
|
|
|
|
ngOnInit(): void {
|
|
|
|
this.getAllBuildingType()
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
getAllBuildingType(){
|
|
|
|
this.http.get("/api/BuildingTypes/Simple").subscribe(data=>{
|
|
|
|
this.allBuildingType = data
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
//创建建筑功能分区
|
|
|
|
onSubmit (e) {
|
|
|
|
let companyId = sessionStorage.getItem("companyId")
|
|
|
|
let lastBuildingOrder = this.data.length != 0 ? this.data[this.data.length - 1].order + 1 : 0
|
|
|
|
let data =
|
|
|
|
{
|
|
|
|
id: "",
|
|
|
|
name: e.propertyName,
|
|
|
|
order: lastBuildingOrder ,
|
|
|
|
enabled: true,
|
|
|
|
companyId: companyId,
|
|
|
|
buildingTypes: [
|
|
|
|
{
|
|
|
|
id: e.buildingId,
|
|
|
|
name: ""
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
this.http.post("/api/CompanyAccount/Buildings",data).subscribe(data=>{
|
|
|
|
this.dialogRef.close("创建成功");
|
|
|
|
},err=>{
|
|
|
|
this.dialogRef.close("创建失败");
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//编辑建筑
|
|
|
|
@Component({
|
|
|
|
selector: 'app-editBuilding',
|
|
|
|
templateUrl: './editBuilding.html',
|
|
|
|
styleUrls: ['./collection-tools.component.scss']
|
|
|
|
})
|
|
|
|
export class EditBuilding {
|
|
|
|
|
|
|
|
constructor(private http:HttpClient,public dialog: MatDialog,public dialogRef: MatDialogRef<EditBuilding>,@Inject(MAT_DIALOG_DATA) public data) { }
|
|
|
|
|
|
|
|
defaultName:String = this.data.item.name//默认建筑名称
|
|
|
|
defaultBuildingType:String = this.data.item.buildingTypes[0].id//默认建筑类型
|
|
|
|
allBuildingType:any//所有的建筑类型
|
|
|
|
|
|
|
|
ngOnInit(): void {
|
|
|
|
this.getAllBuildingType()
|
|
|
|
}
|
|
|
|
|
|
|
|
getAllBuildingType(){
|
|
|
|
this.http.get("/api/BuildingTypes/Simple").subscribe(data=>{
|
|
|
|
this.allBuildingType = data
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
//编辑建筑信息
|
|
|
|
onSubmit (e) {
|
|
|
|
let companyId = sessionStorage.getItem("companyId")
|
|
|
|
let data =
|
|
|
|
{
|
|
|
|
id: this.data.item.id,
|
|
|
|
name: e.propertyName,
|
|
|
|
order: this.data.item.order,
|
|
|
|
enabled: true,
|
|
|
|
companyId: companyId,
|
|
|
|
buildingTypes: [
|
|
|
|
{
|
|
|
|
id: e.buildingId,
|
|
|
|
name: ""
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
this.http.put(`/api/CompanyAccount/Buildings/${this.data.item.id}`,data).subscribe(data=>{
|
|
|
|
this.dialogRef.close("修改成功");
|
|
|
|
},err=>{
|
|
|
|
this.dialogRef.close("修改失败");
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|