zz
2023-05-09 21a9c3ad31fc59ad6361a7635746819b8a837be8
force-app/main/default/lwc/lexApplicationSubmitButton/lexApplicationSubmitButton.js
@@ -1,15 +1,14 @@
import { LightningElement,wire,track,api} from 'lwc';
import { CurrentPageReference } from "lightning/navigation";
import { CloseActionScreenEvent } from 'lightning/actions';
import  init  from '@salesforce/apex/ApplicationButtonController.initSubmitButton';
import UserInfo_Owner from '@salesforce/apex/ApplicationButtonController.UserInfo_Owner';
import submit  from '@salesforce/apex/ApplicationButtonController.submit';
import  init  from '@salesforce/apex/OppSubmitController.initSubmitButton';
import UserInfo_Owner from '@salesforce/apex/OppSubmitController.UserInfo_Owner';
import submit  from '@salesforce/apex/OppSubmitController.submit';
import { updateRecord } from 'lightning/uiRecordApi';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
export default class lexApplicationSubmitButton extends LightningElement {
export default class Submit extends LightningElement {
    @api recordId;//OwnerId
    ownerId;//所有人id
    id;//返回值的id
    IsLoading = true;
    arrMessage = [];
@@ -24,39 +23,41 @@
         }
     }
    
    connectedCallback(){
        init({
            recordId: this.recordId
        }).then(result => {
            if (result != null) {
                this.IsLoading = false;
                this.ownerId = result.OwnerId;
                this.id = result.Id;
                this.Submit();
            }
        }).catch(() => {
        }).finally(() => {
        });
        })
    }
    Submit(){
        this.arrMessage = [];
        //获取获取当前登陆人
        this.arrMessage = [];
        UserInfo_Owner({}).then(result=>{
            if(this.ownerId == result.id){
                submit({
                    recordId: this.recordId
                }).then(requst=>{
                    if(requst == '1'){
                        this.showToast("提交授权信息成功","success");
                        this.updateRecordView();
                        this.dispatchEvent(new CloseActionScreenEvent());
                    }
                    if(requst != "1"){
                        var messageage = "";
                        this.arrMessage = requst.split(',');
                        for(let i=0;i<this.arrMessage.length;i++){ 
                            if(this.arrMessage.length-1 == i){
                                break;
                            }
                            messageage += this.arrMessage[i+1];
                            if(this.arrMessage[i+1].slice(-2) == '[]'){
                                messageage += this.arrMessage[i+1].slice(0,-4);
                            }else{
                                messageage += this.arrMessage[i+1];
                            }
                        }
                        this.showToast(messageage,"error");
                    }
@@ -66,6 +67,7 @@
            }
        })
    }
    updateRecordView() {
        updateRecord({fields: { Id: this.recordId }});
@@ -77,9 +79,6 @@
            variant: type
        });
        this.dispatchEvent(event);
        if(type == 'success'){
            this.updateRecordView();
        }
        this.dispatchEvent(new CloseActionScreenEvent());
    }
}