From 7cd5d7cecb0bc9fef2a34488e5dec8ba15b3e827 Mon Sep 17 00:00:00 2001
From: unknown <sunxia@prec-tech.com>
Date: 星期四, 11 五月 2023 17:39:15 +0800
Subject: [PATCH] 备品借出申请-出库指示

---
 force-app/main/default/lwc/lexLoanerArrangedEmail/lexLoanerArrangedEmail.js |   77 ++++++++++++++++---------
 force-app/main/default/classes/loanerArrangedEmailController.cls            |   67 ++++++++++------------
 2 files changed, 79 insertions(+), 65 deletions(-)

diff --git a/force-app/main/default/classes/loanerArrangedEmailController.cls b/force-app/main/default/classes/loanerArrangedEmailController.cls
index bb34d2f..fd8db23 100644
--- a/force-app/main/default/classes/loanerArrangedEmailController.cls
+++ b/force-app/main/default/classes/loanerArrangedEmailController.cls
@@ -1,9 +1,4 @@
-public with sharing class loanerArrangedEmailController {
-
-	
-
-    public loanerArrangedEmailController() {
-    }
+public with sharing class LoanerArrangedEmailController {
 
     @AuraEnabled
     public static InitData init(String recordId) {
@@ -16,22 +11,22 @@
     	    if( rac.Campaign__c != null ){
     	    	//鑾峰彇瀛︿細瀵硅薄
     	    	Campaign camp = [select Id, Status, Rental_Apply_Flag__c,IF_Approved__c,Approved_Status__c, Meeting_Approved_No__c from Campaign where id = :rac.Campaign__c];
-    	    	res.CampaignId = camp.Id;
-    	    	res.CampaignStatus = camp.Status;
-    	    	res.IFApproved = camp.IF_Approved__c;
-	    	    res.MeetingApprovedNo = camp.Meeting_Approved_No__c;
-	    	    res.ApprovedStatus = camp.Approved_Status__c;
+    	    	res.campaignId = camp.Id;
+    	    	res.campaignStatus = camp.Status;
+    	    	res.iFApproved = camp.IF_Approved__c;
+	    	    res.meetingApprovedNo = camp.Meeting_Approved_No__c;
+	    	    res.approvedStatus = camp.Approved_Status__c;
     	    }   
-    	    res.Id = recordId;   
-    	    res.RaStatus = rac.Status__c;
-    	    res.WeiAssignedCnt = Integer.valueOf(rac.Wei_Assigned_Cnt__c);
-    	    res.AssignedNotShipment = Integer.valueOf(rac.Assigned_Not_Shipment__c);
-    	    res.DemoPurpose1 = rac.Demo_purpose1__c;
-    	    res.ContractPdfUpdated = rac.Contract_pdf_updated__c;
-    	    res.RepairId = rac.Repair__c;
-    	    res.RepairFinalInspectionDateF = rac.Repair_Final_Inspection_Date_F__c;
-    	    res.RCReturnToOffice = rac.RC_return_to_office__c;
-    	    res.StatusList = status;
+    	    res.id = recordId;   
+    	    res.raStatus = rac.Status__c;
+    	    res.weiAssignedCnt = Integer.valueOf(rac.Wei_Assigned_Cnt__c);
+    	    res.assignedNotShipment = Integer.valueOf(rac.Assigned_Not_Shipment__c);
+    	    res.demoPurpose1 = rac.Demo_purpose1__c;
+    	    res.contractPdfUpdated = rac.Contract_pdf_updated__c;
+    	    res.repairId = rac.Repair__c;
+    	    res.repairFinalInspectionDateF = rac.Repair_Final_Inspection_Date_F__c;
+    	    res.rCReturnToOffice = rac.RC_return_to_office__c;
+    	    res.statusList = status;
     	}
     	catch (Exception e) {
     	    System.debug(LoggingLevel.INFO, '****e:' + e);
@@ -62,34 +57,34 @@
 
     public class InitData{
 		@AuraEnabled
-		public String Id;
+		public String id;
 		@AuraEnabled
-		public String CampaignStatus;	//瀛︿細鐘舵��
+		public String campaignStatus;	//瀛︿細鐘舵��
 		@AuraEnabled
-		public String CampaignId;	//瀛︿細Id
+		public String campaignId;	//瀛︿細Id
 		@AuraEnabled
-		public String RaStatus;		//澶囧搧鍊熷嚭鐢宠鐘舵��
+		public String raStatus;		//澶囧搧鍊熷嚭鐢宠鐘舵��
 		@AuraEnabled
-		public Integer WeiAssignedCnt;		//鏈垎閰嶄欢鏁�  Wei_Assigned_Cnt__c
+		public Integer weiAssignedCnt;		//鏈垎閰嶄欢鏁�  Wei_Assigned_Cnt__c
 		@AuraEnabled
-		public Integer AssignedNotShipment;	//宸插垎閰嶆湭鍑哄簱鎸囩ず  Assigned_Not_Shipment__c
+		public Integer assignedNotShipment;	//宸插垎閰嶆湭鍑哄簱鎸囩ず  Assigned_Not_Shipment__c
 		@AuraEnabled
-		public String DemoPurpose1;			//浣跨敤鐩殑1	 Demo_purpose1__c
+		public String demoPurpose1;			//浣跨敤鐩殑1	 Demo_purpose1__c
 		@AuraEnabled
-		public Boolean ContractPdfUpdated;	//鍚堝悓涔﹀凡涓婁紶	Contract_pdf_updated__c
+		public Boolean contractPdfUpdated;	//鍚堝悓涔﹀凡涓婁紶	Contract_pdf_updated__c
 		@AuraEnabled
-		public String RepairId;				//瀛︿細.淇悊Id
+		public String repairId;				//瀛︿細.淇悊Id
 		@AuraEnabled
-		public Date RepairFinalInspectionDateF;		//淇悊鏈�缁堟娴嬫棩F  	Repair_Final_Inspection_Date_F__c
+		public Date repairFinalInspectionDateF;		//淇悊鏈�缁堟娴嬫棩F  	Repair_Final_Inspection_Date_F__c
 		@AuraEnabled
-		public Date RCReturnToOffice;		//RC淇悊鍝佽繑閫佹棩		RC_return_to_office__c
+		public Date rCReturnToOffice;		//RC淇悊鍝佽繑閫佹棩		RC_return_to_office__c
 		@AuraEnabled
-		public Boolean IFApproved;			//瀛︿細.鏄惁闇�瑕佺敵璇峰喅瑁�
+		public Boolean iFApproved;			//瀛︿細.鏄惁闇�瑕佺敵璇峰喅瑁�
 		@AuraEnabled
-		public String MeetingApprovedNo;	//瀛︿細.浼氳鍐宠缂栫爜
+		public String meetingApprovedNo;	//瀛︿細.浼氳鍐宠缂栫爜
 		@AuraEnabled
-		public String ApprovedStatus;		//瀛︿細.鍐宠鐘舵��	Approved_Status__c
+		public String approvedStatus;		//瀛︿細.鍐宠鐘舵��	Approved_Status__c
 		@AuraEnabled
-		public List<String> StatusList;
+		public List<String> statusList;
 	}
 }
\ No newline at end of file
diff --git a/force-app/main/default/lwc/lexLoanerArrangedEmail/lexLoanerArrangedEmail.js b/force-app/main/default/lwc/lexLoanerArrangedEmail/lexLoanerArrangedEmail.js
index 3916190..bd626db 100644
--- a/force-app/main/default/lwc/lexLoanerArrangedEmail/lexLoanerArrangedEmail.js
+++ b/force-app/main/default/lwc/lexLoanerArrangedEmail/lexLoanerArrangedEmail.js
@@ -1,6 +1,8 @@
 import { LightningElement, track, wire, api } from 'lwc';
 import { CurrentPageReference,NavigationMixin } from 'lightning/navigation';
 import { CloseActionScreenEvent } from 'lightning/actions';
+import { ShowToastEvent } from 'lightning/platformShowToastEvent';
+import { updateRecord } from 'lightning/uiRecordApi';
 
 import init from '@salesforce/apex/loanerArrangedEmailController.init';
 import getRentalApplyEquipmentSet from '@salesforce/apex/loanerArrangedEmailController.getRentalApplyEquipmentSet';
@@ -25,49 +27,50 @@
 		init({
 			recordId: this.recordId
 		}).then(result => {
-			console.log(this.recordId);
+			let statusArr = result.statusList;
 			console.log('result==='+JSON.stringify(result));
 			if(result != null) {
-				if( result.WeiAssignedCnt > 0 ) {
-					alert("鐢宠鍗曞唴瀛樺湪鏈垎閰嶇殑閰嶅锛岃鍒嗛厤澶囧搧鎴栧垎鍓茬敵璇峰崟");
-				}else if(result.CampaignStatus == "鍙栨秷") {
-					alert("瀛︿細鍙栨秷锛屼笉鍙嚭搴撴寚绀�"); 
-				}else if (result.RaStatus == "宸插嚭搴撴寚绀�" && result.AssignedNotShipment == 0){
-					alert("鎵�鏈夌殑鍊熷嚭澶囧搧Set涓�瑙堥兘杩涜杩囧嚭搴撴寚绀轰簡");
-				}else if (result.AssignedNotShipment == 0) {
-					alert("娌℃湁鍙互鍑哄簱鎸囩ず鐨勬槑缁�"); 
-				}else if (result.DemoPurpose1 == "闀挎湡鍊熷嚭" && result.ContractPdfUpdated == 0){
-					alert("闀挎湡鍊熷嚭鏃讹紝蹇呴』鍏堜笂浼犲绾︿功"); 
-				}else if (result.RepairId != '' && (result.RepairFinalInspectionDateF != null && result.RepairFinalInspectionDateF != '') || (result.RCReturnToOffice != null && result.RCReturnToOffice != '')){
-					alert("淇悊鏈夋渶缁堟娴嬫棩鎴栦慨鐞嗗搧杩旈�佹棩锛屼笉鍙嚭搴撴寚绀�"); 
-				}else if (result.IFApproved == "true" && (result.MeetingApprovedNo == null || result.MeetingApprovedNo == "")){
-					alert("娌℃湁鍐宠鍙风殑锛屾殏涓嶈兘鍑哄��,璇锋洿鏂拌鍐充俊鎭��"); 
-				}else if (result.IFApproved == "true" && result.MeetingApprovedNo != "" && result.StatusList.indexOf(records[0].Approved_Status__c) != -1){
-					alert("宸茬敵璇峰喅瑁佷絾鍐宠鐘舵�佷笉绗﹀悎鏉′欢銆�"); 
-				}else {
+				if( result.weiAssignedCnt > 0 ) {
+					this.showToast("鐢宠鍗曞唴瀛樺湪鏈垎閰嶇殑閰嶅锛岃鍒嗛厤澶囧搧鎴栧垎鍓茬敵璇峰崟",'error');
+				}else if(result.campaignStatus == "鍙栨秷") {
+					this.showToast("瀛︿細鍙栨秷锛屼笉鍙嚭搴撴寚绀�",'error');
+				}else if (result.raStatus == "宸插嚭搴撴寚绀�" && result.assignedNotShipment == 0){
+					this.showToast("鎵�鏈夌殑鍊熷嚭澶囧搧Set涓�瑙堥兘杩涜杩囧嚭搴撴寚绀轰簡",'error');
+				}else if (result.assignedNotShipment == 0) {
+					this.showToast("娌℃湁鍙互鍑哄簱鎸囩ず鐨勬槑缁�",'error');
+				}else if (result.demoPurpose1 == "闀挎湡鍊熷嚭" && result.contractPdfUpdated == false){
+					this.showToast("闀挎湡鍊熷嚭鏃讹紝蹇呴』鍏堜笂浼犲绾︿功",'error');
+				}else if (result.repairId != '' && (result.repairFinalInspectionDateF != null && result.repairFinalInspectionDateF != '') || (result.rCReturnToOffice != null && result.rCReturnToOffice != '')){
+					this.showToast("淇悊鏈夋渶缁堟娴嬫棩鎴栦慨鐞嗗搧杩旈�佹棩锛屼笉鍙嚭搴撴寚绀�",'error');
+				}else if (result.iFApproved == true && (result.meetingApprovedNo == null || result.meetingApprovedNo == "")){
+					this.showToast("娌℃湁鍐宠鍙风殑锛屾殏涓嶈兘鍑哄��,璇锋洿鏂拌鍐充俊鎭��",'error');
+				}else if (result.iFApproved == true && result.meetingApprovedNo != "" && statusArr.indexOf(result.approvedStatus) != -1){
+					this.showToast("宸茬敵璇峰喅瑁佷絾鍐宠鐘舵�佷笉绗﹀悎鏉′欢銆�",'error');
+				}else{
 					approvalCheck({
 						rentalApplyId: this.recordId
-					}).then(res=>{
-						if (res != '1') {
-							alert(rs1);
-						} else {
+					}).then(res1 =>{
+						if (res1 != '1') {
+							this.showToast(res1,'error');
+						}else{
 							//bp2 var rs2 = sforce.apex.execute("RentalApplyWebService", "reserve", {rentalApplyId: raid});
 							//bp2 if (rs2 != '1') {
 							//bp2 alert(rs2);
 							//bp2 } else {
 							//var rs1 = sforce.apex.execute("RentalApplyWebService", "setShipment_request", {raid : "{!Rental_Apply__c.Id}"}); 
-
+							console.log('setShipment_request==');
 							setShipment_request({
 								raid: this.recordId
 							}).then(res=>{
-								if (res == "鐘舵�佹洿鏂板埌宸插嚭搴撴寚绀�") { 
-									alert("鐘舵�佹洿鏂板埌宸插嚭搴撴寚绀�");
+								console.log('res==',res);
+								if (res == "鐘舵�佹洿鏂板埌宸插嚭搴撴寚绀�") {
+									this.showToast("鐘舵�佹洿鏂板埌宸插嚭搴撴寚绀�",'success');
 									print();
-									setTimeout(function() {
-										location.href = "/{!Rental_Apply__c.Id}"; 
-									},100);
+									// setTimeout(function() {
+									// 	location.href = "/{!Rental_Apply__c.Id}"; 
+									// },100);
 								}else {
-									alert(res);
+									this.showToast(res,'error');
 								}
 							}).catch(e=>{
 								console.log('approvalCheck==='+e);
@@ -99,4 +102,20 @@
 		var Seconds = fixTime(date.getSeconds());
 		return date.getFullYear() + "-" + Month + "-" + Day + "T" + Time;
 	}
+
+	showToast(msg,type) {
+        const event = new ShowToastEvent({
+            message: msg,
+            variant: type
+        });
+        if(type == 'success'){
+            this.updateRecordView();
+        }
+        this.dispatchEvent(event);
+        this.dispatchEvent(new CloseActionScreenEvent());
+    }
+
+    updateRecordView(recordId) {
+        updateRecord({fields: { Id: recordId }});
+    }
 }
\ No newline at end of file

--
Gitblit v1.9.1