import { LightningElement,api, track, wire } from 'lwc';
|
import { CurrentPageReference } from 'lightning/navigation';
|
import { CloseActionScreenEvent } from 'lightning/actions';
|
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
|
import LightningConfirm from 'lightning/confirm';
|
import init from '@salesforce/apex/LexRequestCloseController.init';
|
import getProfileId from '@salesforce/apex/LexRequestCloseController.getProfileId';
|
import updateTask from '@salesforce/apex/LexRequestCloseController.updateTask';
|
import getProfileIds from '@salesforce/apex/LexRequestCloseController.getProfileIds';
|
import { updateRecord } from 'lightning/uiRecordApi';
|
import lwcCSS from '@salesforce/resourceUrl/lwcCSS';
|
import {loadStyle} from 'lightning/platformResourceLoader';
|
export default class lexRequestClose extends LightningElement {
|
@api recordId;
|
@api isDoneRendering;
|
IsLoading=true;
|
isShow=true;
|
Status;
|
@wire(CurrentPageReference)
|
getStateParameters(currentPageReference){
|
console.log("进入页面");
|
console.log(currentPageReference);
|
if(currentPageReference){
|
const urvalue=currentPageReference.state.recordId;
|
if(urvalue){
|
let str=`${urvalue}`;
|
this.recordId=str;
|
}
|
}
|
}
|
|
|
|
connectedCallback(){
|
|
Promise.all([
|
loadStyle(this, lwcCSS)
|
]);
|
this.dispatchEvent(new CloseActionScreenEvent());
|
console.log(this.recordId);
|
init({recordId:this.recordId}).then(result=>{
|
console.log(result);
|
// this.dispatchEvent(new CloseActionScreenEvent());
|
this.Status=result.Status;
|
this.cancelSubmit().then(res=>{
|
this.isShow=false;
|
this.IsLoading=false;
|
this.dispatchEvent(new CloseActionScreenEvent());
|
const passOneEvent = new CustomEvent('closem', {
|
detail: '111'
|
});
|
this.dispatchEvent(passOneEvent);
|
});
|
}).catch(err=>{
|
// console.log("error:");
|
// console.log(err.message);
|
}).finally(()=>{
|
this.dispatchEvent(new CloseActionScreenEvent());
|
});
|
}
|
|
|
|
async cancelSubmit(){
|
if(this.Status != '未着手'&&this.Status != '進行中'){
|
const event = new ShowToastEvent({
|
message:""+'任务已结束,如需修改请联系管理员',
|
variant: 'error',
|
mode: 'sticky'
|
});
|
this.dispatchEvent(event);
|
return;
|
}else{
|
var pro = await getProfileId();
|
var fag = true;
|
var ids = await getProfileIds();
|
// pro='00e10000000s3Jp';
|
console.log("===============");
|
console.log(pro);
|
console.log(ids);
|
console.log(ids.indexOf(pro));
|
if( ids.indexOf(pro) != -1 ){
|
fag=false;
|
|
const event = new ShowToastEvent({
|
message:'不需要做授权确认',
|
variant: 'error',
|
mode: 'sticky'
|
});
|
this.dispatchEvent(event);
|
}
|
if(fag){
|
var Id = this.recordId;
|
var Status = "完了";
|
await updateTask({
|
recordId:Id,
|
Status:Status
|
}).then(res=>{
|
if(res!=null&&res.success==false){
|
var messages=res.errors[0];
|
if (messages!=null&&messages!="") {
|
const event = new ShowToastEvent({
|
message:""+messages,
|
variant: 'error',
|
mode: 'sticky'
|
});
|
this.dispatchEvent(event);
|
return;
|
}
|
}else{
|
const event = new ShowToastEvent({
|
message:'更新已完成',
|
variant:'success'
|
});
|
this.dispatchEvent(event);
|
setTimeout(function() {
|
window.location.reload();
|
}, 2000);
|
}
|
}).catch(err=>{
|
// console.log("updateRentalApplyC error:");
|
// console.log(err.message);
|
});
|
|
}
|
}
|
}
|
updateRecordView(recordId){
|
updateRecord({fields:{Id:recordId}});
|
}
|
|
}
|