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.

81 lines
2.0 KiB

import { Component, OnInit } from '@angular/core';
import { HttpClient } from '@angular/common/http';
@Component({
selector: 'app-collection-tools',
templateUrl: './collection-tools.component.html',
styleUrls: ['./collection-tools.component.scss']
})
export class CollectionToolsComponent implements OnInit {
constructor(private http:HttpClient,) { }
ngOnInit(): void {
this.getAllLibrary()
this.getSitePlan()
}
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
}
})
}
//新增平面图
foundPanel (e) {
e.stopPropagation()
}
//点击选中平面图时
selectSitePlan (item,index) {
this.selectingSitePlan = item
this.selectSitePlanIndex = index
}
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)=>{
data.forEach(element => {
element.imageUrl = element.imageUrl + '?x-oss-process=image/auto-orient,1' //压缩图片
});
e.images = data
})
}
}
//点击选中素材库图片时
selectImg (item,items,index) {
this.selectLibrary = item.name
this.selectImage = items
this.selectImageIndex = index
}
}