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/LexSIAbortBtnController.init';
|
import setAbortSI from '@salesforce/apex/LexSIAbortBtnController.setAbortSI';
|
import LightningPrompt from 'lightning/prompt';
|
import lwcCSS from '@salesforce/resourceUrl/lwcCSS';
|
import {loadStyle} from 'lightning/platformResourceLoader';
|
//SI项目需求表 终止SI需求表
|
export default class lexSIAbortBtnEnd extends NavigationMixin(LightningElement) {
|
@api recordId;
|
IsLoading=true;
|
//提示信息
|
msg;
|
hasError;
|
rentalApplyIds;
|
decideFLG;
|
@wire(CurrentPageReference)
|
getStateParameters(currentPageReference) {
|
if (currentPageReference) {
|
const urlValue = currentPageReference.state.recordId;
|
if (urlValue) {
|
let str = `${urlValue}`;
|
this.recordId = str;
|
}
|
}
|
}
|
connectedCallback(){
|
|
Promise.all([
|
loadStyle(this, lwcCSS)
|
]);
|
init({recordId:this.recordId}).then(res=>{
|
console.log(1);
|
console.log(res);
|
this.decideFLG=res;
|
this.main().then(res=>{
|
this.dispatchEvent(new CloseActionScreenEvent());
|
})
|
})
|
}
|
|
async main(){
|
let hasError ='0';
|
let decideFLG=this.decideFLG;
|
let str;
|
if(decideFLG ==true){
|
this.msg="报价已决定,不能终止";
|
hasError ='1';
|
}else{
|
await LightningPrompt.open({
|
message: '请输入终止理由',
|
//theme defaults to "default"
|
label: '', // this is the header text
|
defaultValue: '', //this is optional
|
}).then((result) => {
|
str=result;
|
});
|
}
|
|
console.log("ttt1");
|
let ids= '';
|
if (hasError == '0') {
|
ids+= this.recordId;
|
let id = this.recordId;
|
try{
|
console.log("ttt1.1");
|
let rtn='Fin';
|
await setAbortSI({isoID:ids,AbortReason:str}).then(res=>{
|
rtn=res;
|
});
|
if(rtn!='Fin'){
|
this.showToast(rtn,'error');
|
}else{
|
// window.top.location.reload();
|
this.showToast('终止成功','success');
|
setTimeout(function() {
|
window.location.reload();
|
}, 2000);
|
}
|
}catch(e){
|
this.showToast(e,'error');
|
}
|
}
|
}
|
showToast(msg,type) {
|
if(type == 'success'){
|
const event = new ShowToastEvent({
|
message: msg,
|
variant: type
|
});
|
this.dispatchEvent(event);
|
this.dispatchEvent(new CloseActionScreenEvent());
|
}else{
|
const event = new ShowToastEvent({
|
message: msg,
|
variant: 'error',
|
// duration: 30000
|
mode: 'sticky'
|
});
|
this.IsReload=false;
|
this.dispatchEvent(event);
|
this.dispatchEvent(new CloseActionScreenEvent());
|
}
|
}
|
}
|