import { LightningElement, api, track, wire } from "lwc"; import { CurrentPageReference } from "lightning/navigation"; import initData from "@salesforce/apex/LexNewAndEditLeadPIPLController.initData"; import queryAccount from "@salesforce/apex/LexNewAndEditLeadPIPLController.queryAccount"; import { NavigationMixin } from "lightning/navigation"; import { AWSService } from "c/piUtils"; import { ShowToastEvent } from "lightning/platformShowToastEvent"; import lexPIPLCustomStyle from "@salesforce/resourceUrl/lexPIPLCustomStyle"; import { loadStyle } from "lightning/platformResourceLoader"; import { decodeDefaultFieldValues } from "lightning/pageReferenceUtils"; import { getObjectInfo } from 'lightning/uiObjectInfoApi'; import LEAD from '@salesforce/schema/Lead'; import { conmentCancel } from "c/lexPIPLConmentMethods"; // Add By Li Jun 20231025 Start import LexRecordNotCreateable from '@salesforce/label/c.LexRecordNotCreateable'; import LexNotCreateNote from '@salesforce/label/c.LexNotCreateNote'; const customLabel = { LexRecordNotCreateable, LexNotCreateNote } // Add By Li Jun 20231025 End export default class LexNewAndEditLeadPIPL extends NavigationMixin( LightningElement ) { sobjectType = "Lead"; @track customLabel = customLabel; @track inputField; @api recordId; @track recordCloneId; @wire(CurrentPageReference) pageRef; @track recordData = {}; @track title; @track recordTypeId = ""; @track isLoading = true; @track layout = []; @track staticResource; @track staticResourceContact; @track piFieldsMap; @track abstractData = ""; @track data = {}; @track piplData = {}; @track isNewMode = false; @track isCloneMode = false; @track isEditMode = false; @track sectionName = []; @track AWSToSobjectMap = {}; @track AWSDataId = ""; @track contactAWSDataId = ""; @track txId = ""; @track isShowSearchAccount = false; @track hospitalId = ""; @track contactId = ""; // @track searchFieldArray = ['Id','Name','AccountManageNumber__c']; // @track searchWhere = 'Department_Class_Name__c = \'泌尿科\''; // @track searchField = 'Name'; @track searchObjectType = "Contact"; @track LeadCreatedDate; @track saveAndNew = false; @track isInitSuccess = false; @track iconName = ""; AWSService; @track decryptContact = false; //姓名 //@track lastName = ''; @track modifyObj = {}; modifyArray = ["LastName", "Hospital_Name__c"]; defaultValueFieldArray = [ "Hospital_Name__c", "RecordType", "Contact_Name__c", "epartment_Class__c", "name_lastlea2", "contactName", "accountName", ]; fieldLabel = {}; defaultValues = {}; @wire(getObjectInfo, { objectApiName: LEAD }) getleadInfo({data,error}){ if(data){ this.fieldLabel = data.fields; } } connectedCallback() { console.log("enter connectedCallback"); loadStyle(this, lexPIPLCustomStyle); this.AWSService = new AWSService(); if (!this.recordId || this.isCloneMode) { this.title = "新建意向"; this.isNewMode = true; } if (this.recordId) { this.title = "编辑意向"; this.isEditMode = true; } if (this.pageRef && this.pageRef.state) { this.recordTypeId = this.pageRef.state.recordTypeId; console.log("this.recordTypeId = " + this.recordTypeId); this.isCloneMode = Boolean(this.pageRef.state.c__isClone); //add by xq 2023/07/25 start if (this.pageRef.state.defaultFieldValues) { this.defaultValues = decodeDefaultFieldValues( this.pageRef.state.defaultFieldValues ); console.log('this.contactAWSDataId = ' + this.contactAWSDataId); } console.log("defaultValues:", JSON.stringify(this.defaultValues)); //add by xq 2023/07/25 end //克隆 if (this.isCloneMode) { this.isNewMode = false; this.isEditMode = false; this.recordTypeId = this.pageRef.state.c__recordTypeId; this.recordCloneId = this.pageRef.state.c__recordId; this.title = "克隆客户人员"; } } console.log( "recordId = " + this.recordId + " pid = " + this.pid + " recordTypeId = " + this.recordTypeId + " sobjectType = " + this.sobjectType ); let id = this.isCloneMode == true ? this.recordCloneId : this.recordId; initData({ rid: id, recordTypeId: this.recordTypeId, sobjectType: this.sobjectType, }).then((r) => { r = JSON.parse(JSON.stringify(r)); console.log("r = " + JSON.stringify(r)); if (r.status == "Success") { let layout = JSON.parse(r.entity.layout); layout = this.sortMetaLayouts(layout); this.recordData = r.entity.data; if (this.recordData && this.recordData.Contact_Name__c != null) { this.iconName = 'utility:close'; } else { this.iconName = 'utility:search'; } this.staticResourceContact = JSON.parse(r.entity.staticResourceContact); this.AWSDataId = r.entity.AWSDataId; this.sectionName = layout.map((s) => s.label); let index = 1; for (let s of layout) { s["showSection"] = false; if (s["editHeading"] || s["detailHeading"]) { s["showSection"] = true; } s["showLabel"] = false; for (let c of s.layoutColumns) { c["index"] = index++; if (c.layoutItems.length != 0 && s["showLabel"] == false) { s["showLabel"] = true; } if (c.layoutItems) { for (let i = 0; i < c.layoutItems.length; i++) { c.layoutItems[i]["isModify"] = false; c.layoutItems[i]["isDisable"] = c.layoutItems[i].behavior == "Readonly" ? true : false; c.layoutItems[i]["isRequired"] = c.layoutItems[i].behavior == "Required" ? true : false; //名字,只留LastName和Salutation if (c.layoutItems[i]["field"] == "Name") { c.layoutItems[i].field = "LastName"; c.layoutItems[i].fieldLabel = "姓名"; c.layoutItems[i]["isModify"] = true; if (this.isEditMode || this.isCloneMode) { c.layoutItems[i]["value"] = this.recordData.LastName; } // 创建要插入的新元素 let newItem = { field: "Salutation", }; // 使用splice方法在满足条件的item后插入新元素 c.layoutItems.splice(i + 1, 0, newItem); } //客户人员名,因为要进行联动和解密所以变为普通input,自己控制值 if (c.layoutItems[i]["field"] == "Contact_Name__c") { c.layoutItems[i]["isModify"] = true; c.layoutItems[i]["isShowIcon"] = true; c.layoutItems[i].fieldLabel = "客户姓名"; if (this.isEditMode || this.isCloneMode) { c.layoutItems[i]["value"] = this.recordData.Contact_Name__r == null ? "" : this.recordData.Contact_Name__r.LastName; this.contactId = this.recordData.Contact_Name__c == null ? "" : this.recordData.Contact_Name__c; this.contactAWSDataId = this.recordData.Contact_Name__r == null ? "" : this.recordData.Contact_Name__r.AWS_Data_Id__c; } } if ( c.layoutItems[i]["field"] == "Hospital_Name__c" && (this.isEditMode || this.isCloneMode) ) { this.hospitalId = this.recordData.Hospital_Name__r == null ? "" : this.recordData.Hospital_Name__r.Id; } if (c.layoutItems[i]["field"] == "RecordTypeId") { c.layoutItems[i]["isDisable"] = true; } //PIPL按钮处理 add by xq 2023/07/25 start debugger if (this.isNewMode && this.defaultValues) { if(this.defaultValues[c.layoutItems[i]["field"]]){ c.layoutItems[i]["value"] = this.defaultValues[c.layoutItems[i]["field"]]; if(c.layoutItems[i]["field"] == 'Hospital_Name__c'){ this.hospitalId = this.defaultValues[c.layoutItems[i]["field"]]; } } if(c.layoutItems[i]["field"] == 'Contact_Name__c'){ //解密客户人员 c.layoutItems[i]["value"] = this.defaultValues['contactName']; this.contactId = this.defaultValues['contact_Name__c']; if(this.defaultValues['contact_Name__c']){ this.iconName = "utility:close"; } if(this.defaultValues['awsDataId']){ this.contactAWSDataId = this.defaultValues['awsDataId']; this.decryptContact = true; } } debugger if(c.layoutItems[i]["field"] == 'Company' && (this.defaultValues['accountName'] != '' && this.defaultValues['accountName'] != null)){ c.layoutItems[i]["value"] = this.defaultValues['accountName']; } } //PIPL按钮处理 add by xq 2023/07/25 start } } } } this.layout = layout; console.log("this.layout = " + JSON.stringify(this.layout)); this.AWSToSobjectMap = JSON.parse(JSON.stringify(r.entity.AWSToSobjectNonEncryptedMap)); this.staticResource = JSON.parse(r.entity.staticResource); this.recordTypeId = r.entity.recordTypeId; this.LeadCreatedDate = r.entity.LeadCreatedDate; console.log("this.AWSToSobjectMap = " + JSON.stringify(this.AWSToSobjectMap)); console.log("this.LeadCreatedDate = " + this.LeadCreatedDate); console.log("this.recordTypeId = " + this.recordTypeId); //编辑 if (this.isEditMode || this.isCloneMode) { //解密客户人员 this.queryContactName(); //解密意向的加密字段 this.queryLeadFromAWSIFS(); } if(this.decryptContact){ //解密客户人员 this.queryContactName(); } this.isInitSuccess = true; } else { this.isLoading = false; //this.showToast("Error", r.Msg); this.showMyToast(r.Msg , '' , 'error') } }); } sortMetaLayouts(layout){ layout.forEach(s => { let c1 = (s.layoutColumns[0].layoutItems != null) ? s.layoutColumns[0].layoutItems : []; let c2 = []; if(s.layoutColumns.length > 1){ c2 = (s.layoutColumns[1].layoutItems != null) ? s.layoutColumns[1].layoutItems : []; } else{ s.layoutColumns.push({ "reserved": null, "layoutItems": [] }); } let emptySpaceItem = { "width": null, "showScrollbars": null, "showLabel": null, "scontrol": null, "reportChartComponent": null, "page_x": null, "height": null, "field": null, "emptySpace": true, "customLink": null, "component": null, "canvas": null, "behavior": null, "analyticsCloudComponent": null } let maxSize = 0 if(c1.length > c2.length){ maxSize = c1.length; for(let i = 0; i < maxSize; i++){ if(c2.length == maxSize){ break; } c2.push(emptySpaceItem); } }else{ maxSize = c2.length; for(let i = 0; i < maxSize; i++){ if(c1.length == maxSize){ break; } c1.push(emptySpaceItem); } } let tempList = []; let index = 0; for(let i = 0; i < maxSize; i++){ tempList.push(c1[i]); if(tempList.length == maxSize){ s.layoutColumns[index].layoutItems = tempList; tempList = []; tempList.push(c2[i]); index++; }else{ tempList.push(c2[i]); if(tempList.length == maxSize){ s.layoutColumns[index].layoutItems = tempList; tempList = []; index++; } } } }) layout = [...layout]; return layout; } handleLoad() { console.log("handleLoad"); console.log("this.isInitSuccess = " + this.isInitSuccess); if (this.isInitSuccess) { let time = 1000; if (!this.isNewMode) { time = 2000; } let that = this; setTimeout(() => { that.isLoading = false; }, time); } } //解密客户人员 queryContactName() { let that = this; this.AWSService.query( this.staticResourceContact.queryUrl, this.contactAWSDataId, function (data) { console.log("data = " + JSON.stringify(data)); if (data.object) { for (let s of that.layout) { for (let c of s.layoutColumns) { if (c.layoutItems) { for (let item of c.layoutItems) { if (item["field"] == "Contact_Name__c") { item["value"] = data.object.lastName; } if(that.defaultValues && that.defaultValues['contactName'] && item["field"] == "LastName"){ item["value"] = data.object.lastName; that.modifyObj['LastName'] = data.object.lastName; } } } } } } }, this.staticResourceContact.token ); } //解密意向的加密字段 queryLeadFromAWSIFS() { let that = this; this.AWSService.query( this.staticResource.queryUrl, this.AWSDataId, function (data) { console.log("queryLeadFromAWSIFS data = " + JSON.stringify(data)); if (data.object) { for (let s of that.layout) { for (let c of s.layoutColumns) { if (c.layoutItems) { for (let item of c.layoutItems) { for (let f in that.AWSToSobjectMap) { if (data.object.hasOwnProperty(f) && item["field"] == that.AWSToSobjectMap[f] ) { item["value"] = data.object[f] == null ? "" : data.object[f]; if (item["field"] == "LastName") { that.modifyObj["LastName"] = data.object[f] == null ? "" : data.object[f]; } } } } } } } } }, this.staticResource.token ); } //取消 cancel() { conmentCancel(this.defaultValues); } //change事件 dataChange(event) { let fieldName = event.target.getAttribute("data-field"); let value = event.detail.value; console.log("fieldName = " + fieldName + " value = " + event.detail.value); if (this.modifyArray.indexOf(fieldName) != -1) { switch (fieldName) { case "LastName": this.modifyObj[fieldName] = value; break; case "Hospital_Name__c": //需要给战略科室分类和公司赋值 if (value != "000000000000000" && value != "") { let ls = ["Department_Class__c"]; this.hospitalId = value; //this.searchWhere = 'Id = 0030l00000tZ1BsAAK'; this.setVlookup(ls, value + ""); } else { //清空战略科室分类 this.clearVlookup(); } break; } } } //战略科室分类和公司赋值 setVlookup(ls, hospitalId) { this.isLoading = true; console.log("ls = " + JSON.stringify(ls)); console.log("hospitalId = " + hospitalId); queryAccount({ accountTypes: JSON.stringify(ls), accountId: hospitalId, }).then((r) => { r = JSON.parse(JSON.stringify(r)); console.log("r = " + JSON.stringify(r)); if (r.status == "Success") { console.log("queryAccount success"); for (let s of this.layout) { for (let c of s.layoutColumns) { if (c.layoutItems) { for (let item of c.layoutItems) { if (item["field"] == "Department_Class__c") { if (JSON.stringify(r.entity.m) != "{}") { item["value"] = r.entity.m.Department_Class__c.Id; } } if (item["field"] == "Company") { item["value"] = r.entity.account.Name; } } } } } //3秒后将会调用执行setTimeout函数 let that = this; setTimeout(function () { that.isLoading = false; }, 3000); //this.isLoading = false; } else { //this.showToast("Error", r.Msg); this.showMyToast(r.Msg , '' , 'error') } }); } //清空战略科室分类 clearVlookup() { console.log("clearVlookup"); for (let s of this.layout) { for (let c of s.layoutColumns) { if (c.layoutItems) { for (let item of c.layoutItems) { if (item["field"] == "Department_Class__c") { item["value"] = ""; } } } } } } clickSubmit() { console.log("clickSubmit"); const btn = this.template.querySelector(".hidden"); if (btn) { btn.click(); } } clickSubmitAndNew() { console.log("clickSubmitAndNew"); this.saveAndNew = true; const btn = this.template.querySelector(".hidden"); if (btn) { btn.click(); } } //提交保存 handleSubmit(event) { this.isLoading = true; //1. Get Sobject Information from Form console.log("handleSubmit"); event.preventDefault(); const fields = event.detail.fields; console.log("this.modifyObj = " + JSON.stringify(this.modifyObj)); Object.assign(fields, this.modifyObj); fields["Contact_Name__c"] = this.contactId; console.log("fields = " + JSON.stringify(fields)); //当ET勾选时,不走这个验证 let days = 100; let cfdate = fields["Close_Forecasted_Date__c"]; let crdate = this.LeadCreatedDate; let test = fields["ET_Check__c"]; if (cfdate != null && cfdate != "") { days = (Date.parse(cfdate) - Date.parse(crdate)) / (1000 * 3600 * 24); } if (days < 75 && test == false) { if ( !confirm('预测日期小于75天,影响当月次月预测,是否继续保存?') ) { this.isLoading = false; return; } } //2. select cannot actively select redaction option let validationResultMessage = this.validateFieldValueFormate(fields); console.log(validationResultMessage); if (validationResultMessage) { //this.showToast("Error", validationResultMessage); this.showMyToast(validationResultMessage , '' , 'error') this.isLoading = false; return; } //3. Check Required Field let checkRequiredFieldMsgResult = this.checkRequiredFieldMsg(fields); console.log("checkRequiredFieldMsgResult = " + checkRequiredFieldMsgResult); if (checkRequiredFieldMsgResult != "") { //this.showToast("Error", checkRequiredFieldMsgResult + "需要进行填写"); this.showMyToast(checkRequiredFieldMsgResult + "需要进行填写" , '' , 'error') this.isLoading = false; return; } //4. Prepare the payload for New PI API To AWS - To Do let payloadForNewPI = this.getPIPayload(fields); console.log("payloadForNewPI = " + payloadForNewPI); //5. PI To AWS //新建 if(this.isNewMode || this.isCloneMode || this.AWSDataId == ''){ this.NewPIToAWS(payloadForNewPI, fields); return } //编辑 if (this.isEditMode) { this.UpdatePIToAWS(payloadForNewPI, fields); } } //提交保存ToAWS NewPIToAWS(payloadForNewPI, fields) { this.AWSService.post( this.staticResource.newUrl, payloadForNewPI, (result) => { if (result && result.object) { console.log("result = " + JSON.stringify(result)); for (let f in this.AWSToSobjectMap) { if (result.object[0].hasOwnProperty(f)) { fields[this.AWSToSobjectMap[f]] = result.object[0][f]; console.log( "this.AWSToSobjectMap[f] = " + this.AWSToSobjectMap[f] ); console.log( "fields[this.AWSToSobjectMap[f]] = " + fields[this.AWSToSobjectMap[f]] ); } else { console.log(f + "is not in result.object[0]"); } } fields["AWS_Data_Id__c"] = result.object[0].dataId; this.txId = result.txId; console.log("this.txId = " + this.txId); console.log("PI After fields = " + JSON.stringify(fields)); if (fields.RecordTypeId) { console.log( "length = " + JSON.stringify(fields.RecordTypeId.length) ); fields["RecordTypeId"] = fields.RecordTypeId.substring( 1, fields.RecordTypeId.length - 1 ); console.log( "RecordTypeId = " + JSON.stringify(fields["RecordTypeId"]) ); } //保存到后端 this.template .querySelector("lightning-record-edit-form") .submit(fields); } else { console.log("result = " + JSON.stringify(result)); } }, this.staticResource.token ); } //编辑保存ToAWS UpdatePIToAWS(payloadForNewPI, fields) { let obj = JSON.parse(payloadForNewPI); if(this.AWSDataId){ obj[0].dataId = this.AWSDataId; }else{ this.showMyToast("Error", '未找到该记录的AWS Id,请确认记录完整性', 'error'); return; } obj[0].dataId = this.AWSDataId; let payloadForNewPIJson = JSON.stringify(obj); this.AWSService.post( this.staticResource.updateUrl, payloadForNewPIJson, (result) => { if (result && result.object) { console.log("result = " + JSON.stringify(result)); for (let f in this.AWSToSobjectMap) { if (result.object[0].hasOwnProperty(f)) { fields[this.AWSToSobjectMap[f]] = result.object[0][f]; console.log( "this.AWSToSobjectMap[f] = " + this.AWSToSobjectMap[f] ); console.log( "fields[this.AWSToSobjectMap[f]] = " + fields[this.AWSToSobjectMap[f]] ); } else { console.log(f + "is not in result.object[0]"); } } if (this.isNewMode) { fields["AWS_Data_Id__c"] = result.object[0].dataId; } else { //更新 fields["AWS_Data_Id__c"] = this.AWSDataId; } this.txId = result.txId; console.log("this.txId = " + this.txId); console.log("PI After fields = " + JSON.stringify(fields)); if (fields.RecordTypeId) { console.log( "length = " + JSON.stringify(fields.RecordTypeId.length) ); fields["RecordTypeId"] = fields.RecordTypeId.substring( 1, fields.RecordTypeId.length - 1 ); console.log( "RecordTypeId = " + JSON.stringify(fields["RecordTypeId"]) ); } //保存到后端 console.log("update submit = " + JSON.stringify(fields)); this.template .querySelector("lightning-record-edit-form") .submit(fields); } else { console.log("result = " + JSON.stringify(result)); } }, this.staticResource.token ); } //提交保存成功 handleSuccess(event) { let updatedRecord = event.detail.id; console.log("onsuccess: ", updatedRecord); //成功之后确认事物 console.log("confirmTrans"); let that = this; debugger this.AWSService.confirm( true, updatedRecord, this.txId, this.staticResource.token, this.staticResource.transactionUrl, function (result) { console.log("result = " + JSON.stringify(result)); //that.showToast('Success', '保存成功'); that.showMyToast('保存成功', '', 'success'); console.log("updatedRecord = " + updatedRecord); if (that.saveAndNew) { that[NavigationMixin.Navigate]({ type: "standard__objectPage", attributes: { objectApiName: that.sobjectType, actionName: "new", }, state: { recordTypeId: that.recordTypeId, }, }); } else { that[NavigationMixin.Navigate]({ type: "standard__recordPage", attributes: { actionName: "view", recordId: updatedRecord, objectApiName: that.sobjectType, }, }); } } ); } //提交保存失败 handleError(event) { event.preventDefault(); event.stopImmediatePropagation(); //this.showToast("Error", event.detail.detail); //字段级别的报错 if (event.detail.output && event.detail.output.fieldErrors && Object.keys(event.detail.output.fieldErrors).length != 0) { let msg = ''; for (let key in event.detail.output.fieldErrors) { msg += ',' + event.detail.output.fieldErrors[key][0].message; } msg = msg.substring(1); this.showMyToast(event.detail.message + ' : ' + msg, '', 'error'); } else { //add by Li Jun 20231025 Start if(event.detail.message != '' && this.customLabel.LexRecordNotCreateable.indexOf(event.detail.message) != -1){ this.showMyToast("Error", this.customLabel.LexNotCreateNote, 'error'); }else{ this.showMyToast("Error", event.detail.message + ' : ' + event.detail.detail, 'error'); } //add by Li Jun 20231025 End } //add by Li Jun 20231025 Start if(this.txId && this.staticResource){ this.AWSService.confirm(false,'',this.txId,this.staticResource.token,this.staticResource.transactionUrl,function(result){ console.log('result = ' + JSON.stringify(result)) }); } //add by Li Jun 20231025 End } //验证字段 validateFieldValueFormate(fields) { let error_msg = ""; let b = false; for (let key in fields) { if (fields[key] == "*****") b = true; } if (b) error_msg = "下拉框不能主动选择密文选项"; return error_msg; } //验证required字段需要进行填写 checkRequiredFieldMsg(fields) { let msg = ""; // for (let s of this.layout) { // for (let c of s.layoutFields) { // if (c.isRequired && c.editableField && (fields[c.fieldAPI] == null || fields[c.fieldAPI] == '')) { // msg += ';' + c.fieldLabel; // } // } // } for (let s of this.layout) { for (let c of s.layoutColumns) { if (c.layoutItems) { for (let item of c.layoutItems) { if (item.isRequired && (fields[item.field] == null || fields[item.field] === "")){ if(item.field == 'LastName'){ msg += ";" + this.fieldLabel[item.field].label ; }else{ msg += ';' + '姓名'; } } } } } } msg = msg.substring(1); return msg; } //获取PI字段 getPIPayload(sobjJsonLwc) { console.log(); let leadPayloadList = []; let leadPIData = {}; for (let f in this.AWSToSobjectMap) { if (sobjJsonLwc.hasOwnProperty(this.AWSToSobjectMap[f])) { leadPIData[f] = sobjJsonLwc[this.AWSToSobjectMap[f]]; } else { console.log(this.AWSToSobjectMap[f] + "is not in sobjJsonLwc"); } } leadPIData.medicalStaffFullName = leadPIData.lastName; leadPIData.sfRecordId = ""; console.log("Sobject PI Data x :" + leadPIData); leadPayloadList.push(leadPIData); console.log("leadPayloadList = " + JSON.stringify(leadPayloadList)); return JSON.stringify(leadPayloadList); } //查询客户人员根据医院 searchHospitalNameModal(event) { try { let fieldName = event.target.getAttribute("data-field"); console.log("fieldName = " + fieldName); console.log("fieldName = " + typeof fieldName); if (fieldName == "Contact_Name__c") { if (this.hospitalId == "000000000000000" || this.hospitalId == "") { //this.showToast("Error", "请先选择医院名"); this.showMyToast('请先选择医院名' , '' , 'error') return; } //this.template.querySelector(".slds-modal").style="display:none"; debugger this.lostFocus(event); this.isShowSearchAccount = true; } } catch (err) { console.log("err.message = " + err.message); //this.showToast("error", err.message); this.showMyToast(err.message , '' , 'error') } } //失去焦点 lostFocus(event){ // 获取data-*属性值,即要失去焦点的元素的标识符 const elementToBlur = event.target.dataset.elementToBlur; // 选择要失去焦点的元素 const element = this.template.querySelector(`[data-element-to-blur="${elementToBlur}"]`); if(element) element.blur(); } //选择客户人员后进行赋值 handleSelectContact(event) { this.isLoading = true; // 在某个操作的回调函数中 // setTimeout(() => { // this.inputField.dispatchEvent(new CustomEvent("change")); // console.log("end this.inputField.dispatchEvent"); // }, 0); console.log("enter handleSelectContact "); const selectContact = event.detail; console.log("selectContact = " + JSON.stringify(selectContact)); for (let s of this.layout) { for (let c of s.layoutColumns) { if (c.layoutItems) { for (let item of c.layoutItems) { if (item["field"] == "Contact_Name__c") { item["value"] = selectContact.data.medicalStaffFullName; this.contactId = selectContact.data.sfRecordId; } if (item["field"] == "LastName") { item["value"] = selectContact.data.medicalStaffFullName; this.modifyObj["LastName"] = selectContact.data.medicalStaffFullName; console.log("item[value] = " + item["value"]); } } } } } this.layout = [...this.layout]; this.isLoading = false; this.closeHospitalNameModal(); this.iconName = "utility:close"; } //关闭客户人员根据医院模态框 closeHospitalNameModal() { this.isShowSearchAccount = false; this.template.querySelector(".slds-modal").style = ""; } //清空客户姓名 clearName() { console.log("enter clearName"); if (this.modifyObj["LastName"] != "") { this.modifyObj["LastName"] = ""; for (let s of this.layout) { for (let c of s.layoutColumns) { if (c.layoutItems) { for (let item of c.layoutItems) { if (item["field"] == "Contact_Name__c") { item["value"] = ""; this.contactId = ""; } } } } } this.layout = [...this.layout]; this.iconName = "utility:search"; } } //显示信息 showToast(type, msg) { this.isLoading = false; const event = new ShowToastEvent({ //title: type, variant: type, message: msg, }); this.dispatchEvent(event); } //显示信息 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 = '

' + title + '

' + message + '
'; } else { content = '

' + title + '

'; } this.template .querySelector('c-common-toast') .showToast(variant, content, iconName, 10000); this.isLoading = false; } }