zz
2023-03-31 347da127ad0e5cbe95f5a1aa2782412bc056355c
force-app/main/default/lwc/lexApplicationCancelSubmit/lexApplicationCancelSubmit.js
@@ -3,10 +3,10 @@
import { CloseActionScreenEvent } from 'lightning/actions';
import { NavigationMixin } from 'lightning/navigation';
import  init  from '@salesforce/apex/ApplicationButtonController.initSubmitButton';
import UserInfo_Owner from '@salesforce/apex/TaskFeedbackController.UserInfo_Owner';
import { updateRecord } from 'lightning/uiRecordApi';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import submitCancel from '@salesforce/apex/ApplicationButtonController.submitCancel';
import UserInfo_Owner from '@salesforce/apex/ApplicationButtonController.UserInfo_Owner';
export default class Submit extends LightningElement {
    @api recordId;//OwnerId
    ownerId;
@@ -15,7 +15,6 @@
    @wire(CurrentPageReference)
     getStateParameters(currentPageReference) {
        console.log(currentPageReference);
         if (currentPageReference) {
           const urlValue = currentPageReference.state.recordId;
           if (urlValue) {
@@ -36,7 +35,6 @@
                this.ownerId = result.OwnerId;
                this.monthlyReportId = result.Id;
                this.cancelSubmit();
                this.dispatchEvent(new CloseActionScreenEvent());
            }
        }).catch(error => {
            console.log("error"+error);
@@ -46,33 +44,41 @@
    }
    cancelSubmit(){
        UserInfo_Owner({}).then(result=>{
            console.log(result,'获取当前登陆人id')
            if(this.ownerId == result.id){
        submitCancel({
            recordId: this.recordId
        }).then(e=>{
            if(e != "1"){
                }).then(requst=>{
                    if(requst == '1'){
                        this.showToast("取消提交授权信息成功","success");
                    }
                    if(requst != "1"){
                var messageage = "";
                messageage = e.split(',')[1];
                this.showToast("error",messageage,"error");
                        messageage = requst.split(',')[1];
                        this.showToast(messageage,"error");
                    }
                })
            }else{
                this.showToast("success","取消提交授权信息成功","success");
                this.updateRecordView();
                this.showToast("只授权申请书所有人可以取消提交","error");
            }
        })
    }
    updateRecordView() {
        console.log(this.recordId)
        updateRecord({fields: { Id: this.recordId }});
    }
    showToast(title,msg,type) {
        console.log(title,msg,type);
    showToast(msg,type) {
        const event = new ShowToastEvent({
            title: title,
            message: msg,
            variant: type
        });
        if(type == 'success'){
            this.updateRecordView();
        }
        this.dispatchEvent(event);
        this.dispatchEvent(new CloseActionScreenEvent());
    }
}