From 0ca03feca4c043ea0e7f40334d01ddc881922990 Mon Sep 17 00:00:00 2001 From: SHAOJIAHAO <55341701@qq.com> Date: Fri, 20 May 2022 08:46:18 +0800 Subject: [PATCH] =?UTF-8?q?[=E5=AE=8C=E5=96=84]=E9=A2=84=E8=AD=A6=E5=BC=B9?= =?UTF-8?q?=E7=AA=97=E6=9F=A5=E7=9C=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../get-out-of-line-details.component.html | 13 ++++-- .../get-out-of-line-details.component.ts | 45 ++++++++++++++++++- 2 files changed, 52 insertions(+), 6 deletions(-) diff --git a/src/app/pages/today-warning/get-out-of-line-details/get-out-of-line-details.component.html b/src/app/pages/today-warning/get-out-of-line-details/get-out-of-line-details.component.html index 1a482a1..46ed29e 100644 --- a/src/app/pages/today-warning/get-out-of-line-details/get-out-of-line-details.component.html +++ b/src/app/pages/today-warning/get-out-of-line-details/get-out-of-line-details.component.html @@ -17,7 +17,12 @@
- + + + + + +
@@ -27,13 +32,13 @@
处置内容 - + 已进行误报处置
- 误报 + 误报 提交 已处置
diff --git a/src/app/pages/today-warning/get-out-of-line-details/get-out-of-line-details.component.ts b/src/app/pages/today-warning/get-out-of-line-details/get-out-of-line-details.component.ts index ade529f..da32c04 100644 --- a/src/app/pages/today-warning/get-out-of-line-details/get-out-of-line-details.component.ts +++ b/src/app/pages/today-warning/get-out-of-line-details/get-out-of-line-details.component.ts @@ -1,6 +1,7 @@ import { HttpClient } from '@angular/common/http'; import { Component, OnInit, Input } from '@angular/core'; import { FormBuilder, FormGroup, Validators } from '@angular/forms'; +import { DomSanitizer } from '@angular/platform-browser'; import { NzMessageService } from 'ng-zorro-antd/message'; import { NzModalRef, NzModalService } from 'ng-zorro-antd/modal'; @Component({ @@ -11,7 +12,7 @@ import { NzModalRef, NzModalService } from 'ng-zorro-antd/modal'; export class GetOutOfLineDetailsComponent implements OnInit { @Input() data: any - constructor(private fb: FormBuilder, private http: HttpClient, private message: NzMessageService, private modal: NzModalService, private initialModal: NzModalRef) { } + constructor(private fb: FormBuilder, private http: HttpClient, private message: NzMessageService, private modal: NzModalService, private initialModal: NzModalRef, private sanitizer: DomSanitizer) { } imgUrl: string @@ -21,12 +22,35 @@ export class GetOutOfLineDetailsComponent implements OnInit { isMisinformation: boolean = false//误报按钮的显隐 + + + isImage //传过来的文件是否是图片 + fileUrl ngOnInit(): void { console.log(this.data) this.details = this.data.content1 - this.imgUrl = this.data.violateImage this.vedioUrl = this.data.violateVideo this.content = this.data.handleRecord + this.imgUrl = this.data.violateImage + + + if (this.getFileType(this.imgUrl) == 'img') { + this.isImage = true + } else { + this.isImage = false + + if (this.getFileType(this.imgUrl) == 'word') { + let arr = this.imgUrl.split('.') + arr[arr.length - 1] = 'pdf' + this.fileUrl = this.sanitizer.bypassSecurityTrustResourceUrl(arr.join('.')); + } else if (this.getFileType(this.imgUrl) == 'pdf') { + this.fileUrl = this.sanitizer.bypassSecurityTrustResourceUrl(this.imgUrl); + } + + } + + + let loginUserInfo if (sessionStorage.getItem('isGasStation') == 'true') { @@ -45,6 +69,23 @@ export class GetOutOfLineDetailsComponent implements OnInit { } + //获取文件格式 + getFileType(name: string): string { + let suffix + if (name.substring(name.length - 4).includes('png') || name.substring(name.length - 4).includes('jpg') || name.substring(name.length - 4).includes('jpeg') || name.substring(name.length - 4).includes('webp')) { + suffix = 'img' + } else if (name.substring(name.length - 4).includes('doc') || name.substring(name.length - 4).includes('docx')) { + suffix = 'word' + } else if (name.substring(name.length - 4).includes('pdf')) { + suffix = 'pdf' + } + return suffix + } + + + + + selectedType: string = 'img' contentType(type) { this.selectedType = type