|
|
|
@ -4,6 +4,7 @@ import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
|
|
|
|
import { HttpClient } from '@angular/common/http'; |
|
|
|
|
import { ObjectsSimpleService } from 'src/app/service/objectsSimple.service'; |
|
|
|
|
import Viewer from 'viewerjs'; |
|
|
|
|
import { NzMessageService } from 'ng-zorro-antd/message'; |
|
|
|
|
@Component({ |
|
|
|
|
selector: 'app-edit-file-category', |
|
|
|
|
templateUrl: './edit-file-category.component.html', |
|
|
|
@ -14,7 +15,7 @@ export class EditFileCategoryComponent implements OnInit {
|
|
|
|
|
@Input() data?: any; |
|
|
|
|
|
|
|
|
|
validateForm!: FormGroup; |
|
|
|
|
constructor(private modal: NzModalRef, private fb: FormBuilder, private http: HttpClient, private objectsSrv: ObjectsSimpleService) { } |
|
|
|
|
constructor(private modal: NzModalRef, private fb: FormBuilder, private http: HttpClient, private objectsSrv: ObjectsSimpleService,private message: NzMessageService) { } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
data2 |
|
|
|
@ -94,9 +95,21 @@ export class EditFileCategoryComponent 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 |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//查看图片
|
|
|
|
|
viewImg(url) { |
|
|
|
|
// url.split('?')[0]
|
|
|
|
|
let dom = document.getElementById(`viewerjs`) |
|
|
|
|
let pObjs = dom.childNodes; |
|
|
|
|
let node = document.createElement("img") |
|
|
|
@ -115,4 +128,20 @@ export class EditFileCategoryComponent implements OnInit {
|
|
|
|
|
}, 0); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//查看文件
|
|
|
|
|
lookFile(item) { |
|
|
|
|
if (!item.imageUrl) { |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
if (this.getFileType(item.imageUrl) == 'word') { |
|
|
|
|
let arr = item.imageUrl.split('.') |
|
|
|
|
arr[arr.length - 1] = 'pdf' |
|
|
|
|
window.open(arr.join('.')) |
|
|
|
|
} else if (this.getFileType(item.imageUrl) == 'pdf') { |
|
|
|
|
window.open(item.imageUrl) |
|
|
|
|
} else { |
|
|
|
|
this.message.create('warning', '暂不支持查看!'); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|