import { LightningElement,api, track, wire } from 'lwc';
|
import {CurrentPageReference} from 'lightning/navigation';
|
import { CloseActionScreenEvent } from 'lightning/actions';
|
import init from '@salesforce/apex/lexLoanerArrangedEmailLWCController.initFromLoanerArrangedEmailLButton';
|
import selectRentalApplyCByName from '@salesforce/apex/lexLoanerArrangedEmailLWCController.selectRentalApplyCByName';
|
import selectCampaignById from '@salesforce/apex/lexLoanerArrangedEmailLWCController.selectCampaignById';
|
import selectRaesById1 from '@salesforce/apex/lexLoanerArrangedEmailLWCController.selectRaesById1';
|
import selectRaesById2 from '@salesforce/apex/lexLoanerArrangedEmailLWCController.selectRaesById2';
|
import getSessionId from '@salesforce/apex/lexLoanerArrangedEmailLWCController.getSessionId';
|
import approvalCheck from '@salesforce/apex/lexLoanerArrangedEmailLWCController.approvalCheck';
|
import setRaesShipment_request from '@salesforce/apex/lexLoanerArrangedEmailLWCController.setRaesShipment_request';
|
// import { label } from '@salesforce/label';
|
import STATUS_PROCESS_STATE from '@salesforce/label/c.StatusProcessState';
|
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
|
import { updateRecord } from 'lightning/uiRecordApi';
|
import getStatusList from '@salesforce/apex/lexLoanerArrangedEmailLWCController.getStatusList';
|
import lwcCSS from '@salesforce/resourceUrl/lwcCSS';
|
import {loadStyle} from 'lightning/platformResourceLoader';
|
import TradeComplianceStatusFlagBP from '@salesforce/label/c.TradeComplianceStatusFlagBP';
|
import IFTradeComplianceAlertBP from '@salesforce/label/c.IFTradeComplianceAlertBP'
|
export default class lexLoanerArrangedEmailLWC extends LightningElement {
|
|
@api recordId;
|
@track TradeComplianceStatusFlagBP = TradeComplianceStatusFlagBP;
|
@track IFTradeComplianceAlertBP = IFTradeComplianceAlertBP;
|
id;
|
IsLoading=true;
|
ra;
|
@track statusStringg = STATUS_PROCESS_STATE;
|
@wire(CurrentPageReference)
|
getStateParameters(currentPageReference){
|
console.log(currentPageReference);
|
if(currentPageReference){
|
const urvalue=currentPageReference.state.recordId;
|
if(urvalue){
|
let str=`${urvalue}`;
|
this.recordId=str;
|
}
|
}
|
}
|
|
|
|
connectedCallback(){
|
|
Promise.all([
|
loadStyle(this, lwcCSS)
|
]);
|
let raes;
|
let campaign;
|
let campaignStatus;
|
init({
|
recordId: this.recordId
|
}).then(res=>{
|
//一览数据
|
raes = res;
|
let statusList = res.statusList;
|
//获取备品借出申请数据
|
selectRentalApplyCByName({recordId: raes.RentalApplyC}).then(result=>{
|
this.ra = result[0];
|
if(this.ra.Campaign__c != null){
|
//获取学会数据
|
selectCampaignById({recordId: ra[0].Campaign__c}).then(campaignRes=>{
|
campaign = campaignRes[0];
|
campaignStatus = campaignRes[0].Status;
|
})
|
}
|
console.log(JSON.stringify(raes)+'==='+JSON.stringify(this.ra)+'==='+JSON.stringify(campaign)+'==='+statusList);
|
//贸易合规 you
|
//var EquipmentGuaranteeFlg = '{!Rental_Apply__c.EquipmentGuaranteeFlg__c}';
|
if(TradeComplianceStatusFlagBP=='true'){
|
//if(EquipmentGuaranteeFlg==false){
|
if(raes.accDealerBlacklist == '1'){
|
this.showToast(IFTradeComplianceAlertBP,'warning');
|
return;
|
}
|
//}
|
}
|
console.log("贸易合规");
|
console.log(this.TradeComplianceStatusFlagBP);
|
console.log(this.IFTradeComplianceAlertBP);
|
console.log(result.accDealerBlacklist);
|
//贸易合规 you
|
//判断条件
|
if(this.ra.Wei_Assigned_Cnt__c > 0){
|
this.showToast("申请单内存在未分配的配套,请分配备品或分割申请单",'warning');
|
return;
|
}else if( campaignStatus == '取消'){
|
this.showToast("学会取消,不可出库指示",'warning');
|
return;
|
}else if(raes.AssignedNotShipmentC == 0){
|
this.showToast("没有可以出库指示的明细",'warning');
|
return;
|
}else if(this.ra.Demo_purpose1__c =='长期借出' && this.ra.Contract_pdf_updated__c == 0){
|
this.showToast("长期借出时,必须先上传契约书",'warning');
|
return;
|
}else if(this.ra.Repair__c != '' && this.ra.Repair__c != null && (this.ra.Repair_Final_Inspection_Date_F__c !=null && this.ra.Repair_Final_Inspection_Date_F__c != '') || (this.ra.RC_return_to_office__c != null && this.ra.RC_return_to_office__c !='')){
|
this.showToast("修理有最终检测日或修理品返送日,不可出库指示",'warning');
|
return;
|
}
|
// 20220217 ljh add OBPM市场活动联动 start
|
else if(campaign!= null && campaign.IF_Approved__c ==true && (campaign.Meeting_Approved_No__c ==null || campaign.Meeting_Approved_No__c == '')){
|
this.showToast("没有决裁号的,暂不能出借,请更新裁决信息。",'warning');
|
return;
|
}else if(campaign!= null && campaign.IF_Approved__c ==true && campaign.Meeting_Approved_No__c != '' && statusList.indexOf(campaign.Approved_Status__c)!= -1){
|
this.showToast("已申请决裁但决裁状态不符合条件。",'warning');
|
return;
|
}// 20220217 ljh add OBPM市场活动联动 end
|
else{
|
//154p 1388 yc 20211020
|
let raidString = this.ra.Id+";"+ this.recordId;
|
approvalCheck({
|
rentalApplyId: raidString
|
}).then(rs1=>{
|
rs1 = 1;
|
if(rs1 != '1'){
|
this.showToast(rs1, 'warning');
|
}else{
|
setRaesShipment_request({
|
raesid: this.recordId
|
}).then(finalResult=>{
|
console.log('finalResult==='+finalResult);
|
if(finalResult == "状态更新到已出库指示"){
|
this.showToast("状态更新到已出库指示",'success');
|
if(this.ra.Bollow_Date__c==undefined || this.ra.Bollow_Date__c == ''){
|
selectRaesById2({recordId2:this.ra.Id}).then(sqlResult=>{
|
let size = sqlResult.length;
|
console.log('sqlResult2==='+size%10 == 0 ? size/10 : parseInt(size/10) +1);
|
let length = size%10 == 0 ? size/10 : parseInt(size/10) +1;
|
for(let i = 0; i<length; i++){
|
console.log('/apex/FixtureRentalPDF?raid=' + this.ra.Id + '&page=' + i);
|
window.open('/apex/FixtureRentalPDF?raid=' + this.ra.Id + '&page=' + i);
|
}
|
}).catch(err=>{
|
console.log('selectRaesById2==='+err);
|
})
|
}else{
|
selectRaesById1({recordId1:this.ra.Id}).then(sqlResult=>{
|
let size = sqlResult.length;
|
let length = size%10 == 0 ? size/10 : parseInt(size/10) +1;
|
for(let i = 0; i<length; i++){
|
console.log('/apex/FixtureRentalPDF?raid=' + this.ra.Id + '&page=' + i);
|
window.open('/apex/FixtureRentalPDF?raid=' + this.ra.Id + '&page=' + i);
|
}
|
}).catch(err=>{
|
console.log('selectRaesById1==='+err);
|
})
|
}
|
window.location.href='/lightning/r/Rental_Apply_Equipment_Set__c/' + this.recordId + '/view';
|
}else{
|
this.showToast(finalResult,'warning');
|
}
|
}).catch(err=>{
|
console.log('setRaesShipment_requestErr==='+err);
|
})
|
}
|
}).catch(err=>{
|
console.log('approvalCheck==='+err);
|
})
|
}
|
}).catch(err=>{
|
console.log('selectRentalApplyCByName==='+err);
|
})
|
}).catch(err=>{
|
console.log('initerr===='+err);
|
})
|
}
|
|
print(raid, bollowDate){
|
let sqlResult;
|
let size;
|
let length;
|
console.log('id===='+raid + 'bollowDate==='+bollowDate);
|
if(bollowDate != ''){
|
selectRaesById1({recordId1:raid}).then(res=>{
|
sqlResult = res;
|
console.log('sqlResult1==='+sqlResult);
|
size = sqlResult.length;
|
length = size%10 == 0 ? size/10 : parseInt(size/10) +1;
|
for(let i = 0; i<length; i++){
|
window.open('/apex/FixtureRentalPDF?raid=' + raid + '&page=' + i);
|
}
|
})
|
}else{
|
selectRaesById2({recordId2:raid}).then(res=>{
|
sqlResult = res;
|
console.log('sqlResult2==='+sqlResult);
|
size = sqlResult.length;
|
length = size%10 == 0 ? size/10 : parseInt(size/10) +1;
|
for(let i = 0; i<length; i++){
|
window.open('/apex/FixtureRentalPDF?raid=' + raid + '&page=' + i);
|
}
|
})
|
}
|
|
}
|
|
showToast(msg,type) {
|
if(type == 'success'){
|
const event = new ShowToastEvent({
|
message: msg,
|
variant: type
|
});
|
// this.updateRecordView(this.recordId);
|
this.dispatchEvent(event);
|
this.dispatchEvent(new CloseActionScreenEvent());
|
}else{
|
const event = new ShowToastEvent({
|
message: msg,
|
variant: type,
|
mode: 'sticky'
|
});
|
// this.updateRecordView(this.recordId);
|
this.dispatchEvent(event);
|
this.dispatchEvent(new CloseActionScreenEvent());
|
}
|
}
|
|
updateRecordView(recordId) {
|
updateRecord({fields: { Id: recordId }});
|
}
|
}
|