123
chenjingwu
2024-04-11 5f43dac2f19ed47ea4cd211a4c6c7f94e8dc0c25
force-app/main/default/lwc/lexDispatchOCSMQARA/lexDispatchOCSMQARA.js
@@ -1,13 +1,24 @@
/*
 * @Description:
 * @version:
 * @Author: chen jing wu
 * @Date: 2023-04-07 09:02:03
 * @LastEditors: chen jing wu
 * @LastEditTime: 2023-10-31 17:31:12
 */
import { api, wire,LightningElement } from 'lwc';
import { CurrentPageReference } from "lightning/navigation";
import { CloseActionScreenEvent } from 'lightning/actions';
import updateForDispatchOCSMQARAButton  from '@salesforce/apex/ReportController.updateForDispatchOCSMQARAButton';
import { updateRecord } from 'lightning/uiRecordApi';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import lwcCSS from '@salesforce/resourceUrl/lwcCSS';
import {loadStyle} from 'lightning/platformResourceLoader';
export default class LexDispatchOCSMQARA extends LightningElement {
    @api recordId;
    IsLoading = true;
    
    @wire(CurrentPageReference)
    getStateParameters(currentPageReference) {
@@ -25,21 +36,31 @@
        }
    }
    connectedCallback(){
        Promise.all([
            loadStyle(this, lwcCSS)
           ]);
        console.log(this.recordId);
        this.IsLoading = false;
        this.DispatchOCSMQARA();
    }
    showToast(msg,type) {
        const event = new ShowToastEvent({
            title: '',
            message: msg,
            variant: type
        });
        this.dispatchEvent(event);
        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: type,
                mode: 'sticky'
            });
            this.dispatchEvent(event);
            this.dispatchEvent(new CloseActionScreenEvent());
        }
    }
@@ -51,8 +72,13 @@
            updateForDispatchOCSMQARAButton({
                recordId: this.recordId
            }).then(result =>{
                this.showToast("成功","success");
                this.updateRecordView(this.recordId);
                if(result){
                    this.showToast(result,"error");
                }else{
                    this.showToast("成功","success");
                    this.updateRecordView(this.recordId);
                    this.IsLoading = false;
                }
                this.dispatchEvent(new CloseActionScreenEvent());
                });
    }