Browse Source

[新增]完成水源审核,修复单位基本信息bug,限制上传图片格式

zhuzhou
邵佳豪 4 years ago
parent
commit
a79cb271b5
  1. 16
      src/app/data-collection/water-collection/water-collection.component.html
  2. 2
      src/app/data-collection/water-collection/water-collection.component.scss
  3. 57
      src/app/data-collection/water-collection/water-collection.component.ts
  4. 2
      src/app/key-unit/basicinfo/basicinfo.component.html
  5. 36
      src/app/key-unit/basicinfo/basicinfo.component.ts

16
src/app/data-collection/water-collection/water-collection.component.html

@ -79,13 +79,17 @@
</div>
</div>
<div class="btnbox">
<span class="state" *ngIf="waterData.verifyState == 3">(待审核)</span>
<span class="state" style="color: rgb(92, 214, 78);" *ngIf="waterData.verifyState == 4">(审核通过)</span>
<span class="state" *ngIf="waterData.verifyState == 5">(审核驳回)</span>
<span class="state" *ngIf="waterData.contentVerify && waterData.contentVerify.verifyState == 3">(
<span *ngIf="waterData.contentVerify.operation == 2" style="color: red;">删除</span>
<span *ngIf="waterData.contentVerify.operation == 0" >新增</span>
<span *ngIf="waterData.contentVerify.operation == 1" >更新</span>
待审核)</span>
<span class="state" style="color: rgb(92, 214, 78);" *ngIf="waterData.contentVerify && waterData.contentVerify.verifyState == 4">(审核通过)</span>
<span class="state" *ngIf="waterData.contentVerify && waterData.contentVerify.verifyState == 5">(审核驳回)</span>
<span class="submitAudit" *ngIf="waterData.verifyState != 3 && waterData.verifyState != 4" (click)="submitAudit()"><mat-icon>open_in_browser</mat-icon>提交审核</span>
<span class="state" *ngIf="waterData.verifyState == 3 || waterData.verifyState == 4" (click)="cancelAudit()">撤销审核</span>
<span class="save state" *ngIf="waterData.verifyState == 5 || waterData.verifyState != 3 && waterData.verifyState != 4" (click)="save()"><mat-icon>save</mat-icon>保存</span>
<span class="submitAudit" *ngIf="!waterData.contentVerify || waterData.contentVerify.verifyState == 5" (click)="submitAudit()"><mat-icon>open_in_browser</mat-icon>提交审核</span>
<span class="state" *ngIf="waterData.contentVerify && waterData.contentVerify.verifyState == 3" (click)="cancelAudit()">撤销审核</span>
<span class="save state" *ngIf="!waterData.contentVerify || waterData.contentVerify.verifyState == 5" (click)="save()"><mat-icon>save</mat-icon>保存</span>
<span class="close" (click)="close()"><mat-icon>close</mat-icon>关闭</span>
</div>
</div>

2
src/app/data-collection/water-collection/water-collection.component.scss

