import { LightningElement,api, track, wire } from 'lwc';
|
import {CurrentPageReference} from 'lightning/navigation';
|
import { CloseActionScreenEvent } from 'lightning/actions';
|
import getUserId from '@salesforce/apex/RentalApplyControllerLWT.getUserId';
|
import init from '@salesforce/apex/SelectSubstituteControllerLWT.initFromSelectSubstituteButton';
|
import selectRentalApplyEquipmentSetByID from '@salesforce/apex/SelectSubstituteControllerLWT.selectRentalApplyEquipmentSetByID';
|
import selectRentalApplyEquipmentSetByRACID from '@salesforce/apex/SelectSubstituteControllerLWT.selectRentalApplyEquipmentSetByRACID';
|
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
|
|
export default class lexRentalApplyJump extends LightningElement {
|
|
@api recordId;
|
id;
|
RentalApplyId;
|
Status;
|
IsLoading=true;
|
@wire(CurrentPageReference)
|
getStateParameters(currentPageReference){
|
alert("进入页面")
|
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=>{
|
console.log(result);
|
if(result!=null){
|
this.id=result.id;
|
this.RentalApplyId=result.RentalApplyId;
|
this.Status=result.Status;
|
this.cancelSubmit().then(res=>{
|
this.IsLoading=false;
|
this.dispatchEvent(new CloseActionScreenEvent());
|
});
|
}
|
}).catch(err=>{
|
console.log("error:");
|
console.log(err);
|
}).finally(()=>{
|
|
});
|
}
|
|
|
|
async cancelSubmit(){
|
// 可分配代替品前提1 -- 备品借出申请的状态:“已批准”到“已出库指示”
|
var userIdArr = ['00510000001O6HoAAK','00510000001O6I2AAK','00510000000gW9pAAE','00510000000gW9BAAU','00510000008pVbWAAU','00510000001OOMjAAO','00510000005sEEMAA2','00510000004pNOtAAM','00510000005QJ2eAAG','00510000007iCmcAAE','00510000006kIg8AAE','00510000004rbkzAAA','00510000003LMHuAAO','00510000000gW92AAE'];
|
//当前用户登录id
|
var userId;
|
await getUserId().then(res=>{
|
userId=res;
|
});
|
console.log(userId);
|
if(userIdArr.indexOf(userId)== -1){
|
// alert('对不起你没有此操作的权限!');
|
const event = new ShowToastEvent({
|
title: '提示信息',
|
message:'对不起你没有此操作的权限!'
|
});
|
this.dispatchEvent(event);
|
} else {
|
console.log(userId);
|
let raid = this.RentalApplyId;
|
console.log("hh1");
|
await selectRentalApplyEquipmentSetByRACID({recordId:this.RentalApplyId}).then(res=>{
|
console.log(res);
|
if (res==null||res.length==0) {
|
// alert("查询结果为空");
|
const event = new ShowToastEvent({
|
title: '提示信息',
|
message:"查询结果为空"
|
});
|
this.dispatchEvent(event);
|
return;
|
}
|
var allRecords = res;
|
var validSize= allRecords.length;
|
var canJump = false;
|
for(i=0;i<validSize;i++){
|
if(allRecords[i].Allow_Adjust_Queue_Flag__c == true){
|
canJump = true;
|
break;
|
}
|
}
|
if(canJump == true){
|
// alert("选择借出备品一览记录有已经允许插队的,请选择未允许的一览");
|
const event = new ShowToastEvent({
|
title: '提示信息',
|
message:"选择借出备品一览记录有已经允许插队的,请选择未允许的一览"
|
});
|
this.dispatchEvent(event);
|
}else{
|
let records=[this.recordId];
|
window.open("/apex/RentalApplyJump?objId="+this.RentalApplyId+"&raesIds="+records, 'RentalApplyJump', 'width=700,height=300');
|
}
|
});
|
}
|
}
|
}
|