import { LightningElement,api, track, wire } from 'lwc'; import {CurrentPageReference} from 'lightning/navigation'; import { ShowToastEvent } from 'lightning/platformShowToastEvent'; import { CloseActionScreenEvent } from 'lightning/actions'; import LightningConfirm from 'lightning/confirm'; import init from '@salesforce/apex/SubmitAndRefreshController.init'; import submitApproval from '@salesforce/apex/HosipitalToDeptController.submitApproval'; import lwcCSS from '@salesforce/resourceUrl/lwcCSS'; import {loadStyle} from 'lightning/platformResourceLoader' export default class LexSampleInventory extends LightningElement { @api recordId; IsLoading=true; @wire(CurrentPageReference) getStateParameters(currentPageReference){ console.log("进入页面"); console.log(this.recordId); console.log(currentPageReference); console.log('1111111111'); if(currentPageReference){ const urvalue=currentPageReference.state.recordId; if(urvalue){ let str=`${urvalue}`; this.recordId=str; } } console.log(this.recordId); } connectedCallback(){ Promise.all([ loadStyle(this, lwcCSS) ]); init({recordId:this.recordId}).then(result=>{ this.IsLoading = false console.log('init result==========',result); if(result!=null){ // WYL DB202311402675【客户】客户页面增加备品送货地址栏 start if (result.isuploadfile == '0' && result.ChangeReason != '备品送货地址维护' || !result.isuploadfile && result.ChangeReason !='备品送货地址维护') { this.showToast('请上传客户变更申请信息附件','error'); return; } // WYL DB202311402675【客户】客户页面增加备品送货地址栏 end var accname=result.hospitalName.substr(-2,2); console.log(accname) if((accname =='公司' || accname =='集团') && result.attributeType !='企业集团'){ // this.showToast('客户为公司或集团,医院性质不是企业集团,请核实医院性质,确认是否提交?','error'); LightningConfirm.open({ message: "客户为公司或集团,医院性质不是企业集团,请核实医院性质,确认是否提交?", variant: 'headerless', label: '提示信息', // setting theme would have no effect }).then(res => { if(!res){ this.dispatchEvent(new CloseActionScreenEvent()); return; }else{ LightningConfirm.open({ message: "一旦提交此记录以待批准,根据您的设置您可能不再能够编辑此记录或将他从批准过程中调回。是否继续?", variant: 'headerless', label: '提示信息', // setting theme would have no effect }).then(res => { if(!res){ this.dispatchEvent(new CloseActionScreenEvent()); return; }else{ this.submit() } }) } }) }else{ LightningConfirm.open({ message: "一旦提交此记录以待批准,根据您的设置您可能不再能够编辑此记录或将他从批准过程中调回。是否继续?", variant: 'headerless', label: '提示信息', // setting theme would have no effect }).then(res => { if(!res){ this.dispatchEvent(new CloseActionScreenEvent()); return; }else{ this.submit() } }) } // if (!confirm("一旦提交此记录以待批准,根据您的设置您可能不再能够编辑此记录或将他从批准过程中调回。是否继续?")) { // return; // } // submitApproval({recordId:this.recordId}).then(res => { // this.IsLoading = false // console.log(res,'<======res') // this.showToast(res,'success') // }).catch(err => { // this.IsLoading = false // console.log(err,'<======err') // this.showToast(err,'error') // }) } }); // console.log('connectedCallback'); // submitApproval({recordId:this.recordId}).then(rep => { // console.log(rep); // if(rep==='OK'){ // console.log('1'); // this.showToast('提交审批成功','success'); // }else{ // console.log('2'); // this.showToast(rep,'error'); // } // }).catch(err => { // console.log('3'); // console.log(err); // this.showToast(err,'error'); // }) } submit(){ submitApproval({recordId:this.recordId}).then(res => { // this.IsLoading = false //chenjingwu 20231225 start if(res.includes('未找到适用批准流程')){ this.showToast('未找到适用批准流程。','error'); return; } console.log(res,'<======res') this.showToast('提交审批成功','success') //chenjingwu 20231225 end }).catch(err => { // this.IsLoading = false console.log(err,'<======err') this.showToast(err,'error') }) } showToast(msg, type) { if(type == 'success'){ const event = new ShowToastEvent({ message: msg, variant: type }); this.dispatchEvent(event); window.location.href = '/lightning/r/Account_Delay_Apply__c/'+this.recordId+'/view'; }else{ const event = new ShowToastEvent({ message: msg, variant: type, mode:'Sticky' }); this.dispatchEvent(event); } this.dispatchEvent(new CloseActionScreenEvent()); } }