/* * @Date: 2023-08-14 13:47:51 * @Author: @zyh * @LastEditTime: 2023-08-25 10:27:32 * @Descripttion: */ import { LightningElement,wire,track,api} from 'lwc'; import { CurrentPageReference,NavigationMixin } from "lightning/navigation"; import { CloseActionScreenEvent } from 'lightning/actions'; import { encodeDefaultFieldValues } from 'lightning/pageReferenceUtils'; import { ShowToastEvent } from 'lightning/platformShowToastEvent'; import init from '@salesforce/apex/lexUpdateDateController.init'; import userCheck from '@salesforce/apex/lexUpdateDateController.userCheck'; export default class LexUpdateDate extends NavigationMixin(LightningElement) { @api recordId; @wire(CurrentPageReference) getStateParameters(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(this.recordId); this.IsLoading = false; init({ recordId: this.recordId }).then(result => { console.log(result.status2.slice(0,1) > 5,'=================1'); console.log(result.status2.slice(0,1) ,'=================1-1'); console.log(result.status2.slice(0,1) < 3,'=================2'); if((result.status2.slice(0,1) >= 5 && result.status2 != '5.盖章完毕') || result.status2.slice(0,1) < 3){ const evt = new ShowToastEvent({ title : '', message : '当前合同不支持修改合同日期,不能申请改期', variant : 'error', mode : 'sticky' }); this.dispatchEvent(evt); this.dispatchEvent(new CloseActionScreenEvent()); console.log("当前合同不支持修改合同日期,不能申请改期"); return; } userCheck({}).then(result => { if(result.adminId || result.Alias == '高文君' || result.Alias == '王良'){ let defaultValues = { Maintenance_Contract__c : this.recordId } this[NavigationMixin.Navigate]({ type: 'standard__objectPage', attributes: { objectApiName: 'Maintenance_New_Update__c', // 要新建的对象API actionName: 'new' }, state:{ // defaultFieldValues:'Repair__c='+this.repairName// 要复制的字段API // defaultFieldValues:this.dataFields// 要复制的字段API defaultFieldValues:encodeDefaultFieldValues(defaultValues)// 要复制的字段API } }); console.log('236===row' , defaultValues); }else { const evt = new ShowToastEvent({ title : '', message : '您没有修改合同日期的权限,不能申请改期', variant : 'error', mode : 'sticky' }); this.dispatchEvent(evt); this.dispatchEvent(new CloseActionScreenEvent()); return; } }) }).catch(error => { console.log("error"); console.log(error); }).finally(() => { }); } }