| | |
| | | import queryForCancelReportButton from '@salesforce/apex/OpportunityLightingButtonController.queryForCancelReportButton'; |
| | | import { updateRecord } from 'lightning/uiRecordApi'; |
| | | import { ShowToastEvent } from 'lightning/platformShowToastEvent'; |
| | | export default class LexCancelReport extends LightningElement { |
| | | import { NavigationMixin } from 'lightning/navigation'; |
| | | import { encodeDefaultFieldValues } from 'lightning/pageReferenceUtils'; |
| | | import lwcCSS from '@salesforce/resourceUrl/lwcCSS'; |
| | | import {loadStyle} from 'lightning/platformResourceLoader'; |
| | | import queryCancelReport from '@salesforce/apex/OpportunityLightingButtonController.queryCancelReport'; |
| | | export default class LexCancelReport extends NavigationMixin(LightningElement) { |
| | | @api recordId; |
| | | stageName; |
| | | sapSendOK; |
| | |
| | | salesManagerDepartmentID; |
| | | salesOwnerBuchang; |
| | | salesOwnerBuchangID; |
| | | recordTypeId; |
| | | haveLostReport; |
| | | IsLoading = true; |
| | | @wire(CurrentPageReference) |
| | | getStateParameters(currentPageReference) { |
| | |
| | | } |
| | | } |
| | | connectedCallback(){ |
| | | Promise.all([ |
| | | loadStyle(this, lwcCSS) |
| | | ]); |
| | | |
| | | init({ |
| | | recordId: this.recordId |
| | | }).then(result=>{ |
| | | this.stageName = result.stageName; |
| | | this.sapSendOK = result.sapSendOK; |
| | | this.cntLostCancelDraft = result.cntLostCancelDraft; |
| | | this.cntLostCancelReport = result.cntLostCancelReport; |
| | | this.jobCategory = result.jobCategory; |
| | | this.biddingProjectNameBid = result.biddingProjectNameBid; |
| | | this.name = result.name; |
| | | this.salesAssistantID = result.salesAssistantID; |
| | | this.salesAssistantName = result.salesAssistantName; |
| | | this.managerName = result.managerName; |
| | | this.salesManagerDepartmentID = result.salesManagerDepartmentID; |
| | | this.salesOwnerBuchang = result.salesOwnerBuchang; |
| | | this.salesOwnerBuchangID = result.salesOwnerBuchangID; |
| | | this.cancelReport(); |
| | | }) |
| | | console.log(result); |
| | | this.stageName = result.stageName == undefined ? '' : result.stageName; |
| | | this.sapSendOK = result.sapSendOK == undefined ? '' : result.sapSendOK; |
| | | this.cntLostCancelDraft = result.cntLostCancelDraft == undefined ? '' : result.cntLostCancelDraft; |
| | | this.cntLostCancelReport = result.cntLostCancelReport == undefined ? '' : result.cntLostCancelReport; |
| | | this.jobCategory = result.jobCategory == undefined ? '' : result.jobCategory; |
| | | this.biddingProjectNameBid = result.biddingProjectNameBid == undefined ? '' : result.biddingProjectNameBid; |
| | | this.name = result.name == undefined ? '' : result.name; |
| | | this.salesAssistantID = result.salesAssistantID == undefined ? '' : result.salesAssistantID; |
| | | this.salesAssistantName = result.salesAssistantName == undefined ? '' : result.salesAssistantName; |
| | | this.managerName = result.managerName == undefined ? '' : result.managerName; |
| | | this.salesManagerDepartmentID = result.salesManagerDepartmentID == undefined ? '' : result.salesManagerDepartmentID; |
| | | this.salesOwnerBuchang = result.salesOwnerBuchang == undefined ? '' : result.salesOwnerBuchang; |
| | | this.salesOwnerBuchangID = result.salesOwnerBuchangID == undefined ? '' : result.salesOwnerBuchangID; |
| | | this.recordTypeId = result.recordTypeId; |
| | | queryCancelReport({ |
| | | recordId: this.recordId |
| | | }).then(result=>{ |
| | | this.haveLostReport = result; |
| | | this.cancelReport(); |
| | | }); |
| | | |
| | | }).catch(error=>{ |
| | | console.log("error"); |
| | | console.log(error); |
| | | }); |
| | | } |
| | | 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()); |
| | | } |
| | | } |
| | | updateRecordView(recordId) { |
| | | updateRecord({fields: { Id: recordId }}); |
| | |
| | | |
| | | } |
| | | else if (this.sapSendOK == '1') { |
| | | this.showToast("已经上传SAP、不能做 取消 了!",""); |
| | | this.showToast("已经上传SAP、不能做 取消 了!","error"); |
| | | } |
| | | else if (this.cntLostCancelReport - this.cntLostCancelDraft > 0) { |
| | | else if (this.haveLostReport) { |
| | | this.showToast("询价已经有 取消/失单报告 了!","error"); |
| | | } |
| | | else if (this.jobCategory == '支援') { |
| | |
| | | } |
| | | //XLIU-CG98L5 【委托】【评估】新需求-招标项目/询价对应流标、废标改善 start |
| | | //else if({!NOT(ISBLANK(Opportunity.Bidding_Project_Name_Bid__c))}&& '{!Opportunity.subInfoType__c}' != '3-1:废标公告' &&'{!Opportunity.subInfoType__c}' != '3-2:流标公告'){ |
| | | else if(this.biddingProjectNameBid != undefined && sqlResult.size == 0){ |
| | | else if(this.biddingProjectNameBid != '' && sqlResult.length == 0){ |
| | | this.showToast("有招投标项目时只能做失单或部分失单报告!","error"); |
| | | } |
| | | //XLIU-CG98L5 【委托】【评估】新需求-招标项目/询价对应流标、废标改善 end |
| | | else { |
| | | location.href = '/a1U/e?retURL=%2F'+ this.recordId + |
| | | '&RecordType=01210000000R4hH' + |
| | | '&CF00N10000004lbGT=' + this.name + |
| | | '&CF00N10000004lbGT_lkid=' + this.recordId + |
| | | '&CF00N10000006QShg=' + this.salesAssistantName + |
| | | '&CF00N10000006QShg_lkid=' + this.salesAssistantID + |
| | | '&CF00N10000006QShq='+ this.managerName + |
| | | '&CF00N10000006QShq_lkid=' + this.salesManagerDepartmentID + |
| | | '&CF00N10000006QShb=' + this.salesOwnerBuchang + |
| | | '&CF00N10000006QShb_lkid=' + this.salesOwnerBuchangID + |
| | | ''; |
| | | const defaultValues = encodeDefaultFieldValues({ |
| | | Opportunity__c: this.recordId, // 关联主记录 ID |
| | | Sales_assistant__c: this.salesAssistantID, |
| | | Manager_sales__c: this.salesManagerDepartmentID, |
| | | Buchang_sales__c: this.salesOwnerBuchangID |
| | | }); |
| | | this[NavigationMixin.Navigate]({ |
| | | type: 'standard__objectPage', |
| | | attributes: { |
| | | objectApiName: 'Lost_cancel_report__c', |
| | | actionName: 'new' |
| | | }, |
| | | state: { |
| | | nooverride: '1', |
| | | defaultFieldValues: defaultValues, |
| | | recordTypeId: this.recordTypeId, |
| | | } |
| | | }); |
| | | } |
| | | this.dispatchEvent(new CloseActionScreenEvent()); |
| | | }); |