/* * @Description: 耗材现场统一收货 * @Author: [lijinhuan] * @Date: 2023-08-14 22:10:52 * @LastEditors: [lijinhuan] * @LastEditTime: 2023-10-17 10:37:23 */ import { LightningElement,wire,track,api} from 'lwc'; import { CurrentPageReference } from "lightning/navigation"; import { CloseActionScreenEvent } from 'lightning/actions'; import { updateRecord } from 'lightning/uiRecordApi'; import { ShowToastEvent } from 'lightning/platformShowToastEvent'; import all_received_fse from '@salesforce/apex/ConsumApplyWebService.all_received_fse'; import { NavigationMixin } from 'lightning/navigation'; export default class LexAllReceivedBtns extends NavigationMixin(LightningElement) { @api raid; IsLoading = true; @wire(CurrentPageReference) getStateParameters(currentPageReference) { console.log(111); console.log(currentPageReference); if (currentPageReference) { // 20231017 ljh update start // const urlValue = currentPageReference.state.raid; const urlValue = currentPageReference.state.recordId; // 20231017 ljh update end if (urlValue) { let str = `${urlValue}`; console.log("str"); console.log(str); this.raid = str; } } } connectedCallback(){ this.IsLoading = false; this.submit() } showToast(msg,type) { if(type == 'success'){ const event = new ShowToastEvent({ message: msg, variant: type, }); this.dispatchEvent(event); this.updateRecordView(this.raid); //20231101 sx add start this.dispatchEvent(new CloseActionScreenEvent()); //20231101 sx add end }else{ const event = new ShowToastEvent({ message: msg, variant: type, mode: 'sticky' }); this.dispatchEvent(event); this.dispatchEvent(new CloseActionScreenEvent()); } } updateRecordView(raid) { updateRecord({fields: { Id: raid }}); } submit(){ all_received_fse({caId:this.raid}) .then(res=>{ if(res =='现场已全部收货'){ //20231101 sx update start this.showToast(res,'success') //20231101 sx update end var url = '/'+this.raid; // window.location.href=url; const config = { type: 'standard__webPage', attributes: { url: url } }; this[NavigationMixin.Navigate](config); }else{ //20231101 sx add start this.showToast(res,'warning'); //20231101 sx add end } }) .catch(e=>{ console.log(e) }) } }