Browse Source

[新增]增加框选

master
邵佳豪 4 years ago
parent
commit
eca20e98e7
  1. 114
      src/app/ui/collection-tools/collection-tools.component.html
  2. 184
      src/app/ui/collection-tools/collection-tools.component.ts

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

@ -19,7 +19,9 @@
基本信息名称
<mat-icon>visibility</mat-icon>
</span>
<span class="marginLeftRight">
<mat-checkbox color="primary" [(ngModel)]="isMultiSelect" (change)='changeMultiSelect($event)'></mat-checkbox> 多选
</span>
<span style="position: absolute;right: 60px;cursor: pointer;">
<mat-icon title="查看/编辑模式" (click)="lookpat()" *ngIf="isEditPattern">tv</mat-icon>
<mat-icon title="查看/编辑模式" (click)="editpat()" *ngIf="!isEditPattern">create</mat-icon>
@ -138,7 +140,7 @@
</div>
</div>
<!-- 平面图属性 -->
<div class="siteproperty" style="user-select: none" *ngIf="isShowProperty && isShowAttribute">
<div class="siteproperty" style="user-select: none" *ngIf="isShowProperty && isShowAttribute && !isMultipleAsset">
<p>面积(平方米)</p>
<div class="siteproperty_size">{{canvasData.selectStorey.area}}</div>
<p>详情</p>
@ -147,7 +149,7 @@
</div>
</div>
<!-- 素材属性 -->
<div class="assetsproperty" style="user-select: none" *ngIf="isShowProperty && !isShowAttribute">
<div class="assetsproperty" style="user-select: none" *ngIf="isShowProperty && !isShowAttribute && !isMultipleAsset">
<h3 style="text-align: center;font-weight: 900;">{{assetName}}</h3>
<div *ngIf="canvasAssetObj.InteractiveMode == 0">
@ -279,8 +281,112 @@
</select>
</div>
</div>
</div>
</div>
<!-- 框选多个素材属性 -->
<div class="assetsproperty" style="user-select: none" *ngIf="isShowProperty && isMultipleAsset">
<div *ngIf="multipleAsset.InteractiveMode == 0">
<p>宽度(像素)</p>
<input type="number" class="biginput" [(ngModel)]="multipleAsset.Width" (input)="multipleAssetWidthInput()" [disabled]="!isEditPattern">
<p>高度(像素)</p>
<input type="number" class="biginput" [(ngModel)]="multipleAsset.Height" (input)="multipleAssetHeightInput()" [disabled]="!isEditPattern">
<p>角度</p>
<div style="width: 100%;display: flex;vertical-align: top;height: 22px;">
<input type="number" class="smallinput" [(ngModel)]="multipleAsset.Angle"
oninput="if(value>360)value=360;if(value<0)value=0;" (input)="multipleAssetAngleInput()" [disabled]="!isEditPattern">
<mat-slider color="primary" min="0" max="360" step="1" style="bottom: 12px;left: 2px;width: 70%;"
[(ngModel)]="multipleAsset.Angle" (change)="multipleAssetAngleInput()" [disabled]="!isEditPattern"></mat-slider>
</div>
</div>
<!-- 如果是多点连线 -->
<div *ngIf="multipleAsset.InteractiveMode == 1 || multipleAsset.InteractiveMode == 3">
<p>厚度</p>
<div style="width: 100%;display: flex;vertical-align: top;height: 22px;">
<input type="number" class="smallinput" [(ngModel)]="multipleAsset.Thickness"
oninput="if(value>999)value=999;if(value<0)value=0;" (input)="multipleAssetThicknessInput()" [disabled]="!isEditPattern">
<mat-slider color="primary" min="0" max="999" step="1" style="bottom: 12px;left: 2px;width: 70%;"
[(ngModel)]="multipleAsset.Thickness" (change)="multipleAssetThicknessInput()" [disabled]="!isEditPattern"></mat-slider>
</div>
</div>
<div class="colorBigDiv" *ngIf="multipleAsset.FillMode == 0">
<div class="colorBigTemplateDiv">
<span>颜色</span>
<div class="colorTemplateDiv" [style]="{'background-color':selectedcolor}">
</div>
</div>
<div class="colorDiv" *ngIf="isEditPattern">
<ul>
<li (click)="multipleAssetSelectcolor(item,key)" class="colorLi" *ngFor="let item of colors,let key=index" [style]="{'background-color':item}"></li>
</ul>
</div>
<span style="color: #9c9fa5;font-size: 14px;">透明度</span>
<mat-slider color="primary" min="0" max="100%" step="1" style="left: 1px; width: 55%;min-width: 90px;"
[(ngModel)]="colorDivSliderValue" (change)="multipleColorDivSliderChange()" [disabled]="!isEditPattern"></mat-slider>
<span style="color: #9c9fa5;font-size: 12px;">{{colorDivSliderValue}}%</span>
</div>
<div *ngFor="let item of multipleAsset.PropertyInfos;index as key ">
<!-- 单行文本 -->
<div *ngIf="item.PropertyType == 0">
<p>{{item.PropertyName}}<span style="font-size: 14px;" *ngIf="item.PhysicalUnit">({{item.PhysicalUnit}})</span></p>
<input type="text" class="biginput" [name]="item.PropertyName" [(ngModel)]="item.PropertyValue" (input)="multipleAssetInputChange(item,$event)" [disabled]="!isEditPattern">
</div>
<!-- 多行文本 -->
<div *ngIf="item.PropertyType == 1">
<p>{{item.PropertyName}}<span style="font-size: 14px;" *ngIf="item.PhysicalUnit">({{item.PhysicalUnit}})</span></p>
<textarea class="textarea" name="" id="" [(ngModel)]="item.PropertyValue" (input)="multipleAssetInputChange(item,$event)" [disabled]="!isEditPattern"></textarea>
</div>
<!-- 数值 -->
<div *ngIf="item.PropertyType == 2">
<p>{{item.PropertyName}}<span style="font-size: 14px;" *ngIf="item.PhysicalUnit">({{item.PhysicalUnit}})</span></p>
<input type="number" class="biginput" [(ngModel)]="item.PropertyValue" (input)="multipleAssetInputChange(item,$event)" [disabled]="!isEditPattern">
</div>
<!-- 方向 -->
<!-- <div *ngIf="item.PropertyType == 5 " class="selectDiv">
<p style="display: inline-block;">{{item.PropertyName}}</p>
<select [(ngModel)]="item.PropertyValue" (change)="direction(item,$event)" [disabled]="!isEditPattern">
<option value ="0" [selected]="item.PropertyValue =='0'"></option>
<option value ="1" [selected]="item.PropertyValue =='1'">西</option>
<option value ="2" [selected]="item.PropertyValue =='2'"></option>
<option value ="3" [selected]="item.PropertyValue =='3'"></option>
<option value ="4" [selected]="item.PropertyValue =='4'">东南</option>
<option value ="5" [selected]="item.PropertyValue =='5'">西南</option>
<option value ="6" [selected]="item.PropertyValue =='6'">东北</option>
<option value ="7" [selected]="item.PropertyValue =='7'">西北</option>
</select>
</div> -->
<!-- 布尔值 是1或否0 -->
<div *ngIf="item.PropertyType == 6">
<p>{{item.PropertyName}}</p>
<input value='1' [(ngModel)]="item.PropertyValue" [disabled]="!isEditPattern" class="input" type="radio" name="radio" (click)="multipleAssetRadioChange(item,'1')"><span></span>
<input value='0' [(ngModel)]="item.PropertyValue" [disabled]="!isEditPattern" class="input" type="radio" name="radio" (click)="multipleAssetRadioChange(item,'0')"><span></span>
</div>
<!-- 供给区域 -->
<div *ngIf="item.PropertyType == 7" class="selectDiv">
<p style="display: inline-block;">{{item.PropertyName}}</p>
<select [(ngModel)]="item.PropertyValue" (change)="multipleSupplyArea(item,$event)" [disabled]="!isEditPattern">
<option value ="0">全部</option>
<option value ="1">高区</option>
<option value ="2">中区</option>
<option value ="3">低区</option>
<option value ="4">高中区</option>
<option value ="5">高低区</option>
<option value ="6">中低区</option>
</select>
</div>
<!-- 供给类型 -->
<div *ngIf="item.PropertyType == 8" class="selectDiv">
<p style="display: inline-block;">{{item.PropertyName}}</p>
<select [(ngModel)]="item.PropertyValue" (change)="multipleSupplyArea(item,$event)" [disabled]="!isEditPattern">
<option value ="0">消火栓</option>
<option value ="1">喷淋</option>
<option value ="2">水幕</option>
<option value ="3">泡沫</option>
<option value ="4">消防</option>
</select>
</div>
</div>
</div>
</div>
<!-- 消防要素 -->
<div id="firecategories" class="firecategories" style="height: 50%;">

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

