黄千龙
2023-07-18 428f42fab44b654c69fbc461513203830743d7de
force-app/main/default/lwc/lexOSHInspect/lexOSHInspect.js
@@ -3,14 +3,22 @@
import { CloseActionScreenEvent } from 'lightning/actions';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import init  from '@salesforce/apex/QISReportController.initForlexOSHInspectButton';
import { updateRecord } from 'lightning/uiRecordApi';
import updateQis  from '@salesforce/apex/QISReportController.updateQisForlexOSHInspect';
/*
 * @Description: OSH检查受理
 * @Author: hql
 * @Date: 2023-07-12 09:45:19
 * @LastEditTime: 2023-07-12 15:44:33
 * @LastEditors:
 */
export default class lexOSHInspect extends LightningElement {
   @api recordId;
   IsLoading = true;
   qisReportId;
   qisStatus;
   oSHInspectionDate;
    @api recordId;
    IsLoading = true;
    qisReportId;
    qisStatus;
    oSHInspectionDate;
    err;
    @wire(CurrentPageReference)
     getStateParameters(currentPageReference) {
@@ -37,30 +45,30 @@
            this.qisReportId = result.Id;
            this.qisStatus = result.qIStatus;
            this.oSHInspectionDate = result.oSHInspectionDate;
            if (this.qisStatus!='OSH检测中') {
               const evt = new ShowToastEvent({
                            title : '需要先点击[OSH现品收到]',
                            message: '',
            if (this.qisStatus!='OSH检测中') {
                const evt = new ShowToastEvent({
                            title : '',
                            message: '需要先点击[OSH现品收到]',
                            variant: 'error'
                        });
                        this.dispatchEvent(evt);
                        this.dispatchEvent(new CloseActionScreenEvent());
                        return;
            }else if(this.oSHInspectionDate != null){
               const evt = new ShowToastEvent({
                            title : 'OSH检测已经受理',
                            message: '',
            }else if(this.oSHInspectionDate != null){
                const evt = new ShowToastEvent({
                            title : '',
                            message: 'OSH检测已经受理',
                            variant: 'error'
                        });
                        this.dispatchEvent(evt);
                        this.dispatchEvent(new CloseActionScreenEvent());
                        return;
            }else{
               this.updateQisSubmit();
            }
            }else{
                this.updateQisSubmit();
            }
    
        }).catch(error => {
            console.log('error='+error);
        }).finally(() => {
@@ -68,21 +76,23 @@
        }); 
    }
    updateQisSubmit(){
           updateQis({
               recordId: this.recordId
              }).then(result =>{
                 console.log('result'+result);
                 if (result!='成功') {
            updateQis({
                 recordId: this.recordId
                }).then(result =>{
                    console.log('result'+result);
                    if (result!='成功') {
                        this.err = result;
                        const evt = new ShowToastEvent({
                            title : '更新失败',
                            message: this.err,
                            title : '',
                            message: '更新失败'+this.err,
                            variant: 'error'
                        });
                        this.dispatchEvent(evt);
                        updateRecord({fields: { Id: this.recordId }});
                    }
                this.dispatchEvent(new CloseActionScreenEvent());
              }).catch(error => {
                updateRecord({fields: { Id: this.recordId }});
                }).catch(error => {
            console.log('error='+error);
        }).finally(() => {