中化加油站项目
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

315 lines
8.3 KiB

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";
import { NzTreeModule } from "ng-zorro-antd/tree";
import { ObjectsSimpleService } from "src/app/service/objectsSimple.service";
import { PublicMethodsService } from "src/app/service/publicMethods.service";
import Viewer from "viewerjs";
@Component({
selector: "app-get-out-of-line-details",
templateUrl: "./get-out-of-line-details.component.html",
styleUrls: ["./get-out-of-line-details.component.scss"],
})
export class GetOutOfLineDetailsComponent implements OnInit {
@Input() data: any;
constructor(
private objectsSrv: ObjectsSimpleService,
private fb: FormBuilder,
private http: HttpClient,
private message: NzMessageService,
private modal: NzModalService,
private initialModal: NzModalRef,
private sanitizer: DomSanitizer,
private openmodal: NzModalRef,
private pubilcMethods: PublicMethodsService
) {}
imgUrl: string;
vedioUrl: string;
content;
details;
isMisinformation: boolean = false; //误报按钮的显隐
isImage = true; //传过来的文件是否是图片
fileUrl;
isLicenseWarning = false;
isSubmit;
ngOnInit(): void {
console.log("预警信息", this.data);
if (this.data.violation.violationType == "证照资质") {
this.isLicenseWarning = true;
} else {
this.isLicenseWarning = false;
}
this.details = this.data.content1;
this.vedioUrl = this.data.violateVideo;
this.content = this.data.handleRecord;
this.imgUrl = this.data.violateImage;
if (this.imgUrl) {
if (this.pubilcMethods.getFileType(this.imgUrl) == "img") {
this.isImage = true;
} else {
this.isImage = false;
if (this.pubilcMethods.getFileType(this.imgUrl) == "word") {
let arr = this.imgUrl.split(".");
arr[arr.length - 1] = "pdf";
this.fileUrl = this.sanitizer.bypassSecurityTrustResourceUrl(
arr.join(".")
);
} else if (this.pubilcMethods.getFileType(this.imgUrl) == "pdf") {
this.fileUrl = this.sanitizer.bypassSecurityTrustResourceUrl(
this.imgUrl
);
}
}
}
let loginUserInfo;
if (sessionStorage.getItem("isGasStation") == "true") {
loginUserInfo = JSON.parse(
sessionStorage.getItem("userdataOfgasstation")
);
} else {
loginUserInfo = JSON.parse(sessionStorage.getItem("userdata"));
}
if (
loginUserInfo.userName == "admin" ||
sessionStorage.getItem("isGasStation") == "true"
) {
this.isSubmit = true;
} else {
this.isSubmit = false;
}
console.log("this.isSubmit", this.isSubmit);
if (
loginUserInfo.permissions.find((item) => {
return item.name == "Data.Violation.Positive.Censor";
}) &&
this.data.violation.eventSystemName.indexOf("证照有效期") == -1
) {
this.isMisinformation = true;
} else {
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.pubilcMethods.getFileType(item) == "word") {
let arr = item.split(".");
arr[arr.length - 1] = "pdf";
window.open(arr.join("."));
} else if (this.pubilcMethods.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);
}
selectedType: string = "img";
contentType(type) {
this.selectedType = type;
}
submit() {
let body = {
id: this.data.id,
handleRecord: this.content,
};
this.http
.post("/api/services/app/ViolateRecord/HandleViolateRecord", body)
.subscribe((data) => {
this.message.create("success", "处置成功!");
this.data.handleTime = new Date();
this.data.handleStateStr = "已处置";
this.data.handleRecord = this.content;
});
}
//误报
misinformation() {
this.modal.confirm({
nzTitle: "判定该预警为误报吗?",
nzOkText: "确定",
nzOkType: "primary",
nzOnOk: () => {
let body = {
id: this.data.id,
positive: false,
};
this.http
.post("/api/services/app/ViolateRecord/CensorViolateRecord", body)
.subscribe(
(data) => {
this.message.create("success", "处置成功!");
// this.data.handleTime = new Date()
this.initialModal.triggerOk();
},
(err) => {
this.message.create("warning", "处置失败,请联系管理员!");
}
);
},
nzCancelText: "取消",
nzOnCancel: () => console.log("Cancel"),
});
}
// 申诉
isAppeal;
appealValue;
appeal() {
this.isAppeal = true;
}
handleOk() {
let body = {
appealReason: this.appealValue,
appealAttachments: this.fileList,
};
this.http
.post("/api/services/app/ViolateRecord/Appeal", body, {
params: {
id: this.data.id,
},
})
.subscribe(
(data: any) => {
this.message.create("success", "申诉提交成功");
this.isAppeal = false;
this.data.appealStatus = 1;
this.data.appealLog = data.result.appealLog;
},
(err) => {
this.message.create("warning", "申诉提交失败,请联系管理员!");
}
);
}
handleCancel(): void {
this.isAppeal = false;
}
Unappeal() {
this.http
.post("/api/services/app/ViolateRecord/Unappeal", null, {
params: {
id: this.data.id,
},
})
.subscribe(
(data) => {
this.message.create("success", "申诉撤销成功");
this.data.appealStatus = 4;
},
(err) => {
this.message.create("warning", "申诉撤销失败,请联系管理员!");
}
);
}
closeModel() {
this.openmodal.close();
}
}