@ -10,7 +10,7 @@ import {CanvasShareDataService} from '../../canvas-share-data.service' //引入
import Viewer from 'viewerjs';
import Swiper from 'swiper';
import * as ObjectID from 'bson-objectid';
import { AxMessageSystem } from 'src/app/working-area/model/axMessageSystem';
@Component({
selector: 'app-collection-tools',
templateUrl: './collection-tools.component.html',
@ -73,9 +73,11 @@ export class CollectionToolsComponent implements OnInit {
setTimeout(() => {
obj.PropertyInfos.forEach(item => {
if(item.PropertyType == 4){
this.gallery = new Viewer(document.getElementById('viewerjs'),{
url: 'data-original'
});
if(document.getElementById('viewerjs')){
this.gallery = new Viewer(document.getElementById('viewerjs'),{
url: 'data-original'
});
}
}
})
}, 0);
@ -431,10 +433,72 @@ export class CollectionToolsComponent implements OnInit {
this.canvasData.isChange = true
}
isMultiSelect:boolean = false; // 多选/单选 切换
changeMultiSelect (e) { this.canvas.setMulitSelect(this.isMultiSelect) }
isMultipleAsset:boolean = false//框选多个素材属性显隐
multipleAsset:any = {
Width:null,
Height:null,
Angle:null,
Thickness:null,
Color:null,
PropertyInfos:[]
}//多个素材共同属性
multipleAssetData:any//当前多选的素材
firstMultipleAssetData:any//当前多选的第一个素材
ngOnInit(): void {
this.getAllLibrary()
let _this = this
AxMessageSystem.addListener('selectionChanged', ()=>{
if(this.canvas.selection.size() == 1){//如果是单选
this.isMultipleAsset = false
this.setAssetsProperty(this.canvas.selection.first().assetData)
}else if(this.canvas.selection.size()){
this.isShowProperty = true
this.multipleAssetData = this.canvas.selection.all()
this.firstMultipleAssetData = this.canvas.selection.first()
this.multipleAsset = {
Width:null,
Height:null,
Angle:null,
Thickness:null,
Color:null,
PropertyInfos:[]
}
this.isMultipleAsset = true
let firstAssetData = this.canvas.selection.first().assetData;//拿出第一个素材作为例子与其他素材进行对比
let InteractiveMode = firstAssetData.InteractiveMode //素材连接方式
let isInteractiveMode = this.canvas.selection.all().every(item => item.assetData.InteractiveMode === InteractiveMode)
if(isInteractiveMode){
this.multipleAsset.InteractiveMode = InteractiveMode
}
let isFillMode = this.canvas.selection.all().every(item => item.assetData.FillMode === 0) //素材填充方式都为0
if(isFillMode){
this.multipleAsset.FillMode = 0
}
this.canvas.selection.first().assetData.PropertyInfos.forEach(i => {
let index = 0
this.canvas.selection.all().forEach(item => {
item.assetData.PropertyInfos.forEach(element => {
if(element.PropertyName == i.PropertyName && element.PropertyType == i.PropertyType && element.PropertyType != 3 && element.PropertyType != 4){
index++
if(index == this.canvas.selection.size()){
let newElement = JSON.parse(JSON.stringify(element))
newElement.PropertyValue = ''
this.multipleAsset.PropertyInfos.push(newElement)
}
}
});
})
})
}else if(this.canvas.selection.size() == 0){
this.isShowProperty = false
}
}, this)
this.getAllLibrary()
let that = this
window.setTimeout(()=>{
document.getElementById("functionalDomainContent").oncontextmenu = function (event) {
@ -445,19 +509,107 @@ export class CollectionToolsComponent implements OnInit {
})
}
ngAfterViewInit(): void {
this.getAllBuildings(true)
// 监听canvas组件选中素材事件
this.canvas.on("select",obj=>{
//选中素材属性注入函数
this.setAssetsProperty(obj.assetData)
//多选宽度共同改变
multipleAssetWidthInput(){
this.multipleAssetData.forEach(item=>{
item.assetData.Width = this.multipleAsset.Width
this.canvas.refreshIcon(item.assetData.Id)
this.canvasData.isChange = true
})
}
//多选高度共同改变
multipleAssetHeightInput(){
this.multipleAssetData.forEach(item=>{
item.assetData.Height = this.multipleAsset.Height
this.canvas.refreshIcon(item.assetData.Id)
this.canvasData.isChange = true
})
}
//多选角度共同改变
multipleAssetAngleInput(){
this.multipleAssetData.forEach(item=>{
item.assetData.Angle = this.multipleAsset.Angle
this.canvas.refreshIcon(item.assetData.Id)
this.canvasData.isChange = true
})
}
//多选厚度共同改变
multipleAssetThicknessInput(){
this.multipleAssetData.forEach(item=>{
item.assetData.Thickness = this.multipleAsset.Thickness
this.canvas.refreshIcon(item.assetData.Id)
this.canvasData.isChange = true
})
}
//多选颜色共同改变
multipleSelectedcolor:any
multipleAssetSelectcolor(item,key){
//在当前透明度基础上改变颜色
this.multipleSelectedcolor = item
this.multipleAssetData.forEach(item=>{
item.assetData.Color = this.multipleSelectedcolor
this.canvasData.isChange = true
this.canvas.refreshIcon(item.assetData.Id)
})
}
//多选颜色滑竿改变
multipleColorDivSliderChange(){
let colorOpacity = Math.round(255 * this.colorDivSliderValue * 0.01)
//根据滑竿值改变16进制颜色后两位
function replacepos(text,start,stop,replacetext){
let mystr = text.substring(0,stop-1)+replacetext+text.substring(stop+1);
return mystr;
}
this.multipleAssetData.forEach(item=>{
this.multipleSelectedcolor = replacepos(this.multipleSelectedcolor,7,8,colorOpacity.toString(16))
item.assetData.Color = this.multipleSelectedcolor
this.canvasData.isChange = true
this.canvas.refreshIcon(item.assetData.Id)
})
}
//多选状态动态属性素材input框值改变
multipleAssetInputChange(i,e){
e.stopPropagation()
setTimeout(() => {
this.multipleAssetData.forEach(item=>{
item.assetData.PropertyInfos.forEach(element => {
if(element.PropertyName == i.PropertyName){
element.PropertyValue = i.PropertyValue
this.canvas.refreshIcon(item.assetData.Id)
this.canvasData.isChange = true
}
})
})
}, 0);
}
//多选状态动态属性素材radio框值改变
multipleAssetRadioChange(i,value){
// e.stopPropagation()
this.multipleAssetData.forEach(item=>{
item.assetData.PropertyInfos.forEach(element => {
if(element.PropertyName == i.PropertyName){
element.PropertyValue = value
this.canvas.refreshIcon(item.assetData.Id)
this.canvasData.isChange = true
}
})
})
// 监听canvas组件取消选中素材事件
this.canvas.on("deselect",obj=>{
this.isShowProperty = false
}
//多选状态动态属性素材下拉框值改变
multipleSupplyArea(i,e){
e.stopPropagation()
this.multipleAssetData.forEach(item=>{
item.assetData.PropertyInfos.forEach(element => {
if(element.PropertyName == i.PropertyName){
element.PropertyValue = i.PropertyValue
this.canvas.refreshIcon(item.assetData.Id)
this.canvasData.isChange = true
}
})
})
}
ngAfterViewInit(): void {
this.getAllBuildings(true)
// 监听canvas组件新增素材事件
this.canvas.on("canvasDataChanged",obj=>{
this.renovateTreeData(false)

Loading…
Cancel
Save