import { LightningElement, wire, api, track } from 'lwc'; import init from '@salesforce/apex/LexSummonsCreatController.init'; import { ShowToastEvent } from 'lightning/platformShowToastEvent'; import searchConsumableorderdetails from '@salesforce/apex/LexSummonsCreatController.searchConsumableorderdetails'; import PraseToPDF from '@salesforce/apex/LexSummonsCreatController.PraseToPDF'; import apexSearch from '@salesforce/apex/SampleLookupController.search'; import save from '@salesforce/apex/LexSummonsCreatController.save'; import OPPORTUNITY_OBJECT from '@salesforce/schema/Consumable_Orderdetails__c'; import { getObjectInfo } from 'lightning/uiObjectInfoApi'; import hospitalInit from '@salesforce/apex/lexSearchAgencyHospitalController.init'; import serContact from '@salesforce/apex/lexSearchAgencyHospitalController.serContact'; import { NavigationMixin } from 'lightning/navigation'; export default class LexSummonsCreat extends NavigationMixin(LightningElement) { @track isShowSpinner = true; @track showResults = true; @track results = [ { Id:'1', Name : 'z' }, { Id:'2', Name : 'h' }, { Id:'3', Name : 'j' } ]; @track COLS = [ { label: 'Account Name', type: 'customName', typeAttributes: { accountName: { fieldName: 'Name' } } }]; @track columns = [ { label: '消耗品名称', fieldName: 'Name__c', hideDefaultActions: true , wrapText:true, //initialWidth : 100, }, { label: '规格', fieldName: 'packinglist', //initialWidth : 50, wrapText:true, hideDefaultActions: true }, { label: 'CFDA状态', fieldName: 'SFDA_Status__c', //initialWidth : 100, wrapText:true, hideDefaultActions: true }, { label: '注册证编码号', fieldName: 'approbation_No', //initialWidth : 150, wrapText:true, hideDefaultActions: true }, { label: '注册证效期', //initialWidth : 100, wrapText:true, fieldName: 'expiration_Date', hideDefaultActions: true , }, { label: '第3分类', fieldName: 'Category3__c', //initialWidth : 100, wrapText:true, hideDefaultActions: true, sortable: true, }, { label: '第4分类', fieldName: 'Category4__c', //initialWidth : 100, wrapText:true, hideDefaultActions: true, sortable: true }, { label: '第5分类', fieldName: 'Category5__c', //initialWidth : 100, wrapText:true, hideDefaultActions: true, sortable: true }, { label: '单位', type:'customUnit', //initialWidth : 100, hideDefaultActions: true, typeAttributes: { unitValue: { fieldName: 'unitValue' }, unitOptions: { fieldName: 'unitOptions' }, recordId: { fieldName: 'recordId' } }, }, { label: '出货数量', type: 'customShipment', //initialWidth : 150, hideDefaultActions: true, typeAttributes: { recordId: { fieldName: 'recordId' }, shipmentNumber: { fieldName: 'shipmentNumber' }, }, }, { label: '出货单价(元)', type: 'customShipmentUnitPrice', //initialWidth : 150, hideDefaultActions: true, typeAttributes: { recordId: { fieldName: 'recordId' }, shippingUnitPrice: { fieldName: 'shippingUnitPrice' } }, }, { label: '出货金额(元)', type: 'customShipmentAmount', //initialWidth : 120, hideDefaultActions: true, typeAttributes: { shipmentAmount: { fieldName: 'shipmentAmount' } }, }, { label: '有效期内库存(盒)', fieldName: 'Boxnumber', //initialWidth : 120, wrapText:true, hideDefaultActions: true, }, { label: '有效期内库存(个)', fieldName: 'Piecenumber', //initialWidth : 120, wrapText:true, hideDefaultActions: true, } ]; @track editColumns = [ { label: '消耗品名称', fieldName: 'Name__c', hideDefaultActions: true , initialWidth : 250, }, { label: '规格', fieldName: 'packinglist', initialWidth : 50, hideDefaultActions: true }, { label: 'CFDA状态', fieldName: 'SFDA_Status__c', initialWidth : 100, hideDefaultActions: true }, { label: '注册证编码号', fieldName: 'approbation_No', initialWidth : 150, hideDefaultActions: true }, { label: '注册证效期', initialWidth : 100, fieldName: 'expiration_Date', hideDefaultActions: true , }, { label: '第3分类', fieldName: 'Category3__c', initialWidth : 100, hideDefaultActions: true, sortable: true, }, { label: '第4分类', fieldName: 'Category4__c', initialWidth : 100, hideDefaultActions: true, sortable: true }, { label: '第5分类', fieldName: 'Category5__c', initialWidth : 100, hideDefaultActions: true, sortable: true }, { label: '单位', fieldName: 'Box_Piece__c', initialWidth : 100, hideDefaultActions: true, }, { label: '出货数量', fieldName: 'Shipment_Count__c', initialWidth : 150, hideDefaultActions: true, }, { label: '出货单价(元)', fieldName: 'Shipment_amount__c', initialWidth : 150, hideDefaultActions: true, } ]; @track hospitalList=[]; @track hospitalColumns = [ { label: '医院名称', fieldName: 'Name', initialWidth : 400, hideDefaultActions: true , }, { label: '省份', fieldName: 'stateMasterName', hideDefaultActions: true , }, { label: '选择', fieldName : 'Id1', type : 'button', hideDefaultActions: true , typeAttributes: { label: '选择', name: 'Id2', size: 1 } } ]; @track accountid = ''; @track consumableproductdetailsRecords = []; @track SummonsStatus = ''; @track ESetid = ''; @track cocLwc = {}; @track selectedRows = []; @track ConsumableOut_report = ''; //显示按钮 @track isSaveShow = false; @track isEditShow = false; @track isDeliveryShow = false; @track isOpenToInvoiceShow = false; @track isPraseToPDFShow = false; @track isOpenReportShow = false; @track isDeleteShow = false; @track isFileShow = false; //disable按钮 @track isEditDisabled = false; @track isDeliveryDisabled = false; @track isOpenToInvoiceDisabled = true; @track isPraseToPDFDisabled = true; @track isOpenReportDisabled = true; @track isDeleteDisabled = false; //出库单信息 @track cocId = '' @track EditAble = false; @track summonsStatusPriceNotDetermined = false; @track isSummonsForDirctionTwoShow = false; @track isSummonsFlag = false; @track isConInvoiceShow = false; @track sumPrice = ''; @track isSearchShow = false; @track Existarrive = false; @track Category3 = ''; @track category3Options=[]; @track Category4 = ''; @track category4Options=[]; @track Category5 = ''; @track category5Options=[]; //二级经销商 @track secondaryDistributor = ''; @track secondaryDistributorOptions = []; @track isDisabledSecondaryDistributor = false; //经销商录入 @track ForDealerText = ''; @track isDisabledForDealerText = false; //客户名 @track isModalOpen = false; @track HospitalName = ''; @track searchHospitalName = ''; @track OECId = ''; @track isDisabledHospitalName = false; //科室 @track ForCustomerText = ''; @track isDisabledForCustomerText = false; //没有确定价格 @track NoConfirmedPrice = false; //消耗品名称 @track consumableName = ''; @track agencyProType = ''; @track accountName = ''; @track userWorkLocation = ''; @track OutPattern__c = false; @track outOutPattern = ''; //出库单明细 @track showTable = false; @track data = []; @track isSelectShow = false; @track hidecheckboxcolumn = false; @track is345Show = false; @track arriveorder = ''; @track hasHosPro = false; @track InvoiceProNotLabel = ''; @track RrturnProLabel = ''; @track InvoicedLabel = ''; @track outOutPatternOptionList = []; //InvoiceProNotLabel RrturnProLabel InvoicedLabel @wire(getObjectInfo, { objectApiName: OPPORTUNITY_OBJECT }) oppInfo({ data, error }) { if (data) { this.InvoiceProNotLabel = data.fields.InvoiceProNot_count__c.label this.RrturnProLabel = data.fields.RrturnPro_count__c.label this.InvoicedLabel = data.fields.Invoiced_Procount__c.label console.log('this.InvoiceProNotLabel = ' + this.InvoiceProNotLabel); console.log('this.RrturnProLabel = ' + this.RrturnProLabel); console.log('this.InvoicedLabel = ' + this.InvoicedLabel); } } // get secondaryDistributorOptions() { // return this.secondaryDistributorOptions; // } // get outOutPatternOptionList() { // return this.outOutPatternOptionList; // } // // get category3Options() { // // return this.category3Options; // // } // get category4Options() { // return this.category4Options; // } // get category5Options() { // return this.category5Options; // } //获取链接参数 getQueryString(name) { console.log('getQueryString name ' + name) let reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i"); let r = window.location.search.substr(1).match(reg); if (r != null) { return decodeURIComponent(r[2]); }; return null; } connectedCallback(){ this.ESetid = this.getQueryString('ESetid'); this.ESetid = this.ESetid == null ? '' : this.ESetid; init({ ESetidJs : this.ESetid }).then((r) => { r = JSON.parse(JSON.stringify(r)); console.log('r = ' + JSON.stringify(r)); if (r.status == 'Success') { this.ConsumableOut_report = r.entity.ConsumableOut_report; console.log('this.ConsumableOut_report = ' + this.ConsumableOut_report) this.accountid = r.entity.accountid; this.consumableproductdetailsRecords = r.entity.consumableproductdetailsRecords; this.accountName = r.entity.accountName; this.agencyProType = r.entity.agencyProType; this.accountName = r.entity.accountName; this.userWorkLocation = r.entity.userWorkLocation; this.EditAble = r.entity.EditAble; console.log('this.agencyProType = ' + this.agencyProType); console.log('this.EditAble = ' + this.EditAble); //第3分类 for(var key in r.entity.categoryOptionMap){ let object = {}; object['label'] = r.entity.categoryOptionMap[key]; object['value'] = key; this.category3Options.push(object); } console.log('this.category3Options = ' + this.category3Options) //第4分类 for(var key in r.entity.category4OptionMap){ let object = {}; object['label'] = r.entity.category4OptionMap[key]; object['value'] = key; this.category4Options.push(object); } console.log('this.category4Options = ' + this.category4Options) //第5分类 for(var key in r.entity.category5OptionMap){ let object = {}; object['label'] = r.entity.category5OptionMap[key]; object['value'] = key; this.category5Options.push(object); } console.log('this.category5Options = ' + this.category5Options) this.data = r.entity.pageRecords; for(var i in this.data){ let unitOptions = []; for(var key in this.data[i].boxorpieceMap){ let unitOption = {}; unitOption['label'] = this.data[i].boxorpieceMap[key]; unitOption['value'] = key; unitOptions.push(unitOption); } this.data[i]['unitOptions'] = unitOptions; this.data[i]['unitValue'] = unitOptions[0].value; if(this.EditAble){ this.data[i].orderdetails1['Box_Piece__c'] = unitOptions[0].value; this.data[i].orderdetails1['Shipment_Count__c'] = 0; this.data[i].orderdetails1['Delivery_List_RMB__c'] = 0.00; }else{ this.data[i]['InvoiceProNot_count__c'] = this.data[i].orderdetails1.InvoiceProNot_count__c; this.data[i]['RrturnPro_count__c'] = this.data[i].orderdetails1.RrturnPro_count__c; this.data[i]['Invoiced_Procount__c'] = this.data[i].orderdetails1.Invoiced_Procount__c; } this.data[i]['shipmentNumber'] = 0; this.data[i]['shippingUnitPrice'] = 0.00; this.data[i]['recordId'] = this.data[i].Prod.Id; this.data[i]['Id'] = this.data[i].Prod.Id; this.data[i]['Name__c'] = this.data[i].Prod.Name__c; this.data[i]['SFDA_Status__c'] = this.data[i].Prod.SFDA_Status__c; this.data[i]['Category3__c'] = this.data[i].Prod.Category3__c; this.data[i]['Category4__c'] = this.data[i].Prod.Category4__c; this.data[i]['Category5__c'] = this.data[i].Prod.Category5__c; this.data[i]['Box_Piece__c'] = this.data[i].orderdetails1.Box_Piece__c; this.data[i]['shipmentAmount'] = this.data[i].orderdetails1.Shipment_amount__c; this.data[i]['Shipment_amount__c'] = this.data[i].orderdetails1.Shipment_amount__c; this.data[i]['Shipment_Count__c'] = this.data[i].orderdetails1.Shipment_Count__c; } console.log('this.data = ' + JSON.stringify(this.data)); //show if(r.entity.EditDelCommitBtnDisabled || r.entity.EditAble){ this.isSaveShow = true; }else{ this.isEditShow = true; this.isDeliveryShow = true; this.isOpenToInvoiceShow = true; this.isPraseToPDFShow = true; this.isOpenReportShow = true; this.isDeleteShow = true; } this.Existarrive = r.entity.Existarrive; console.log('this.EditAble = ' + this.EditAble); this.hasHosPro = r.entity.hasHosPro; //disable if(Object.values(r.entity.coc).length > 0){ this.cocLwc = r.entity.coc; console.log('this.cocLwc = ' + JSON.stringify(this.cocLwc)); var coc = r.entity.coc; this.cocId = coc.Id; coc.SummonsStatus = coc.SummonsStatus_c__c; if(coc.SummonsStatus_c__c == '已完成'){ this.isEditDisabled = true; } if(coc.SummonsStatus_c__c == '批准' || coc.SummonsStatus_c__c == '已销售待上传纳品书' || coc.SummonsStatus_c__c == '出库单已打印' || coc.SummonsStatus_c__c == '已完成'){ this.isDeliveryDisabled = true; } if(((coc.Billed_Status__c != '全部开票' && coc.SummonsStatus_c__c == '已完成') || coc.Onchange_order__c == true) && coc.SummonsForDirction__c != '互相调货'){ this.isOpenToInvoiceDisabled = false; } if(coc.SummonsStatus_c__c == '已销售待上传纳品书' || coc.SummonsStatus_c__c == '批准' || coc.SummonsStatus_c__c == '出库单已打印' || coc.SummonsStatus_c__c == '草案中'){ this.isPraseToPDFDisabled = false; } if(coc.Billed_Status__c != '还没开票' || coc.SummonsStatus_c__c == '已完成'){ this.isOpenReportDisabled = false; } if(coc.SummonsStatus_c__c == '已销售待上传纳品书' || coc.SummonsStatus_c__c == '价格未定' || coc.SummonsStatus_c__c == '批准' || coc.SummonsStatus_c__c == '出库单已打印' || coc.SummonsStatus_c__c == '已完成'){ this.isDeleteDisabled = true; } this.isConInvoiceShow = (coc.SummonsStatus_c__c == '已完成' && coc.SummonsForDirction__c != '互相调货') ? true : false; this.summonsStatusPriceNotDetermined = coc.SummonsStatus_c__c == '价格未定' ? true : false; this.isSummonsForDirctionTwoShow = coc.SummonsForDirction__c == '销售给二级经销商' ? true : false; } this.isSearchShow = (!this.Existarrive && r.entity.coc.SummonsStatus_c__c != '价格未定' && r.entity.EditAble) ? true : false; this.hidecheckboxcolumn = !this.isSearchShow; this.arriveorder = r.entity.arriveorder; this.is345Show = (this.arriveorder == '' && this.Existarrive == false && this.EditAble) ? true : false; //如果不显示345分类,columns里面删除3,4,5分类 if(!this.is345Show){ for(var i=0; i { r = JSON.parse(JSON.stringify(r)); if (r.status == 'Success') { this.hospitalList = r.entity.at; for(var i in this.hospitalList){ this.hospitalList[i]['stateMasterName'] = this.hospitalList[i].State_Master__r.Name; } console.log('hospitalInit r = ' + JSON.stringify(this.hospitalList)); this.isModalOpen = true; } }); } searchHospital(){ console.log('this.searchHospitalName = ' + this.searchHospitalName); serContact({ searchName : this.searchHospitalName, ctype : this.agencyProType }).then((r) => { r = JSON.parse(JSON.stringify(r)); if (r.status == 'Success') { this.hospitalList = r.entity.at; for(var i in this.hospitalList){ this.hospitalList[i]['stateMasterName'] = this.hospitalList[i].State_Master__r.Name; } console.log('hospitalInit r = ' + JSON.stringify(this.hospitalList)); } }); } searchHandleRowAction(event) { console.log('searchHandleRowAction') let row = event.detail.row; this.OECId = row.Id; this.HospitalName = row.Name; console.log('this.OECId = ' + this.OECId + ' this.HospitalName = ' + this.HospitalName); this.isModalOpen = false; console.log('this.isModalOpen = ' + this.isModalOpen); } clearAgencyI(event){ this.HospitalName = event.target.value; if(this.HospitalName == '' || this.HospitalName == null){ this.OECId = ''; } console.log('this.HospitalName = ' + this.HospitalName); console.log('this.OECId = ' + this.OECId); if (this.OECId != null && this.OECId != '') { this.checkOutPattern(); } } checkOutPattern(){ //根据用户选中的产品给 出库单上的是否医院特价出库字段赋值 let ishos = 0; for(var i in this.data){ if(this.data[i].check == true && this.data[i].hospitalSpecialOffer == true){ ishos = ishos +1; } } if (ishos > 0) { this.cocLwc['OutPattern__c'] = true; }else{ this.cocLwc['OutPattern__c'] = false; } } closeModal(){ this.isModalOpen = false; } handleUnitChange(event){ console.log('handleUnitChange') const unitDetail = event.detail; console.log('unitDetail = ' + JSON.stringify(unitDetail)) for(var i in this.data){ if(this.data[i].recordId == unitDetail.data.recordId){ this.data[i].unitValue = unitDetail.data.unitValue; this.data[i].orderdetails1['Box_Piece__c'] = unitDetail.data.unitValue; } } console.log('this.data = ' + JSON.stringify(this.data)) } handleShipmentNumber(event){ console.log('handleShipmentNumber') const numberDetail = event.detail; console.log('numberDetail = ' + JSON.stringify(numberDetail)) let index = 0; for(var i in this.data){ if(this.data[i].recordId == numberDetail.data.recordId){ index = i; this.data[i].shipmentNumber = Number(numberDetail.data.shipmentnumber); this.data[i].orderdetails1['Shipment_Count__c'] = Number(numberDetail.data.shipmentnumber); console.log('this.data[i].shipmentNumber = ' + this.data[i].shipmentNumber) } } this.ComputePrice(index,this.data[index].shipmentNumber,this.data[index].shippingUnitPrice); } handleShipmentUnitPrice(event){ console.log('handleShipmentUnitPrice') const priceDetail = event.detail; let index = 0; for(var i in this.data){ if(this.data[i].recordId == priceDetail.data.recordId){ index = i; this.data[i].shippingUnitPrice = Number(priceDetail.data.shipmentunitprice); this.data[i].orderdetails1['Delivery_List_RMB__c'] = Number(priceDetail.data.shipmentunitprice); console.log('this.data[i].shippingUnitPrice = ' + this.data[i].shippingUnitPrice) } } this.ComputePrice(index,this.data[index].shipmentNumber,this.data[index].shippingUnitPrice); } ComputePrice(index,number,price){ console.log('index = ' + index); console.log('number = ' + number); console.log('price = ' + price); let shipmentAmount = this.amend(number,price,'*'); console.log('shipmentAmount = ' + shipmentAmount); let sumPrice = 0.00; this.data[index].shipmentAmount = shipmentAmount; for(var i in this.data){ if(this.data[i].shipmentAmount) sumPrice += this.data[i].shipmentAmount; } this.sumPrice = sumPrice + '元'; //存下选择行,不会被清空 this.selectedRows = []; for(var i in this.data){ if(this.data[i].check){ this.selectedRows.push(this.data[i].Id); } } this.data = [...this.data]; console.log('this.selectedRows = ' + JSON.stringify(this.selectedRows)) console.log('this.data = ' + JSON.stringify(this.data)) } //num1 num2传入两个值 symbol +-*/符号 amend(num1,num2,symbol){ var str1=num1.toString(),str2=num2.toString(),result,str1Length,str2Length //解决整数没有小数点方法 try {str1Length= str1.split('.')[1].length} catch (error) {str1Length=0} try {str2Length= str2.split('.')[1].length} catch (error) {str2Length=0} var step=Math.pow(10,Math.max(str1Length,str2Length)) // console.log(step); switch (symbol) { case "+": result= (num1*step+num2*step)/step break; case "-": result= (num1*step-num2*step)/step break; case "*": result= ((num1*step)*(num2*step)) / step/step break; case "/": result= (num1*step)/(num2*step) break; default: break; } return result } getSelectedRows(event) { const selectedRows = event.detail.selectedRows; console.log('this.selectedRows = ' + this.selectedRows); for(var i in this.data){ this.data[i]['check'] = false; } for(var i in this.data){ for(var j in selectedRows){ if(this.data[i].Id == selectedRows[j].Id){ this.data[i]['check'] = true; } } } } saveConfirmJs(){ let msg = "出库价格仅可操作一次变更,保存后将无法修改。\n\n请确认!"; if(this.SummonsStatus == '价格未定'){ if(confirm(msg)==true){ this.saveConfirm() } }else{ this.saveConfirm() } } saveConfirm(){ this.isShowSpinner = true; let cloneData = this.data; for(var i in cloneData){ cloneData[i]['Name'] = cloneData[i].Name__c; cloneData[i]['Category3'] = cloneData[i].Category3__c; cloneData[i]['Category4'] = cloneData[i].Category4__c; cloneData[i]['Category5'] = cloneData[i].Category5__c; cloneData[i]['BoxPiece'] = cloneData[i].Box_Piece__c; delete cloneData[i].Name__c; delete cloneData[i].Category3__c; delete cloneData[i].Category4__c; delete cloneData[i].Category5__c; delete cloneData[i].Box_Piece__c; } console.log('this.cocLwc = ' + JSON.stringify(this.cocLwc)) console.log('this.OECId = ' + this.OECId) console.log('this.HospitalName = ' + this.HospitalName) console.log('this.secondaryDistributor = ' + this.secondaryDistributor) console.log('this.pageRecordsLwc = ' + JSON.stringify(cloneData)) console.log('this.accountid = ' + this.accountid) console.log('this.ESetid = ' + this.ESetid) console.log('this.consumableproductdetailsRecords = ' + JSON.stringify(this.consumableproductdetailsRecords)) save({ cocLwc : this.cocLwc, hospitalInfoLwc : this.OECId, hospitalNameLwc : this.HospitalName, secondaryDistributor : this.secondaryDistributor, pageRecordsLwc : cloneData, accountid : this.accountid, ESetId : this.ESetid, consumableproductdetailsRecordsLwc : this.consumableproductdetailsRecords }).then((r) => { r = JSON.parse(JSON.stringify(r)); console.log('r = ' + JSON.stringify(r)); if (r.status == 'Success') { let url = '/lexsummonscreat?ESetid=' + r.entity.ESetId; this[NavigationMixin.Navigate]({ type: 'standard__webPage', attributes: { url: url } }); }else{ console.log('r.msg = ' + r.msg); this.showToast('Error', r.msg); } }).catch((error) => { console.log('error = ' + JSON.stringify(error)) }); } //打印指示单 PraseToPDFJs(){ console.log('this.cocLwc = ' + JSON.stringify(this.cocLwc)) console.log('this.ESetId = ' + this.ESetid) PraseToPDF({ cocLwc : this.cocLwc, ESetId : this.ESetid }).then((r) => { r = JSON.parse(JSON.stringify(r)); console.log('r = ' + JSON.stringify(r)); if (r.status == 'Success') { window.open('/customer/summonsPDF?ESetid=' + r.entity.ESetId); }else{ console.log('r.msg = ' + r.msg); this.showToast('Error', r.msg); } }); } //显示明细 openReportJs(){ var reportId = this.ESetid; reportId = reportId.substring(0,15); window.open("/customer/" +this.ConsumableOut_report+ "?pv1="+ reportId); } setVisitorPlace(){ console.log('setVisitorPlace') if(this.summonsForDirction == '互相调货'){ } } vpClear2Delay(event){ console.log('vpClear2Delay') if(this.summonsForDirction != '互相调货'){ this.cocLwc['Order_ForDealerText__c'] = event.target.value; }else{ console.log('Order_ForDealerTextID__c = ' + this.cocLwc['Order_ForDealerTextID__c']) this.cocLwc['Order_ForDealerText__c'] = (this.cocLwc['Order_ForDealerTextID__c'] == '' || this.cocLwc['Order_ForDealerTextID__c'] == null || this.cocLwc['Order_ForDealerTextID__c'] == undefined) ? '' : this.cocLwc['Order_ForDealerText__c']; console.log('this.cocLwc = ' + JSON.stringify(this.cocLwc)); this.ForDealerText = this.cocLwc['Order_ForDealerText__c']; event.target.value = this.cocLwc['Order_ForDealerText__c']; console.log('this.ForDealerText = ' + this.ForDealerText); } } handleSearch(event) { debugger const lookupElement = event.target; console.log('event.detail = ' + JSON.stringify(event.detail)) apexSearch({ searchTerm : event.detail.searchTerm, selectedIds : event.detail.selectedIds }) .then(results => { lookupElement.setSearchResults(results); }) .catch(error => { // TODO: handle error console.log('error'+JSON.stringify(error)); }); } handleSelectionChange(event) { // Get the selected ids from the event (same interface as lightning-input-field) const selectedIds = event.detail; // Or, get the selection objects with ids, labels, icons... const selection = event.target.getSelection(); // TODO: do something with the lookup selection } }