import { LightningElement, track, wire, api } from 'lwc';
|
import { CurrentPageReference,NavigationMixin } from 'lightning/navigation';
|
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
|
import { CloseActionScreenEvent } from 'lightning/actions';
|
import { updateRecord } from 'lightning/uiRecordApi';
|
|
import init from '@salesforce/apex/lexConsumApplyController.init';
|
import approvalCheck from '@salesforce/apex/ConsumApplyWebService.approvalCheck';
|
import setShipment_request from '@salesforce/apex/ConsumApplyWebService.setShipment_request';
|
import getLength1 from '@salesforce/apex/lexConsumApplyController.getLength1';
|
import getLength2 from '@salesforce/apex/lexConsumApplyController.getLength2';
|
import TradeComplianceStatusFlagBP from '@salesforce/label/c.TradeComplianceStatusFlagBP';
|
import IFTradeComplianceAlertBP from '@salesforce/label/c.IFTradeComplianceAlertBP';
|
import lwcCSS from '@salesforce/resourceUrl/lwcCSS';
|
import {loadStyle} from 'lightning/platformResourceLoader';
|
export default class lexLoanerArrangedEmailConsumApply extends LightningElement {
|
@api recordId;
|
|
@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(res=>{
|
|
//贸易合规
|
if(TradeComplianceStatusFlagBP){
|
if(res.accDealerBlacklist == '1'){
|
this.showToast(IFTradeComplianceAlertBP,'warning');
|
return;
|
}
|
}
|
//贸易合规
|
if(res.weiAssignedCnt > 0){
|
this.showToast('申请单内存在未分配的耗材,请分配或分割申请单','warning');
|
return;
|
}else if(res.campaignStatus == '取消'){
|
this.showToast('学会取消,不可出库指示','warning');
|
return;
|
}else if(res.consumApplyStatus == '已出库指示' && res.assignedNotShipment == 0){
|
this.showToast('所有的耗材备品Set一览都进行过出库指示了','warning');
|
return;
|
}else if(res.assignedNotShipment == 0){
|
this.showToast('没有可以出库指示的明细','warning');
|
return;
|
}else{
|
approvalCheck({
|
ConsumApplyId: this.recordId
|
}).then(rs1=>{
|
console.log('rs1===='+rs1);
|
if(rs1 != '1'){
|
this.showToast(rs1,'warning');
|
}else{
|
setShipment_request({
|
raid: this.recordId
|
}).then(result=>{
|
console.log('result===='+result);
|
if(result == '状态更新到已出库指示'){
|
this.showToast('状态更新到已出库指示','success');
|
setTimeout(() => {
|
window.open('/apex/ConsumTrialPDF?id=' + this.recordId);
|
}, 3000);
|
// if(res.bollowDate!= '' || res.bollowDate != null){
|
// getLength1({recordId:this.recordId}).then(result1=>{
|
// window.open('/apex/ConsumTrialPDF?id={!Consum_Apply__c.Id}');
|
// })
|
// }else{
|
// getLength2({recordId:this.recordId}).then(result2=>{
|
|
// })
|
// }
|
//var length = size%10 ==0? size/10 : parseInt(size/10) +1;
|
//for(var i =0;i<length;i++){}
|
return;
|
}else{
|
this.showToast(result,'warning');
|
return;
|
}
|
})
|
}
|
})
|
}
|
})
|
}
|
|
showToast(msg,type) {
|
if(type == 'success'){
|
const event = new ShowToastEvent({
|
message: msg,
|
variant: type,
|
mode: 'sticky'
|
});
|
this.updateRecordView(this.recordId);
|
this.dispatchEvent(event);
|
this.dispatchEvent(new CloseActionScreenEvent());
|
}else{
|
const event = new ShowToastEvent({
|
message: msg,
|
variant: type,
|
mode: 'sticky'
|
});
|
this.dispatchEvent(event);
|
this.dispatchEvent(new CloseActionScreenEvent());
|
}
|
}
|
|
updateRecordView(recordId) {
|
updateRecord({fields: { Id: recordId }});
|
}
|
|
}
|