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 initSelectProfile from '@salesforce/apex/buttonQISReportCtl.initSelectProfile';
|
import {
|
ShowToastEvent
|
} from 'lightning/platformShowToastEvent';
|
import LightningConfirm from 'lightning/confirm';
|
import lwcCSS from '@salesforce/resourceUrl/lwcCSS';
|
import {loadStyle} from 'lightning/platformResourceLoader';
|
|
export default class lexSendQISToEtQ extends LightningElement {
|
@api recordId;
|
str;
|
IsLoading = true;
|
Id;
|
userId;
|
profileId;
|
PAEDetermineC;
|
PAEDetermineACC;
|
OCMJudgementC;
|
QISFinalJudgementC;
|
ETQUPLOADSTATUSC;
|
AEDetermineResultC;
|
profileName;
|
statu = '';
|
|
@wire(CurrentPageReference)
|
getStateParameters(currentPageReference) {
|
if (currentPageReference) {
|
const urlValue = currentPageReference.state.recordId;
|
if (urlValue) {
|
let str = `${urlValue}`;
|
this.recordId = str;
|
}
|
}
|
}
|
|
connectedCallback() {
|
Promise.all([
|
loadStyle(this, lwcCSS)
|
]);
|
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;
|
|
initSelectProfile({
|
profileId: this.profileId
|
}).then(result => {
|
console.log('11111');
|
if (result != null) {
|
this.IsLoading = false;
|
this.profileName = result[0].Name;
|
|
this.myDate();
|
this.myReload();
|
}
|
})
|
}
|
}).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() {
|
if (this.profileName != "2F7_OSH担当" && this.profileName != "2F7_OSH质量法规") {
|
this.ShowToastEvent("您没有发送QIS到EtQ的权限。", "error");
|
this.dispatchEvent(new CloseActionScreenEvent());
|
return;
|
}
|
if (this.PAEDetermineC == undefined) {
|
this.ShowToastEvent("OCSM QARA的PAE判定是空的时候,不可以发送到EtQ。", "error");
|
this.dispatchEvent(new CloseActionScreenEvent());
|
return;
|
}
|
if (this.AEDetermineResultC == "nonAE" && this.PAEDetermineC == "nonPAE" && this.PAEDetermineACC == "nonPAE" && this.OCMJudgementC == undefined && this.QISFinalJudgementC == undefined) {
|
this.ShowToastEvent("nonAE并nonPAE的QIS同步到EtQ的时候,检测结论(OCSM)是必填的。不可以发送到EtQ。", "error");
|
this.dispatchEvent(new CloseActionScreenEvent());
|
return;
|
}
|
if (this.ETQUPLOADSTATUSC == "3") {
|
this.handleConfirmClick("是否清空EtQ同步状态,重新同步数据?");
|
} else {
|
this.ll();
|
}
|
}
|
|
myReload() {
|
selectQISReportC({
|
QId: this.Id
|
}).then(record => {
|
console.log(record);
|
if (record[0].AsyncData__c == 'true' && record[0].ETQ_UPLOAD_STATUS__c != '3' || record[0].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';
|
}
|
this.ShowToastEvent('该QIS之前已经发送过了', "error");
|
this.dispatchEvent(new CloseActionScreenEvent());
|
return;
|
} else {
|
this.SendQISToEtQ();
|
}
|
})
|
}
|
|
ll() {
|
if (this.AEDetermineResultC != undefined && this.PAEDetermineC != undefined && this.PAEDetermineACC == undefined) {
|
this.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 == "质量问题")) {
|
this.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 == "非质量问题"))) {
|
this.statu = "Q3";
|
}
|
updateQISReportC({
|
QId: this.Id,
|
uid: this.userId
|
}).then(result => {
|
if (result == "更新成功!") {
|
this.ShowToastEvent(result, "success");
|
this.dispatchEvent(new CloseActionScreenEvent());
|
var qisreports = new Array()
|
qisreports[0] = this.Id;
|
|
var statuArr = new Array();
|
statuArr.push(this.statu);
|
|
sendToETQ({
|
iflog_Id: "",
|
rowDataSFDC: "",
|
repairIds: qisreports,
|
statu: statuArr[0]
|
}).then(result => {
|
if (result == "发送成功!") {
|
this.ShowToastEvent(result, "success");
|
this.dispatchEvent(new CloseActionScreenEvent());
|
window.open('/lightning/r/QIS_Report__c/'+this.recordId+'/view','_self');
|
} else {
|
this.ShowToastEvent("发送QIS到EtQ失败," + result, "error");
|
this.dispatchEvent(new CloseActionScreenEvent());
|
}
|
})
|
|
var btns = document.getElementsByName("sendqistoetq");
|
for (var i = 0; i < btns.length; i++) {
|
btns[i].disabled = true;
|
btns[i].className = 'btnDisabled';
|
}
|
|
} else {
|
this.ShowToastEvent(result, "error");
|
this.dispatchEvent(new CloseActionScreenEvent());
|
}
|
})
|
|
|
|
}
|
|
// 弹窗
|
ShowToastEvent(msg, type) {
|
if (type=='success') {
|
const event = new ShowToastEvent({
|
title: '',
|
message: msg,
|
variant: type
|
});
|
this.dispatchEvent(event);
|
}else{
|
const event = new ShowToastEvent({
|
title: '',
|
message: msg,
|
variant: type,
|
mode: 'sticky'
|
});
|
this.dispatchEvent(event);
|
}
|
}
|
|
async handleConfirmClick(msg) {
|
const result = await LightningConfirm.open({
|
message: msg,
|
variant: 'headerless',
|
label: 'this is the aria-label value'
|
});
|
|
if (result) {
|
this.ll();
|
} else {
|
this.dispatchEvent(new CloseActionScreenEvent());
|
}
|
}
|
}
|