123
chenjingwu
2024-04-16 cc914d1a68f71cf0b8fe7f1c4bfac9fc1e54e3d8
force-app/main/default/lwc/lexDispatchOCSMQARA/lexDispatchOCSMQARA.js
@@ -4,7 +4,7 @@
 * @Author: chen jing wu
 * @Date: 2023-04-07 09:02:03
 * @LastEditors: chen jing wu
 * @LastEditTime: 2023-04-11 09:07:34
 * @LastEditTime: 2023-10-31 17:31:12
 */
import { api, wire,LightningElement } from 'lwc';
import { CurrentPageReference } from "lightning/navigation";
@@ -12,6 +12,8 @@
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;
@@ -35,18 +37,30 @@
    }
    connectedCallback(){
        Promise.all([
            loadStyle(this, lwcCSS)
           ]);
        console.log(this.recordId);
        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());
        }
    }
@@ -58,9 +72,13 @@
            updateForDispatchOCSMQARAButton({
                recordId: this.recordId
            }).then(result =>{
                this.showToast("成功","success");
                this.updateRecordView(this.recordId);
                this.IsLoading = false;
                if(result){
                    this.showToast(result,"error");
                }else{
                    this.showToast("成功","success");
                    this.updateRecordView(this.recordId);
                    this.IsLoading = false;
                }
                this.dispatchEvent(new CloseActionScreenEvent());
                });
    }