/* * @Description: * @version: * @Author: chen jing wu * @Date: 2023-04-20 14:08:55 * @LastEditors: chen jing wu * @LastEditTime: 2023-10-16 14:45:16 */ /* * @Description: * @version: * @Author: chen jing wu * @Date: 2023-04-14 10:16:19 * @LastEditors: chen jing wu * @LastEditTime: 2023-04-14 10:41:46 */ import { api, wire,LightningElement } from 'lwc'; import { CurrentPageReference } from "lightning/navigation"; import { CloseActionScreenEvent } from 'lightning/actions'; import { updateRecord } from 'lightning/uiRecordApi'; import { ShowToastEvent } from 'lightning/platformShowToastEvent'; import init from '@salesforce/apex/OpportunityLightingButtonController.initForLostReportButton'; import queryLostReport from '@salesforce/apex/OpportunityLightingButtonController.queryLostReport'; import lwcCSS from '@salesforce/resourceUrl/lwcCSS'; import {loadStyle} from 'lightning/platformResourceLoader'; export default class LexLoseReport extends LightningElement { @api recordId; stageName; sapSendOK; cntLostCancelReport; name; salesAssistantName; salesAssistantID; managerName; salesManagerDepartmentID; salesOwnerBuchang; salesOwnerBuchangID; cntLostCancelDraft; haveLostReport; IsLoading = true; @wire(CurrentPageReference) getStateParameters(currentPageReference) { console.log(111); console.log(currentPageReference); if (currentPageReference) { const urlValue = currentPageReference.state.recordId; if (urlValue) { let str = `${urlValue}`; console.log("str"); console.log(str); this.recordId = str; } } } connectedCallback(){ Promise.all([ loadStyle(this, lwcCSS) ]); init({ recordId: this.recordId }).then(result=>{ this.stageName = result.stageName; this.sapSendOK = result.sapSendOK; this.cntLostCancelReport = result.cntLostCancelReport; 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.cntLostCancelDraft = result.cntLostCancelDraft; if(!result.isHavePower){ this.showToast('您不能创建失单/部分失单报告!','error'); this.dispatchEvent(new CloseActionScreenEvent()); return; } queryLostReport({ recordId: this.recordId }).then(result=>{ this.haveLostReport = result; this.loseReport(); }); }) } loseReport(){ // jsの場合、翻訳された値がでるので、要注意 if (this.stageName != '引合' && this.stageName != '询价' ) { this.showToast("状态1:" + this.stageName + "、不能做 失单 了!","error"); } else if (this.sapSendOK == '1') { this.showToast("已经上传SAP、不能做 失单 了!","error"); } else if (this.haveLostReport) { this.showToast('询价已经有 取消/失单报告 了!','error'); } else { var url = '/lightning/n/PCLLostReportPageLwc#pageStatus=Create&oppId=' + this.recordId + '&lostType=失单'; location.href = url; } this.dispatchEvent(new CloseActionScreenEvent()); } showToast(msg,type) { 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()); } } //显示信息 showMyToast(title, message, variant) { console.log('show custom message'); let iconName = ''; let content = ''; if (variant == 'success') { iconName = 'utility:check'; } else { iconName = 'utility:error'; } if (message != '') { content = '