import { LightningElement,api,wire,track } from 'lwc'; import { ShowToastEvent } from 'lightning/platformShowToastEvent'; import { CloseActionScreenEvent } from 'lightning/actions'; import { CurrentPageReference,NavigationMixin } from "lightning/navigation"; import lwcCSS from '@salesforce/resourceUrl/lwcCSS'; import {loadStyle} from 'lightning/platformResourceLoader'; import SelectRentalApply from '@salesforce/apex/LexSelectConsumAddressController.SelectRentalApply'; import saveAllDatas from '@salesforce/apex/LexSelectConsumAddressController.saveAllDatas'; export default class LexSelectConsumAddress extends NavigationMixin(LightningElement) { //修改时记得将备品借出申请lexSelectMedicalInstitutionAddress 文件逻辑同步 @api recordId; @track IsLoading = true; @track RentalApply ={}; @track MedicalInstitutionAddress = []; @track flg = false; @wire(CurrentPageReference) getStateParameters(currentPageReference) { console.log(currentPageReference); if (currentPageReference) { const urlValue = currentPageReference.state.recordId; if (urlValue) { let str = `${urlValue}`; console.warn("str"); console.warn(str); this.recordId = str; } } } connectedCallback(){ Promise.all([ loadStyle(this, lwcCSS) ]); SelectRentalApply({RentalApplyId:this.recordId}).then(item=>{ debugger if(JSON.stringify(item) != "{}"){ if(item.Hospital__c){ if(item.direct_send__c !== '医疗机构'){ this.showToast('发送方不是医疗机构不可以修改医疗地址','error'); this.dispatchEvent(new CloseActionScreenEvent()); }else{ this.MedicalInstitutionAddresssup(item); var va = item.Medical_Institution_Address__c; var opt = this.MedicalInstitutionAddress for(var i=0;i 1){ this.RentalApply.Sparepartsdeliveryaddress__c = dscList[1]; this.RentalApply.detailedAddress__c = dscList[2]; } this.RentalApply.Medical_Institution_Address__c = this.RentalApply.Medical_Institution_Address__c.replaceAll('_',''); }else{ this.RentalApply.Sparepartsdeliveryaddress__c = ''; this.RentalApply.detailedAddress__c = ''; } var RentalApply = JSON.stringify(this.RentalApply); saveAllDatas({RentalApplyjson:RentalApply}).then(ret=>{ if(ret == 'success'){ this.showToast('保存成功','success'); window.open('/' +this.recordId, '_self'); }else{ this.showToast(ret,'error'); } this.IsLoading = false; }); } } showToast(msg,type) { if(type == "success"){ const event = new ShowToastEvent({ message: msg, variant: type }); this.dispatchEvent(event); this.dispatchEvent(new CloseActionScreenEvent()); }else{ const event = new ShowToastEvent({ message: msg, variant: type, mode:"sticky" }); this.dispatchEvent(event); } } }