@ -252,7 +252,7 @@
}
}
span:hover{
text-decoration: underline;
// text-decoration: underline;
}
.state{
margin-right:30px;

57
src/app/data-collection/water-collection/water-collection.component.ts

@ -244,16 +244,34 @@ export class WaterCollectionComponent implements OnInit {
e.stopPropagation()
let isDelete = window.confirm('确定要删除此条水源信息吗')
if(isDelete){
this.http.delete(`/api/WaterSources/${item.id}`).subscribe(data => {
const config = new MatSnackBarConfig();
// this.http.delete(`/api/WaterSources/${item.id}`).subscribe(data => {
// const config = new MatSnackBarConfig();
// config.verticalPosition = 'top';
// config.duration = 3000
// this.addWaterListData.items = this.addWaterListData.items.filter(x => {
// return item.id != x.id
// })
// this.dataLength = this.dataLength - 1
// this.snackBar.open('删除成功','确定',config);
// })
let body = {
title: item.name,
operation: 2,//删除操作方式
contentType: 12,//水源类型
itemId: item.id,
verifyState: 3,
}
this.http.post('/api/ContentVerifies',body).subscribe((data) => {
let config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.addWaterListData.items = this.addWaterListData.items.filter(x => {
return item.id != x.id
})
this.dataLength = this.dataLength - 1
// this.getAllWaterData()
this.snackBar.open('删除成功','确定',config);
this.snackBar.open('删除审核提交成功','确定',config);
this.addWaterListData.items.forEach(element => {
if(element.id == item.id){
element.contentVerify = data
}
});
})
}
}
@ -435,24 +453,37 @@ export class WaterCollectionComponent implements OnInit {
submitAudit(){
let isTrue = window.confirm('请确认保存后提交审核,否则将无法审核最新内容,是否继续?')
if(isTrue){
console.log('提交审核的水源',this.waterData)
// console.log('提交审核的水源',this.waterData)
let body = {
title: this.waterData.name,
operation: this.waterData.verifyState == -1 ? 0 : 1,//操作方式
operation: this.waterData.contentVerify ? 1 : 0,//操作方式
contentType: 12,//水源类型
itemId: this.waterData.id,
verifyState: 3,
}
this.http.post('/api/ContentVerifies',body).subscribe((data) => {
console.log('提交成功',data)
this.waterData.verifyState = 3
this.waterData.contentVerify = data
let config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('提交成功','确定',config);
})
}
}
//撤销审核
cancelAudit(){
let isTrue = window.confirm('您确认要撤销该审核吗?')
if(isTrue){
// console.log('撤销审核的水源',this.waterData)
this.http.delete(`/api/ContentVerifies/${this.waterData.contentVerify.id}`).subscribe((data) => {
this.waterData.contentVerify = null
let config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('撤销成功','确定',config);
})
}
}
//关闭
close(){

2
src/app/key-unit/basicinfo/basicinfo.component.html

@ -112,7 +112,7 @@
<mat-spinner *ngIf="isspinner" diameter= 50></mat-spinner>
</div>
<div class="image" (click)="closeorganizationbox()">
<input id="selectedfile" type="file" ng2FileSelect [uploader]="uploader" (change)="filechange($event)" name="imgFile" accept=".jpg,.png,.jpeg,.gif,.webp">
<input id="selectedfile" type="file" ng2FileSelect [uploader]="uploader" (change)="filechange($event)" name="imgFile" accept=".jpg,.png,.jpeg">
</div>
<div class="addbtn">
<button type="submit" color="primary" class="submit1" mat-button mat-raised-button>保存</button>

36
src/app/key-unit/basicinfo/basicinfo.component.ts

@ -103,7 +103,9 @@ export class BasicinfoComponent implements OnInit {
element.data = []
});
this.houses = data
this.getBuildingInfo()
if(this.houses.length != 0){
this.getBuildingInfo()
}
})
}
@ -513,9 +515,12 @@ export class BasicinfoComponent implements OnInit {
selectedTabChange(e){
// console.log(e)
this.selectedBuildingIndex = e.index
if((this.houses[this.selectedBuildingIndex].data && !this.houses[this.selectedBuildingIndex].data.length) || !this.houses[this.selectedBuildingIndex].data){
this.getBuildingInfo()
if(this.houses.length != 0){
if((this.houses[this.selectedBuildingIndex].data && !this.houses[this.selectedBuildingIndex].data.length) || !this.houses[this.selectedBuildingIndex].data){
this.getBuildingInfo()
}
}
}
//表格加一行
addline(ele){
@ -660,11 +665,30 @@ export class BasicinfoComponent implements OnInit {
image.src = reader.result
}
setTimeout(() => {
if(image.width>=4096 || image.height>=5000 ){
if(this.file.type.indexOf('image') == -1){
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('请上传图片','确定',config);
if((<HTMLInputElement>document.getElementById('selectedfile'))){
(<HTMLInputElement>document.getElementById('selectedfile')).value = null //清空input框缓存
}
}else if(this.file.name.toLowerCase().indexOf('png') == -1 && this.file.name.toLowerCase().indexOf('jpg') == -1 && this.file.name.toLowerCase().indexOf('jpeg') == -1){
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('请上传图片后缀为png,jpg,jpeg的文件','确定',config);
if((<HTMLInputElement>document.getElementById('selectedfile'))){
(<HTMLInputElement>document.getElementById('selectedfile')).value = null //清空input框缓存
}
}else if(image.width>=4096 || image.height>=5000 ){
const config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('请选择分辨率小于4096*5000的图片','确定',config);
if((<HTMLInputElement>document.getElementById('selectedfile'))){
(<HTMLInputElement>document.getElementById('selectedfile')).value = null //清空input框缓存
}
}else{
if(this.file){
this.startUploading()
@ -856,7 +880,9 @@ export class BasicinfoComponent implements OnInit {
}
]
}
this.http.post("/api/Buildings",addbody).subscribe(data=>{//首先创建建筑成功了,需要刷出当前建筑类型的模板
this.http.post("/api/Buildings",addbody,{params:{
companyId : this.unitId
}}).subscribe(data=>{//首先创建建筑成功了,需要刷出当前建筑类型的模板
// alert('创建主体建筑成功')
this.getUnitAllBuildings()
})

Loading…
Cancel
Save