import { LightningElement,api, track, wire } from 'lwc'; import {CurrentPageReference} from 'lightning/navigation'; import { CloseActionScreenEvent } from 'lightning/actions'; import { ShowToastEvent } from 'lightning/platformShowToastEvent'; import { NavigationMixin } from 'lightning/navigation'; import init from '@salesforce/apex/LexNewSICustomNewController.init'; import getISOPList from '@salesforce/apex/LexNewSICustomNewController.getISOPList'; import getProfileName from '@salesforce/apex/LexNewSICustomNewController.getProfileName'; export default class lexNewSICustomNew extends NavigationMixin(LightningElement) { @api recordId; IsLoading=true; //提示信息 msg; hasError; records; recordTypeId; async connectedCallback(){ console.log(this.recordId); await init({recordId:this.recordId}).then(res=>{ console.log(1); console.log(res); this.recordTypeId=res.RecordTypeId; this.main().then(res=>{ this.IsLoading=false; if(this.msg==''){ this.dispatchEvent(new CloseActionScreenEvent()); this.closeAction(); } }) }) } async main(){ console.log("in main"); var records = new Array(); if(this.recordTypeId=='012100000006KMeAAM'){ records = await getISOPList({recordId:this.recordId}); } var RecordTypeid = this.recordTypeId; if(RecordTypeid=='012100000006KMeAAM'&&records.length!=0){ // alert("存在已有的SI需求表,不能新建SI需求表"); this.msg="存在已有的SI需求表,不能新建SI需求表"; }else if(await getProfileName() !='2S'){ // 添加新建需求表的限制 // alert("非营业部人员不能创建需求表"); this.msg="非营业部人员不能创建需求表"; }else if(RecordTypeid!='012100000006KMeAAM'){ // alert("非SI询价,不能新建SI需求表"); this.msg="非SI询价,不能新建SI需求表"; } else if(RecordTypeid=='012100000006KMeAAM'&&records.length==0){ window.top.location.href="/apex/ISO_DemandOperAndDemonsNew?OppoerID="+this.recordId; } } closeAction() { //返回当前的备品申请 window.open("/"+this.recordId,'_self'); } }