import { LightningElement,api, track, wire } from 'lwc';
|
import {CurrentPageReference} from 'lightning/navigation';
|
import { CloseActionScreenEvent } from 'lightning/actions';
|
import getUserId from '@salesforce/apex/lexClearReturnDeliverySlipController.getUserId';
|
import init from '@salesforce/apex/lexClearReturnDeliverySlipController.initClearReturnDeliverySlipButton';
|
import updateRaescList from '@salesforce/apex/lexClearReturnDeliverySlipController.updateRaescList';
|
import selectRacById from '@salesforce/apex/lexClearReturnDeliverySlipController.selectRacById';
|
import selectRaesdcId from '@salesforce/apex/lexClearReturnDeliverySlipController.selectRaesdcId';
|
|
import { loadScript } from 'lightning/platformResourceLoader';
|
import { submitForApproval } from 'lightning/uiRecordApi';
|
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
|
import { updateRecord } from 'lightning/uiRecordApi';
|
import lwcCSS from '@salesforce/resourceUrl/lwcCSS';
|
import {loadStyle} from 'lightning/platformResourceLoader';
|
export default class lexClearReturnDeliverySlip extends LightningElement {
|
|
@api recordId;
|
id;
|
RentalApplyId;
|
Status;
|
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(){
|
|
Promise.all([
|
loadStyle(this, lwcCSS)
|
]);
|
console.log(this.recordId);
|
init({recordId:this.recordId}).then(result=>{
|
console.log(result);
|
if(result!=null){
|
this.Rental_Apply_Equipment_Set__c=result;
|
this.cancelSubmit().then(res=>{
|
this.IsLoading=false;
|
this.dispatchEvent(new CloseActionScreenEvent());
|
});
|
}
|
}).catch(err=>{
|
console.log("error:");
|
console.log(err);
|
}).finally(()=>{
|
|
});
|
}
|
|
|
|
async cancelSubmit(){
|
console.log("hhh1");
|
var raesId = this.recordId;
|
console.log("hhh2");
|
var result = await selectRaesdcId({recordId:this.recordId});
|
console.log("hhh3");
|
var objs = result;
|
if (objs.length< 1) {
|
// alert('没有需要清空的一览明细');
|
|
this.showToast("没有需要清空的一览明细",'warning');
|
} else {
|
console.log("hhh4");
|
var result;
|
console.log("hhh5");
|
await updateRaescList({updateList:objs})
|
.then(res=>{
|
console.log(res);
|
result=res;
|
});
|
if (result.success==true) {
|
// success
|
// alert("回寄运输单信息已清空");
|
this.showToast("回寄运输单信息已清空");
|
setTimeout(function() {
|
window.location.reload();
|
}, 100);
|
} else {
|
console.log("hhh8");
|
// alert("failed to update:" + result.errors.fields + " " + result[0].errors.message);
|
this.showToast("failed to update:" + result.errors.fields + " " + result[0].errors.message,'warning');
|
}
|
}
|
}
|
|
updateRecordView(recordId){
|
updateRecord({fields:{Id:recordId}});
|
}
|
showToast(msg,type) {
|
if(type == 'success'){
|
const event = new ShowToastEvent({
|
message: msg,
|
variant: type
|
});
|
// this.updateRecordView(this.recordId);
|
this.dispatchEvent(event);
|
this.dispatchEvent(new CloseActionScreenEvent());
|
}else{
|
const event = new ShowToastEvent({
|
message: msg,
|
variant: type,
|
mode: 'sticky'
|
});
|
// this.updateRecordView(this.recordId);
|
this.dispatchEvent(event);
|
this.dispatchEvent(new CloseActionScreenEvent());
|
}
|
}
|
}
|