From dfff58b7cd897b824a129edba6b5cdae20bb1e5c Mon Sep 17 00:00:00 2001
From: unknown <sunxia@prec-tech.com>
Date: 星期三, 23 八月 2023 17:40:58 +0800
Subject: [PATCH] 发起再注册分析并同步SAP
---
force-app/main/default/lwc/lexCreateRepairFromAsset/lexCreateRepairFromAsset.js | 297 +++++++++++++++++++++++++++++++++++++---------------------
1 files changed, 188 insertions(+), 109 deletions(-)
diff --git a/force-app/main/default/lwc/lexCreateRepairFromAsset/lexCreateRepairFromAsset.js b/force-app/main/default/lwc/lexCreateRepairFromAsset/lexCreateRepairFromAsset.js
index 7b58902..97ec5dd 100644
--- a/force-app/main/default/lwc/lexCreateRepairFromAsset/lexCreateRepairFromAsset.js
+++ b/force-app/main/default/lwc/lexCreateRepairFromAsset/lexCreateRepairFromAsset.js
@@ -15,8 +15,18 @@
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;
@@ -38,6 +48,20 @@
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) {
@@ -56,7 +80,6 @@
}).then(result => {
console.log(result);
if (result != null) {
- this.IsLoading = false;
this.Id = result.Id;
this.userID = result.userID;
this.day = result.day;
@@ -84,9 +107,6 @@
}
this.CreateRepairFromAsset();
})
-
-
- this.dispatchEvent(new CloseActionScreenEvent());
}
}).catch(error => {
console.log(error);
@@ -102,61 +122,61 @@
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澶╁唴閲嶅鎶ュ憡锛屽鏋滄槸锛岃浣跨敤鍘烸IS淇℃伅濉啓銆�');
- 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澶╁唴閲嶅鎶ュ憡锛屽鏋滄槸锛岃浣跨敤鍘烸IS淇℃伅濉啓銆�');
+ } 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;
- }
+
+ var partSupplyFinishDate = this.NoPartRiskDateFC;
+ if (this.day < this.NoPartRiskDateFC && this.NoPartRiskDateFC <= this.day2) {
+ this.ShowToastEvent('棰勮' + partSupplyFinishDate + '闆朵欢鍗冲皢鍋滀骇锛岃閫佷慨鍓嶄笌宸ュ巶鍙奟C鑱旂粶', "error");
+ this.dispatchEvent(new CloseActionScreenEvent());
+ return;
+ }
+ if (this.NoPartRiskDateFC != null && this.NoPartRiskDateFC != undefined && this.NoPartRiskDateFC <= this.day) {
+ this.ShowToastEvent('璇ュ瀷鍙烽浂浠跺凡缁忓仠浜э紝鏈夌壒娈婇渶姹傦紝璇烽�佷慨鍓嶄笌宸ュ巶RC鑱旂粶', "error");
+ this.dispatchEvent(new CloseActionScreenEvent());
+ return;
}
if (records2.length >= 1) {
- Old_Repair_Name = records2[0].Name;
+ this.Old_Repair_Name = records2[0].Name;
+ }
+ if (records2.length >= 1) {
+ this.handleConfirmClick02('姝や欢璁惧濡備负10澶╁唴閲嶅鎶ュ憡锛屽缓璁洖鍒板師淇悊鍗曚娇鐢ㄥ鍒跺姛鑳芥彁浜ゃ�傝纭鏄惁缁х画鏂板缓淇悊锛� ');
+ } else {
+ this.ll();
}
})
- var partSupplyFinishDate = this.NoPartRiskDateFC;
- if (this.day < this.NoPartRiskDateFC && this.NoPartRiskDateFC <= this.day2) {
- alert('棰勮' + partSupplyFinishDate + '闆朵欢鍗冲皢鍋滀骇锛岃閫佷慨鍓嶄笌宸ュ巶鍙奟C鑱旂粶');
- }
- if (this.NoPartRiskDateFC != null && this.NoPartRiskDateFC != undefined && this.NoPartRiskDateFC <= this.day) {
- alert('璇ュ瀷鍙烽浂浠跺凡缁忓仠浜э紝鏈夌壒娈婇渶姹傦紝璇烽�佷慨鍓嶄笌宸ュ巶RC鑱旂粶');
- }
+ }
+
+ ll() {
selecctProduct2ById({
Id: this.ProductIDC
}).then(recordP => {
@@ -165,87 +185,146 @@
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(List);
- if (List != null) {
- var RecordTypeId = List[0]['Parent']['RecordType_DeveloperName__c'].substring(0, 15);
- 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'];
- }
- 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'];
- }
- 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'];
- }
- } 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'];
- }
+ selecctAccountByAccountId({
+ AccountId: this.AccountId
+ }).then(List => {
+ console.log(List);
+ if (List != null) {
+ var RecordTypeId = List[0]['Parent']['RecordType_DeveloperName__c'].substring(0, 15);
+ console.log(RecordTypeId);
+ if (RecordTypeId != 'Agency') {
+ if (List[0]['Parent']['Parent']['FSE_GI_Main_Leader__c'] != null) {
+ 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) {
+ 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) {
+ 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) {
+ this.Work_Location = List[0]['Parent']['Parent']['FSE_SP_Main_Leader__r']['this.Work_Location__c'];
+ }
+ }
+ }
+ if (RecordTypeId == 'Department_Class_GI') {
+ this.Incharge_Staff = this.FSE_GI_Main_Leader__name;
+ this.Incharge_Staff_id = this.FSE_GI_Main_Leader__id;
+ }
+ if (RecordTypeId == 'Department_Class_BF') {
+ this.Incharge_Staff = this.FSE_GI_Main_Leader__name;
+ this.Incharge_Staff_id = this.FSE_GI_Main_Leader__id;
+ }
+ if (RecordTypeId == 'Department_Class_ET') {
+ this.Incharge_Staff = this.FSE_GI_Main_Leader__name;
+ this.Incharge_Staff_id = this.FSE_GI_Main_Leader__id;
+ }
+ if (RecordTypeId == 'Department_Class_GS') {
+ this.Incharge_Staff = this.FSE_SP_Main_Leader__name;
+ this.Incharge_Staff_id = this.FSE_SP_Main_Leader__id;
+ }
+ if (RecordTypeId == 'Department_Class_URO') {
+ this.Incharge_Staff = this.FSE_SP_Main_Leader__name;
+ this.Incharge_Staff_id = this.FSE_SP_Main_Leader__id;
+ }
+ if (RecordTypeId == 'Department_Class_ENT') {
+ this.Incharge_Staff = this.FSE_SP_Main_Leader__name;
+ this.Incharge_Staff_id = this.FSE_SP_Main_Leader__id;
+ }
+ if (RecordTypeId == 'Department_Class_GYN') {
+ this.Incharge_Staff = this.FSE_SP_Main_Leader__name;
+ this.Incharge_Staff_id = this.FSE_SP_Main_Leader__id;
+ }
+ if (RecordTypeId == 'Department_Class_OTH') {
+ this.Incharge_Staff = this.FSE_SP_Main_Leader__name;
+ this.Incharge_Staff_id = this.FSE_SP_Main_Leader__id;
}
}
- if (RecordTypeId == 'Department_Class_GI') {
- Incharge_Staff = FSE_GI_Main_Leader__name;
- Incharge_Staff_id = 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;
- }
- if (RecordTypeId == 'Department_Class_ET') {
- Incharge_Staff = FSE_GI_Main_Leader__name;
- Incharge_Staff_id = 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;
- }
- if (RecordTypeId == 'Department_Class_URO') {
- Incharge_Staff = FSE_SP_Main_Leader__name;
- Incharge_Staff_id = 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;
- }
- if (RecordTypeId == 'Department_Class_GYN') {
- Incharge_Staff = FSE_SP_Main_Leader__name;
- Incharge_Staff_id = 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;
- }
}
-
- }
- 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);
+ 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());
+ }
+ }
+
+ ShowToastEvent(msg, type) {
+ const event = new ShowToastEvent({
+ title: '',
+ message: msg,
+ variant: type
+ });
+ this.dispatchEvent(event);
+ }
+
+ closeAction() {
+ location.reload();
+ }
}
\ No newline at end of file
--
Gitblit v1.9.1