|
|
|
@ -5,6 +5,9 @@ import { DomSanitizer } from '@angular/platform-browser';
|
|
|
|
|
import { NzMessageService } from 'ng-zorro-antd/message'; |
|
|
|
|
import { NzModalRef, NzModalService } from 'ng-zorro-antd/modal'; |
|
|
|
|
import { NzTreeModule } from 'ng-zorro-antd/tree'; |
|
|
|
|
import { ObjectsSimpleService } from 'src/app/service/objectsSimple.service'; |
|
|
|
|
import Viewer from 'viewerjs'; |
|
|
|
|
|
|
|
|
|
@Component({ |
|
|
|
|
selector: 'app-get-out-of-line-details', |
|
|
|
|
templateUrl: './get-out-of-line-details.component.html', |
|
|
|
@ -13,7 +16,7 @@ import { NzTreeModule } from 'ng-zorro-antd/tree';
|
|
|
|
|
export class GetOutOfLineDetailsComponent implements OnInit { |
|
|
|
|
@Input() data: any |
|
|
|
|
|
|
|
|
|
constructor(private fb: FormBuilder, private http: HttpClient, private message: NzMessageService, private modal: NzModalService, private initialModal: NzModalRef, private sanitizer: DomSanitizer) { } |
|
|
|
|
constructor(private objectsSrv: ObjectsSimpleService, private fb: FormBuilder, private http: HttpClient, private message: NzMessageService, private modal: NzModalService, private initialModal: NzModalRef, private sanitizer: DomSanitizer) { } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
imgUrl: string |
|
|
|
@ -88,7 +91,104 @@ export class GetOutOfLineDetailsComponent implements OnInit {
|
|
|
|
|
this.isMisinformation = false |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
fileList = [] |
|
|
|
|
|
|
|
|
|
isLoadingSave: boolean = false |
|
|
|
|
uploadIndex: string |
|
|
|
|
filechange(e) { |
|
|
|
|
this.isLoadingSave = true |
|
|
|
|
let file = e.target.files[0] || null //获取上传的文件
|
|
|
|
|
this.openFileSelect(file, `stationPhotos/${this.data.gasStation.id}/appealFile/${this.data.id}`) |
|
|
|
|
} |
|
|
|
|
//设置文件路径并上传
|
|
|
|
|
postFilePath |
|
|
|
|
async openFileSelect(file: File, extensionPath: string) { |
|
|
|
|
this.postFilePath = extensionPath; |
|
|
|
|
let fileSize = file.size || null //上传文件的总大小
|
|
|
|
|
let shardSize = 5 * 1024 * 1024 //5MB 超过5MB要分块上传
|
|
|
|
|
if (fileSize >= shardSize) // 超过5MB要分块上传
|
|
|
|
|
{ |
|
|
|
|
await this.postFileByMul(file); |
|
|
|
|
} |
|
|
|
|
else //普通上传
|
|
|
|
|
{ |
|
|
|
|
await this.postFile(file); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
//上传文件
|
|
|
|
|
async postFile(file: File) { |
|
|
|
|
await new Promise((resolve, reject) => { |
|
|
|
|
this.objectsSrv.postFile(this.postFilePath, file).subscribe(data => { |
|
|
|
|
let dataObj = data as any; |
|
|
|
|
let filePath: string = ObjectsSimpleService.baseUrl + dataObj.objectName; |
|
|
|
|
this.fileList.push(filePath) |
|
|
|
|
this.isLoadingSave = false |
|
|
|
|
resolve('success') |
|
|
|
|
}); |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 分块上传 |
|
|
|
|
* @param file
|
|
|
|
|
*/ |
|
|
|
|
postFileByMul(file: File) { |
|
|
|
|
this.objectsSrv.postFile_MultipartUpload(this.postFilePath, file).then((value) => { |
|
|
|
|
let dataObj = value as any; |
|
|
|
|
let filePath = dataObj.filePath |
|
|
|
|
this.fileList.push(filePath) |
|
|
|
|
this.isLoadingSave = false |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
lookfile(item) { |
|
|
|
|
if (!item) { |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
if (this.getFileType(item) == 'word') { |
|
|
|
|
let arr = item.split('.') |
|
|
|
|
arr[arr.length - 1] = 'pdf' |
|
|
|
|
window.open(arr.join('.')) |
|
|
|
|
} else if (this.getFileType(item) == 'pdf') { |
|
|
|
|
window.open(item) |
|
|
|
|
} else { |
|
|
|
|
this.viewImg(item) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
delete(fileList, key) { |
|
|
|
|
this.modal.confirm({ |
|
|
|
|
nzTitle: `确定要删除这个文件吗?`, |
|
|
|
|
nzOkText: '确定', |
|
|
|
|
nzOkType: 'primary', |
|
|
|
|
nzOnOk: () => { |
|
|
|
|
fileList.splice(key, 1) |
|
|
|
|
}, |
|
|
|
|
nzCancelText: '取消' |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//查看图片
|
|
|
|
|
viewImg(url) { |
|
|
|
|
let dom = document.getElementById(`viewerjs`) |
|
|
|
|
let pObjs = dom.childNodes; |
|
|
|
|
let node = document.createElement("img") |
|
|
|
|
node.style.display = "none"; |
|
|
|
|
node.src = url; |
|
|
|
|
node.id = 'img' |
|
|
|
|
dom.appendChild(node) |
|
|
|
|
setTimeout(() => { |
|
|
|
|
let viewer = new Viewer(document.getElementById(`viewerjs`), { |
|
|
|
|
hidden: () => { |
|
|
|
|
dom.removeChild(pObjs[0]); |
|
|
|
|
viewer.destroy(); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
node.click(); |
|
|
|
|
}, 0); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//获取文件格式
|
|
|
|
|
getFileType(name: string): string { |
|
|
|
@ -156,10 +256,13 @@ export class GetOutOfLineDetailsComponent implements OnInit {
|
|
|
|
|
this.isAppeal = true |
|
|
|
|
} |
|
|
|
|
handleOk() { |
|
|
|
|
this.http.post('/api/services/app/ViolateRecord/Appeal', null, { |
|
|
|
|
let body = { |
|
|
|
|
appealReason: this.appealValue, |
|
|
|
|
appealAttachments: this.fileList |
|
|
|
|
} |
|
|
|
|
this.http.post('/api/services/app/ViolateRecord/Appeal', body, { |
|
|
|
|
params: { |
|
|
|
|
id: this.data.id, |
|
|
|
|
reason: this.appealValue |
|
|
|
|
id: this.data.id |
|
|
|
|
} |
|
|
|
|
}).subscribe(data => { |
|
|
|
|
this.message.create('success', '申诉提交成功'); |
|
|
|
|