黄千龙
2023-08-08 1363fbac72b3c291821917fc883587c1928f1651
force-app/main/default/lwc/lexOSHRecieved/lexOSHRecieved.js
@@ -1,18 +1,23 @@
import { LightningElement,wire,track,api} from 'lwc';
import { CurrentPageReference } from "lightning/navigation";
import { CloseActionScreenEvent } from 'lightning/actions';
import { NavigationMixin } from 'lightning/navigation';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import { updateRecord } from 'lightning/uiRecordApi';
import init  from '@salesforce/apex/QISReportController.initForOSHRecievedButton';
import updateQis  from '@salesforce/apex/QISReportController.updateQis';
import { updateRecord } from 'lightning/uiRecordApi';
/*
 * @Description: OSH现品收到
 * @Author: hql
 * @Date: 2023-07-12 09:45:19
 * @LastEditTime: 2023-07-12 15:44:33
 * @LastEditors:
 */
export default class lexOSHRecieved extends LightningElement {
   @api recordId;
   IsLoading = true;
   qisReportId;
   qisStatus;
    @wire(CurrentPageReference)
    @api recordId;
    IsLoading = true;
    qisReportId;
    qisStatus;
     @wire(CurrentPageReference)
     getStateParameters(currentPageReference) {
             console.log(111);
             console.log(currentPageReference);
@@ -36,46 +41,42 @@
            this.qisReportId = result.Id;
            this.qisStatus = result.qIStatus;
            console.log('this.qisStatus='+this.qisStatus);
            if (this.qisStatus!='OSH检测申请' && this.qisStatus!='完毕') {
            if (this.qisStatus!='OSH检测申请' && this.qisStatus!='完毕') {
                const evt = new ShowToastEvent({
                        title : 'OSH已经收到实物',
                        message: '',
                        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(() => {
            
        }); 
    }
    updateRecordView(recordId) {
        updateRecord({fields: { Id: recordId }});
    }
    updateQisSubmit(){
           updateQis({
               recordId: this.recordId
              }).then(result =>{
            updateQis({
                 recordId: this.recordId
                }).then(result =>{
                    
                 console.log('result'+result);
                 if (result!='成功') {
                    console.log('result'+result);
                    if (result!='成功') {
                        const evt = new ShowToastEvent({
                            title : '更新失败',
                            message: result,
                            title : '',
                            message: '更新失败'+result,
                            variant: 'error'
                        });
                        this.dispatchEvent(evt);
                        updateRecord({fields: { Id: this.recordId }});
                    }
                this.dispatchEvent(new CloseActionScreenEvent());
                this.updateRecordView(this.recordId);
              }).catch(error => {
                updateRecord({fields: { Id: this.recordId }});
                }).catch(error => {
            console.log('error='+error);
        }).finally(() => {