| | |
| | | import selecctProduct2ById from '@salesforce/apex/buttonAssetCtl.selecctProduct2ById'; |
| | | import selecctRepairByFomatToday from '@salesforce/apex/buttonAssetCtl.selecctRepairByFomatToday'; |
| | | import selecctQISReportByFomatToday from '@salesforce/apex/buttonAssetCtl.selecctQISReportByFomatToday'; |
| | | import { |
| | | NavigationMixin |
| | | } from 'lightning/navigation'; |
| | | import { |
| | | encodeDefaultFieldValues |
| | | } from 'lightning/pageReferenceUtils'; |
| | | import LightningConfirm from 'lightning/confirm'; |
| | | import { |
| | | ShowToastEvent |
| | | } from 'lightning/platformShowToastEvent'; |
| | | |
| | | export default class LexCreateRepairFromAsset extends LightningElement { |
| | | export default class LexCreateRepairFromAsset extends NavigationMixin(LightningElement) { |
| | | @api recordId; |
| | | str; |
| | | IsLoading = true; |
| | |
| | | RepairSalesPointProvinceChinaC; |
| | | notCreateRepairFromAssetButton; |
| | | notCreateRepairFromAssetButton02; |
| | | msg; |
| | | flag = false; |
| | | fomatToday; |
| | | QIS_Name = ''; |
| | | QIS_Id = ''; |
| | | Old_Repair_Name = ''; |
| | | Work_Location = ''; |
| | | FSE_GI_Main_Leader__id = ''; |
| | | FSE_GI_Main_Leader__name = ''; |
| | | FSE_SP_Main_Leader__id = ''; |
| | | FSE_SP_Main_Leader__name = ''; |
| | | Incharge_Staff = ''; |
| | | Incharge_Staff_id = ''; |
| | | |
| | | |
| | | @wire(CurrentPageReference) |
| | | getStateParameters(currentPageReference) { |
| | |
| | | }).then(result => { |
| | | console.log(result); |
| | | if (result != null) { |
| | | this.IsLoading = false; |
| | | this.Id = result.Id; |
| | | this.userID = result.userID; |
| | | this.day = result.day; |
| | |
| | | } |
| | | this.CreateRepairFromAsset(); |
| | | }) |
| | | |
| | | |
| | | this.dispatchEvent(new CloseActionScreenEvent()); |
| | | } |
| | | }).catch(error => { |
| | | console.log(error); |
| | |
| | | var EmployeeNo = this.EmployeeNoC; |
| | | |
| | | if (nCRepairFromAssetBList.indexOf(EmployeeNo) != -1) { |
| | | alert("对不起,您无权使用此按钮创建修理!"); |
| | | this.ShowToastEvent("对不起,您无权使用此按钮创建修理!", "error"); |
| | | this.dispatchEvent(new CloseActionScreenEvent()); |
| | | return; |
| | | } |
| | | |
| | | var fomatToday = this.day1; |
| | | var QIS_Name = ''; |
| | | var QIS_Id = ''; |
| | | var url1 = ""; |
| | | var FSE_GI_Main_Leader__id = ''; |
| | | var FSE_GI_Main_Leader__name = ''; |
| | | var FSE_SP_Main_Leader__id = ''; |
| | | var FSE_SP_Main_Leader__name = ''; |
| | | var Incharge_Staff = ''; |
| | | var Incharge_Staff_id = ''; |
| | | var Work_Location = ''; |
| | | var Old_Repair_Name = ''; |
| | | this.fomatToday = this.day1; |
| | | |
| | | |
| | | selecctQISReportByFomatToday({ |
| | | AssetId: this.Id, |
| | | fomatToday: fomatToday |
| | | fomatToday: this.fomatToday |
| | | }).then(records => { |
| | | console.log(records); |
| | | if (records.length >= 1) { |
| | | var boolday = confirm('请确认此件是否属于10天内重复报告,如果是,请使用原QIS信息填写。'); |
| | | if (!boolday) { |
| | | return; |
| | | } |
| | | this.QIS_Name = records[0].Name; |
| | | this.QIS_Id = records[0].Id; |
| | | } |
| | | if (records.length >= 1) { |
| | | QIS_Name = records[0].Name; |
| | | QIS_Id = records[0].Id; |
| | | this.handleConfirmClick01('请确认此件是否属于10天内重复报告,如果是,请使用原QIS信息填写。'); |
| | | } else { |
| | | this.ss(); |
| | | } |
| | | |
| | | }) |
| | | } |
| | | |
| | | ss() { |
| | | selecctRepairByFomatToday({ |
| | | AssetId: this.Id, |
| | | fomatToday: fomatToday |
| | | fomatToday: this.fomatToday |
| | | }).then(records2 => { |
| | | console.log(records2); |
| | | if (records2.length >= 1) { |
| | | var boolday = confirm('此件设备如为10天内重复报告,建议回到原修理单使用复制功能提交。请确认是否继续新建修理? '); |
| | | if (!boolday) { |
| | | return; |
| | | } |
| | | } |
| | | if (records2.length >= 1) { |
| | | Old_Repair_Name = records2[0].Name; |
| | | } |
| | | }) |
| | | |
| | | var partSupplyFinishDate = this.NoPartRiskDateFC; |
| | | if (this.day < this.NoPartRiskDateFC && this.NoPartRiskDateFC <= this.day2) { |
| | | alert('预计' + partSupplyFinishDate + '零件即将停产,请送修前与工厂及RC联络'); |
| | | this.ShowToastEvent('预计' + partSupplyFinishDate + '零件即将停产,请送修前与工厂及RC联络', "error"); |
| | | this.dispatchEvent(new CloseActionScreenEvent()); |
| | | return; |
| | | } |
| | | if (this.NoPartRiskDateFC != null && this.NoPartRiskDateFC != undefined && this.NoPartRiskDateFC <= this.day) { |
| | | alert('该型号零件已经停产,有特殊需求,请送修前与工厂RC联络'); |
| | | this.ShowToastEvent('该型号零件已经停产,有特殊需求,请送修前与工厂RC联络', "error"); |
| | | this.dispatchEvent(new CloseActionScreenEvent()); |
| | | return; |
| | | } |
| | | if (records2.length >= 1) { |
| | | this.Old_Repair_Name = records2[0].Name; |
| | | } |
| | | if (records2.length >= 1) { |
| | | this.handleConfirmClick02('此件设备如为10天内重复报告,建议回到原修理单使用复制功能提交。请确认是否继续新建修理? '); |
| | | } else { |
| | | this.ll(); |
| | | } |
| | | }) |
| | | } |
| | | |
| | | ll() { |
| | | selecctProduct2ById({ |
| | | Id: this.ProductIDC |
| | | }).then(recordP => { |
| | |
| | | if (recordP != null && recordP.length > 0) { |
| | | var canRepair = recordP[0].Can_Repair__c; |
| | | if (canRepair == '第三方') { |
| | | alert('非我司修理对象,无法新建修理,如有不明请咨询CIC'); |
| | | this.ShowToastEvent('非我司修理对象,无法新建修理,如有不明请咨询CIC', "error"); |
| | | this.dispatchEvent(new CloseActionScreenEvent()); |
| | | return; |
| | | } |
| | | if (canRepair == '不' || canRepair == null) { |
| | | alert('本设备无法新建修理'); |
| | | this.ShowToastEvent('本设备无法新建修理', "error"); |
| | | this.dispatchEvent(new CloseActionScreenEvent()); |
| | | return; |
| | | } |
| | | if (canRepair == 'RC送修') { |
| | | url1 = "&00N10000009HAJl=TRUE" |
| | | this.flag = true; |
| | | } |
| | | } |
| | | }) |
| | | selecctAccountByAccountId({ |
| | | AccountId: this.AccountId |
| | | }).then(List => { |
| | |
| | | console.log(RecordTypeId); |
| | | if (RecordTypeId != 'Agency') { |
| | | if (List[0]['Parent']['Parent']['FSE_GI_Main_Leader__c'] != null) { |
| | | FSE_GI_Main_Leader__id = List[0]['Parent']['Parent']['FSE_GI_Main_Leader__c'].substring(0, 15); |
| | | FSE_GI_Main_Leader__name = List[0]['Parent']['Parent']['FSE_GI_Main_Leader__r']['Name']; |
| | | this.FSE_GI_Main_Leader__id = List[0]['Parent']['Parent']['FSE_GI_Main_Leader__c'].substring(0, 15); |
| | | this.FSE_GI_Main_Leader__name = List[0]['Parent']['Parent']['FSE_GI_Main_Leader__r']['Name']; |
| | | } |
| | | if (List[0]['Parent']['Parent']['FSE_SP_Main_Leader__c'] != null) { |
| | | FSE_SP_Main_Leader__id = List[0]['Parent']['Parent']['FSE_SP_Main_Leader__c'].substring(0, 15); |
| | | FSE_SP_Main_Leader__name = List[0]['Parent']['Parent']['FSE_SP_Main_Leader__r']['Name']; |
| | | this.FSE_SP_Main_Leader__id = List[0]['Parent']['Parent']['FSE_SP_Main_Leader__c'].substring(0, 15); |
| | | this.FSE_SP_Main_Leader__name = List[0]['Parent']['Parent']['FSE_SP_Main_Leader__r']['Name']; |
| | | } |
| | | if (List[0]['Parent']['RecordType_DeveloperName__c'] != null || List[0]['Parent']['RecordType_DeveloperName__c'] != undefined) { |
| | | var recordId = List[0]['Parent']['RecordType_DeveloperName__c'].substring(0, 15); |
| | | if (recordId == 'Department_Class_GI' || recordId == 'Department_Class_BF' || recordId == 'Department_Class_ET') { |
| | | if (List[0]['Parent']['Parent']['FSE_GI_Main_Leader__c'] != null) { |
| | | Work_Location = List[0]['Parent']['Parent']['FSE_GI_Main_Leader__r']['Work_Location__c']; |
| | | this.Work_Location = List[0]['Parent']['Parent']['FSE_GI_Main_Leader__r']['this.Work_Location__c']; |
| | | } |
| | | } else if (recordId == 'Department_Class_GS' || recordId == 'Department_Class_URO' || recordId == 'Department_Class_ENT' || recordId == 'Department_Class_GYN' || recordId == 'Department_Class_OTH') { |
| | | if (List[0]['Parent']['Parent']['FSE_SP_Main_Leader__c'] != null) { |
| | | Work_Location = List[0]['Parent']['Parent']['FSE_SP_Main_Leader__r']['Work_Location__c']; |
| | | this.Work_Location = List[0]['Parent']['Parent']['FSE_SP_Main_Leader__r']['this.Work_Location__c']; |
| | | } |
| | | |
| | | } |
| | | } |
| | | if (RecordTypeId == 'Department_Class_GI') { |
| | | Incharge_Staff = FSE_GI_Main_Leader__name; |
| | | Incharge_Staff_id = FSE_GI_Main_Leader__id; |
| | | this.Incharge_Staff = this.FSE_GI_Main_Leader__name; |
| | | this.Incharge_Staff_id = this.FSE_GI_Main_Leader__id; |
| | | } |
| | | if (RecordTypeId == 'Department_Class_BF') { |
| | | Incharge_Staff = FSE_GI_Main_Leader__name; |
| | | Incharge_Staff_id = FSE_GI_Main_Leader__id; |
| | | this.Incharge_Staff = this.FSE_GI_Main_Leader__name; |
| | | this.Incharge_Staff_id = this.FSE_GI_Main_Leader__id; |
| | | } |
| | | if (RecordTypeId == 'Department_Class_ET') { |
| | | Incharge_Staff = FSE_GI_Main_Leader__name; |
| | | Incharge_Staff_id = FSE_GI_Main_Leader__id; |
| | | this.Incharge_Staff = this.FSE_GI_Main_Leader__name; |
| | | this.Incharge_Staff_id = this.FSE_GI_Main_Leader__id; |
| | | } |
| | | if (RecordTypeId == 'Department_Class_GS') { |
| | | Incharge_Staff = FSE_SP_Main_Leader__name; |
| | | Incharge_Staff_id = FSE_SP_Main_Leader__id; |
| | | this.Incharge_Staff = this.FSE_SP_Main_Leader__name; |
| | | this.Incharge_Staff_id = this.FSE_SP_Main_Leader__id; |
| | | } |
| | | if (RecordTypeId == 'Department_Class_URO') { |
| | | Incharge_Staff = FSE_SP_Main_Leader__name; |
| | | Incharge_Staff_id = FSE_SP_Main_Leader__id; |
| | | this.Incharge_Staff = this.FSE_SP_Main_Leader__name; |
| | | this.Incharge_Staff_id = this.FSE_SP_Main_Leader__id; |
| | | } |
| | | if (RecordTypeId == 'Department_Class_ENT') { |
| | | Incharge_Staff = FSE_SP_Main_Leader__name; |
| | | Incharge_Staff_id = FSE_SP_Main_Leader__id; |
| | | this.Incharge_Staff = this.FSE_SP_Main_Leader__name; |
| | | this.Incharge_Staff_id = this.FSE_SP_Main_Leader__id; |
| | | } |
| | | if (RecordTypeId == 'Department_Class_GYN') { |
| | | Incharge_Staff = FSE_SP_Main_Leader__name; |
| | | Incharge_Staff_id = FSE_SP_Main_Leader__id; |
| | | this.Incharge_Staff = this.FSE_SP_Main_Leader__name; |
| | | this.Incharge_Staff_id = this.FSE_SP_Main_Leader__id; |
| | | } |
| | | if (RecordTypeId == 'Department_Class_OTH') { |
| | | Incharge_Staff = FSE_SP_Main_Leader__name; |
| | | Incharge_Staff_id = FSE_SP_Main_Leader__id; |
| | | this.Incharge_Staff = this.FSE_SP_Main_Leader__name; |
| | | this.Incharge_Staff_id = this.FSE_SP_Main_Leader__id; |
| | | } |
| | | } |
| | | } |
| | | const url = encodeDefaultFieldValues({ |
| | | Hospital__c: this.HospitalId, |
| | | Department_Class__c: this.DepartmentClassId, |
| | | Account__c: this.AccountId, |
| | | Delivered_Product__c: this.Id, |
| | | Incharge_Staff__c: this.Incharge_Staff_id, |
| | | Work_Location_select__c: this.RepairSalesPointProvinceChinaC, |
| | | SalesOfficeCode_selection__c: encodeURI(this.Work_Location), |
| | | Source_QIS__c: this.QIS_Id, |
| | | Old_Name__c: this.Old_Repair_Name, |
| | | Exc_Work_Location__c: this.flag |
| | | }); |
| | | this[NavigationMixin.Navigate]({ |
| | | type: 'standard__objectPage', |
| | | attributes: { |
| | | objectApiName: 'Repair__c', |
| | | actionName: 'new' |
| | | }, |
| | | state: { |
| | | nooverride: '1', |
| | | defaultFieldValues: url |
| | | } |
| | | }); |
| | | this.dispatchEvent(new CloseActionScreenEvent()); |
| | | }) |
| | | }) |
| | | } |
| | | |
| | | async handleConfirmClick01(msg) { |
| | | const result = await LightningConfirm.open({ |
| | | message: msg, |
| | | variant: 'headerless', |
| | | label: 'this is the aria-label value' |
| | | }); |
| | | if (result) { |
| | | this.ss(); |
| | | } else { |
| | | this.dispatchEvent(new CloseActionScreenEvent()); |
| | | } |
| | | } |
| | | |
| | | async handleConfirmClick02(msg) { |
| | | const result = await LightningConfirm.open({ |
| | | message: msg, |
| | | variant: 'headerless', |
| | | label: 'this is the aria-label value' |
| | | }); |
| | | if (result) { |
| | | this.ll(); |
| | | } else { |
| | | this.dispatchEvent(new CloseActionScreenEvent()); |
| | | } |
| | | var url = "/a0J/e?CF00N10000002Dx66_lkid=" + this.HospitalId + "&CF00N10000002Dx66=" + this.HospitalC + "&CF00N10000002Dx5t_lkid=" + this.DepartmentClassId + "&CF00N10000002Dx5t=" + this.DepartmentClassC + "&CF00N10000002Dx5n_lkid=" + this.Id + "&CF00N10000002Dx5n=" + this.Name + "&CF00N10000002Dx1X_lkid=" + this.Id + "&CF00N10000002Dx1X=" + this.Name + "&CF00N10000002EMHw_lkid=" + Incharge_Staff_id + "&CF00N10000002EMHw=" + Incharge_Staff + "&00N10000002FH86=%e5%8f%aa%e4%bf%ae%e7%90%86&00N10000006P6Rn=" + this.RepairSalesPointProvinceChinaC + "&00N10000006P6SM=" + encodeURI(Work_Location) + "&CF00N10000009H7yM=" + QIS_Name + "&CF00N10000009H7yM_lkid=" + QIS_Id + "&00N10000009H2fa=" + Old_Repair_Name + "&retURL=%2F" + this.Id; |
| | | if (url1 != undefined) { |
| | | url = url + url1; |
| | | } |
| | | window.open(url); |
| | | }) |
| | | |
| | | ShowToastEvent(msg, type) { |
| | | const event = new ShowToastEvent({ |
| | | title: '', |
| | | message: msg, |
| | | variant: type |
| | | }); |
| | | this.dispatchEvent(event); |
| | | } |
| | | |
| | | closeAction() { |
| | | location.reload(); |
| | | } |
| | | } |