import { LightningElement,wire,api,track } from 'lwc';
|
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
|
import submitApproval from '@salesforce/apex/LexProductLimitApprovalCtrl.submitApproval';
|
|
export default class LexProductLimitApprovalLwc extends LightningElement {
|
|
@api recordId;
|
@track isShowSpinner = false;
|
@track comment;
|
@track sender;
|
|
connectedCallback(){
|
|
}
|
|
commentChange(event){
|
this.comment = event.detail.value;
|
}
|
|
senderChange(event){
|
this.sender = event.detail.value;
|
}
|
|
confirm(){
|
this.isShowSpinner = true;
|
submitApproval({recordId : this.recordId, comment : this.comment, sender : this.sender})
|
.then((result)=>{
|
if (result.result == 'Success') {
|
this.showToast('提交成功', '', 'success');
|
this.isShowSpinner = false;
|
this.refresh();
|
this.cancel();
|
}else{
|
console.log('Error:' + result.errorMsg);
|
this.isShowSpinner = false;
|
this.showToast(result.errorMsg, '', 'error');
|
}
|
})
|
}
|
|
cancel(){
|
this.dispatchEvent(new CustomEvent('close'));
|
}
|
|
refresh(){
|
this.dispatchEvent(new CustomEvent('refresh'));
|
}
|
|
showToast(title, message, variant) {
|
const evt = new ShowToastEvent({
|
title: title,
|
message: message,
|
variant: variant
|
});
|
this.dispatchEvent(evt);
|
}
|
}
|