import { LightningElement,api, track, wire } from 'lwc';
|
import {CurrentPageReference} from 'lightning/navigation';
|
import { CloseActionScreenEvent } from 'lightning/actions';
|
import getUserId from '@salesforce/apex/LexRentalApplyControllerLWT.getUserId';
|
import getProfileName from '@salesforce/apex/LexRentalApplyControllerLWT.getProfileName';
|
import RentalApplyJumpUserId from '@salesforce/apex/LexRentalApplyControllerLWT.RentalApplyJumpUserId';
|
import init from '@salesforce/apex/LexSelectSubstituteControllerLWT.initFromSelectSubstituteButton';
|
import selectRentalApplyEquipmentSetByID from '@salesforce/apex/LexSelectSubstituteControllerLWT.selectRentalApplyEquipmentSetByID';
|
import selectRentalApplyEquipmentSetByRACID from '@salesforce/apex/LexSelectSubstituteControllerLWT.selectRentalApplyEquipmentSetByRACID';
|
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
|
|
export default class lexRentalApplyJump extends LightningElement {
|
|
@api recordId;
|
id;
|
@api rentalApplyIds;
|
RentalApplyId;
|
//提示信息
|
msg;
|
IsLoading=true;
|
|
@wire(CurrentPageReference)
|
getStateParameters(currentPageReference){
|
console.log("进入页面");
|
console.log(currentPageReference);
|
if(currentPageReference){
|
const urvalue=currentPageReference.state.recordId;
|
if(urvalue){
|
let str=`${urvalue}`;
|
console.log('str');
|
console.log(str);
|
this.recordId=str;
|
}
|
}
|
}
|
|
|
|
connectedCallback(){
|
console.log(this.recordId);
|
init({recordId:this.recordId}).then(result=>{
|
if(result!=null){
|
this.id=result.id;
|
this.RentalApplyId=result.RentalApplyId;
|
this.cancelSubmit().then(res=>{
|
this.IsLoading=false;
|
this.dispatchEvent(new CloseActionScreenEvent());
|
});
|
}
|
}).catch(err=>{
|
console.log("error:");
|
console.log(err);
|
}).finally(()=>{
|
|
});
|
}
|
|
|
|
async cancelSubmit(){
|
// 可分配代替品前提1 -- 备品借出申请的状态:“已批准”到“已出库指示”
|
// 20231007 ljh update start
|
// var userIdArr = ['00510000001O6HoAAK','00510000001O6I2AAK','00510000000gW9pAAE','00510000000gW9BAAU','00510000008pVbWAAU','00510000001OOMjAAO',
|
// '00510000005sEEMAA2','00510000004pNOtAAM','00510000005QJ2eAAG','00510000007iCmcAAE','00510000006kIg8AAE','00510000004rbkzAAA','00510000003LMHuAAO',
|
// '00510000000gW92AAE'];
|
var userIdArr;
|
await RentalApplyJumpUserId().then(res=>{
|
if(res != null){
|
userIdArr=res.split(',');
|
}
|
}).catch(err=>{
|
console.log("RentalApplyJumpUserId==="+err);
|
})
|
// 20231007 ljh update end
|
//当前用户登录id
|
var userId;
|
await getUserId().then(res=>{
|
userId=res;
|
})
|
.catch(err=>{
|
console.log("getUserIderr==="+err);
|
})
|
|
//当前用户登录简档 备品智能化添加 du 20240108 start
|
var profileName;
|
await getProfileName().then(res=>{
|
profileName=res;
|
})
|
.catch(err=>{
|
console.log("getProfileNameerr==="+err);
|
})
|
//当前用户登录简档 备品智能化添加 du 20240108 end
|
//TODO====
|
console.log("userId==="+userId);
|
console.log("profileName==="+profileName);
|
//当前用户登录简档 备品智能化添加 du 20240108 start 增加2B1简档权限
|
if(userIdArr.indexOf(userId)== -1 && profileName != '2B1_备品中心受理窗口'){
|
this.msg = '对不起你没有此操作的权限!';
|
this.IsLoading = false;
|
return;
|
} else {
|
console.log('this.rentalApplyIds=='+this.rentalApplyIds);
|
if(this.rentalApplyIds == undefined || this.rentalApplyIds.length<1){
|
this.msg = '请选择借出备品一览记录';
|
this.IsLoading = false;
|
return;
|
}else{
|
let raid = this.RentalApplyId;
|
await selectRentalApplyEquipmentSetByRACID({recordId:this.recordId}).then(res=>{
|
console.log('selectRentalApplyEquipmentSetByRACID=='+JSON.stringify(res));
|
|
var allRecords = res;
|
var validSize= allRecords.length;
|
var canJump = false;
|
for(var i=0;i<validSize;i++){
|
if(allRecords[i].Allow_Adjust_Queue_Flag__c == true){
|
canJump = true;
|
break;
|
}
|
}
|
if(canJump == true){
|
this.msg = '选择借出备品一览记录有已经允许插队的,请选择未允许的一览';
|
this.IsLoading = false;
|
return;
|
}else{
|
let records=[this.recordId];
|
window.open("/apex/RentalApplyJump?objId="+this.recordId+"&raesIds="+ this.rentalApplyIds, 'RentalApplyJump', 'width=750,height=300');
|
this.closeAction();
|
}
|
})
|
.catch(error=>{
|
console.log('selectRentalApplyEquipmentSetByRACIDerr==='+error);
|
})
|
}
|
}
|
}
|
|
closeAction() {
|
//返回当前的备品申请
|
window.open("/"+this.recordId,'_self');
|
}
|
}
|