/* * @Date: 2023-04-03 14:21:56 * @Author: @zyh * @LastEditTime: 2023-04-04 15:15:17 * @Descripttion: */ import { LightningElement,wire,track,api } from 'lwc'; import { CurrentPageReference } from "lightning/navigation"; import { CloseActionScreenEvent } from 'lightning/actions'; import { NavigationMixin } from 'lightning/navigation'; import init from '@salesforce/apex/OPDLwcController.initOPDCancelSubmit'; import RecordType from '@salesforce/apex/OPDLwcController.RecordType'; import opdSelect from '@salesforce/apex/OPDLwcController.opdSelect'; // import applySelect from '@salesforce/apex/OPDLwcController.applySelect'; import changeTrade from '@salesforce/apex/OpdPlanWebService.changeTrade'; import datacheck from '@salesforce/apex/OpdPlanWebService.dataCheck'; import { encodeDefaultFieldValues } from 'lightning/pageReferenceUtils'; export default class OpdSupplementaryApplication extends NavigationMixin(LightningElement) { @api recordId; Status; Name; Id; supplementaryApplication; OriginalOpdPlanRental; Rental_Apply2; @wire(CurrentPageReference) getStateParmeters(currentPageReference) { console.log(111); console.log(currentPageReference); if (currentPageReference) { const urlValue = currentPageReference.state.recordId; if (urlValue) { let str = `${urlValue}`; console.log("str"); console.log(str); this.recordId = str; } } } connectedCallback(){ console.log('zheli'+this.recordId); init({ recordId: this.recordId }).then(result => { console.log('zheli11'+result); console.log(result); if(result != null) { this.IsLoading = false; this.Id = result.Id; this.Status = result.Status; this.Name = result.Name; this.supplementaryApplication = result.supplementaryApplication; this.OriginalOpdPlanRental = result.OriginalOpdPlanRental; this.Rental_Apply2 = result.Rental_Apply2; console.log("123"); console.log(this.Id); console.log(this.Status); console.log(this.Name); console.log(this.supplementaryApplication); console.log(this.OriginalOpdPlanRental); this.SupApplication(); // this.updateDateSubmit(); this.dispatchEvent(new CloseActionScreenEvent()); } }).catch(error => { console.log("error"); console.log(error); }).finally(() => { }); } SupApplication(){ var opdList = []; if(this.Status != '计划中'){ alert("只有OPD计划状态为计划中,才能进行OPD补充申请"); return; } if(this.supplementaryApplication == '1'){ alert('OPD计划无法进行补充申请'); return; } if(this.OriginalOpdPlanRental != ''){ alert('请转至OPD计划原单进行申请'); return; } datacheck({ rentalApplyId : this.Rental_Apply2 }).then( result => { console.log(result); if(result != 'OK'){ alert(result); return; } }); opdSelect({ OpdId : this.Id }).then( result => { console.log(result); opdList = result; var records = opdList.getArray("records"); if(records != null && records.length > 0){ alert('OPD计划已进行过补充申请,无法再次进行补充申请'); return; } }); } }