|
|
@ -1,31 +1,43 @@ |
|
|
|
import { Component, OnInit, Inject ,ViewChild} from '@angular/core'; |
|
|
|
import { Component, OnInit, Inject, ViewChild } from '@angular/core'; |
|
|
|
import { HttpClient } from '@angular/common/http'; |
|
|
|
import { HttpClient } from '@angular/common/http'; |
|
|
|
import { MatDialog, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; |
|
|
|
import { MatDialog, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; |
|
|
|
import Swiper from 'swiper'; |
|
|
|
import Swiper from 'swiper'; |
|
|
|
|
|
|
|
import { MatSnackBar, MatSnackBarConfig } from '@angular/material/snack-bar'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Component({ |
|
|
|
@Component({ |
|
|
|
selector: 'keysiteimgs', |
|
|
|
selector: 'keysiteimgs', |
|
|
|
templateUrl: './keysiteimgs.component.html', |
|
|
|
templateUrl: './keysiteimgs.component.html', |
|
|
|
styleUrls: ['./key-site.component.scss'] |
|
|
|
styleUrls: ['./key-site.component.scss'] |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
export class KeySiteImgs { |
|
|
|
export class KeySiteImgs { |
|
|
|
|
|
|
|
|
|
|
|
constructor(private http:HttpClient,public dialog: MatDialog,public dialogRef: MatDialogRef<KeySiteImgs>, |
|
|
|
constructor(private http: HttpClient, public dialog: MatDialog, public dialogRef: MatDialogRef<KeySiteImgs>, |
|
|
|
@Inject(MAT_DIALOG_DATA) public data) { } |
|
|
|
@Inject(MAT_DIALOG_DATA) public data,public snackBar: MatSnackBar) { } |
|
|
|
testSwiper: Swiper; |
|
|
|
testSwiper: Swiper; |
|
|
|
|
|
|
|
|
|
|
|
ngOnInit(): void { |
|
|
|
ngOnInit(): void { |
|
|
|
this.allImages = [] |
|
|
|
this.allImages = [] |
|
|
|
this.data.forEach(element => { |
|
|
|
this.data.imageUrls.forEach(element => { |
|
|
|
element = `${element}?x-oss-process=image/auto-orient,1` |
|
|
|
element = `${element}` |
|
|
|
this.allImages.push(element) |
|
|
|
this.allImages.push(element) |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
setTimeout(() => { |
|
|
|
|
|
|
|
this.testSwiper = new Swiper('.swiper-container', { |
|
|
|
|
|
|
|
direction: 'horizontal', |
|
|
|
|
|
|
|
loop: false, |
|
|
|
|
|
|
|
lazy: true, |
|
|
|
|
|
|
|
// 如果需要前进后退按钮
|
|
|
|
|
|
|
|
navigation: { |
|
|
|
|
|
|
|
nextEl: '.swiper-button-next', |
|
|
|
|
|
|
|
prevEl: '.swiper-button-prev', |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}, 0); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ngAfterViewInit() {
|
|
|
|
ngAfterViewInit() { |
|
|
|
|
|
|
|
|
|
|
|
this.testSwiper = new Swiper('.swiper-container', { |
|
|
|
this.testSwiper = new Swiper('.swiper-container', { |
|
|
|
direction: 'horizontal', |
|
|
|
direction: 'horizontal', |
|
|
@ -33,23 +45,51 @@ export class KeySiteImgs { |
|
|
|
lazy: true, |
|
|
|
lazy: true, |
|
|
|
// 如果需要前进后退按钮
|
|
|
|
// 如果需要前进后退按钮
|
|
|
|
navigation: { |
|
|
|
navigation: { |
|
|
|
nextEl: '.swiper-button-next', |
|
|
|
nextEl: '.swiper-button-next', |
|
|
|
prevEl: '.swiper-button-prev', |
|
|
|
prevEl: '.swiper-button-prev', |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
allImages:any; //展示所有的图片
|
|
|
|
allImages: any; //展示所有的图片
|
|
|
|
rotationAngle:number=0; //旋转角度
|
|
|
|
rotationAngle: number = 0; //旋转角度
|
|
|
|
|
|
|
|
|
|
|
|
//旋转图片
|
|
|
|
//旋转图片
|
|
|
|
rotate () { |
|
|
|
rotate() { |
|
|
|
this.rotationAngle = this.rotationAngle+90 |
|
|
|
this.rotationAngle = this.rotationAngle + 90 |
|
|
|
if (this.rotationAngle === 360) {this.rotationAngle = 0} |
|
|
|
if (this.rotationAngle === 360) { this.rotationAngle = 0 } |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
deleteImg(){ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(this.allImages.legth != 0){ |
|
|
|
|
|
|
|
let isTrue = window.confirm('您确定要删除该图片吗?') |
|
|
|
|
|
|
|
if(isTrue){ |
|
|
|
|
|
|
|
// this.allImages = [...this.allImages.filter((item)=>{
|
|
|
|
|
|
|
|
// return item != this.allImages[this.testSwiper.activeIndex]
|
|
|
|
|
|
|
|
// })]
|
|
|
|
|
|
|
|
//在图片循环数组中将图片去掉
|
|
|
|
|
|
|
|
this.allImages.splice(this.testSwiper.activeIndex, 1); |
|
|
|
|
|
|
|
//更新swiper视图
|
|
|
|
|
|
|
|
setTimeout(() => { |
|
|
|
|
|
|
|
this.testSwiper.update() |
|
|
|
|
|
|
|
}, 0); |
|
|
|
|
|
|
|
this.data.imageUrls = this.allImages |
|
|
|
|
|
|
|
this.http.put(`/api/BuildingImportantLocations/${this.data.id}`,this.data,{ |
|
|
|
|
|
|
|
params:{ |
|
|
|
|
|
|
|
companyId : sessionStorage.getItem("companyId") |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}).subscribe((data)=>{ |
|
|
|
|
|
|
|
// console.log(666,'修改成功')
|
|
|
|
|
|
|
|
const config = new MatSnackBarConfig(); |
|
|
|
|
|
|
|
config.verticalPosition = 'top'; |
|
|
|
|
|
|
|
config.duration = 3000 |
|
|
|
|
|
|
|
this.snackBar.open('删除成功','确定',config) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|