import { api, wire,LightningElement } from 'lwc'; import { CurrentPageReference } from "lightning/navigation"; import { CloseActionScreenEvent } from 'lightning/actions'; import init from '@salesforce/apex/OpportunityLightingButtonController.initForRequestDBButton'; import { updateRecord } from 'lightning/uiRecordApi'; import { ShowToastEvent } from 'lightning/platformShowToastEvent'; export default class LexRequestDB extends LightningElement { @api recordId; stageName; sapSendOK; cntLostCancelReport; cntLostCancelDraft; agency1; agency1Id; name; bidPlannedDate; salesAssistantName; salesAssistantID; profileId; @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(){ init({ recordId: this.recordId }).then(result=>{ this.stageName = result.stageName; this.sapSendOK = result.sapSendOK; this.cntLostCancelReport = result.cntLostCancelReport; this.cntLostCancelDraft = result.cntLostCancelDraft; this.agency1 = result.agency1; this.agency1Id = result.agency1Id; this.name = result.name; this.bidPlannedDate = result.bidPlannedDate; this.salesAssistantName = result.salesAssistantName; this.salesAssistantID = result.salesAssistantID; this.profileId = result.profileId; this.requestDB(); }) } requestDB(){ var profileId = this.profileId; if (profileId != '00e10000000Y3o5' && profileId != '00e10000000xnp2' && profileId != '00e10000000xnpH') { this.showToast("您没有授权委托的权限。请联系系统管理员。","error"); } // jsの場合、翻訳された値がでるので、要注意 else if (this.stageName != '引合' && this.stageName != '询价' ) { this.showToast("状态1:" + this.stageName + "、不能做授权申请!",""); } else if (this.sapSendOK == '1') { this.showToast("已经上传SAP、不能做授权申请了!","error"); } else if (this.cntLostCancelReport - this.cntLostCancelDraft > 0) { this.showToast("询价已经有取消/失单报告了!","error"); } else { location.href = '/a2C/e?retURL=%2F' + encodeURI(this.recordId) + '&RecordType=01210000000RNXi' + '&CF00N10000006QdJz=' + encodeURI(this.agency1) + '&CF00N10000006QdJz_lkid=' + encodeURI(this.agency1Id) + '&CF00N10000006QdKn=' + encodeURI(this.name) + '&CF00N10000006QdKn_lkid=' + encodeURI(this.recordId) + '&00N10000006QdK4=' + encodeURI(this.name) + '&00N10000006QdYB=' + encodeURI(this.bidPlannedDate) + '&CF00N10000006QdZT=' + encodeURI(this.salesAssistantName) + '&CF00N10000006QdZT_lkid=' + encodeURI(this.salesAssistantID) + ''; }; this.dispatchEvent(new CloseActionScreenEvent()); } showToast(msg,type) { const event = new ShowToastEvent({ title: '', message: msg, variant: type }); this.dispatchEvent(event); } updateRecordView(recordId) { updateRecord({fields: { Id: recordId }}); } }