| | |
| | | import { LightningElement, track, wire, api } from 'lwc'; |
| | | import { CurrentPageReference,NavigationMixin } from 'lightning/navigation'; |
| | | import { CloseActionScreenEvent } from 'lightning/actions'; |
| | | import { ShowToastEvent } from 'lightning/platformShowToastEvent'; |
| | | import { updateRecord } from 'lightning/uiRecordApi'; |
| | | |
| | | import init from '@salesforce/apex/SubmitExtensionApprovalProcessController.init'; |
| | | import extension_approval_processCheck from '@salesforce/apex/RentalApplyWebService.extension_approval_processCheck' |
| | |
| | | connectedCallback(){ |
| | | init({ |
| | | recordId:this.recordId |
| | | }).then(result=>{ |
| | | console.log(result); |
| | | }).then(res=>{ |
| | | console.log('res==='+JSON.stringify(res)); |
| | | var today = new Date(); |
| | | //追加备品申请状态确认,已经提交过的申请,不能重复提交Status__c |
| | | if(result.ExtensionStatus == '填写完毕' || result.ExtensionStatus == '申请中') { |
| | | alert('请确认延期申请状态,已经提交过的申请,不能重复提交'); |
| | | if(res.extensionStatus == '填写完毕' || res.extensionStatus == '申请中') { |
| | | this.showToast('请确认延期申请状态,已经提交过的申请,不能重复提交','error'); |
| | | return; |
| | | } |
| | | extension_approval_processCheck({rentalApplyId:this.recordId}).then( result =>{ |
| | | extension_approval_processCheck({rentalApplyId:this.recordId}).then(result =>{ |
| | | console.log('result==='+result); |
| | | if(result != '1'){ |
| | | if(result == '2'){ |
| | | //返回值为2,判断入口为从单还是主单,如果是从单,那么就需要跳原来的单个延期页面 |
| | | if(result.RootRentalApply == '' || result.RootRentalApply == null){ |
| | | if(result.rootRentalApply == '' || result.rootRentalApply == null){ |
| | | window.open("/apex/RentalApplyMultiPostpone?parentId=" + this.recordId); |
| | | }else { |
| | | window.open("/apex/RentalApplyExtensions?parentId=" + this.recordId); |
| | | } |
| | | }else{ |
| | | alert(result); |
| | | this.dispatchEvent(new CloseActionScreenEvent()); |
| | | this.showToast(result,'error'); |
| | | return |
| | | } |
| | | }else{ |
| | | if(result.demoPurpose2 == '协议借用'){ |
| | | alert('请在[附件]内上传新的合同附件,并依据合同内期限进行日期填写,之后提交审批'); |
| | | if(res.demoPurpose2 == '协议借用'){ |
| | | this.showToast('请在[附件]内上传新的合同附件,并依据合同内期限进行日期填写,之后提交审批','error'); |
| | | return; |
| | | } |
| | | if(result.AgreementBorrowingExtensionDate =='' || result.AgreementBorrowingExtensionDate == null){ |
| | | alert('协议借用的延期申请的【协议借用延期日期】不能为空'); |
| | | console.log('typeof'+typeof(res.agreementBorrowingExtensionDate)); |
| | | if(res.agreementBorrowingExtensionDate =='' || res.agreementBorrowingExtensionDate == null){ |
| | | this.showToast('协议借用的延期申请的【协议借用延期日期】不能为空','error'); |
| | | return; |
| | | } |
| | | if(result.AgreementBorrowingExtensionDate <= result.ReturnDadelineFinal){ |
| | | alert('协议借用的延期申请的【协议借用延期日期】必须大于最新预定归还日'); |
| | | typeof(res.agreementBorrowingExtensionDate) == 'string' ? res.agreementBorrowingExtensionDate = new Date(res.agreementBorrowingExtensionDate) : ''; |
| | | typeof(res.returnDadelineFinal) == 'string' ? res.returnDadelineFinal = new Date(res.returnDadelineFinal) : ''; |
| | | if(res.agreementBorrowingExtensionDate <= res.returnDadelineFinal){ |
| | | this.showToast('协议借用的延期申请的【协议借用延期日期】必须大于最新预定归还日','error'); |
| | | return; |
| | | } |
| | | if(result.AgreementBorrowingExtensionDate <= today ){ |
| | | alert('协议借用的延期申请的【协议借用延期日期】必须大于今天'); |
| | | if(res.agreementBorrowingExtensionDate <= today ){ |
| | | this.showToast('协议借用的延期申请的【协议借用延期日期】必须大于今天','error'); |
| | | return; |
| | | } |
| | | } |
| | |
| | | console.log('error====>'+err); |
| | | }) |
| | | } |
| | | |
| | | showToast(msg,type) { |
| | | const event = new ShowToastEvent({ |
| | | message: msg, |
| | | variant: type |
| | | }); |
| | | if(type == 'success'){ |
| | | this.updateRecordView(); |
| | | } |
| | | this.dispatchEvent(event); |
| | | this.dispatchEvent(new CloseActionScreenEvent()); |
| | | } |
| | | |
| | | updateRecordView(recordId) { |
| | | updateRecord({fields: { Id: recordId }}); |
| | | } |
| | | } |