import { LightningElement,wire,track,api} from 'lwc'; import { CurrentPageReference } from "lightning/navigation"; import { CloseActionScreenEvent } from 'lightning/actions'; import { ShowToastEvent } from 'lightning/platformShowToastEvent'; import LightningConfirm from 'lightning/confirm'; import init from '@salesforce/apex/lexToAddMaintenanceContractController.initMcpPreSubmit'; import updateMcDate from '@salesforce/apex/lexToAddMaintenanceContractController.updateMcDate'; import processResults from '@salesforce/apex/otherButtonMaintenanceContractCtl.processResults'; import lwcCSS from '@salesforce/resourceUrl/lwcCSS'; import {loadStyle} from 'lightning/platformResourceLoader'; import lexSendNfm103 from '@salesforce/resourceUrl/lexSendNfm103'; export default class lexCmpPreSubmit extends LightningElement { @api recordId; @wire(CurrentPageReference) getStateParameters(currentPageReference) { if (currentPageReference) { const urlValue = currentPageReference.state.recordId; if (urlValue) { let str = `${urlValue}`; this.recordId = str; } } } connectedCallback(){ Promise.all([ loadStyle(this,lwcCSS), loadStyle(this, lexSendNfm103) ]); init({ recordId: this.recordId }).then(returnData => { if(returnData) { console.log(returnData); debugger this.IsLoading = false; if(!returnData.mcp.Estimation_Id__c) { this.showToast('没有决定的报价组合,不能进行合同复核。','error'); this.dispatchEvent(new CloseActionScreenEvent()); return; } if(returnData.mcpeList.length ==0){ this.showToast('没有决定的报价组合,不能进行合同复核。','error'); this.dispatchEvent(new CloseActionScreenEvent()); return; } var dateMsg = '请先填写'; if(!returnData.mcp.OCM_Print_request__c) { dateMsg += '【OCM盖章申請】'; } if(!returnData.mcp.HP_Dealer_print__c) { dateMsg += ' 【医院(经销商)印】'; } if(!returnData.mcp.Contract_print_completed__c){ dateMsg += ' 【合同盖章完毕】'; } if(!returnData.mcp.Submit_contract_to_Financial_dept__c) { dateMsg += ' 【财务提交日】'; } if(!returnData.mcp.Contract_Conclusion_Date__c) { dateMsg += ' 【合同日】'; } if(dateMsg!='请先填写') { this.showToast(dateMsg,'error'); this.dispatchEvent(new CloseActionScreenEvent()); return; } var records = returnData.mcList; //判断小合同是否符合合同复核条件 var msg = ''; for(var i=0;i{ if(!submit){ this.dispatchEvent(new CloseActionScreenEvent()); return; } else { updateMcDate({ recordId: this.recordId }).then(result=>{ if(result=='2') { this.showToast('小合同日期更新失败','error'); this.dispatchEvent(new CloseActionScreenEvent()); return; } else { processResults({ recordId: this.recordId }).then(processResult=>{ if(processResult=='1') { this.showToast('合同复核提交申请成功!','success'); this.dispatchEvent(new CloseActionScreenEvent()); window.location.href = '/'+this.recordId; } else { this.showToast(returnData.mcp.Name+'更新失败。\n','error'); //zzm 20231121 bug修复 this.dispatchEvent(new CloseActionScreenEvent()); return; } }); } }); } }) ; } else { console.log('没有查到数据'); } }); } showToast(msg,type) { if(type == 'success'){ const event = new ShowToastEvent({ message: msg, variant: type }); this.dispatchEvent(event); }else{ const event = new ShowToastEvent({ message: msg, variant: type, mode: 'sticky' }); this.dispatchEvent(event); } } } //old js //zhangzhengmei 20230629 start /*var excuteFoo =function () { var decideEstimationId = '{!MaintanceContractPack__c.Estimation_Id__c}'; if(decideEstimationId ) { var decideEstimationSql = "select Id,Decide__c from MaintanceContractPackEstimate__c where Name='" + decideEstimationId + "' and Decide__c=true" ; var decideEstimationResult = sforce.connection.query(decideEstimationSql ); var decideEstimationRecords = decideEstimationResult.getArray("records"); if(decideEstimationRecords.length==0) { alert('没有决定的报价组合,不能进行合同复核。'); return; } } else { alert('没有决定的报价组合,不能进行合同复核。'); return; } var dateMsg = '请先填写'; console.log('mcp.OCM_Print_request__c typeof:'+typeof('{!MaintanceContractPack__c.OCM_Print_request__c}')); if(!'{!MaintanceContractPack__c.OCM_Print_request__c}') { dateMsg += '【OCM盖章申請】'; } if(!'{!MaintanceContractPack__c.HP_Dealer_print__c}') { dateMsg += ' 【医院(经销商)印】'; } if(!'{!MaintanceContractPack__c.Contract_print_completed__c}'){ dateMsg += ' 【合同盖章完毕】'; } if(!'{!MaintanceContractPack__c.Submit_contract_to_Financial_dept__c}') { dateMsg += ' 【财务提交日】'; } if(!'{!MaintanceContractPack__c.Contract_Conclusion_Date__c}') { dateMsg += ' 【合同日】'; } if(dateMsg!='请先填写') { alert(dateMsg); return; } var mcpid = '{!MaintanceContractPack__c.Id}'; console.log('mcpid ='+mcpid); var sql = "select Id,Name,Decided_Estimation__c,Status__c,MC_approval_status__c,Is_Recognition_Model_True__c,Contract_print_completed__c,Contract_quotation_or_not__c,Maintenance_Contract_No__c,upload_to_sap_time__c,upload_to_RM_time__c,old_Is_RecognitionModel__c,Payment_Plan_Sum_First__c from Maintenance_Contract__c where MaintanceContractPack__c='" + mcpid + "'"; var sqlResult = sforce.connection.query(sql); var records = sqlResult.getArray("records"); //判断小合同是否符合合同复核条件 var msg = ''; for(var i=0;i