Browse Source

[完善] 平面图,楼层/区域 新建,上传底图完成

develop
陈鹏飞 5 years ago
parent
commit
a0b32cfd27
  1. 38
      src/app/ui/collection-tools/addPlaneFigure.html
  2. 27
      src/app/ui/collection-tools/collection-tools.component.html
  3. 156
      src/app/ui/collection-tools/collection-tools.component.ts
  4. 39
      src/app/ui/collection-tools/editPlaneFigure.html
  5. 73
      src/app/ui/collection-tools/leftFunctionalDomain.ts
  6. 85
      src/app/ui/collection-tools/panel.scss
  7. 3
      src/app/ui/ui.module.ts

38
src/app/ui/collection-tools/addPlaneFigure.html

@ -0,0 +1,38 @@
<div class="functionalDomainContent">
<div mat-dialog-title>
<label *ngIf="!data.isBuilding">新建平面图</label>
<label *ngIf="data.isBuilding">新建楼层/区域</label>
</div>
<form (ngSubmit)="onSubmit(form.value)" #form="ngForm" class="example-container">
<div class="keyMargin">
<mat-form-field>
<input matInput name="name" required ngModel placeholder="名称">
</mat-form-field>
</div>
<div class="keyMargin" *ngIf="data.isBuilding">
<mat-checkbox name="isRefugeStorey" [(ngModel)]="checked">是否为避难层</mat-checkbox>
</div>
<div class="keyMargin">
<mat-form-field>
<input matInput name="area" type="number" required ngModel placeholder="面积 (平方米)">
</mat-form-field>
</div>
<div class="keyMargin">
<textarea name="details" required ngModel placeholder="详情"></textarea>
</div>
<div class="submitBottom">
<button mat-raised-button color="primary" type="submit" [disabled]="!form.form.valid">
确定
</button>
<button mat-raised-button mat-dialog-close>取消</button>
</div>
</form>
</div>

27
src/app/ui/collection-tools/collection-tools.component.html

@ -40,12 +40,12 @@
<!-- 头部操作栏 -->
<div class="headerOperate">
<button mat-button (click)="checkedBuilding({name:'总平面图'})"
[ngClass]="{'buildingbtnchecked': '总平面图' == checkedBuildingDate}">
<button mat-button (click)="checkedBuilding({name:'总平面图'},-1)"
[ngClass]="{'buildingbtnchecked': checkedBuildingIndex==-1}">
<span>总平面图</span>
</button>
<button mat-button *ngFor="let item of allBuildings" (click)="checkedBuilding(item)" class="bigeditdeletebtn"
[ngClass]="{'buildingbtnchecked': item.name == checkedBuildingDate}">
<button mat-button *ngFor="let item of allBuildings;let key = index" (click)="checkedBuilding(item,key)" class="bigeditdeletebtn"
[ngClass]="{'buildingbtnchecked': checkedBuildingIndex==key}">
<span>{{item.name}}</span>
<span class="editdeletebtn">
<mat-icon (click)="editBuilding($event,item)"
@ -63,8 +63,8 @@
<div class="functionalDomain">
<div class='functionalDomainContent'>
<!-- H5Canvas -->
<app-working-area></app-working-area>
<!-- H5Canvas -->
<app-working-area></app-working-area>
<!-- H5Canvas -->
<div class='functionalDomainLeft publicCss' [ngClass]="{'togglePanel': toggleExpandPanel==true}">
@ -80,17 +80,24 @@
</div>
<div [hidden]="!togglePlane">
<div class="sitePlanContent" *ngFor="let item of sitePlanData;let key = index"
[ngClass]="{'selectSitePlan': selectSitePlanIndex==key}" (click)='selectSitePlan(item,key)'>
[ngClass]="{'isRefugeStorey':item.isRefugeStorey==true,'selectSitePlan': selectSitePlanIndex==key}" (click)='selectSitePlan(item,key)'>
<mat-icon *ngIf="!item.imageUrl" class="matIcons">broken_image</mat-icon>
<label class="overflowText">{{item.name}}</label>
<mat-icon title="替换底图" class="matIcons replaceBaseMap" *ngIf="selectSitePlanIndex==key">photo_size_select_actual</mat-icon>
<a href="javascript:;" class="a-upload" *ngIf="selectSitePlanIndex==key" title="替换底图" >
<input type="file" (change)='replaceBaseMap($event,item)'>
<mat-icon class="matIcons">photo_size_select_actual</mat-icon>
</a>
<a href="javascript:;" id="a-uploadImg" *ngIf="selectSitePlanIndex==key && !item.imageUrl" title="上传底图" >
<input type="file" (change)='replaceBaseMap($event,item)'>
<img src="../../../assets/images/upload.jpg">
</a>
<!-- 右边定位操作栏 -->
<div id="rightOperate" *ngIf="selectSitePlanIndex==key">
<div id="rightOperate" *ngIf="selectSitePlanIndex==key && item.imageUrl" (click)="$event.stopPropagation();">
<p class="functionButton">
<mat-icon class="functionIcon bigFunctionIcon" title="上移">keyboard_arrow_up</mat-icon>
</p>
<p class="functionButton">
<mat-icon class="functionIcon" title="编辑属性">edit</mat-icon>
<mat-icon class="functionIcon" title="编辑属性" (click)='editPlaneData(item)'>edit</mat-icon>
<mat-icon class="functionIcon" title="删除">delete</mat-icon>
</p>
<p class="functionButton">

