import { LightningElement, track, wire, api } from 'lwc'; import { CloseActionScreenEvent } from 'lightning/actions'; import { ShowToastEvent } from 'lightning/platformShowToastEvent'; import { CurrentPageReference,NavigationMixin } from 'lightning/navigation'; import init from '@salesforce/apex/AddSubmitApprovalProcessController.init'; export default class lexAddSubmitApprovalProcess extends LightningElement { @api recordId; IsLoading = true; RecordTypeId; @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=>{ if(result.addApprovalStatus != '草案中' || result.detailSize == 0){ this.ToastShow('没有需要审批的追加附属品'); return; } if (!confirm("一旦提交此记录以待批准,根据您的设置您可能不再能够编辑此记录或将他从批准过程中调回。是否继续?")) { this.dispatchEvent(new CloseActionScreenEvent()); return; } // 希望到货日不能早于申请提交日-0418追加 //if ('{!Rental_Apply__c.Request_shipping_day__c}' < '{!TODAY()}') { // alert('希望到货日不能早于申请提交日'); // return; // } if(result.repairId != null){ if(result.demoPurpose1 == '维修代用' && result.demoPurpose2 == '一般用户'){ if(result.repairEstimatedDateFormula == null){ this.ToastShow('一般维修无报价日,不可借用备品'); return; }else if(result.repairEstimatedDateFormula <'2019-07-01' && result.agreedDate == null){ this.ToastShow('报价日在2019/7/1之前且户同意日为空,不可借用备品'); return; } } if(result.recordTypeId !='01210000000RHIn' && result.newProductGuaranteeObject=='2: 服务多年保修' && (result.assetModelNo=='CV-V1' ||result.assetModelNo=='CV-V1(A)'||result.assetModelNo=='CV-V1(B)'||result.assetModelNo=='GIF-LV1'||result.assetModelNo=='CF-LV1L'||result.assetModelNo=='CF-LV1I'||result.assetModelNo=='MAJ-1910') &&(result.demoPurpose2=='一般用户'||result.demoPurpose2=='再修理')){ this.ToastShow('奥辉设备,保修期内不提供备品.'); return; } } }) } ToastShow(msg){ const evt = new ShowToastEvent({ title : msg, message: '', variant: 'warning' }); this.dispatchEvent(evt); this.dispatchEvent(new CloseActionScreenEvent()); } }