import {
|
LightningElement,
|
wire,
|
api
|
} from 'lwc';
|
import {
|
CurrentPageReference
|
} from "lightning/navigation";
|
import {
|
CloseActionScreenEvent
|
} from 'lightning/actions';
|
import init from '@salesforce/apex/buttonQISReportCtl.init';
|
import sendToETQ from '@salesforce/apex/buttonQISReportCtl.sendToETQ';
|
import updateQISReportC from '@salesforce/apex/buttonQISReportCtl.updateQISReportC';
|
import selectQISReportC from '@salesforce/apex/buttonQISReportCtl.selectQISReportC';
|
|
import {
|
ShowToastEvent
|
} from 'lightning/platformShowToastEvent';
|
|
export default class LexSendQISToEtQ extends LightningElement {
|
@api recordId;
|
str;
|
IsLoading = true;
|
Id;
|
userId;
|
profileId;
|
PAEDetermineC;
|
PAEDetermineACC;
|
OCMJudgementC;
|
QISFinalJudgementC;
|
ETQUPLOADSTATUSC;
|
AEDetermineResultC;
|
|
@wire(CurrentPageReference)
|
getStateParameters(currentPageReference) {
|
if (currentPageReference) {
|
const urlValue = currentPageReference.state.recordId;
|
if (urlValue) {
|
let str = `${urlValue}`;
|
this.recordId = str;
|
}
|
}
|
}
|
|
connectedCallback() {
|
init({
|
recordId: this.recordId
|
}).then(result => {
|
console.log(result);
|
if (result != null) {
|
this.IsLoading = false;
|
this.Id = result.Id;
|
this.userId = result.userId;
|
this.profileId = result.profileId;
|
this.PAEDetermineC = result.PAEDetermineC;
|
this.PAEDetermineACC = result.PAEDetermineACC;
|
this.OCMJudgementC = result.OCMJudgementC;
|
this.QISFinalJudgementC = result.QISFinalJudgementC;
|
this.ETQUPLOADSTATUSC = result.ETQUPLOADSTATUSC;
|
this.AEDetermineResultC = result.AEDetermineResultC;
|
|
this.myDate();
|
this.myReload();
|
this.dispatchEvent(new CloseActionScreenEvent());
|
}
|
}).catch(error => {
|
console.log(error);
|
})
|
}
|
|
myDate() {
|
let messageNumber = '';
|
let today = new Date();
|
messageNumber = today.getFullYear() + '' + (today.getMonth() + 1) + '' + today.getDate() + '' + today.getHours() + '' +
|
today.getMinutes() + '' + today.getSeconds();
|
return messageNumber;
|
}
|
|
// 发送QIS到EtQ
|
SendQISToEtQ() {
|
var QId = this.Id;
|
var uid = this.userId;
|
|
if (this.profileId != "00e10000000xnoO" && this.profileId != "00e10000000hl7w") {
|
alert("您没有发送QIS到EtQ的权限。");
|
return;
|
}
|
|
if (this.PAEDetermineC == undefined) {
|
alert("OCSM QARA的PAE判定是空的时候,不可以发送到EtQ。");
|
return;
|
}
|
|
if (this.AEDetermineResultC == "nonAE" && this.PAEDetermineC == "nonPAE" && this.PAEDetermineACC == "nonPAE" && this.OCMJudgementC == undefined && this.QISFinalJudgementC == undefined) {
|
alert("nonAE并nonPAE的QIS同步到EtQ的时候,检测结论(OCSM)是必填的。不可以发送到EtQ。");
|
return;
|
}
|
|
if (this.ETQUPLOADSTATUSC == "3") {
|
if (!confirm("是否清空EtQ同步状态,重新同步数据?")) {
|
return;
|
}
|
}
|
|
var statu = '';
|
if (this.AEDetermineResultC != undefined && this.PAEDetermineC != undefined && this.PAEDetermineACC == undefined) {
|
statu = "Q1";
|
} else if (
|
(this.AEDetermineResultC != undefined && this.PAEDetermineC != undefined && this.PAEDetermineACC != "nonPAE" && this.PAEDetermineACC != undefined) ||
|
(this.AEDetermineResultC == "nonAE" && this.PAEDetermineC == "nonPAE" && this.PAEDetermineACC == "nonPAE") &&
|
((this.OCMJudgementC == undefined &&
|
this.QISFinalJudgementC == "质量问题") ||
|
((this.OCMJudgementC == "质量问题" || this.OCMJudgementC == "质量问题+非质量问题") &&
|
(this.QISFinalJudgementC == undefined || this.QISFinalJudgementC == "质量问题")) ||
|
(this.OCMJudgementC == "非质量问题" || this.OCMJudgementC == "现象未发现") &&
|
this.QISFinalJudgementC == "质量问题")) {
|
statu = "Q2";
|
} else if ((this.AEDetermineResultC == "nonAE" && this.PAEDetermineC == "nonPAE" && this.PAEDetermineACC == "nonPAE") &&
|
((this.OCMJudgementC == undefined || this.OCMJudgementC == "质量问题" || this.OCMJudgementC == "质量问题+非质量问题") && this.QISFinalJudgementC == "非质量问题") ||
|
((this.OCMJudgementC == "非质量问题" || this.OCMJudgementC == "现象未发现") && (this.QISFinalJudgementC == undefined || this.QISFinalJudgementC == "非质量问题"))) {
|
statu = "Q3";
|
}
|
try {
|
updateQISReportC({
|
QId: QId,
|
uid: uid
|
})
|
|
var qisreports = new Array()
|
qisreports[0] = this.Id;
|
|
var statuArr = new Array();
|
statuArr.push(statu);
|
|
sendToETQ({
|
iflog_Id: "",
|
rowDataSFDC: "",
|
repairIds: qisreports,
|
statu: statuArr[0]
|
}).then(result => {
|
alert(result);
|
})
|
|
alert("发送成功!")
|
var btns = document.getElementsByName("sendqistoetq");
|
for (var i = 0; i < btns.length; i++) {
|
btns[i].disabled = true;
|
btns[i].className = 'btnDisabled';
|
}
|
location.reload();
|
} catch (error) {
|
alert("发送QIS到EtQ失败" + error.faultstring + ' code:' + error.faultcode)
|
}
|
}
|
|
myReload() {
|
selectQISReportC({
|
QId: this.Id
|
}).then(record => {
|
if (record.AsyncData__c == 'true' && record.ETQ_UPLOAD_STATUS__c != '3' || record.Complaint_Number__c != null) {
|
var btns = document.getElementsByName("sendqistoetq");
|
for (var i = 0; i < btns.length; i++) {
|
btns[i].disabled = true;
|
btns[i].className = 'btnDisabled';
|
}
|
alert('该QIS之前已经发送过了')
|
} else {
|
SendQISToEtQ();
|
}
|
})
|
}
|
|
// 弹窗
|
ShowToastEvent(msg, type) {
|
const event = new ShowToastEvent({
|
title: '',
|
message: msg,
|
variant: type
|
});
|
this.dispatchEvent(event);
|
}
|
}
|