156
src/app/ui/collection-tools/collection-tools.component.ts

@ -2,6 +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 {leftFunctionalDomainComponent,editPlaneFigureComponent} from './leftFunctionalDomain'
@Component({
selector: 'app-collection-tools',
@ -11,19 +12,22 @@ import { MatSnackBar, MatSnackBarConfig } from '@angular/material/snack-bar';
export class CollectionToolsComponent implements OnInit {
constructor(private http:HttpClient,public dialog: MatDialog,public snackBar: MatSnackBar) { }
selected = 'option1' //图标大小选择框
basicInfo:boolean = true //基本信息名称显隐
wantToWork:boolean = true //想定作业名称显隐
allBuildings //该单位所有建筑
checkedBuildingDate //当前点击选择的建筑
beforeOneCheckedBuilding:any = {name:"总平面图"}; //当前点击选择的建筑
checkedBuildingIndex:number = -1 //当前点击选择的建筑index
isEditPat:boolean = true //当前是否是编辑模式
sliderValue:String = "30"//滑竿的值
ngOnInit(): void {
this.getAllLibrary()
this.getSitePlan()
this.checkedBuildingDate = "总平面图"
this.getAllBuildings()
}
//点击基本信息名称
basicInfoClick(){
this.basicInfo = !this.basicInfo
@ -78,8 +82,16 @@ export class CollectionToolsComponent implements OnInit {
});
}
//选择建筑
checkedBuilding(item){
this.checkedBuildingDate = item.name
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){
@ -109,7 +121,12 @@ export class CollectionToolsComponent implements OnInit {
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('删除成功','确定',config);
this.getAllBuildings()
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';
@ -142,30 +159,132 @@ export class CollectionToolsComponent implements OnInit {
this.toggleMaterialBank = !this.toggleMaterialBank
}
sitePlanData:any = []; //总平面图数据
selectingSitePlan:any; //选中的平面图
selectSitePlanIndex:number; //选中的平面图index
sitePlanData:any = []; //总平面图 楼层/区域 数据
selectingSitePlan:any; //选中的 平面图 楼层/区域
selectSitePlanIndex:number; //选中的 平面图 楼层/区域 index
//获取总平面图
getSitePlan () {
this.http.get('/api/CompanyAccount/SitePlans').subscribe(data=>{
this.sitePlanData = data
if (this.sitePlanData.length) { //数据不为空时
this.selectingSitePlan = this.sitePlanData[0]
this.selectSitePlanIndex = 0
}
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) {
this.selectingSitePlan = item
this.selectSitePlanIndex = 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 = []; //所有素材库 + 素材
@ -187,9 +306,6 @@ export class CollectionToolsComponent implements OnInit {
opened (e) {
if (!e.images.length) { //当前素材库没加载素材时
this.http.get(`/api/Assets?libraryId=${e.id}`).subscribe((data:any)=>{
data.forEach(element => {
element.imageUrl = element.imageUrl + '?x-oss-process=image/auto-orient,1' //压缩图片
});
e.images = data
})
}
@ -201,7 +317,7 @@ export class CollectionToolsComponent implements OnInit {
this.selectImage = items
this.selectImageIndex = index
}
}

39
src/app/ui/collection-tools/editPlaneFigure.html

@ -0,0 +1,39 @@
<div class="functionalDomainContent">
1
<!-- <div mat-dialog-title>
<label *ngIf="!data.isBuilding">编辑平面图</label>
<label *ngIf="data.isBuilding">编辑楼层/区域</label>
</div>
<form (ngSubmit)="onSubmit(form.value)" #form="ngForm" class="example-container">
<div class="keyMargin">
<mat-form-field>
<input matInput name="name" required ngModel placeholder="名称">
</mat-form-field>
</div>
<div class="keyMargin" *ngIf="data.isBuilding">
<mat-checkbox name="isRefugeStorey" [(ngModel)]="checked">是否为避难层</mat-checkbox>
</div>
<div class="keyMargin">
<mat-form-field>
<input matInput name="area" type="number" required ngModel placeholder="面积 (平方米)">
</mat-form-field>
</div>
<div class="keyMargin">
<textarea name="details" required ngModel placeholder="详情"></textarea>
</div>
<div class="submitBottom">
<button mat-raised-button color="primary" type="submit" [disabled]="!form.form.valid">
确定
</button>
<button mat-raised-button mat-dialog-close>取消</button>
</div>
</form> -->
</div>

73
src/app/ui/collection-tools/leftFunctionalDomain.ts

@ -0,0 +1,73 @@
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';
@Component({
selector: 'app-leftFunctionalDomain',
templateUrl: './addPlaneFigure.html',
styleUrls: ['./panel.scss']
})
export class leftFunctionalDomainComponent implements OnInit {
constructor(private http:HttpClient,public dialog: MatDialog,public snackBar: MatSnackBar,public dialogRef: MatDialogRef<any>,@Inject(MAT_DIALOG_DATA) public data) { }
ngOnInit(): void {
}
checked:boolean = false;//是否为避难层
//提交表单创建平面图
onSubmit (e) {
if (!this.data.isBuilding) { //总平面图 创建平面图
let data = {
companyId: sessionStorage.getItem('companyId'),
name: e.name,
order: this.data.order,
area:e.area,
details:e.details,
enabled: true,
modifiedTime: new Date(),
}
this.http.post('/api/CompanyAccount/SitePlans',data).subscribe(data=>{
this.dialogRef.close('总平面图');
})
} else { //建筑 创建楼层/区域
let data = {
isRefugeStorey: e.isRefugeStorey,
buildingId: this.data.Panel.id,
name: e.name,
order: this.data.order,
area:e.area,
details:e.details,
enabled: true,
modifiedTime: new Date(),
}
this.http.post('/api/CompanyAccount/BuildingAreas',data).subscribe(data=>{
this.dialogRef.close('建筑');
})
}
}
}
//编辑平面图 楼层/区域
@Component({
selector: 'app-editPlaneFigure',
templateUrl: './editPlaneFigure.html',
styleUrls: ['./panel.scss']
})
export class editPlaneFigureComponent implements OnInit {
constructor(private http:HttpClient,public dialog: MatDialog,public snackBar: MatSnackBar,public dialogRef: MatDialogRef<any>,@Inject(MAT_DIALOG_DATA) public data) { }
ngOnInit(): void {
}
}

85
src/app/ui/collection-tools/panel.scss

@ -45,13 +45,61 @@
font-size: 20px;
}
}
.replaceBaseMap {
//替换底图 inputfile
.a-upload {
display: block;
float: right;
margin-top: 8px;
margin: 8px 5px 0 0;
width: 20px;
height: 20px;
line-height: 20px;
text-align: center;
position: relative;
overflow: hidden;
input {
position: absolute;
width: 20px;
height: 20px;
left: 0;
top: 0;
opacity: 0;
}
}
.replaceBaseMap:hover {
color: #fff;
.a-upload:hover {
.mat-icon {
color: #fff;
}
}
//上传底图 inputfile
#a-uploadImg {
display: block;
width: 300px;
height: 170px;
position: fixed;
top: 40%;
left: 48%;
overflow: hidden;
border-radius: 5px;
border: 1px solid #999;
z-index: 999;
input {
position: absolute;
width: 300px;
height: 170px;
left: 0;
top: 0;
opacity: 0;
}
img {
width: 100%;
height: auto;
}
}
#a-uploadImg:hover {
border: 5px solid skyblue;
}
//hover时显示右边操作栏
.sitePlanContent:hover {
#rightOperate {
@ -125,6 +173,11 @@
text-overflow:ellipsis;
white-space: nowrap;
}
// 楼层/区域 是避难层时
.isRefugeStorey {
color: #fff;
background-color: rgb(238, 186, 186);
}
//选中平面图时
.selectSitePlan {
color: #fff;
@ -135,3 +188,27 @@
color: #fff;
background-color: #4DA5FA;
}
//左侧功能区弹出框样式
.keyMargin {
margin: 5px 0;
}
.submitBottom {
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: space-between; /* 水平居中 */
}
.functionalDomainContent {
width: 100%;
height: 100%;
textarea {
border-radius: 5px;
border: 1px solid #999;
width: 180px;
height: 120px;
resize:none;
}
}

3
src/app/ui/ui.module.ts

@ -97,9 +97,10 @@ import { KeyImgDetail } from './key-site/keyimgdetail.component';
import { LookMaster } from './basicinfo/lookmaster.component';
import { CollectionToolsComponent, CreateBuilding, EditBuilding } from './collection-tools/collection-tools.component';
import { WorkingAreaComponent } from '../working-area/working-area.component';
import {leftFunctionalDomainComponent,editPlaneFigureComponent} from './collection-tools/leftFunctionalDomain'
@NgModule({
declarations: [UiComponent, CardComponent, StepperComponent, TabgroupComponent, ProgressComponent, SnackbarComponent, PersonaldataComponent, UserdataComponent, ChangepasswordComponent, OrganizationComponent, UnittypeComponent, AuthorityComponent, RoleComponent, UsermanagementComponent, IsnoPipe, ConfirmpswDirective, DialogOverviewExampleDialog, CreateAuthority, CreateRole, EditRole, TimePipe, CreateNewUser, EditNewUser, allRoles, SharePower, CreateOrganization, EditOrganization, seeInformation, EditUser, editorialUnit, FireProtectionElementsComponent, Establish, EditingFireControl, FireFightingTemplateComponent, NavmenusComponent, CreateMenus, EditMenus, NewFireFighting, EditFireClassification, MaterialBankComponent, UnitInformationComponent, AddMatLibrary, EditMatLibrary, attributeComponent, AddOriginalCopy, addAttributeComponent, editAttribute, EditOriginalCopy, SelectOriginalCopy, EditUnitInfo, AddUnitInfo, AddGroups, EditGroup, BasicinfoComponent, PlanComponent, AllaroundComponent, FireFightingDeviceComponent, KeySiteComponent, FunctionDivisionComponent, RealisticPictureComponent, UploadingCADComponent, AddHouseInfo, ImgDetails, ImagesData, ImgsDataDetail, KeySiteImgs, KeyImgDetail, addPartition, addPartitionAttribute, previewImg, addRealPicture, editRealPicture, readFile, editFile, LookMaster, previewBigImg, CollectionToolsComponent, WorkingAreaComponent,CreateBuilding,EditBuilding
declarations: [UiComponent, CardComponent, StepperComponent, TabgroupComponent, ProgressComponent, SnackbarComponent, PersonaldataComponent, UserdataComponent, ChangepasswordComponent, OrganizationComponent, UnittypeComponent, AuthorityComponent, RoleComponent, UsermanagementComponent, IsnoPipe, ConfirmpswDirective, DialogOverviewExampleDialog, CreateAuthority, CreateRole, EditRole, TimePipe, CreateNewUser, EditNewUser, allRoles, SharePower, CreateOrganization, EditOrganization, seeInformation, EditUser, editorialUnit, FireProtectionElementsComponent, Establish, EditingFireControl, FireFightingTemplateComponent, NavmenusComponent, CreateMenus, EditMenus, NewFireFighting, EditFireClassification, MaterialBankComponent, UnitInformationComponent, AddMatLibrary, EditMatLibrary, attributeComponent, AddOriginalCopy, addAttributeComponent, editAttribute, EditOriginalCopy, SelectOriginalCopy, EditUnitInfo, AddUnitInfo, AddGroups, EditGroup, BasicinfoComponent, PlanComponent, AllaroundComponent, FireFightingDeviceComponent, KeySiteComponent, FunctionDivisionComponent, RealisticPictureComponent, UploadingCADComponent, AddHouseInfo, ImgDetails, ImagesData, ImgsDataDetail, KeySiteImgs, KeyImgDetail, addPartition, addPartitionAttribute, previewImg, addRealPicture, editRealPicture, readFile, editFile, LookMaster, previewBigImg, CollectionToolsComponent, WorkingAreaComponent,CreateBuilding,EditBuilding,leftFunctionalDomainComponent,editPlaneFigureComponent
],
imports: [

Loading…
Cancel
Save