import { LightningElement,wire,track,api} from 'lwc';
|
import { CurrentPageReference } from "lightning/navigation";
|
import { CloseActionScreenEvent } from 'lightning/actions';
|
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
|
|
import updateLastMc from '@salesforce/apex/lexToAddMaintenanceContractController.updateLastMc';
|
|
|
export default class lexUpdateLastMc extends LightningElement {
|
@api recordId;
|
|
|
@wire(CurrentPageReference)
|
getStateParameters(currentPageReference) {
|
if (currentPageReference) {
|
const urlValue = currentPageReference.state.recordId;
|
if (urlValue) {
|
let str = `${urlValue}`;
|
this.recordId = str;
|
}
|
}
|
}
|
|
connectedCallback(){
|
updateLastMc({
|
recordId: this.recordId
|
}).then(returnData => {
|
|
console.log(returnData);
|
this.dispatchEvent(new CloseActionScreenEvent());
|
// /lightning/r/Report/00O100000058Bzh/view?fv0={!Maintenance_Contract_Estimate__c.Name}
|
if(returnData !='2') {
|
window.open(returnData);
|
} else {
|
this.showToast('报表错误,请联系管理员','error');
|
}
|
|
this.IsLoading = false;
|
})
|
}
|
showToast(msg,type) {
|
if(type == 'success'){
|
const event = new ShowToastEvent({
|
message: msg,
|
variant: type
|
});
|
this.dispatchEvent(event);
|
}else{
|
const event = new ShowToastEvent({
|
message: msg,
|
variant: type,
|
mode: 'sticky'
|
});
|
this.dispatchEvent(event);
|
}
|
}
|
}
|
|
// old js
|
/*var excuteFoo =function () {
|
var mcpid = '{!MaintanceContractPackEstimate__c.Id}';
|
// 1、编写SQL通过报价的ID 获取大合同的Id
|
var mapcSql = "select id,name from MaintanceContractPack__c where Estimation_Id__r.id ='"+mcpid+"'";
|
var mpcsqlResult = sforce.connection.query(mapcSql);
|
var records = mpcsqlResult.getArray("records");
|
var msg = '';
|
for(var i=0;i<records.length;i++) {
|
mc = records[0];
|
console.log('result:'+mc.Id);
|
// 2、通过大合同的id获取小合同的ID
|
var mccSql = "select id,Name,LastMContract1_NO__c,LastMContract2_NO__c,LastMContract3_NO__c,LastMContract4_NO__c,LastMContract5_NO__c from Maintenance_Contract__c where MaintanceContractPack__c='"+mc.Id+"'";
|
var mccsqlResult = sforce.connection.query(mccSql);
|
var records2 = mccsqlResult.getArray("records");
|
for(var i=0;i<records2.length;i++){
|
mc2 = records2[i];
|
if(mc2.LastMContract1_NO__c != null && mc2.LastMContract1_NO__c!= ''){
|
msg+=mc2.LastMContract1_NO__c+',';
|
}
|
if(mc2.LastMContract2_NO__c != null && mc2.LastMContract2_NO__c!= ''){
|
msg+=mc2.LastMContract2_NO__c+',';
|
}
|
if(mc2.LastMContract3_NO__c != null && mc2.LastMContract3_NO__c!= ''){
|
msg+=mc2.LastMContract3_NO__c+',';
|
}
|
if(mc2.LastMContract4_NO__c != null && mc2.LastMContract4_NO__c!= ''){
|
msg+=mc2.LastMContract4_NO__c+',';
|
}
|
if(mc2.LastMContract5_NO__c != null && mc2.LastMContract5_NO__c!= ''){
|
msg+=mc2.LastMContract5_NO__c+',';
|
}
|
}
|
}
|
msg = msg.substring(0, msg.length - 1);
|
console.log('result:'+msg);
|
window.open('/00O6D000000UpHI?pv0='+msg);
|
}
|
excuteFoo();*/
|