| | |
| | | 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/loanerArrangedEmailController.init'; |
| | | import getRentalApplyEquipmentSet from '@salesforce/apex/loanerArrangedEmailController.getRentalApplyEquipmentSet'; |
| | | import init from '@salesforce/apex/LoanerArrangedEmailController.init'; |
| | | import getRentalApplyEquipmentSet from '@salesforce/apex/LoanerArrangedEmailController.getRentalApplyEquipmentSet'; |
| | | import approvalCheck from '@salesforce/apex/RentalApplyWebService.approvalCheck'; |
| | | import setShipment_request from '@salesforce/apex/RentalApplyWebService.approvalCheck'; |
| | | export default class lexLoanerArrangedEmail extends LightningElement { |
| | |
| | | init({ |
| | | recordId: this.recordId |
| | | }).then(result => { |
| | | console.log(this.recordId); |
| | | let statusArr = result.statusList; |
| | | console.log('result==='+JSON.stringify(result)); |
| | | if(result != null) { |
| | | if( result.WeiAssignedCnt > 0 ) { |
| | | alert("申请单内存在未分配的配套,请分配备品或分割申请单"); |
| | | }else if(result.CampaignStatus == "取消") { |
| | | alert("学会取消,不可出库指示"); |
| | | }else if (result.RaStatus == "已出库指示" && result.AssignedNotShipment == 0){ |
| | | alert("所有的借出备品Set一览都进行过出库指示了"); |
| | | }else if (result.AssignedNotShipment == 0) { |
| | | alert("没有可以出库指示的明细"); |
| | | }else if (result.DemoPurpose1 == "长期借出" && result.ContractPdfUpdated == 0){ |
| | | alert("长期借出时,必须先上传契约书"); |
| | | }else if (result.RepairId != '' && (result.RepairFinalInspectionDateF != null && result.RepairFinalInspectionDateF != '') || (result.RCReturnToOffice != null && result.RCReturnToOffice != '')){ |
| | | alert("修理有最终检测日或修理品返送日,不可出库指示"); |
| | | }else if (result.IFApproved == "true" && (result.MeetingApprovedNo == null || result.MeetingApprovedNo == "")){ |
| | | alert("没有决裁号的,暂不能出借,请更新裁决信息。"); |
| | | }else if (result.IFApproved == "true" && result.MeetingApprovedNo != "" && result.StatusList.indexOf(records[0].Approved_Status__c) != -1){ |
| | | alert("已申请决裁但决裁状态不符合条件。"); |
| | | if( result.weiAssignedCnt > 0 ) { |
| | | this.showToast("申请单内存在未分配的配套,请分配备品或分割申请单",'error'); |
| | | }else if(result.campaignStatus == "取消") { |
| | | this.showToast("学会取消,不可出库指示",'error'); |
| | | }else if (result.raStatus == "已出库指示" && result.assignedNotShipment == 0){ |
| | | this.showToast("所有的借出备品Set一览都进行过出库指示了",'error'); |
| | | }else if (result.assignedNotShipment == 0) { |
| | | this.showToast("没有可以出库指示的明细",'error'); |
| | | }else if (result.demoPurpose1 == "长期借出" && result.contractPdfUpdated == false){ |
| | | this.showToast("长期借出时,必须先上传契约书",'error'); |
| | | }else if (result.repairId != '' && (result.repairFinalInspectionDateF != null && result.repairFinalInspectionDateF != '') || (result.rCReturnToOffice != null && result.rCReturnToOffice != '')){ |
| | | this.showToast("修理有最终检测日或修理品返送日,不可出库指示",'error'); |
| | | }else if (result.iFApproved == true && (result.meetingApprovedNo == null || result.meetingApprovedNo == "")){ |
| | | this.showToast("没有决裁号的,暂不能出借,请更新裁决信息。",'error'); |
| | | }else if (result.iFApproved == true && result.meetingApprovedNo != "" && statusArr.indexOf(result.approvedStatus) != -1){ |
| | | this.showToast("已申请决裁但决裁状态不符合条件。",'error'); |
| | | }else { |
| | | approvalCheck({ |
| | | rentalApplyId: this.recordId |
| | | }).then(res=>{ |
| | | if (res != '1') { |
| | | alert(rs1); |
| | | }).then(res1 =>{ |
| | | if (res1 != '1') { |
| | | this.showToast(res1,'error'); |
| | | } else { |
| | | //bp2 var rs2 = sforce.apex.execute("RentalApplyWebService", "reserve", {rentalApplyId: raid}); |
| | | //bp2 if (rs2 != '1') { |
| | | //bp2 alert(rs2); |
| | | //bp2 } else { |
| | | //var rs1 = sforce.apex.execute("RentalApplyWebService", "setShipment_request", {raid : "{!Rental_Apply__c.Id}"}); |
| | | |
| | | console.log('setShipment_request=='); |
| | | setShipment_request({ |
| | | raid: this.recordId |
| | | }).then(res=>{ |
| | | console.log('res==',res); |
| | | if (res == "状态更新到已出库指示") { |
| | | alert("状态更新到已出库指示"); |
| | | this.showToast("状态更新到已出库指示",'success'); |
| | | print(); |
| | | setTimeout(function() { |
| | | location.href = "/{!Rental_Apply__c.Id}"; |
| | | },100); |
| | | // setTimeout(function() { |
| | | // location.href = "/{!Rental_Apply__c.Id}"; |
| | | // },100); |
| | | }else { |
| | | alert(res); |
| | | this.showToast(res,'error'); |
| | | } |
| | | }).catch(e=>{ |
| | | console.log('approvalCheck==='+e); |
| | |
| | | var Seconds = fixTime(date.getSeconds()); |
| | | return date.getFullYear() + "-" + Month + "-" + Day + "T" + Time; |
| | | } |
| | | |
| | | 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 }}); |
| | | } |
| | | } |