import { LightningElement, track, wire ,api} from 'lwc'; import LightningConfirm from 'lightning/confirm'; import jquery183minjs from '@salesforce/resourceUrl/jquery183minjs'; import PleaseWaitDialog from '@salesforce/resourceUrl/PleaseWaitDialog'; import { ShowToastEvent } from 'lightning/platformShowToastEvent'; import Selected from '@salesforce/label/c.Selected'; import Set_Search from '@salesforce/label/c.Set_Search'; import Search_Condition from '@salesforce/label/c.Search_Condition'; import Search from '@salesforce/label/c.Search'; import Search_Result from '@salesforce/label/c.Search_Result'; import { NavigationMixin } from 'lightning/navigation'; import { encodeDefaultFieldValues } from 'lightning/pageReferenceUtils'; import { CurrentPageReference } from 'lightning/navigation'; import { CloseActionScreenEvent } from 'lightning/actions'; import getNeedParm1 from "@salesforce/apex/LexChoiceAssetController.getNeedParm1"; import init from "@salesforce/apex/LexChoiceAssetController.init"; import searchAss from "@salesforce/apex/LexChoiceAssetController.searchAss"; import getData from "@salesforce/apex/LexChoiceAssetController.getData"; import getDatainit from "@salesforce/apex/LexChoiceAssetController.getDatainit"; import getDataNone from "@salesforce/apex/LexChoiceAssetController.getDataNone"; import lwcCSS from '@salesforce/resourceUrl/lwcCSS'; import {loadStyle} from 'lightning/platformResourceLoader'; // hql 20231213 添加贸易合规 start import TradeComplianceStatusFlagFW from '@salesforce/label/c.TradeComplianceStatusFlagFW'; import IFTradeComplianceAlert from '@salesforce/label/c.IFTradeComplianceAlert'; // hql 20231213 添加贸易合规 end // sx 20231218 贸易合规二期 add start import IFTradeComplianceAlert2 from '@salesforce/label/c.IFTradeComplianceAlert2'; import accSendEmailFW from '@salesforce/apex/buttonAssetCtl.accSendEmailFW'; import IFTradeComplianceAlertName from '@salesforce/label/c.IFTradeComplianceAlertName'; // sx 20231218 贸易合规二期 add end const columns = [ { label: '选择', fieldName: 'Selected'}, { label: '保有设备名称', fieldName: 'Name' }, { label: '机身编码', fieldName: 'SerialNumber' }, { label: '医院', fieldName: 'HP_Name' }, { label: '科室', fieldName: 'Department_Name' }, { label: '发货日', fieldName: 'Posting_Date' }, { label: '多年保修期至', fieldName: 'Extend_Gurantee_DateTo'}, { label: '最近一期维修合同结束日', fieldName: 'CurrentContract_End_Date'}, // { label: '无零件风险日期', fieldName: 'NoPartRiskDate'}, ]; export default class lexChoiceAsset extends NavigationMixin(LightningElement) { // Label = { // Set_Search, // Search_Condition, // Search, // Search_Result, // Selected // } @api recordId; IsLoading=true; data = []; columns = columns; SSPLine; Delivered_Product; Department_Name; HospitalId; AirframeCodeEngineer; WorkLocation; DepartmentClass; //搜索需要的数据 @track inputData1; @track inputData2; @track inputData3; Id; currentDate; StatusC; Incharge_Staff; Repair_Detail; FaultTime; RepairApplicantName; HPname; DepName; PlannedVisitDay; ActualVisitDateFirst; RepairsReportDate; ReceiverTime; ActualVisitDateSecon; ActualVisitDateThird; ApplicationTime; AssetCode; canRepair; //搜索出的数据 report onclick拼接需要的参数 needParm2; // 2023 08 04 张赫阳 PIPL相关按钮改造 Start assetName; //AWSId; //deloitte-zhj 20231205 PIPL还原 // 2023 08 04 张赫阳 PIPL相关按钮改造 End shouldRender = false; SupportingProducts; IfDeadHurt; ReturnWayType; ProblemOccurred; ProblemOccurredSelect; ReportAdverseEvents; WhatProject; OperationOrExaminationName; BreakORFallOff; UseFailProductFinish; AfterFailureInformation; Delay15Min; InformationFrom; FailureQInHospital; DelayReportReason; ProductFailureRelated; DeliveryLogisticsNo; engineerSendDate; engineerSendDateTime; //Deloitte-Nancy 20231222 Excworklocation; engineerSendDateStr;//lwt 20240301 // hql 20231213 添加贸易合规 start accDealerBlacklist; a=IFTradeComplianceAlert; b=TradeComplianceStatusFlagFW; // hql 20231213 添加贸易合规 end //deloitte-zhj 20231206 PIPL还原带上直返地址信息 start ReturnedPersonName; ReturnedPersonPhone; ReturnedCustomer; ReturnedCity; ReturnedAddress; ReturnedZipCode; //deloitte-zhj 20231206 PIPL还原带上直返地址信息 end AccountName; // WYL 贸易合规2期 add state; // WYL 贸易合规2期 add @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; } } } handleRowAction(event) { const action = event.detail.action; const row = event.detail.row; switch (action.name) { case '点击添加': this.handleAdd(row); break; default: break; } } handleAdd(row) { // Implement edit logic here console.log('Editing row' + JSON.stringify(row)); this.SetProductId(row.setProductidFull); } getInput1(event){ this.inputData1=event.detail.value; } getInput2(event){ this.inputData2=event.detail.value; } getInput3(event){ this.inputData3=event.detail.value; } connectedCallback(){ Promise.all([ loadStyle(this, lwcCSS) ]); init({ recordId: this.recordId }).then(result => { // console.log(result); if (result != null) { this.IsLoading = false; this.Id = result.Id; this.StatusC = result.StatusC; this.Incharge_Staff = result.OwnerId; this.Repair_Detail = result.Repair_Detail; this.FaultTime = result.FaultTime; this.RepairApplicantName = result.RepairApplicantName; this.HPname = result.HPname; this.AssetCode = result.AssetCode; this.DepName = result.DepName; this.AirframeCodeEngineer = result.AirframeCodeEngineer; this.RepairsReportDate = result.RepairsReportDate; this.ReceiverTime = result.ReceiverTime; this.PlannedVisitDay = result.PlannedVisitDay; this.ActualVisitDateFirst = result.ActualVisitDateFirst; this.ActualVisitDateSecon = result.ActualVisitDateSecon; this.ActualVisitDateThird = result.ActualVisitDateThird; this.SupportingProducts = result.SupportingProducts; this.ApplicationTime = result.ApplicationTime; this.IfDeadHurt = result.IfDeadHurt; this.ReturnWayType = result.ReturnWayType; this.ProblemOccurred = result.ProblemOccurred; this.ProblemOccurredSelect=result.ProblemOccurredSelect; this.ReportAdverseEvents = result.ReportAdverseEvents; this.WhatProject = result.WhatProject; this.OperationOrExaminationName=result.OperationOrExaminationName; this.BreakORFallOff = result.BreakORFallOff; this.UseFailProductFinish = result.UseFailProductFinish; this.AfterFailureInformation = result.AfterFailureInformation; this.Delay15Min = result.Delay15Min; this.InformationFrom = result.InformationFrom; this.FailureQInHospital = result.FailureQInHospital; this.DelayReportReason = result.DelayReportReason; this.ProductFailureRelated = result.ProductFailureRelated; this.DeliveryLogisticsNo = result.DeliveryLogisticsNo; //deloitte-zhj 20231129 PIPL还原 start this.engineerSendDate = result.engineerSendDate; this.engineerSendDateTime = result.engineerSendDateTime; //Deloitte-Nancy 20231222 this.engineerSendDateStr=result.engineerSendDateStr;//lwt 20240301 //deloitte-zhj 20231129 PIPL还原 end this.currentDate = result.currentDate; //deloitte-zhj 20231206 PIPL还原带上直返地址信息 start this.ReturnedPersonName = result.ReturnedPersonName; this.ReturnedPersonPhone = result.ReturnedPersonPhone; this.ReturnedCustomer = result.ReturnedCustomer; this.ReturnedCity = result.ReturnedCity; this.ReturnedAddress = result.ReturnedAddress; this.ReturnedZipCode = result.ReturnedZipCode; //deloitte-zhj 20231206 PIPL还原带上直返地址信息 end //2023 08 21 Zhang Heyang PIPL按钮改造 strat //this.AWSId = result.AWSId; //deloitte-zhj 20231205 PIPL还原 //2023 08 21 Zhang Heyang PIPL按钮改造 end this.SearchSN = this.AssetCode; this.inputData3 = this.AssetCode; // hql 20231213 添加贸易合规 start this.accDealerBlacklist = result.accDealerBlacklist; // hql 20231213 添加贸易合规 end this.AccountName = result.AccountName;// WYL 贸易合规2期 add this.state = result.state; // WYL 贸易合规2期 add // this.ApplyForRepair(); console.log('this.AssetCode='+this.AssetCode); console.log('this.IfDeadHurt='+this.IfDeadHurt); var status = this.StatusC; console.log('status=='+status); if (status != '待处理') { this.dispatchEvent(new CloseActionScreenEvent()); const evt = new ShowToastEvent({ title : '报修子单的状态不是 待处理 无法申请修理', message: '', variant: 'error', mode: 'sticky' }); this.dispatchEvent(evt); // this.dispatchEvent(new CloseActionScreenEvent()); return; }else{ } this.serContactinit(); } }).catch(error => { console.log(error); }) } // WYL 贸易合规2期 邮件 start async SendEmailFW (Hospital,recordId,type,state,Asset_Model_No){ accSendEmailFW({ accname:Hospital, mcid:recordId, type:type, state:state, Asset_Model_No:Asset_Model_No }) .then(result=>{ return; }).catch(err=>{ console.log('邮件错误'+error); }) } // WYL 贸易合规2期 邮件 end // hql 20231213 添加贸易合规 start async invid1() { this.invid(); } async invid() { return new Promise((resolve, reject) => { console.log('IFTradeComplianceAlert=='+this.a); console.log('TradeComplianceStatusFlagFW=='+this.b); console.log('accDealerBlacklist=='+this.accDealerBlacklist); if(this.b=='true'){ if(this.accDealerBlacklist==1){ const evt = new ShowToastEvent({ title : '您所选择的医院存在贸易合规风险,无法新建修理,'+this.a, message: '', variant: 'error', mode: 'sticky' }); this.SendEmailFW(this.AccountName,this.recordId,'1',this.state,null);// WYL 贸易合规add this.dispatchEvent(evt); this.dispatchEvent(new CloseActionScreenEvent()); } //2023/12/18 sx 贸易合规二期 注释 start // else if(this.accDealerBlacklist==2){ // LightningConfirm.open({ // message: '您所选择的医院存在贸易合规警示风险,是否继续申请修理,'+this.a, // variant: 'headerless', // label: 'this is the aria-label value', // }).then(cancel=>{ // if(cancel) { // resolve(true); // } else { // this.dispatchEvent(new CloseActionScreenEvent()); // resolve(false); // } // }); // } //2023/12/18 sx 贸易合规二期 注释 end else{ resolve(true); } }else{ resolve(true); } }); } // hql 20231213 添加贸易合规 end async SelectNone(){ const inputSearchNo = this.template.querySelector('lightning-input[data-target="SearchNo"]'); if (inputSearchNo) { inputSearchNo.value = ''; } const inputSearchName = this.template.querySelector('lightning-input[data-target="SearchName"]'); if (inputSearchName) { inputSearchName.value = ''; } const inputSearchSN = this.template.querySelector('lightning-input[data-target="SearchSN"]'); console.log('inputSearchSN=='+inputSearchSN); if (inputSearchSN) { inputSearchSN.value = ''; } this.inputData1=''; this.inputData2=''; this.inputData3=''; var SearchNo = this.inputData1; var SearchName = this.inputData2; var SearchSN = this.inputData3; await getDataNone({SearchName : SearchName , SearchNo : SearchNo , SearchSN : SearchSN}).then(res=>{ if(res!=null){ this.IsLoading=false; this.data=res; console.log(res); console.log(this.data[0]); } }).catch(error=>{ console.log(error); }) } async validate(){ return new Promise((resolve, reject) => { var selectedRecords = this.template.querySelector("lightning-datatable").getSelectedRows(); var today = new Date(); var targetDate = (today.getFullYear()+1) + '/' + (today.getMonth()+1) + '/' + today.getDate(); var todayNew = today; var partSupplyFinishDate = selectedRecords[0].NoPartRiskDate; var partSupplyFinishDateNew = new Date(partSupplyFinishDate); console.log('partSupplyFinishDateNew=='+partSupplyFinishDateNew); console.log('结果1 ='+partSupplyFinishDateNew > todayNew); console.log('结果2 ='+partSupplyFinishDateNew <= new Date(targetDate)); console.log('getFullYear ='+partSupplyFinishDateNew .getFullYear()); console.log('getMonth ='+partSupplyFinishDateNew.getMonth()); console.log('getDate ='+partSupplyFinishDateNew.getDate()); var monthNum = partSupplyFinishDateNew.getMonth()+1; if (partSupplyFinishDate != null){ var DateOne = partSupplyFinishDateNew.getFullYear() + '/' + monthNum + '/' + partSupplyFinishDateNew.getDate(); console.log('结果3 ='+DateOne); if (partSupplyFinishDateNew > todayNew && partSupplyFinishDateNew <= new Date(targetDate)){ LightningConfirm.open({ message: '预计'+ DateOne +'零件即将停产,请送修前与工厂及RC联络', variant: 'headerless', label: '提示信息', }).then(submit=>{ console.log("ttt:"+submit); if(!submit){ this.dispatchEvent(new CloseActionScreenEvent()); resolve(false); }else{ resolve(true); } }) }else if (partSupplyFinishDateNew <= todayNew){ LightningConfirm.open({ message: '该型号零件已经停产,有特殊需求,请送修前与工厂RC联络', variant: 'headerless', label: '提示信息', }).then(submit=>{ console.log("ttt:"+submit); if(!submit){ this.dispatchEvent(new CloseActionScreenEvent()); resolve(false); }else{ resolve(true); } }) }else{ resolve(true); } }else{ resolve(true); } }); } async SelectDone(){ var selectedRecords = this.template.querySelector("lightning-datatable").getSelectedRows(); console.log('selectedRecords.length=='+selectedRecords.length); if(selectedRecords.length>0){ if (selectedRecords.length>1) { const evt = new ShowToastEvent({ title : '只能选择一个保有设备', message: '', variant: 'error', mode: 'sticky' }); this.dispatchEvent(evt); // this.dispatchEvent(new CloseActionScreenEvent()); return; } const shouldContinue = await this.validate(); console.log('shouldContinue='+shouldContinue); if (!shouldContinue) { return; // 用户选择不继续,退出 } searchAss({ recordId: selectedRecords[0].Assetid }).then(result => { // console.log(result); if (result != null) { console.log('result.canRepair=='+result.canRepair); this.IsLoading = false; this.canRepair = result.canRepair; if (this.canRepair == 'RC送修') { this.Excworklocation = true; } } console.log('this.canRepair=='+this.canRepair); if (this.canRepair == '第三方') { const evt = new ShowToastEvent({ title : '非我司修理对象,无法新建修理,如有不明请咨询CIC', message: '', variant: 'error', mode: 'sticky' }); this.dispatchEvent(evt); // this.dispatchEvent(new CloseActionScreenEvent()); return; } if (this.canRepair == '不'||this.canRepair == null) { const evt = new ShowToastEvent({ title : '本设备无法新建修理', message: '', variant: 'error', mode: 'sticky' }); this.dispatchEvent(evt); // this.dispatchEvent(new CloseActionScreenEvent()); return; } if (this.Id == null || this.Id == '') { const evt = new ShowToastEvent({ title : '报修子单Id 不能为空', message: '', variant: 'error', mode: 'sticky' }); this.dispatchEvent(evt); // this.dispatchEvent(new CloseActionScreenEvent()); return; } //20231218 sx 贸易合规二期 add start // WYl 2024/1/30 update 新增proTradeComplianceStatus 判断条件 start if(this.accDealerBlacklist==2 && result.proTradeComplianceStatus == '0'){ // WYl 2024/1/30 update 新增proTradeComplianceStatus 判断条件 end this.SendEmailFW(this.AccountName,this.recordId,'9',this.state,result.Asset_Model_No); LightningConfirm.open({ message: '您此次申请的业务可能存在贸易合规风险,是否继续申请,如有问题请联系法务本部贸易合规窗口'+IFTradeComplianceAlertName+'进一步评估(一般需5-10个工作日)', variant: 'headerless', label: 'this is the aria-label value', }).then(confirm=>{ if(confirm){ // 2023 08 04 张赫阳 PIPL相关按钮改造 Start this.assetName = selectedRecords[0].Name; // 2023 08 04 张赫阳 PIPL相关按钮改造 End this.Delivered_Product = selectedRecords[0].Assetid; this.Department_Name = selectedRecords[0].Accountid; this.HospitalId = selectedRecords[0].Hospital; this.WorkLocation = selectedRecords[0].WorkLocation; this.DepartmentClass = selectedRecords[0].DepartmentClass; this.navigateToNewObjectPage(); }else{ return; } }) }else{ // 2023 08 04 张赫阳 PIPL相关按钮改造 Start this.assetName = selectedRecords[0].Name; // 2023 08 04 张赫阳 PIPL相关按钮改造 End this.Delivered_Product = selectedRecords[0].Assetid; this.Department_Name = selectedRecords[0].Accountid; this.HospitalId = selectedRecords[0].Hospital; this.WorkLocation = selectedRecords[0].WorkLocation; this.DepartmentClass = selectedRecords[0].DepartmentClass; this.navigateToNewObjectPage(); } //20231218 sx 贸易合规二期 add end }).catch(error => { console.log(error); }) }else{ console.log('else'); const evt = new ShowToastEvent({ title : '请选择一个保有设备', message: '', variant: 'error', mode: 'sticky' }); this.dispatchEvent(evt); // this.dispatchEvent(new CloseActionScreenEvent()); return; } } async serContactinit(){ console.log('into serContact') // hql 20231213 添加贸易合规 start const shouldToContinue = await this.invid(); if (!shouldToContinue) { return; // 用户选择不继续,退出 } this.shouldRender = true; // hql 20231213 添加贸易合规 end if (this.template.querySelector("lightning-datatable") !=null) { // 刷新数据表 const dataTable = this.template.querySelector('lightning-datatable'); dataTable.selectedRows = []; // dataTable.refresh(); console.log('执行') } var SearchNo = this.inputData1; var SearchName = this.inputData2; var SearchSN = this.inputData3; if(SearchSN == undefined){ SearchSN=''; } if(SearchName == undefined){ SearchName=''; } if(SearchNo == undefined){ SearchNo = ''; } console.log('SearchName='+SearchName); console.log('SearchNo='+SearchNo); console.log('SearchSN='+SearchSN); await getDatainit({SearchName : SearchName , SearchNo : SearchNo , SearchSN : SearchSN}).then(res=>{ // console.log('res==='+res); // console.log('res2==='+res[0].name); if(res!=null){ this.IsLoading=false; this.data=res; console.log(res); console.log(this.data[0]); } }).catch(error=>{ console.log(error); }) } async serContact(){ console.log('into serContact') if (this.template.querySelector("lightning-datatable") !=null) { // 刷新数据表 const dataTable = this.template.querySelector('lightning-datatable'); dataTable.selectedRows = []; // dataTable.refresh(); console.log('执行') } var SearchNo = this.inputData1; var SearchName = this.inputData2; var SearchSN = this.inputData3; if(SearchSN == undefined){ SearchSN=''; } if(SearchName == undefined){ SearchName=''; } if(SearchNo == undefined){ SearchNo = ''; } console.log('SearchName='+SearchName); console.log('SearchNo='+SearchNo); console.log('SearchSN='+SearchSN); await getData({SearchName : SearchName , SearchNo : SearchNo , SearchSN : SearchSN}).then(res=>{ // console.log('res==='+res); // console.log('res2==='+res[0].name); if(res!=null){ this.IsLoading=false; this.data=res; console.log(res); console.log(this.data[0]); } }).catch(error=>{ console.log(error); }) } navigateToNewObjectPage() { // console.log('RepairApplicantName=='+this.RepairApplicantName); // console.log('this.id=='+this.id); // var currentDate = new Date(); const defaultFieldValues =encodeDefaultFieldValues({ Delivered_Product__c: this.Delivered_Product, // 2023 08 04 张赫阳 PIPL相关按钮改造 Start AssetName: this.assetName, //AWSId: this.AWSId, //deloitte-zhj 20231205 PIPL还原 // 2023 08 04 张赫阳 PIPL相关按钮改造 End Account__c: this.Department_Name, Hospital__c: this.HospitalId, SalesOfficeCode_selection__c: this.WorkLocation, Incharge_Staff__c:this.Incharge_Staff, Repair_Detail__c:this.Repair_Detail, Failure_Occurrence_Date__c:this.FaultTime, Repair_Source__c:'从报修子单', RepairApplicant__c:this.RepairApplicantName, RepairApplicantHospital__c:this.HPname, RepairApplicantDepartment__c:this.DepName, RepairTime__c:this.RepairsReportDate, ReceiverTime__c:this.ReceiverTime, PlannedVisitDay__c:this.PlannedVisitDay, ActualVisitDateFirst__c:this.ActualVisitDateFirst, ActualVisitDateSecond__c:this.ActualVisitDateSecon, ActualVisitDateThird__c:this.ActualVisitDateThird, SubOrderCreatedDate__c:this.currentDate, Exc_work_location__c:this.Excworklocation, DateReceiptQuestions__c:this.ApplicationTime, RepairSubOrder__c:this.recordId, Department_Class__c:this.DepartmentClass, SupportingProducts__c:this.SupportingProducts, ifDeadHurt__c:this.IfDeadHurt, ProblemOccurred__c:this.ProblemOccurred, Returns_Product_way__c:this.ReturnWayType, // hql 20231212 增加移动端申请修理日传值 start SubOrderCompleteDate__c: this.ApplicationTime, // hql 20231212 增加移动端申请修理日传值 end ProblemOccurredSelect__c:this.ProblemOccurredSelect, ReportAdverseEvents__c:this.ReportAdverseEvents, WhatProject__c:this.WhatProject, OperationOrExaminationName__c:this.OperationOrExaminationName, BreakORFallOff__c:this.BreakORFallOff, UseFailProductFinish__c:this.UseFailProductFinish, AfterFailureInformation__c:this.AfterFailureInformation, Delay15Min__c:this.Delay15Min, InformationFrom__c:this.InformationFrom, FailureQInHospital__c:this.FailureQInHospital, DelayReportReason__c:this.DelayReportReason, ProductFailureRelated__c:this.ProductFailureRelated, DeliveryLogisticsNo__c:this.DeliveryLogisticsNo, //20231227 lwt DB202312554975 start // engineerSendDate__c:this.engineerSendDateTime,//Deloitte-Nancy 20231222 Send_To_RC_Date__c:this.engineerSendDateStr, //20231227 lwt DB202312554975 end PassType:'lexChoiceAsset', //deloitte-zhj 2023-09-14 //deloitte-zhj 20231206 PIPL还原带上直返地址信息 start address_Contacts__c:this.ReturnedPersonName, address_Telephone__c:this.ReturnedPersonPhone, address_Contacts_Name__c:this.ReturnedCustomer, address_City__c:this.ReturnedCity, Detailed_Address__c:this.ReturnedAddress, address_ZipCode__c:this.ReturnedZipCode //deloitte-zhj 20231206 PIPL还原带上直返地址信息 end }); this[NavigationMixin.Navigate]({ type: 'standard__objectPage', attributes: { objectApiName: 'Repair__c', actionName: 'new' }, state: { // 2023 08 07 张赫阳 PIPL相关按钮改造 Start //nooverride: '1', // 2023 08 07 张赫阳 PIPL相关按钮改造 End defaultFieldValues: defaultFieldValues } }); this.dispatchEvent(new CloseActionScreenEvent()); } }